Package org.glassfish.ejb.mdb
Class MessageBeanContainer
- java.lang.Object
-
- com.sun.ejb.containers.BaseContainer
-
- org.glassfish.ejb.mdb.MessageBeanContainer
-
- All Implemented Interfaces:
com.sun.ejb.Container,com.sun.enterprise.container.common.spi.JavaEEContainer,org.glassfish.ejb.api.MessageBeanProtocolManager,org.glassfish.enterprise.iiop.spi.EjbContainerFacade
public final class MessageBeanContainer extends com.sun.ejb.containers.BaseContainer implements org.glassfish.ejb.api.MessageBeanProtocolManagerThis class provides container functionality specific to message-driven EJBs. At deployment time, one instance of the MessageDrivenBeanContainer is created for each message-driven bean in an application.The 3 states of a Message-driven EJB (an EJB can be in only 1 state at a time): 1. POOLED : ready for invocations, no transaction in progress 2. INVOKING : processing an invocation 3. DESTROYED : does not exist A Message-driven Bean can hold open DB connections across invocations. It's assumed that the Resource Manager can handle multiple incomplete transactions on the same connection.
- Author:
- Kenneth Saks
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMessageBeanContainer.MessageDeliveryType
-
Field Summary
-
Fields inherited from class com.sun.ejb.containers.BaseContainer
cacheProbeListener, cacheProbeNotifier, callFlowInfo, componentId, CONTAINER_INITIALIZING, CONTAINER_ON_HOLD, CONTAINER_STARTED, CONTAINER_STOPPED, CONTAINER_UNDEPLOYED, containerInfo, containerState, containerStateManager, containerTransactionManager, containerType, debugMonitorFlag, ejbActivateMethod, ejbClass, ejbContainerUtilImpl, ejbDescriptor, ejbGeneratedOptionalLocalBusinessIntfClass, ejbHome, ejbHomeImpl, ejbHomeStub, ejbIntfMethodInfo, ejbIntfMethods, ejbLocalBusinessHome, ejbLocalBusinessHomeImpl, ejbLocalHome, ejbLocalHomeImpl, EJBLocalObject_getPrimaryKey, EJBObject_getPrimaryKey, ejbOptionalLocalBusinessHome, ejbOptionalLocalBusinessHomeImpl, ejbOptionalLocalBusinessHomeIntf, ejbPassivateMethod, ejbProbeListener, ejbProbeNotifier, ejbRemoteBusinessHome, ejbRemoteBusinessHomeImpl, ejbRemoteBusinessHomeStub, ejbRemoveMethod, envProps, hasLocalBusinessView, hasLocalHomeView, hasOptionalLocalBusinessView, hasRemoteBusinessView, hasRemoteHomeView, homeIntf, injectionManager, interceptorManager, invocationInfoMap, invocationManager, isBeanManagedTran, isLocal, isMessageDriven, isRemote, isSession, isSingleton, isStatefulSession, isStatelessSession, isWebServiceEndpoint, loader, localBusinessHomeIntf, localBusinessIntfs, localHomeIntf, logParams, metadata, methodMonitorMap, monitorOn, namingManager, NO_PARAMS, optIntfClassLoader, poolProbeListener, remoteBusinessHomeIntf, remoteBusinessIntfInfo, remoteHomeRefFactory, remoteIntf, scheduleIds, securityManager, sfsbSerializedClass, SINGLETON_BEAN_POOL_PROP, timerProbeListener, timerProbeNotifier, transactionManager, webServiceEndpointIntf, webServiceInvocationInfoMap
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.sun.ejb.containers.EJBContextImpl_constructEJBContextImpl(Object instance)protected com.sun.ejb.ComponentContext_getContext(com.sun.ejb.EjbInvocation inv)voidactivateEJB(Object ctx, Object instanceKey)protected voidaddLocalRemoteInvocationInfo()protected voidafterBegin(com.sun.ejb.containers.EJBContextImpl context)protected voidafterCompletion(com.sun.ejb.containers.EJBContextImpl ctx, int status)voidafterMessageDelivery(com.sun.appserv.connectors.internal.api.ResourceHandle resourceHandle)protected voidbeforeCompletion(com.sun.ejb.containers.EJBContextImpl context)voidbeforeMessageDelivery(Method method, MessageBeanContainer.MessageDeliveryType deliveryType, boolean txImported, com.sun.appserv.connectors.internal.api.ResourceHandle resourceHandle)Actual message delivery happens in three steps : 1) beforeMessageDelivery(Message, MessageListener) This is our chance to make the message delivery itself part of the instance's global transaction.protected booleancallEJBTimeout(com.sun.ejb.containers.RuntimeTimerState timerState, com.sun.ejb.containers.EJBTimerService timerService)Override callEJBTimeout from BaseContainer since delivery to message driven beans is a bit different from session/entity.com.sun.ejb.containers.EJBObjectImplcreateEJBObjectImpl()org.glassfish.ejb.api.MessageBeanListenercreateMessageBeanListener(com.sun.appserv.connectors.internal.api.ResourceHandle resource)The following are implementation for methods required by the * MessageBeanProtocalManager interface.ObjectcreateMessageBeanProxy(InvocationHandler handler)Generates the appropriate Proxy based on the message listener type.ObjectdeliverMessage(Object[] params)voiddestroyMessageBeanListener(org.glassfish.ejb.api.MessageBeanListener listener)protected voiddoConcreteContainerShutdown(boolean appBeingUndeployed)Called by BaseContainer during container shutdown sequenceprotected voidforceDestroyBean(com.sun.ejb.containers.EJBContextImpl sc)Force destroy the EJB.com.sun.ejb.containers.EJBObjectImplgetEJBObjectImpl(byte[] instanceKey)longgetMessageCount()StringgetMonitorAttributeValues()protected com.sun.ejb.monitoring.stats.EjbMonitoringStatsProvidergetMonitoringStatsProvider(String appName, String modName, String ejbName)com.sun.enterprise.deployment.runtime.BeanPoolDescriptorgetPoolDescriptor()protected voidinitializeHome()protected booleanisCreateHomeFinder(Method method)booleanisDeliveryTransacted(Method method)booleanpassivateEJB(com.sun.ejb.ComponentContext context)voidpostInvoke(com.sun.ejb.EjbInvocation inv)TODO public void appendStats(StringBuffer sbuf) { sbuf.append("\nMessageBeanContainer: ").append("CreateCount=").append( statCreateCount).append("; ").append("RemoveCount=").append( statRemoveCount).append("; ").append("MsgCount=").append( statMessageCount).append("; "); sbuf.append("]"); }voidpreInvoke(com.sun.ejb.EjbInvocation inv)protected voidregisterMonitorableComponents(Method[] msgListenerMethods)voidreleaseContext(com.sun.ejb.EjbInvocation inv)Return instance to a pooled state.protected voidremoveBean(com.sun.ejb.containers.EJBLocalRemoteObject ejbo, Method removeMethod, boolean local)booleanscanForEjbCreateMethod()voidsetEJBHome(jakarta.ejb.EJBHome ejbHome)voidstartApplication(boolean deploy)Called when the application containing this message-bean has successfully gotten through the initial load phase of each module.protected static intstringToInt(String val, String appName, Logger logger)booleanuserTransactionMethodsAllowed(org.glassfish.api.invocation.ComponentInvocation inv)protected intvalidateValue(int value, int lowLimit, int highLimit, int deft, String emsg, String appName, Logger logger)-
Methods inherited from class com.sun.ejb.containers.BaseContainer
_constructEJBInstance, addInvocationInfo, addProxyInterfacesSetClass, adjustHomeTargetMethodInfo, adjustInvocationInfo, assertValidLocalObject, assertValidRemoteObject, authorize, authorizeLocalGetPrimaryKey, authorizeLocalMethod, authorizeRemoteGetPrimaryKey, authorizeRemoteMethod, cancelTimers, checkExceptionClientTx, checkExists, checkUnfinishedTx, checkUserTransactionLookup, cleanupInstance, containerStateToString, createCallFlowAgent, createEjbInstanceAndContext, createEjbInstanceForInterceptors, createEjbInvocation, createEjbInvocation, createEJBLocalObjectImpl, createMonitoringRegistry, createRemoteReferenceWithId, delistExtendedEntityManagers, doAfterBegin, doEJBHomeRemove, doFlush, doTimerInvocationInit, enlistExtendedEntityManagers, externalPostInvoke, externalPreInvoke, findFlushEnabledAttr, getApplicationId, getClassLoader, getComponentId, getContainerClassLoader, getContainerId, getContainerType, getContext, getDebugMonitorFlag, getDescriptor, getEJBClass, getEjbDescriptor, getEJBHome, getEJBHomeInvocationHandler, getEJBHomeStub, getEJBLocalBusinessHome, getEJBLocalHome, getEJBLocalHomeInvocationHandler, getEJBLocalObjectForPrimaryKey, getEJBLocalObjectForPrimaryKey, getEJBLocalObjectImpl, getEJBMetaData, getEJBObjectForPrimaryKey, getInvocationKey, getJaccEjb, getJavaGlobalJndiNamePrefix, getMonitoringMethodsArray, getMonitoringMethodsArray, getPassByReference, getPre30LifecycleMethodNames, getProtocolManager, getSecurityManager, getTargetObject, getTimeoutMethod, getTxAttr, getTxAttr, getTxAttrForLifecycleCallback, getUserTransaction, getUseThreadPoolId, incrementCreatedTimedObject, incrementDeliveredTimedObject, incrementRemovedTimedObject, initializeProtocolManager, injectEjbInstance, instantiateEJBLocalBusinessObjectImpl, instantiateEJBLocalObjectImpl, instantiateEJBLocalObjectImpl, instantiateEJBObjectImpl, instantiateEJBObjectImpl, instantiateOptionalEJBLocalBusinessObjectImpl, instantiateRemoteBusinessObjectImpl, intercept, intercept, invokeBeanMethod, invokeFindByPrimaryKey, invokeTargetBeanMethod, isApplicationException, isEjbTimeoutMethod, isHAEnabled, isIdentical, isLocalInterfaceSupported, isLocalObject, isRemoteInterfaceSupported, isRemoteObject, isStopped, isSystemUncheckedException, isTimedObject, isUndeployed, lookupExtendedEntityManager, onEnteringContainer, onLeavingContainer, onReady, onShutdown, onTermination, postCreate, postEjbTimeout, postFind, postInvoke, postInvokeNoTx, postInvokeTx, postProcessInvocationInfo, preInitialize, preInvokeNoTx, preInvokeTx, prepareEjbTimeoutParams, preSelect, registerMonitorableComponents, registerTimerMonitorableComponent, releaseTargetObject, removeBeanUnchecked, removeBeanUnchecked, resumeTransaction, setDebugMonitorFlag, setEJBMetaData, setStartedState, setStoppedState, setUndeployedState, suspendTransaction, toString, undeploy, useClientTx, validateEMForClientTx, validateTxAttr, webServicePostInvoke
-
-
-
-
Method Detail
-
registerMonitorableComponents
protected void registerMonitorableComponents(Method[] msgListenerMethods)
-
getMonitoringStatsProvider
protected com.sun.ejb.monitoring.stats.EjbMonitoringStatsProvider getMonitoringStatsProvider(String appName, String modName, String ejbName)
- Specified by:
getMonitoringStatsProviderin classcom.sun.ejb.containers.BaseContainer
-
scanForEjbCreateMethod
public boolean scanForEjbCreateMethod()
- Overrides:
scanForEjbCreateMethodin classcom.sun.ejb.containers.BaseContainer
-
initializeHome
protected void initializeHome() throws Exception- Overrides:
initializeHomein classcom.sun.ejb.containers.BaseContainer- Throws:
Exception
-
addLocalRemoteInvocationInfo
protected void addLocalRemoteInvocationInfo() throws Exception- Overrides:
addLocalRemoteInvocationInfoin classcom.sun.ejb.containers.BaseContainer- Throws:
Exception
-
isCreateHomeFinder
protected final boolean isCreateHomeFinder(Method method)
- Overrides:
isCreateHomeFinderin classcom.sun.ejb.containers.BaseContainer
-
validateValue
protected int validateValue(int value, int lowLimit, int highLimit, int deft, String emsg, String appName, Logger logger)
-
getMonitorAttributeValues
public String getMonitorAttributeValues()
-
userTransactionMethodsAllowed
public boolean userTransactionMethodsAllowed(org.glassfish.api.invocation.ComponentInvocation inv)
- Specified by:
userTransactionMethodsAllowedin interfacecom.sun.ejb.Container- Overrides:
userTransactionMethodsAllowedin classcom.sun.ejb.containers.BaseContainer
-
getEJBObjectImpl
public com.sun.ejb.containers.EJBObjectImpl getEJBObjectImpl(byte[] instanceKey)
- Specified by:
getEJBObjectImplin classcom.sun.ejb.containers.BaseContainer
-
createEJBObjectImpl
public com.sun.ejb.containers.EJBObjectImpl createEJBObjectImpl() throws jakarta.ejb.CreateException- Specified by:
createEJBObjectImplin classcom.sun.ejb.containers.BaseContainer- Throws:
jakarta.ejb.CreateException
-
removeBean
protected void removeBean(com.sun.ejb.containers.EJBLocalRemoteObject ejbo, Method removeMethod, boolean local) throws jakarta.ejb.RemoveException, jakarta.ejb.EJBException- Specified by:
removeBeanin classcom.sun.ejb.containers.BaseContainer- Throws:
jakarta.ejb.RemoveExceptionjakarta.ejb.EJBException
-
callEJBTimeout
protected boolean callEJBTimeout(com.sun.ejb.containers.RuntimeTimerState timerState, com.sun.ejb.containers.EJBTimerService timerService) throws ExceptionOverride callEJBTimeout from BaseContainer since delivery to message driven beans is a bit different from session/entity.- Overrides:
callEJBTimeoutin classcom.sun.ejb.containers.BaseContainer- Throws:
Exception
-
forceDestroyBean
protected void forceDestroyBean(com.sun.ejb.containers.EJBContextImpl sc)
Force destroy the EJB. Called from postInvokeTx. Note: EJB2.0 section 18.3.1 says that discarding an EJB means that no methods other than finalize() should be invoked on it.- Specified by:
forceDestroyBeanin classcom.sun.ejb.containers.BaseContainer
-
preInvoke
public void preInvoke(com.sun.ejb.EjbInvocation inv)
- Specified by:
preInvokein interfacecom.sun.ejb.Container- Overrides:
preInvokein classcom.sun.ejb.containers.BaseContainer
-
_getContext
protected com.sun.ejb.ComponentContext _getContext(com.sun.ejb.EjbInvocation inv)
- Specified by:
_getContextin classcom.sun.ejb.containers.BaseContainer
-
releaseContext
public void releaseContext(com.sun.ejb.EjbInvocation inv)
Return instance to a pooled state.- Specified by:
releaseContextin classcom.sun.ejb.containers.BaseContainer
-
postInvoke
public void postInvoke(com.sun.ejb.EjbInvocation inv)
TODO public void appendStats(StringBuffer sbuf) { sbuf.append("\nMessageBeanContainer: ").append("CreateCount=").append( statCreateCount).append("; ").append("RemoveCount=").append( statRemoveCount).append("; ").append("MsgCount=").append( statMessageCount).append("; "); sbuf.append("]"); }- Specified by:
postInvokein interfacecom.sun.ejb.Container- Overrides:
postInvokein classcom.sun.ejb.containers.BaseContainer
-
createMessageBeanListener
public org.glassfish.ejb.api.MessageBeanListener createMessageBeanListener(com.sun.appserv.connectors.internal.api.ResourceHandle resource) throws org.glassfish.ejb.api.ResourcesExceededExceptionThe following are implementation for methods required by the * MessageBeanProtocalManager interface. *- Specified by:
createMessageBeanListenerin interfaceorg.glassfish.ejb.api.MessageBeanProtocolManager- Throws:
org.glassfish.ejb.api.ResourcesExceededException
-
destroyMessageBeanListener
public void destroyMessageBeanListener(org.glassfish.ejb.api.MessageBeanListener listener)
- Specified by:
destroyMessageBeanListenerin interfaceorg.glassfish.ejb.api.MessageBeanProtocolManager
-
isDeliveryTransacted
public boolean isDeliveryTransacted(Method method)
- Specified by:
isDeliveryTransactedin interfaceorg.glassfish.ejb.api.MessageBeanProtocolManager- Parameters:
method- One of the methods used to deliver messages, e.g. onMessage method for jakarta.jms.MessageListener. Note that if themethodis not one of the methods for message delivery, the behavior of this method is not defined.
-
getPoolDescriptor
public com.sun.enterprise.deployment.runtime.BeanPoolDescriptor getPoolDescriptor()
- Specified by:
getPoolDescriptorin interfaceorg.glassfish.ejb.api.MessageBeanProtocolManager
-
createMessageBeanProxy
public Object createMessageBeanProxy(InvocationHandler handler) throws Exception
Generates the appropriate Proxy based on the message listener type.- Specified by:
createMessageBeanProxyin interfaceorg.glassfish.ejb.api.MessageBeanProtocolManager- Parameters:
handler- InvocationHandler responsible for calls on the proxy- Returns:
- an object implementing MessageEndpoint and the appropriate MDB view
- Throws:
Exception
-
_constructEJBContextImpl
protected com.sun.ejb.containers.EJBContextImpl _constructEJBContextImpl(Object instance)
- Overrides:
_constructEJBContextImplin classcom.sun.ejb.containers.BaseContainer
-
afterBegin
protected void afterBegin(com.sun.ejb.containers.EJBContextImpl context)
- Specified by:
afterBeginin classcom.sun.ejb.containers.BaseContainer
-
beforeCompletion
protected void beforeCompletion(com.sun.ejb.containers.EJBContextImpl context)
- Specified by:
beforeCompletionin classcom.sun.ejb.containers.BaseContainer
-
afterCompletion
protected void afterCompletion(com.sun.ejb.containers.EJBContextImpl ctx, int status)- Specified by:
afterCompletionin classcom.sun.ejb.containers.BaseContainer
-
passivateEJB
public boolean passivateEJB(com.sun.ejb.ComponentContext context)
- Specified by:
passivateEJBin classcom.sun.ejb.containers.BaseContainer
-
startApplication
public void startApplication(boolean deploy)
Called when the application containing this message-bean has successfully gotten through the initial load phase of each module. Now we can "turn on the spigot" and allow incoming requests, which could result in the creation of message-bean instances.- Specified by:
startApplicationin interfacecom.sun.ejb.Container- Overrides:
startApplicationin classcom.sun.ejb.containers.BaseContainer- Parameters:
deploy- true if this method is called during application deploy
-
doConcreteContainerShutdown
protected void doConcreteContainerShutdown(boolean appBeingUndeployed)
Called by BaseContainer during container shutdown sequence- Specified by:
doConcreteContainerShutdownin classcom.sun.ejb.containers.BaseContainer
-
beforeMessageDelivery
public void beforeMessageDelivery(Method method, MessageBeanContainer.MessageDeliveryType deliveryType, boolean txImported, com.sun.appserv.connectors.internal.api.ResourceHandle resourceHandle)
Actual message delivery happens in three steps : 1) beforeMessageDelivery(Message, MessageListener) This is our chance to make the message delivery itself part of the instance's global transaction. 2) onMessage(Message, MessageListener) This is where the container delegates to the actual ejb instance's onMessage method. 3) afterMessageDelivery(Message, MessageListener) Perform transaction cleanup and error handling. We use the EjbInvocation manager's thread-specific state to track the invocation across these three calls.
-
afterMessageDelivery
public void afterMessageDelivery(com.sun.appserv.connectors.internal.api.ResourceHandle resourceHandle)
-
getMessageCount
public long getMessageCount()
-
-