Update of /cvsroot/magicmap/magicmapserver/src/net/sf/magicmap/server/cache
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8592/src/net/sf/magicmap/server/cache
Modified Files:
PositionCache.java
Log Message:
Daten aus Chache in Datanbank schreiben (ServletContextListener)
Index: PositionCache.java
===================================================================
RCS file: /cvsroot/magicmap/magicmapserver/src/net/sf/magicmap/server/cache/PositionCache.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** PositionCache.java 30 Nov 2005 17:57:13 -0000 1.7
--- PositionCache.java 5 Dec 2005 16:11:43 -0000 1.8
***************
*** 19,22 ****
--- 19,26 ----
import javax.jdo.Query;
import javax.jdo.Transaction;
+ import javax.servlet.ServletContextEvent;
+ import javax.servlet.ServletContextListener;
+
+ import com.sun.org.apache.xml.internal.utils.SuballocatedByteVector;
import net.sf.magicmap.db.AccessPoint;
***************
*** 51,67 ****
}
! protected void finalize() throws Throwable{
! Enumeration<String> mapNames = this.keys();
! while (mapNames.hasMoreElements()){
! String currentMap = mapNames.nextElement();
! PositionCacheEntry posCache = this.get(currentMap);
! PositionDTO[] positions = posCache.getPositionsSince(Long.valueOf(-1));
! for (int i = 0; i < positions.length; ++i){
! writePositionToDB(currentMap, positions[i]);
! }
! }
! super.finalize();
! }
!
private Map checkMap(String mapName, PersistenceManager pm) throws MapException{
Map result = null;
--- 55,59 ----
}
!
private Map checkMap(String mapName, PersistenceManager pm) throws MapException{
Map result = null;
***************
*** 155,158 ****
--- 147,151 ----
private void writePositionToDB(String mapName, PositionDTO position){
+ System.out.println("Finalize:writePositionToDB()");
PersistenceManager pm = null;
Transaction tx = null;
***************
*** 365,368 ****
--- 358,377 ----
}
+ public void writeCacheDataToDB(){
+ System.out.println("Begin Schreiben in Datenbank");
+ Enumeration<String> mapNames = this.keys();
+ while (mapNames.hasMoreElements()){
+ String currentMap = mapNames.nextElement();
+ currentMap = currentMap.substring(0,currentMap.indexOf('#')-1);
+ PositionCacheEntry posCache = this.get(currentMap);
+ PositionDTO[] positions = posCache.getPositionsSince(Long.valueOf(-1));
+ for (int i = 0; i < positions.length; ++i){
+ writePositionToDB(currentMap, positions[i]);
+ }
+ }
+
+ System.out.println("Schreiben in Datenbank beendet");
+ }
+
}
|