public void stop() { if (container != null && pm != null && ((EntityContainer) container).getPersistenceManager() == this) { ((EntityContainer) container).setPersistenceManager(pm); pm = null; } unsharableResources.clear(); }
protected void activate(EnterpriseContext ctx) throws RemoteException { m_container.getPersistenceManager().activateEntity((EntityEnterpriseContext)ctx); }
public Map retrieveStatistic() { // Loop through all Interceptors and add statistics Map lStatistics = new HashMap(); StatisticsProvider lProvider = (StatisticsProvider) getPersistenceManager(); lStatistics.putAll( lProvider.retrieveStatistic() ); lProvider = (StatisticsProvider) getInstancePool(); lStatistics.putAll( lProvider.retrieveStatistic() ); return lStatistics; }
/** * Invokes ejbStore method on the instance * @param ctx the instance to invoke ejbStore on * @throws Exception */ public void invokeEjbStore(EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() != null) { final EntityPersistenceManager pm = getPersistenceManager(); pm.invokeEjbStore(ctx); } }
protected void passivate(EnterpriseContext ctx) throws RemoteException { removeTimerServiceIfAllCancelledOrExpired(ctx); m_container.getPersistenceManager().passivateEntity((EntityEnterpriseContext)ctx); }
/** * For CMP actually stores the instance */ public void storeEntity(EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() != null) { final EntityPersistenceManager pm = getPersistenceManager(); if(pm.isStoreRequired(ctx)) { pm.storeEntity(ctx); } } }
protected boolean changed (org.jboss.invocation.Invocation mi, org.jboss.ejb.EntityEnterpriseContext ctx) throws Exception { if (ctx.getId() == null) return true; if(!container.isReadOnly()) { java.lang.reflect.Method method = mi.getMethod(); if(method == null || !container.getBeanMetaData().isMethodReadOnly(method.getName())) { return invalidateRelated ? container.getPersistenceManager().isModified(ctx) : container.getPersistenceManager().isStoreRequired(ctx); } } return false; }
/** * Delegates to the persistence manager postCreateEntityMethod. */ public void postCreateHome(Invocation mi) throws Exception { // The persistence manager takes care of the post create step getPersistenceManager().postCreateEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); }
/** * Delegates to the persistence manager postCreateEntityMethod. */ public void postCreateLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the post create step getPersistenceManager().postCreateEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); }
public EnterpriseContext get(Object id) throws RemoteException, NoSuchObjectException { if(id == null) throw new IllegalArgumentException("Can't get an object with a null key"); Map cache = getLocalCache(); EntityEnterpriseContext instance = (EntityEnterpriseContext) cache.get(id); if(instance == null) { try { // acquire instance = (EntityEnterpriseContext) container.getInstancePool().get(); // set key instance.setId(id); instance.setCacheKey(id); // activate container.getPersistenceManager().activateEntity(instance); // insert cache.put(id, instance); } catch(Throwable x) { throw new NoSuchObjectException(x.getMessage()); } } return instance; }
/** * Local home interface implementation */ public EJBLocalObject createLocalHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBLocalObject final EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().createEntity(mi.getMethod(), mi.getArguments(), ctx); // The context implicitely carries the EJBObject createCount++; return localProxyFactory.getEntityEJBLocalObject(ctx.getId(), true); }
Collection c = getPersistenceManager().findEntities(method, args, instance, localProxyFactory);
try ((EntityContainer) con).getPersistenceManager().start();
/** * This method takes care of the wiring of the "EJBObject" trio * (target, context, proxy). It delegates to the persistence manager. */ public EJBObject createHome(Invocation mi) throws Exception { // The persistence manager takes care of the wiring and creating the EJBObject getPersistenceManager().createEntity(mi.getMethod(),mi.getArguments(), (EntityEnterpriseContext) mi.getEnterpriseContext()); // The context implicitely carries the EJBObject createCount++; return ((EntityEnterpriseContext)mi.getEnterpriseContext()).getEJBObject(); }
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { EntityContainer container = (EntityContainer)instance.getContainer(); if(container.getPersistenceManager().isStoreRequired(instance)) { throw new EJBException("The instance of " + container.getBeanMetaData().getEjbName() + " with pk=" + instance.getId() + " was not stored to prevent potential inconsistency of data in the database:" + " the instance was evicted from the cache during the transaction" + " and the database was possibly updated by another process."); } }
private Object findSingleObject(Transaction tx, Method method, Object[] args, EntityEnterpriseContext instance, GenericEntityObjectFactory factory) throws Exception { if(method.getName().equals("findByPrimaryKey")) { if(args[0] == null) throw new IllegalArgumentException("findByPrimaryKey called with null argument."); if(metaData.getContainerConfiguration().getCommitOption() != ConfigurationMetaData.B_COMMIT_OPTION) { Object key = instance.getCacheKey(); if(key == null) { key = ((EntityCache)instanceCache).createCacheKey(args[0]); } if(instanceCache.isActive(key)) { return factory.getEntityEJBObject(key); } } } else if(!metaData.getContainerConfiguration().getSyncOnCommitOnly()) { EntityContainer.synchronizeEntitiesWithinTransaction(tx); } return getPersistenceManager().findEntity(method, args, instance, factory); }
Collection c = getPersistenceManager().findEntities(method, args, instance, ci);
public void remove(Invocation mi) throws RemoteException, RemoveException { // synchronize entities with the datastore before the bean is removed // this will write queued updates so datastore will be consistent before removal Transaction tx = mi.getTransaction(); if (!getBeanMetaData().getContainerConfiguration().getSyncOnCommitOnly()) synchronizeEntitiesWithinTransaction(tx); // Get the persistence manager to do the dirty work EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); getPersistenceManager().removeEntity(ctx); final Object pk = ctx.getId(); AccessController.doPrivileged(new PrivilegedAction<Object>() { public Object run() { removeTimerService(pk); return null; } }); // We signify "removed" with a null id // There is no need to synchronize on the context since all the threads reaching here have // gone through the InstanceInterceptor so the instance is locked and we only have one thread // the case of reentrant threads is unclear (would you want to delete an instance in reentrancy) ctx.setId(null); removeCount++; }
container.getPersistenceManager().passivateEntity(entity); container.getInstancePool().free(instance);
EntityPersistenceManager pm = ec.getPersistenceManager(); pm.activateEntity(ctx);