public boolean isStoreRequired(EntityEnterpriseContext ctx) throws Exception { if(isModified == null) { return true; } Boolean modified = (Boolean) isModified.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); return modified.booleanValue(); }
/** * This method is called whenever an entity shall be stored to the * underlying storage. The persistence manager must call ejbStore on the * supplied instance and then store the state to the underlying storage. * * @param ctx the instance to synchronize */ public void storeEntity (EntityEnterpriseContext ctx) { storeEntity (ctx.getId (), ctx.getInstance ()); }
protected EnterpriseContext create(Object instance) throws Exception { return new EntityEnterpriseContext(instance, getContainer()); } }
public String toString() { return getContainer().getBeanMetaData().getEjbName() + '#' + getId(); }
public static void destroyPersistenceContext(EntityEnterpriseContext ctx) { // If we have an EJB 2.0 dynaymic proxy, // notify the handler of the assigned context. Object instance = ctx.getInstance(); if(instance instanceof Proxies.ProxyTarget) { InvocationHandler handler = ((Proxies.ProxyTarget)instance).getInvocationHandler(); if(handler instanceof EntityBridgeInvocationHandler) ((EntityBridgeInvocationHandler)handler).setContext(null); } ctx.setPersistenceContext(null); }
int commitOption = ctx.isPassivateAfterCommit() ? ConfigurationMetaData.C_COMMIT_OPTION : EntitySynchronizationInterceptor.this.commitOption; ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); ctx.setTransaction(null); try container.getInstanceCache().remove(ctx.getCacheKey()); case ConfigurationMetaData.D_COMMIT_OPTION: ctx.setValid(true); break; ctx.setValid(false); break; if(ctx.getId() != null) container.getInstanceCache().remove(ctx.getId()); container.getPersistenceManager().passivateEntity(ctx);
/** * This method is called when an entity shall be removed from the * underlying storage. The persistence manager must call ejbRemove on the * instance and then remove its state from the underlying storage. * * @param ctx the instance to remove * * @throws javax.ejb.RemoveException thrown if the instance could not be removed */ public void removeEntity (EntityEnterpriseContext ctx) throws javax.ejb.RemoveException { if (this.beans.remove (ctx.getId ()) == null) throw new javax.ejb.RemoveException ("Could not remove bean:" + ctx.getId ()); }
try ctxContainer = (EntityContainer)ctx.getContainer(); if(!ctx.hasTxSynchronization()) ctx.hasTxSynchronization(true); ctx.getTxAssociation().scheduleSync(tx, ctx); ctx.setValid(false); ctx.hasTxSynchronization(false); ctx.setTransaction(null); ctx.setTxAssociation(GlobalTxEntityMap.NONE); ctx.hasTxSynchronization(false); ctx.setTxAssociation(GlobalTxEntityMap.NONE); if(t instanceof RuntimeException) throw (RuntimeException)t;
Object id = ctx.getId(); Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id ); ctx.setCacheKey(cacheKey); ejbActivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e)
NonReentrantLock methodLock = ctx.getMethodLock(); Transaction miTx = ctx.getTransaction(); boolean locked = false; try + ctx.getId().toString()); + ctx.getId().toString()); ctx.lock(); return getNext().invoke(mi); ctx.unlock(); methodLock.release(nonReentrant);
ejbPassivate.invoke(ctx.getInstance(), EMPTY_OBJECT_ARRAY); } catch (IllegalAccessException e) AllowedOperationsAssociation.popInMethodFlag(); ctx.setEJBObject(null); ctx.setEJBLocalObject(null);
ctx.setTxAssociation(GlobalTxEntityMap.NOT_READY); InstancePool pool = container.getInstancePool(); ctx.setTransaction(mi.getTransaction()); ctx.setPrincipal(mi.getPrincipal()); if (ctx.getId() != null) BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey()); cache.remove(ctx.getCacheKey()); container.getLockManager().removeLockRef(ctx.getCacheKey()); ctx.setTransaction(null);
public Object execute(Method m, Object[] args, EntityEnterpriseContext ctx) throws CreateException PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); if(ctx.getId() == null) throw new DuplicateKeyException("Unique key violation or invalid foreign key value: pk=" + ctx.getId()); throw new CreateException("Failed to create instance: pk=" + ctx.getId() + ", state=" + e.getSQLState() + ", msg=" + e.getMessage()); pk = ctx.getId();
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 Object getValue(EntityEnterpriseContext ctx) { PersistentContext pctx = (PersistentContext) ctx.getPersistenceContext(); return pctx.getFieldValue(rowIndex); }
public Object invokeHome(Invocation mi) throws Exception { EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); Transaction tx = mi.getTransaction(); Object rtn = getNext().invokeHome(mi); // An anonymous context was sent in, so if it has an id it is a real instance now if(ctx.getId() != null) { // it doesn't need to be read, but it might have been changed from the db already. ctx.setValid(true); if(tx != null) { BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey()); try { lock.schedule(mi); register(ctx, tx); // Set tx lock.endInvocation(mi); } finally { container.getLockManager().removeLockRef(lock.getId()); } } } return rtn; }
public void initInstance(EntityEnterpriseContext ctx) { ctx.setPersistenceContext(new PersistentContext(this, table.getRow(ctx.getId()))); for(int i = 0; i < tableFields.length; ++i) { tableFields[i].initInstance(ctx); } for(int i = 0; i < cmrFields.length; ++i) { cmrFields[i].initInstance(ctx); } }
public boolean loadEntity(EntityEnterpriseContext ctx, boolean failIfNotFound) { // is any on the data already in the entity valid if(!ctx.isValid()) { if(log.isTraceEnabled()) { log.trace("RESET PERSISTENCE CONTEXT: id=" + ctx.getId()); } entityBridge.resetPersistenceContext(ctx); } // mark the entity as created; if it was loading it was created JDBCEntityBridge.setCreated(ctx); return loadEntityCommand.execute(ctx, failIfNotFound); }
protected Object getKey(EnterpriseContext ctx) { return ((EntityEnterpriseContext)ctx).getCacheKey(); }
public Object updateVersion(EntityEnterpriseContext ctx) { Object value = ctx.getEJBContext().getCallerPrincipal().getName(); setInstanceValue(ctx, value); return value; } }