1 7 8 package org.enhydra.snapper.business; 9 10 11 import org.enhydra.dods.DODS; 12 import org.enhydra.dods.DODSException; 13 import org.enhydra.snapper.SnapperManager; 14 import org.enhydra.snapper.spec.Update; 15 import org.enhydra.snapper.spec.UpdateAll; 16 import org.enhydra.snapper.spec.UpdateThreadFactory; 17 18 import com.lutris.appserver.server.sql.DatabaseManager; 19 20 21 23 24 27 28 public class UpdateAllImpl implements UpdateAll, Runnable { 29 30 private String [] ids; 31 private DatabaseManager dbm; 32 33 public void run() { 34 try { 35 for (int numSites = 0; numSites < ids.length; numSites++) { 36 try { 37 Update update = UpdateThreadFactory.getUpdateThread("org.enhydra.snapper.business.UpdateThread"); 38 String id = ids[numSites]; 39 update.update(id, dbm); 40 SnapperManager.getInstance().addThread(id, update); 41 42 DatabaseManager tempDbManager = DODS.getDatabaseManager(Thread.currentThread()); 43 new Thread ((Runnable ) update, id).run(); 44 DODS.register(Thread.currentThread(), tempDbManager); 45 46 } catch (Exception e) { 48 SnapperManager.getInstance().getLoggingManager().error("Could not update site"); 49 } 50 } 51 } finally { 52 try { 53 DODS.unregister(Thread.currentThread()); 54 } catch (DODSException e) { 55 e.printStackTrace(); 56 } 57 } 58 } 59 60 public void stop(){}; 61 62 public UpdateAllImpl() { 63 } 64 65 public void update(String [] ids, DatabaseManager dbm){ 66 this.ids = ids; 67 this.dbm = dbm; 68 } 69 70 } | Popular Tags |