/** * 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 Object invokeHome(Invocation mi) throws Exception { // stateless: no context, no transaction, no call to the instance if (stateless || mi.getEnterpriseContext() == null) return getNext().invokeHome(mi); else return invokeNext(mi); }
public Object invoke(Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invoke(mi); } finally { } }
/** * releaseMethodLock * * if we reach the count of zero it means the instance is free from threads (and reentrency) * we wake up the next thread in the currentLock */ public void endInvocation(Invocation mi) { // Do we own the lock? Transaction tx = mi.getTransaction(); if (tx != null && tx.equals(getTransaction())) { // If there is no context or synchronization, release the lock EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); if (ctx == null || ctx.hasTxSynchronization() == false) endTransaction(tx); } }
/** * 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()); }
public EJBLocalObject createLocalHome(Invocation mi) throws Exception { StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); createSession(mi.getMethod(), mi.getArguments(), ctx); return ctx.getEJBLocalObject(); }
public EJBObject createHome(Invocation mi) throws Exception { StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); createSession(mi.getMethod(), mi.getArguments(), ctx); return ctx.getEJBObject(); }
/** * 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 Object invokeHome(Invocation mi) throws Exception { Method getEJBObject = Handle.class.getMethod("getEJBObject", new Class[0]); //Invocation on the handle, we don't need a bean instance if (getEJBObject.equals(mi.getMethod())) return getNext().invokeHome(mi); EnterpriseContext ctx = (EnterpriseContext) mi.getEnterpriseContext(); if(ctx == null) throw new IllegalStateException("EJBContext is null"); //Set the current security information ctx.setPrincipal(mi.getPrincipal()); try { // Invoke through interceptors return getNext().invokeHome(mi); } finally { } } }
public Object invokeHome (Invocation mi) throws Exception { EnterpriseContext ctx = (EnterpriseContext)mi.getEnterpriseContext (); try { // Invoke through interceptors return getNext ().invokeHome (mi); } finally { if ( (ctx != null) && (ctx.getId () != null) ) // Still a valid instance and instance not removed // { // Everything went ok (at least no J2EE problem) and the instance will most probably be called // many more times. Consequently, we need to synchronize the state of our bean instance with // our persistant store (which will forward this to its HASessionState implementation) for clustering // behaviour. This is only necessary for "create" calls (which is the case because ctx.getId() != null) // synchronizeState (ctx); } } }
/** * 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); }
EntityEnterpriseContext instance = (EntityEnterpriseContext)mi.getEnterpriseContext();
public Object invoke(Invocation mi) throws Exception { Object key = ((EnterpriseContext) mi.getEnterpriseContext()).getInstance(); try { ccm.pushMetaAwareObject(key, unsharableResources); try { return getNext().invoke(mi); } finally { ccm.popMetaAwareObject(unsharableResources); } } catch (ResourceException e) { InvocationType type = mi.getType(); boolean isLocal = (type == InvocationType.LOCAL || type == InvocationType.LOCALHOME); if (isLocal) throw new EJBException("Resource problem during invoke", e); else throw new RemoteException("Resource problem during invoke", e); } }
public Object invokeHome(Invocation mi) throws Exception { // Apply any custom security checks if( securityProxy != null ) { EJBContext ctx = null; EnterpriseContext ectx = (EnterpriseContext)mi.getEnterpriseContext(); if( ectx != null ) ctx = ectx.getEJBContext(); Object[] args = mi.getArguments(); securityProxy.setEJBContext(ctx); try { securityProxy.invokeHome(mi.getMethod(), args); } catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invokeHome exception, principal=" + principal; log.error(msg, e); throw e; } } return getNext().invokeHome(mi); }
public Object invoke(Invocation mi) throws Exception { // Apply any custom security checks if( securityProxy != null ) { EnterpriseContext ectx = (EnterpriseContext)mi.getEnterpriseContext(); Object bean = ectx.getInstance(); EJBContext ctx = ectx.getEJBContext(); Object[] args = mi.getArguments(); securityProxy.setEJBContext(ctx); try { securityProxy.invoke(mi.getMethod(), args, bean); } catch(SecurityException e) { Principal principal = mi.getPrincipal(); String msg = "SecurityProxy.invoke exception, principal="+principal; log.error(msg, e); throw e; } } return getNext().invoke(mi); } }
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++; }
public void remove(Invocation mi) throws RemoteException, RemoveException { // if the session is removed already then let the user know they have a problem StatefulSessionEnterpriseContext ctx = (StatefulSessionEnterpriseContext) mi.getEnterpriseContext(); if (ctx.getId() == null) { throw new RemoveException("SFSB has been removed already"); } // Remove from storage try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_REMOVE); getPersistenceManager().removeSession(ctx); } finally { AllowedOperationsAssociation.popInMethodFlag(); } // We signify "removed" with a null id ctx.setId(null); removeCount++; }
public Object invokeHome(Invocation mi) throws Exception { // Invoke through interceptors Object retVal = getNext().invokeHome(mi); // Is the context now with an identity? // This means that a create method was called, so invoke ejbPostCreate. EntityEnterpriseContext ctx = (EntityEnterpriseContext) mi.getEnterpriseContext(); if(ctx != null && ctx.getId() != null) { // copy from the context into the mi // interceptors down the chain look in the mi for the id not the ctx. mi.setId(ctx.getId()); // invoke down the invoke chain // the final interceptor in EntityContainer will redirect this // call to postCreateEntity, which calls ejbPostCreate getNext().invoke(mi); // now it's ready and can be scheduled for the synchronization if(TxUtils.isActive(mi.getTransaction())) { GlobalTxEntityMap.NONE.scheduleSync(mi.getTransaction(), ctx); } } return retVal; }
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; }
org.jboss.ejb.EntityEnterpriseContext ctx = (org.jboss.ejb.EntityEnterpriseContext)mi.getEnterpriseContext(); Object id = ctx.getId();