com.sun.ejb.containers
Class MessageBeanContainer

java.lang.Object
  extended by com.sun.ejb.containers.BaseContainer
      extended by com.sun.ejb.containers.MessageBeanContainer
All Implemented Interfaces:
Container, JavaEEContainer, MessageBeanProtocolManager, EjbContainerFacade

public final class MessageBeanContainer
extends BaseContainer
implements MessageBeanProtocolManager

This 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
static class MessageBeanContainer.MessageDeliveryType
           
 
Nested classes/interfaces inherited from class com.sun.ejb.containers.BaseContainer
BaseContainer.ContainerType
 
Field Summary
 
Fields inherited from class com.sun.ejb.containers.BaseContainer
cacheProbeListener, cacheProbeNotifier, callFlowInfo, cmtTimeoutInSeconds, componentId, CONTAINER_INITIALIZING, CONTAINER_ON_HOLD, CONTAINER_STARTED, CONTAINER_STOPPED, CONTAINER_UNDEPLOYED, containerInfo, containerState, containerType, debugMonitorFlag, ejbActivateMethod, ejbClass, ejbContainerUtilImpl, ejbDescriptor, ejbGeneratedOptionalLocalBusinessIntfClass, ejbHome, ejbHomeImpl, ejbHomeStub, ejbIntfMethodInfo, ejbIntfMethods, ejbLocalBusinessHome, ejbLocalBusinessHomeImpl, ejbLocalHome, ejbLocalHomeImpl, ejbMethodStatsManager, ejbOptionalLocalBusinessHome, ejbOptionalLocalBusinessHomeImpl, ejbOptionalLocalBusinessHomeIntf, ejbPassivateMethod, ejbProbeListener, ejbProbeNotifier, ejbRemoteBusinessHome, ejbRemoteBusinessHomeImpl, ejbRemoteBusinessHomeStub, ejbRemoveMethod, ejbTimeoutMethod, envProps, hasLocalBusinessView, hasLocalHomeView, hasOptionalLocalBusinessView, hasRemoteBusinessView, hasRemoteHomeView, homeIntf, injectionManager, interceptorManager, invocationInfoMap, invocationManager, isEntity, isLocal, isMessageDriven, isRemote, isSession, isSingleton, isStatefulSession, isStatelessSession, isWebServiceEndpoint, lifecycleCallbackAnnotationClasses, loader, localBusinessHomeIntf, localBusinessIntfs, localHomeIntf, logParams, metadata, methodMonitorMap, monitorOn, namingManager, NO_PARAMS, optIntfClassLoader, poolProbeListener, registryMediator, remoteBusinessHomeIntf, remoteBusinessIntfInfo, remoteHomeRefFactory, remoteIntf, scheduleIds, securityManager, sfsbSerializedClass, SINGLETON_BEAN_POOL_PROP, timerProbeListener, timerProbeNotifier, transactionManager, webServiceEndpointIntf, webServiceInvocationInfoMap
 
Fields inherited from interface com.sun.ejb.Container
SEC_CHECKED, SEC_EXCLUDED, SEC_NOT_INITIALIZED, SEC_UNCHECKED, secAttrStrings, TX_BEAN_MANAGED, TX_MANDATORY, TX_NEVER, TX_NOT_INITIALIZED, TX_NOT_SUPPORTED, TX_REQUIRED, TX_REQUIRES_NEW, TX_SUPPORTS, txAttrStrings
 
Method Summary
protected  EJBContextImpl _constructEJBContextImpl(Object instance)
           
protected  ComponentContext _getContext(EjbInvocation inv)
           
 void activateEJB(Object ctx, Object instanceKey)
           
 void afterMessageDelivery(ResourceHandle resourceHandle)
           
 void beforeMessageDelivery(Method method, MessageBeanContainer.MessageDeliveryType deliveryType, boolean txImported, 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.
 EJBObjectImpl createEJBObjectImpl()
           
 MessageBeanListener createMessageBeanListener(ResourceHandle resource)
          The following are implementation for methods required by the * MessageBeanProtocalManager interface.
 Object deliverMessage(Object[] params)
           
 void destroyMessageBeanListener(MessageBeanListener listener)
           
protected  void doConcreteContainerShutdown(boolean appBeingUndeployed)
          Called by BaseContainer during container shutdown sequence
 EJBObjectImpl getEJBObjectImpl(byte[] instanceKey)
          Called when a remote invocation arrives for an EJB.
 long getMessageCount()
           
 String getMonitorAttributeValues()
           
protected  EjbMonitoringStatsProvider getMonitoringStatsProvider(String appName, String modName, String ejbName)
           
 BeanPoolDescriptor getPoolDescriptor()
           
protected  void initializeHome()
          Called from the ContainerFactory during initialization.
 boolean isDeliveryTransacted(Method method)
           
 boolean passivateEJB(ComponentContext context)
           
 void postInvoke(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("]"); }
 void preInvoke(EjbInvocation inv)
          Called from EJBObject/EJBHome before invoking on EJB.
protected  void registerMonitorableComponents(Method[] msgListenerMethods)
           
 void releaseContext(EjbInvocation inv)
          Return instance to a pooled state.
 void setEJBHome(EJBHome ejbHome)
           
 void startApplication(boolean deploy)
          Called when the application containing this message-bean has successfully gotten through the initial load phase of each module.
protected static int stringToInt(String val, String appName, Logger logger)
           
 boolean userTransactionMethodsAllowed(ComponentInvocation inv)
          EJB spec makes a distinction between access to the UserTransaction object itself and access to its methods.
protected  int validateValue(int value, int lowLimit, int highLimit, int deft, String emsg, String appName, Logger logger)
           
 
Methods inherited from class com.sun.ejb.containers.BaseContainer
_constructEJBInstance, addSchedule, assertValidLocalObject, assertValidRemoteObject, authorize, checkExceptionClientTx, checkUnfinishedTx, checkUserTransactionLookup, cleanupInstance, containerStateToString, createCallFlowAgent, createEjbInstanceAndContext, createMonitoringRegistryMediator, createRemoteReferenceWithId, doAfterBegin, doEJBHomeRemove, doFlush, enlistExtendedEntityManagers, externalPostInvoke, externalPreInvoke, findFlushEnabledAttr, findTxAttr, getClassLoader, getComponentId, getContainerClassLoader, getContainerType, getContext, getDebugMonitorFlag, getDescriptor, getEJBClass, getEjbDescriptor, getEJBHome, getEJBHomeStub, getEJBLocalBusinessHome, getEJBLocalHome, getEJBLocalObjectForPrimaryKey, getEJBLocalObjectForPrimaryKey, getEJBMetaData, getEJBObjectForPrimaryKey, getJaccEjb, getJavaGlobalJndiNamePrefix, getMonitoringMethodsArray, getMonitoringMethodsArray, getPre30LifecycleMethodNames, getProtocolManager, getSecurityManager, getTargetObject, getTxAttr, getTxAttr, incrementCreatedTimedObject, incrementDeliveredTimedObject, incrementRemovedTimedObject, injectEjbInstance, instantiateEJBLocalBusinessObjectImpl, instantiateEJBLocalObjectImpl, instantiateEJBObjectImpl, instantiateOptionalEJBLocalBusinessObjectImpl, instantiateRemoteBusinessObjectImpl, invokeBeanMethod, isAppExceptionRequiringRollback, isApplicationException, isHAEnabled, isLocalInterfaceSupported, isRemoteInterfaceSupported, isStopped, isSystemUncheckedException, isTimedObject, isUndeployed, lookupExtendedEntityManager, onReady, onShutdown, onTermination, populateMethodMonitorMap, populateMethodMonitorMap, populateMethodMonitorMap, postCreate, postFind, postInvoke, postInvokeTx, postProcessInvocationInfo, preInitialize, preInvokeTx, preSelect, registerMonitorableComponents, registerTimerMonitorableComponent, registerTxAttrForMethod, releaseTargetObject, removeBeanUnchecked, removeBeanUnchecked, setDebugMonitorFlag, setMonitorOn, setSecurityManager, setStartedState, setStoppedState, setUndeployedState, toString, undeploy, useClientTx, webServicePostInvoke
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

registerMonitorableComponents

protected void registerMonitorableComponents(Method[] msgListenerMethods)

getMonitoringStatsProvider

protected EjbMonitoringStatsProvider getMonitoringStatsProvider(String appName,
                                                                String modName,
                                                                String ejbName)
Specified by:
getMonitoringStatsProvider in class BaseContainer

initializeHome

protected void initializeHome()
                       throws Exception
Description copied from class: BaseContainer
Called from the ContainerFactory during initialization.

Throws:
Exception

stringToInt

protected static int stringToInt(String val,
                                 String appName,
                                 Logger logger)

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(ComponentInvocation inv)
Description copied from class: BaseContainer
EJB spec makes a distinction between access to the UserTransaction object itself and access to its methods. getUserTransaction covers the first check and this method covers the second. It is called by the UserTransaction implementation to verify access.

Specified by:
userTransactionMethodsAllowed in interface Container
Overrides:
userTransactionMethodsAllowed in class BaseContainer

setEJBHome

public void setEJBHome(EJBHome ejbHome)
                throws Exception
Throws:
Exception

getEJBObjectImpl

public EJBObjectImpl getEJBObjectImpl(byte[] instanceKey)
Description copied from class: BaseContainer
Called when a remote invocation arrives for an EJB. Implemented in subclasses.


createEJBObjectImpl

public EJBObjectImpl createEJBObjectImpl()
                                  throws CreateException
Throws:
CreateException

preInvoke

public void preInvoke(EjbInvocation inv)
Description copied from class: BaseContainer
Called from EJBObject/EJBHome before invoking on EJB. Set the EJB instance in the EjbInvocation. It must be ensured that the following general pattern is followed by various parts of the EJBContainer code: try { container.preInvoke(inv); returnValue = container.intercept(inv); } catch (Exception1 e1) { ... } catch (Exception2 e2) { ... } finally { container.postInvoke(); }

Specified by:
preInvoke in interface Container
Overrides:
preInvoke in class BaseContainer

_getContext

protected ComponentContext _getContext(EjbInvocation inv)
Specified by:
_getContext in class BaseContainer

releaseContext

public void releaseContext(EjbInvocation inv)
Return instance to a pooled state.

Specified by:
releaseContext in class BaseContainer

postInvoke

public void postInvoke(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:
postInvoke in interface Container
Overrides:
postInvoke in class BaseContainer

createMessageBeanListener

public MessageBeanListener createMessageBeanListener(ResourceHandle resource)
                                              throws ResourcesExceededException
The following are implementation for methods required by the * MessageBeanProtocalManager interface. *

Specified by:
createMessageBeanListener in interface MessageBeanProtocolManager
Throws:
ResourcesExceededException

destroyMessageBeanListener

public void destroyMessageBeanListener(MessageBeanListener listener)
Specified by:
destroyMessageBeanListener in interface MessageBeanProtocolManager

isDeliveryTransacted

public boolean isDeliveryTransacted(Method method)
Specified by:
isDeliveryTransacted in interface MessageBeanProtocolManager
Parameters:
method - One of the methods used to deliver messages, e.g. onMessage method for javax.jms.MessageListener. Note that if the method is not one of the methods for message delivery, the behavior of this method is not defined.

getPoolDescriptor

public BeanPoolDescriptor getPoolDescriptor()
Specified by:
getPoolDescriptor in interface MessageBeanProtocolManager

_constructEJBContextImpl

protected EJBContextImpl _constructEJBContextImpl(Object instance)
Overrides:
_constructEJBContextImpl in class BaseContainer

passivateEJB

public boolean passivateEJB(ComponentContext context)

activateEJB

public void activateEJB(Object ctx,
                        Object instanceKey)

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:
startApplication in interface Container
Overrides:
startApplication in class 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:
doConcreteContainerShutdown in class BaseContainer

beforeMessageDelivery

public void beforeMessageDelivery(Method method,
                                  MessageBeanContainer.MessageDeliveryType deliveryType,
                                  boolean txImported,
                                  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.


deliverMessage

public Object deliverMessage(Object[] params)
                      throws Throwable
Throws:
Throwable

afterMessageDelivery

public void afterMessageDelivery(ResourceHandle resourceHandle)

getMessageCount

public long getMessageCount()


Copyright © 2012 GlassFish Community. All Rights Reserved.