public void run() { // Guard against NPE at shutdown if (container == null) { cancel(); return; } if(log.isTraceEnabled()) log.trace("Flushing the valid contexts " + container.getBeanMetaData().getEjbName()); EntityCache cache = (EntityCache) container.getInstanceCache(); try { if(cache != null) cache.flush(); } catch (Throwable t) { log.debug("Ignored error while trying to flush() entity cache", t); } } }
if (container instanceof EntityContainer) cache = ((EntityContainer)container).getInstanceCache();
final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(e.nextElement()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o); final Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(i.next()); Object o = factory.getEntityEJBObject(cacheKey); array.add(o);
public EJBLocalObject getEJBLocalObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBLocalObject", IN_EJB_POST_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_EJB_LOAD | IN_EJB_STORE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); if (con.getLocalHomeClass()==null) throw new IllegalStateException( "No local interface for bean." ); if (ejbLocalObject == null) { Object cacheKey = ((EntityCache)((EntityContainer)con).getInstanceCache()).createCacheKey(id); ejbLocalObject = ((EntityContainer)con).getLocalProxyFactory().getEntityEJBLocalObject(cacheKey); } return ejbLocalObject; }
public Object findEntity(Method finderMethod, Object[] args, EntityEnterpriseContext ctx, GenericEntityObjectFactory factory) throws Exception { try { AllowedOperationsAssociation.pushInMethodFlag(IN_EJB_FIND); // call the finder method Object objectId = callFinderMethod(finderMethod, args, ctx); final Object cacheKey = ((EntityCache)con.getInstanceCache()).createCacheKey( objectId ); return factory.getEntityEJBObject(cacheKey); } finally { AllowedOperationsAssociation.popInMethodFlag(); } }
Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id );
Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey( id );
public EJBObject getEJBObject() { AllowedOperationsAssociation.assertAllowedIn("getEJBObject", IN_EJB_POST_CREATE | IN_EJB_REMOVE | IN_EJB_ACTIVATE | IN_EJB_PASSIVATE | IN_EJB_LOAD | IN_EJB_STORE | IN_BUSINESS_METHOD | IN_EJB_TIMEOUT); if(((EntityContainer)con).getRemoteClass() == null) { throw new IllegalStateException( "No remote interface defined." ); } if (ejbObject == null) { // Create a new CacheKey Object cacheKey = ((EntityCache)((EntityContainer)con).getInstanceCache()).createCacheKey(id); EJBProxyFactory proxyFactory = con.getProxyFactory(); if(proxyFactory == null) { String defaultInvokerName = con.getBeanMetaData(). getContainerConfiguration().getDefaultInvokerName(); proxyFactory = con.lookupProxyFactory(defaultInvokerName); } ejbObject = (EJBObject)proxyFactory.getEntityEJBObject(cacheKey); } return ejbObject; }
Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id);
try ctx = (EntityEnterpriseContext) container.getInstanceCache().get(key); container.getInstanceCache().remove(key); container.getInstanceCache().remove(key);
container.getInstanceCache().remove(ctx.getCacheKey()); container.getInstanceCache().remove(ctx.getId()); container.getPersistenceManager().passivateEntity(ctx);
Object cacheKey = ((EntityCache) con.getInstanceCache()).createCacheKey(id);
EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext();
/** * Schedules the instance with myId for cascade delete. */ private Object invokeScheduleForCascadeDelete(Transaction tx, Object myId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.SCHEDULE_FOR_CASCADE_DELETE); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); return manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in scheduleForCascadeDelete()", e); } }
EntityCache instanceCache = (EntityCache)manager.getContainer().getInstanceCache();
EntityCache instanceCache = (EntityCache)manager.getContainer().getInstanceCache();
/** * Schedules the instance with myId for batch cascade delete. */ private Object invokeScheduleForBatchCascadeDelete(Transaction tx, Object myId) { try { EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.SCHEDULE_FOR_BATCH_CASCADE_DELETE); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); return manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in scheduleForBatchCascadeDelete()", e); } }
/** * Invokes the addRelation on the related CMR field via the container * invocation interceptor chain. */ private void invokeAddRelation(Transaction tx, Object myId, Object relatedId) { try { SecurityContext sc = SecurityActions.getSecurityContext(); EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); CMRInvocation invocation = new CMRInvocation(); invocation.setCmrMessage(CMRMessage.ADD_RELATION); invocation.setEntrancy(Entrancy.NON_ENTRANT); invocation.setId(instanceCache.createCacheKey(myId)); invocation.setArguments(new Object[]{this, relatedId}); invocation.setTransaction(tx); invocation.setPrincipal(sc.getUtil().getUserPrincipal()); invocation.setCredential(sc.getUtil().getCredential()); invocation.setType(InvocationType.LOCAL); manager.getContainer().invoke(invocation); } catch(EJBException e) { throw e; } catch(Exception e) { throw new EJBException("Error in addRelation", e); } }
EntityCache instanceCache = (EntityCache) manager.getContainer().getInstanceCache(); SecurityContext sc = SecurityActions.getSecurityContext();
InstanceCache cache = container.getInstanceCache(); cache.remove(ctx.getCacheKey());