public synchronized void refCountedClose() { referenceCount--; if (referenceCount == 0) { if (underlyingEntityManager.isOpen()) { underlyingEntityManager.close(); if (isTraceEnabled) { ROOT_LOGGER.tracef("closed extended persistence context (%s)", puScopedName); } } } else if (isTraceEnabled) { ROOT_LOGGER.tracef("decremented extended persistence context (%s) owner count to %d", puScopedName, referenceCount); } // referenceCount should never be negative, if it is we need to fix the bug that caused it to decrement too much if (referenceCount < 0) { throw JpaLogger.ROOT_LOGGER.referenceCountedEntityManagerNegativeCount(referenceCount, getScopedPuName()); } }
public synchronized void refCountedClose() { referenceCount--; if (referenceCount == 0) { if (underlyingEntityManager.isOpen()) { underlyingEntityManager.close(); if (isTraceEnabled) { ROOT_LOGGER.tracef("closed extended persistence context (%s)", puScopedName); } } } else if (isTraceEnabled) { ROOT_LOGGER.tracef("decremented extended persistence context (%s) owner count to %d", puScopedName, referenceCount); } // referenceCount should never be negative, if it is we need to fix the bug that caused it to decrement too much if (referenceCount < 0) { throw JpaLogger.ROOT_LOGGER.referenceCountedEntityManagerNegativeCount(referenceCount, getScopedPuName()); } }
@Override public Object processInvocation(InterceptorContext interceptorContext) throws Exception { ComponentInstance componentInstance = interceptorContext.getPrivateData(ComponentInstance.class); Map<String, ExtendedEntityManager> entityManagers = null; if(componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY) == null) { // Get all of the extended persistence contexts in use by the bean (some of which may of been inherited from // other beans). entityManagers = new HashMap<String, ExtendedEntityManager>(); componentInstance.setInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY, new ImmediateManagedReference(entityManagers)); } else { ManagedReference entityManagerRef = (ManagedReference) componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY); entityManagers = (Map<String, ExtendedEntityManager>)entityManagerRef.getInstance(); } final ExtendedEntityManager[] ems = CreatedEntityManagers.getDeferredEntityManagers(); for (ExtendedEntityManager e : ems) { entityManagers.put(e.getScopedPuName(), e); } return interceptorContext.proceed(); } }
@Override public Object processInvocation(InterceptorContext interceptorContext) throws Exception { ComponentInstance componentInstance = interceptorContext.getPrivateData(ComponentInstance.class); Map<String, ExtendedEntityManager> entityManagers = null; if(componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY) == null) { // Get all of the extended persistence contexts in use by the bean (some of which may of been inherited from // other beans). entityManagers = new HashMap<String, ExtendedEntityManager>(); componentInstance.setInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY, new ImmediateManagedReference(entityManagers)); } else { ManagedReference entityManagerRef = (ManagedReference) componentInstance.getInstanceData(SFSBInvocationInterceptor.CONTEXT_KEY); entityManagers = (Map<String, ExtendedEntityManager>)entityManagerRef.getInstance(); } final ExtendedEntityManager[] ems = CreatedEntityManagers.getDeferredEntityManagers(); for (ExtendedEntityManager e : ems) { entityManagers.put(e.getScopedPuName(), e); } return interceptorContext.proceed(); } }