1 4 package com.nightlabs.ipanema.jdo; 5 6 import java.rmi.RemoteException ; 7 import java.util.Collection ; 8 import java.util.Set ; 9 10 import javax.ejb.CreateException ; 11 import javax.ejb.EJBException ; 12 import javax.ejb.SessionBean ; 13 import javax.jdo.PersistenceManager; 14 15 import com.nightlabs.ModuleException; 16 import com.nightlabs.ipanema.base.BaseSessionBeanImpl; 17 import com.nightlabs.ipanema.jdo.cache.CacheManager; 18 19 20 28 public abstract class JDOManagerBean 29 extends BaseSessionBeanImpl 30 implements SessionBean 31 { 32 36 public void ejbCreate() 37 throws CreateException 38 { 39 } 40 45 public void ejbRemove() throws EJBException , RemoteException 46 { 47 } 48 49 66 public String getPersistenceCapableClassName(Object objectID) 67 throws ModuleException 68 { 69 PersistenceManager pm = getPersistenceManager(); 70 try { 71 Object o = pm.getObjectById(objectID); 72 return o.getClass().getName(); 73 } finally { 74 pm.close(); 75 } 76 } 77 78 94 public void removeAddChangeListeners( 95 String cacheSessionID, 96 Collection removeObjectIDs, 97 Collection addObjectIDs) 98 throws ModuleException 99 { 100 CacheManager cm = getLookup().getCacheManager(cacheSessionID); 101 102 if (removeObjectIDs != null) 103 cm.removeChangeListeners(removeObjectIDs); 104 105 if (addObjectIDs != null) 106 cm.addChangeListeners(addObjectIDs); 107 } 108 109 124 public void resubscribeAllChangeListeners( 125 String cacheSessionID, 126 Set subscribedObjectIDs) 127 throws ModuleException 128 { 129 CacheManager cm = getLookup().getCacheManager(cacheSessionID); 130 cm.resubscribeAllChangeListeners(subscribedObjectIDs); 131 } 132 133 142 public void closeCacheSession(String cacheSessionID) 143 throws ModuleException 144 { 145 CacheManager cm = getLookup().getCacheManager(cacheSessionID); 146 cm.closeCacheSession(); 147 } 148 149 170 public Collection waitForChanges(String cacheSessionID, long waitTimeout) 171 throws ModuleException 172 { 173 CacheManager cm = getLookup().getCacheManager(cacheSessionID); 174 return cm.waitForChanges(waitTimeout); 175 } 176 177 } 178 | Popular Tags |