/** * create the service, do expensive operations etc */ protected void createService() throws Exception { this.beans = new HashMap(1000); String ejbName = con.getBeanMetaData ().getEjbName (); idField = con.getBeanClass ().getField ("id"); log.debug("Using id field: " + idField); // Lookup the isModified method if it exists try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) { isModified = null; // Has to have "boolean" as return type! log.warn("Found isModified method, but return type is not boolean; ignoring"); } else { log.debug("Using isModified method: " + isModified); } } catch (NoSuchMethodException ignored) {} }
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; }
public void stop() { if (container != null && pm != null && ((EntityContainer) container).getPersistenceManager() == this) { ((EntityContainer) container).setPersistenceManager(pm); pm = null; } unsharableResources.clear(); }
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; }
boolean setCl = !oldCl.equals(container.getClassLoader()); if(setCl) SecurityActions.setContextClassLoader(container.getClassLoader()); container.pushENC(); container.getInstanceCache().remove(ctx.getCacheKey()); container.getInstanceCache().remove(ctx.getId()); container.getPersistenceManager().passivateEntity(ctx); container.getInstancePool().free(ctx); container.getLockManager().removeLockRef(lock.getId()); container.popENC(); if(setCl)
container.getPersistenceManager().loadEntity(ctx); ctx.setValid(true); (container.isReadOnly() || container.getBeanMetaData().isMethodReadOnly(mi.getMethod()))) boolean isReadOnly = container.isReadOnly(); if(isReadOnly == false) isReadOnly = container.getBeanMetaData().isMethodReadOnly(method.getName()); container.getInstanceCache().remove(ctx.getId()); if(ctx.getId() != null && !container.isReadOnly()) container.invokeEjbStore(ctx); container.storeEntity(ctx); container.getInstanceCache().remove(ctx.getId());
SecurityActions.setContextClassLoader(getClassLoader()); pushENC(); try checkCoherency (); setupBeanMapping(); setupHomeMapping(); setupMarshalledInvocationMapping(); popENC();
public JDBCCommandFactory(JDBCStoreManager manager) throws Exception { this.manager = manager; log = Logger.getLogger( this.getClass().getName() + "." + manager.getContainer().getBeanMetaData().getEjbName()); }
SecurityActions.setContextClassLoader(container.getClassLoader()); container.pushENC(); ctx.hasTxSynchronization(false); ctx.setTransaction(null); container.getPersistenceManager().passivateEntity(ctx); container.getInstancePool().free(ctx); container.popENC(); SecurityActions.setContextClassLoader(oldCl);
EntityContainer container = new EntityContainer(); int transType = CMT; initializeContainer(container, conf, bean, transType, unit); container.setInstanceCache(createInstanceCache(conf, cl)); container.setInstancePool(createInstancePool(conf, cl)); container.setLockManager(lockMgr); container.setPersistenceManager(pm); persistenceManager.setPersistenceStore(pm); container.setPersistenceManager(persistenceManager);
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++; }
EJBProxyFactory ci = getProxyFactory(); if (ci == null) synchronizeEntitiesWithinTransaction(tx); Collection c = getPersistenceManager().findEntities(method, args, instance, ci); return findSingleObject(tx, method, args, instance, ci);
public JDBCSelectorBridge(JDBCStoreManager manager, JDBCQueryMetaData queryMetaData) { this.queryMetaData = queryMetaData; this.manager = manager; EntityContainer container = manager.getContainer(); tm = container.getTransactionManager(); syncBeforeSelect = !container.getBeanMetaData().getContainerConfiguration().getSyncOnCommitOnly(); }
protected void activate(EnterpriseContext ctx) throws RemoteException { m_container.getPersistenceManager().activateEntity((EntityEnterpriseContext)ctx); }
/** * Returns a new instance of the bean class or a subclass of the bean class. * * @return the new instance */ public Object createBeanClassInstance() throws Exception { return con.getBeanClass().newInstance(); }
public void invokeEjbStore(Thread thread, EntityEnterpriseContext instance) throws Exception { if(instance.getId() != null) { EntityContainer container = (EntityContainer) instance.getContainer(); // set the context class loader before calling the store method SecurityActions.setContextClassLoader(thread, container.getClassLoader()); container.pushENC(); try { // store it container.invokeEjbStore(instance); } finally { container.popENC(); } } }
public void create() throws Exception { ejbLoad = EntityBean.class.getMethod("ejbLoad", new Class[0]); ejbStore = EntityBean.class.getMethod("ejbStore", new Class[0]); ejbActivate = EntityBean.class.getMethod("ejbActivate", new Class[0]); ejbPassivate = EntityBean.class.getMethod("ejbPassivate", new Class[0]); ejbRemove = EntityBean.class.getMethod("ejbRemove", new Class[0]); // Create cache of create methods if (con.getHomeClass() != null) { Method[] methods = con.getHomeClass().getMethods(); createMethodCache( methods ); } if (con.getLocalHomeClass() != null) { Method[] methods = con.getLocalHomeClass().getMethods(); createMethodCache( methods ); } try { isModified = con.getBeanClass().getMethod("isModified", new Class[0]); if (!isModified.getReturnType().equals(Boolean.TYPE)) isModified = null; // Has to have "boolean" as return type! } catch (NoSuchMethodException ignored) {} }
public void create() throws Exception { if(con.getHomeClass() != null) { Method[] methods = con.getHomeClass().getMethods(); createMethodCache(methods); } if(con.getLocalHomeClass() != null) { Method[] methods = con.getLocalHomeClass().getMethods(); createMethodCache(methods); } insertAfterEjbPostCreate = con.getBeanMetaData().getContainerConfiguration().isInsertAfterEjbPostCreate(); store.create(); }
public void synchronize(Thread thread, Transaction tx, EntityEnterpriseContext instance) throws Exception { // only synchronize if the id is not null. A null id means // that the entity has been removed. if(instance.getId() != null) { EntityContainer container = (EntityContainer) instance.getContainer(); // set the context class loader before calling the store method SecurityActions.setContextClassLoader(thread, container.getClassLoader()); container.pushENC(); try { // store it container.storeEntity(instance); instance.setTxAssociation(SYNCHRONIZED); } finally { container.popENC(); } } } };
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."); } }