org.jboss.ejb.plugins.jms
Class JMSContainerInvoker

java.lang.Object
  extended by org.jboss.mx.util.JBossNotificationBroadcasterSupport
      extended by org.jboss.system.ServiceMBeanSupport
          extended by org.jboss.ejb.plugins.jms.JMSContainerInvoker
All Implemented Interfaces:
javax.management.MBeanRegistration, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, AllowedOperationsFlags, ContainerPlugin, EJBProxyFactory, GenericEntityObjectFactory, JMSContainerInvokerMBean, org.jboss.system.Service, org.jboss.system.ServiceMBean

public class JMSContainerInvoker
extends org.jboss.system.ServiceMBeanSupport
implements EJBProxyFactory, JMSContainerInvokerMBean

EJBProxyFactory for JMS MessageDrivenBeans

Version:
$Revision: 57506 $
Author:
Peter Antman ., Rickard Oberg, Sebastien Alborini, Marc Fleury, Jason Dillon, Adrian Brock

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jboss.ejb.GenericEntityObjectFactory
GenericEntityObjectFactory.UTIL
 
Field Summary
protected  int acknowledgeMode
          JMS acknowledge mode, used when session is not XA.
protected  javax.jms.Connection connection
          The JMS connection.
protected  javax.jms.ConnectionConsumer connectionConsumer
          The JMS connection consumer.
protected  Container container
          The container.
protected  boolean createJBossMQDestination
           
protected static String DEFAULT_DESTINATION_TYPE
          Default destination type.
protected  boolean deliveryActive
           
protected  Element dlqConfig
          DLQConfig element from MDBConfig element from jboss.xml.
protected  DLQHandler dlqHandler
          Dead letter queue handler.
protected  org.jboss.ejb.plugins.jms.JMSContainerInvoker.ExceptionListenerImpl exListener
           
protected  String invokerBinding
           
protected  InvokerProxyBindingMetaData invokerMetaData
           
protected  boolean isContainerManagedTx
           
protected  boolean isNotSupportedTx
           
protected  long keepAlive
          Keep alive server sessions.
protected  int maxMessagesNr
          Maximum number provider is allowed to stuff into a session.
protected  int maxPoolSize
          Maximun pool size of server sessions.
protected  int minPoolSize
          Minimun pool size of server sessions.
protected static Method ON_MESSAGE
          MessageListener.onMessage(javax.jms.Message) reference.
protected  boolean optimize
           
protected  javax.jms.ServerSessionPool pool
           
protected  String providerAdapterJNDI
          JNDI name of the provider adapter.
protected  long reconnectInterval
          Time to wait before retrying to reconnect a lost connection.
protected  String serverSessionPoolFactoryJNDI
          JNDI name of the server session factory.
protected  TransactionManager tm
           
protected  boolean useDLQ
          If Dead letter queue should be used or not.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport
server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.ejb.AllowedOperationsFlags
IN_AFTER_BEGIN, IN_AFTER_COMPLETION, IN_BEFORE_COMPLETION, IN_BUSINESS_METHOD, IN_EJB_ACTIVATE, IN_EJB_CREATE, IN_EJB_FIND, IN_EJB_HOME, IN_EJB_LOAD, IN_EJB_PASSIVATE, IN_EJB_POST_CREATE, IN_EJB_REMOVE, IN_EJB_STORE, IN_EJB_TIMEOUT, IN_INTERCEPTOR_METHOD, IN_SERVICE_ENDPOINT_METHOD, IN_SET_ENTITY_CONTEXT, IN_SET_MESSAGE_DRIVEN_CONTEXT, IN_SET_SESSION_CONTEXT, IN_UNSET_ENTITY_CONTEXT, NOT_ALLOWED
 
Fields inherited from interface org.jboss.system.ServiceMBean
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
JMSContainerInvoker()
           
 
Method Summary
protected  javax.jms.Destination createDestination(Class type, Context ctx, String jndiName, String jndiSuffix)
          Create and or lookup a JMS destination.
protected  void createService()
          Initialize the container invoker.
protected  javax.jms.ServerSessionPool createSessionPool(javax.jms.Destination destination, javax.jms.Connection connection, int minSession, int maxSession, long keepAlive, boolean isTransacted, int ack, javax.jms.MessageListener listener)
          Create a server session pool for the given connection.
protected  String getActivationConfigProperty(String property)
           
 boolean getCreateJBossMQDestination()
          Get whether JBossMQ destinations should be constructed when the destination is not in JNDI
 boolean getDeliveryActive()
          Get whether delivery is active
protected  String getDestinationType(Context ctx, String destinationJNDI)
          Try to get a destination type by looking up the destination JNDI, or provide a default if there is not destinationJNDI or if it is not possible to lookup.
 Object getEJBHome()
          This method is called whenever the EJBHome implementation for this container is needed.
 javax.ejb.EJBMetaData getEJBMetaData()
          This method is called whenever the metadata for this container is needed.
 Collection getEntityCollection(Collection ids)
          This method is called whenever a collection of EJBObjects for a collection of primary keys is needed.
 Object getEntityEJBObject(Object id)
          This method is called whenever an EJBObject implementation for an entitybean is needed.
protected  JMSProviderAdapter getJMSProviderAdapter()
          Return the JMSProviderAdapter that should be used.
 long getKeepAliveMillis()
          Get the keep alive millis
 int getMaxMessages()
          Get the maximum number of messages
 int getMaxPoolSize()
          Get the maximum pool size
 MessageDrivenMetaData getMetaData()
          Get the message driven metadata
 int getMinPoolSize()
          Get the minimum pool size
 Object getStatefulSessionEJBObject(Object id)
          This method is called whenever an EJBObject implementation for a stateful session bean is needed.
 Object getStatelessSessionEJBObject()
          This method is called whenever an EJBObject implementation for a stateless session bean is needed.
 void importXml(Element element)
          XmlLoadable implementation.
protected  void innerStartDelivery()
          Initialize the container invoker.
protected  void innerStopDelivery()
          Stop done from inside, we should not stop the exceptionListener in inner stop.
 Object invoke(Object id, Method m, Object[] args, Transaction tx, Principal identity, Object credential)
           
 boolean isIdentical(Container container, Invocation mi)
          Protocol specific isIdentical implementation
 boolean isOptimized()
           
protected  String parseJndiSuffix(String jndiname, String defautSuffix)
          Parse the JNDI suffix from the given JNDI name.
protected  void sendNotification(String event, Object userData)
          Notify of an event
 void setContainer(Container container)
          Set the container for which this is an invoker to.
 void setInvokerBinding(String binding)
          Set the invoker jndi binding
 void setInvokerMetaData(InvokerProxyBindingMetaData imd)
          Set the invoker meta data so that the ProxyFactory can initialize properly
 void setKeepAliveMillis(long keepAlive)
          Set the keep alive millis
 void setMaxMessages(int maxMessages)
          Set the maximum number of messages
 void setMaxPoolSize(int maxPoolSize)
          Set the maximum pool size
 void setMinPoolSize(int minPoolSize)
          Set the minimum pool size
 void setOptimized(boolean optimize)
          Sets the Optimized attribute of the JMSContainerInvoker object
 void startDelivery()
          Start delivery
protected  void startService()
           
 void stopDelivery()
          Stop delivery
protected  void stopService()
           
 String toString()
          Return a string representation of the current config state.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport
create, destroy, destroyService, getDeploymentInfo, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, nextNotificationSequenceNumber, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 
Methods inherited from interface org.jboss.system.ServiceMBean
getName, getState, getStateString, jbossInternalLifecycle
 
Methods inherited from interface org.jboss.system.Service
create, destroy, start, stop
 

Field Detail

ON_MESSAGE

protected static Method ON_MESSAGE
MessageListener.onMessage(javax.jms.Message) reference.


DEFAULT_DESTINATION_TYPE

protected static final String DEFAULT_DESTINATION_TYPE
Default destination type. Used when no message-driven-destination is given in ejb-jar, and a lookup of destinationJNDI from jboss.xml is not successfull. Default value: javax.jms.Topic.

See Also:
Constant Field Values

optimize

protected boolean optimize

maxMessagesNr

protected int maxMessagesNr
Maximum number provider is allowed to stuff into a session.


minPoolSize

protected int minPoolSize
Minimun pool size of server sessions.


keepAlive

protected long keepAlive
Keep alive server sessions.


maxPoolSize

protected int maxPoolSize
Maximun pool size of server sessions.


reconnectInterval

protected long reconnectInterval
Time to wait before retrying to reconnect a lost connection.


useDLQ

protected boolean useDLQ
If Dead letter queue should be used or not.


providerAdapterJNDI

protected String providerAdapterJNDI
JNDI name of the provider adapter.

See Also:
JMSProviderAdapter

serverSessionPoolFactoryJNDI

protected String serverSessionPoolFactoryJNDI
JNDI name of the server session factory.

See Also:
ServerSessionPoolFactory

acknowledgeMode

protected int acknowledgeMode
JMS acknowledge mode, used when session is not XA.


isContainerManagedTx

protected boolean isContainerManagedTx

isNotSupportedTx

protected boolean isNotSupportedTx

container

protected Container container
The container.


connection

protected javax.jms.Connection connection
The JMS connection.


connectionConsumer

protected javax.jms.ConnectionConsumer connectionConsumer
The JMS connection consumer.


tm

protected TransactionManager tm

pool

protected javax.jms.ServerSessionPool pool

exListener

protected org.jboss.ejb.plugins.jms.JMSContainerInvoker.ExceptionListenerImpl exListener

dlqHandler

protected DLQHandler dlqHandler
Dead letter queue handler.


dlqConfig

protected Element dlqConfig
DLQConfig element from MDBConfig element from jboss.xml.


invokerMetaData

protected InvokerProxyBindingMetaData invokerMetaData

invokerBinding

protected String invokerBinding

deliveryActive

protected boolean deliveryActive

createJBossMQDestination

protected boolean createJBossMQDestination
Constructor Detail

JMSContainerInvoker

public JMSContainerInvoker()
Method Detail

setInvokerMetaData

public void setInvokerMetaData(InvokerProxyBindingMetaData imd)
Set the invoker meta data so that the ProxyFactory can initialize properly

Specified by:
setInvokerMetaData in interface EJBProxyFactory

setInvokerBinding

public void setInvokerBinding(String binding)
Set the invoker jndi binding

Specified by:
setInvokerBinding in interface EJBProxyFactory

setContainer

public void setContainer(Container container)
Set the container for which this is an invoker to.

Specified by:
setContainer in interface ContainerPlugin
Parameters:
container - The container for which this is an invoker to.

getMinPoolSize

public int getMinPoolSize()
Description copied from interface: JMSContainerInvokerMBean
Get the minimum pool size

Specified by:
getMinPoolSize in interface JMSContainerInvokerMBean
Returns:
the minimum pool size

setMinPoolSize

public void setMinPoolSize(int minPoolSize)
Description copied from interface: JMSContainerInvokerMBean
Set the minimum pool size

Specified by:
setMinPoolSize in interface JMSContainerInvokerMBean
Parameters:
minPoolSize - the size

getMaxPoolSize

public int getMaxPoolSize()
Description copied from interface: JMSContainerInvokerMBean
Get the maximum pool size

Specified by:
getMaxPoolSize in interface JMSContainerInvokerMBean
Returns:
the maximum pool size

setMaxPoolSize

public void setMaxPoolSize(int maxPoolSize)
Description copied from interface: JMSContainerInvokerMBean
Set the maximum pool size

Specified by:
setMaxPoolSize in interface JMSContainerInvokerMBean
Parameters:
maxPoolSize - the size

getKeepAliveMillis

public long getKeepAliveMillis()
Description copied from interface: JMSContainerInvokerMBean
Get the keep alive millis

Specified by:
getKeepAliveMillis in interface JMSContainerInvokerMBean
Returns:
the milliseconds

setKeepAliveMillis

public void setKeepAliveMillis(long keepAlive)
Description copied from interface: JMSContainerInvokerMBean
Set the keep alive millis

Specified by:
setKeepAliveMillis in interface JMSContainerInvokerMBean
Parameters:
keepAlive - the milliseconds

getMaxMessages

public int getMaxMessages()
Description copied from interface: JMSContainerInvokerMBean
Get the maximum number of messages

Specified by:
getMaxMessages in interface JMSContainerInvokerMBean
Returns:
the number of messages

setMaxMessages

public void setMaxMessages(int maxMessages)
Description copied from interface: JMSContainerInvokerMBean
Set the maximum number of messages

Specified by:
setMaxMessages in interface JMSContainerInvokerMBean
Parameters:
maxMessages - the number of messages

getMetaData

public MessageDrivenMetaData getMetaData()
Description copied from interface: JMSContainerInvokerMBean
Get the message driven metadata

Specified by:
getMetaData in interface JMSContainerInvokerMBean
Returns:
the metadata

getDeliveryActive

public boolean getDeliveryActive()
Description copied from interface: JMSContainerInvokerMBean
Get whether delivery is active

Specified by:
getDeliveryActive in interface JMSContainerInvokerMBean
Returns:
true when active

getCreateJBossMQDestination

public boolean getCreateJBossMQDestination()
Description copied from interface: JMSContainerInvokerMBean
Get whether JBossMQ destinations should be constructed when the destination is not in JNDI

Specified by:
getCreateJBossMQDestination in interface JMSContainerInvokerMBean
Returns:
true to create

startDelivery

public void startDelivery()
                   throws Exception
Description copied from interface: JMSContainerInvokerMBean
Start delivery

Specified by:
startDelivery in interface JMSContainerInvokerMBean
Throws:
Exception - for any error

stopDelivery

public void stopDelivery()
                  throws Exception
Description copied from interface: JMSContainerInvokerMBean
Stop delivery

Specified by:
stopDelivery in interface JMSContainerInvokerMBean
Throws:
Exception - for any error

setOptimized

public void setOptimized(boolean optimize)
Sets the Optimized attribute of the JMSContainerInvoker object

Parameters:
optimize - The new Optimized value

isIdentical

public boolean isIdentical(Container container,
                           Invocation mi)
Description copied from interface: EJBProxyFactory
Protocol specific isIdentical implementation

Specified by:
isIdentical in interface EJBProxyFactory
Parameters:
container - the container
mi - the invocation
Returns:
true when identical, false otherwise

getEJBHome

public Object getEJBHome()
Description copied from interface: EJBProxyFactory
This method is called whenever the EJBHome implementation for this container is needed.

Specified by:
getEJBHome in interface EJBProxyFactory
Returns:
An implementation of the home interface for this container.

getEJBMetaData

public javax.ejb.EJBMetaData getEJBMetaData()
Description copied from interface: EJBProxyFactory
This method is called whenever the metadata for this container is needed.

Specified by:
getEJBMetaData in interface EJBProxyFactory
Returns:
An implementation of the EJBMetaData interface.

getEntityCollection

public Collection getEntityCollection(Collection ids)
Description copied from interface: EJBProxyFactory
This method is called whenever a collection of EJBObjects for a collection of primary keys is needed.

Specified by:
getEntityCollection in interface EJBProxyFactory
Parameters:
ids - Enumeration of primary keys.
Returns:
A collection of EJBObjects implementing the remote interface for this container.

getEntityEJBObject

public Object getEntityEJBObject(Object id)
Description copied from interface: EJBProxyFactory
This method is called whenever an EJBObject implementation for an entitybean is needed.

Specified by:
getEntityEJBObject in interface EJBProxyFactory
Specified by:
getEntityEJBObject in interface GenericEntityObjectFactory
Parameters:
id - The primary key of the entity.
Returns:
An implementation of the remote interface for this container.

getStatefulSessionEJBObject

public Object getStatefulSessionEJBObject(Object id)
Description copied from interface: EJBProxyFactory
This method is called whenever an EJBObject implementation for a stateful session bean is needed.

Specified by:
getStatefulSessionEJBObject in interface EJBProxyFactory
Parameters:
id - The id of the session.
Returns:
An implementation of the remote interface for this container.

getStatelessSessionEJBObject

public Object getStatelessSessionEJBObject()
Description copied from interface: EJBProxyFactory
This method is called whenever an EJBObject implementation for a stateless session bean is needed.

Specified by:
getStatelessSessionEJBObject in interface EJBProxyFactory
Returns:
An implementation of the remote interface for this container.

isOptimized

public boolean isOptimized()

importXml

public void importXml(Element element)
               throws Exception
XmlLoadable implementation.

Parameters:
element - Description of Parameter
Throws:
org.jboss.deployment.DeploymentException - Description of Exception
Exception

createService

protected void createService()
                      throws Exception
Initialize the container invoker. Sets up a connection, a server session pool and a connection consumer for the configured destination.

Any JMSExceptions produced while initializing will be assumed to be caused due to JMS Provider failure.

Overrides:
createService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception - Failed to initalize.

innerStartDelivery

protected void innerStartDelivery()
                           throws Exception
Initialize the container invoker. Sets up a connection, a server session pool and a connection consumer for the configured destination.

Throws:
Exception - Failed to initalize.

startService

protected void startService()
                     throws Exception
Overrides:
startService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

stopService

protected void stopService()
                    throws Exception
Overrides:
stopService in class org.jboss.system.ServiceMBeanSupport
Throws:
Exception

innerStopDelivery

protected void innerStopDelivery()
Stop done from inside, we should not stop the exceptionListener in inner stop.


invoke

public Object invoke(Object id,
                     Method m,
                     Object[] args,
                     Transaction tx,
                     Principal identity,
                     Object credential)
              throws Exception
Throws:
Exception

getDestinationType

protected String getDestinationType(Context ctx,
                                    String destinationJNDI)
Try to get a destination type by looking up the destination JNDI, or provide a default if there is not destinationJNDI or if it is not possible to lookup.

Parameters:
ctx - The naming context to lookup destinations from.
destinationJNDI - The name to use when looking up destinations.
Returns:
The destination type, either derived from destinationJDNI or DEFAULT_DESTINATION_TYPE

getJMSProviderAdapter

protected JMSProviderAdapter getJMSProviderAdapter()
                                            throws NamingException
Return the JMSProviderAdapter that should be used.

Returns:
The JMSProviderAdapter to use.
Throws:
NamingException

createDestination

protected javax.jms.Destination createDestination(Class type,
                                                  Context ctx,
                                                  String jndiName,
                                                  String jndiSuffix)
                                           throws Exception
Create and or lookup a JMS destination.

Parameters:
type - Either javax.jms.Queue or javax.jms.Topic.
ctx - The naming context to lookup destinations from.
jndiName - The name to use when looking up destinations.
jndiSuffix - The name to use when creating destinations.
Returns:
The destination.
Throws:
IllegalArgumentException - Type is not Queue or Topic.
Exception - Description of Exception

getActivationConfigProperty

protected String getActivationConfigProperty(String property)

createSessionPool

protected javax.jms.ServerSessionPool createSessionPool(javax.jms.Destination destination,
                                                        javax.jms.Connection connection,
                                                        int minSession,
                                                        int maxSession,
                                                        long keepAlive,
                                                        boolean isTransacted,
                                                        int ack,
                                                        javax.jms.MessageListener listener)
                                                 throws NamingException,
                                                        javax.jms.JMSException
Create a server session pool for the given connection.

Parameters:
destination - the destination
connection - The connection to use.
minSession - The minumum number of sessions
maxSession - The maximum number of sessions.
keepAlive - The time to keep sessions alive
isTransacted - True if the sessions are transacted.
ack - The session acknowledgement mode.
listener - The message listener.
Returns:
A server session pool.
Throws:
javax.jms.JMSException
NamingException - Description of Exception

sendNotification

protected void sendNotification(String event,
                                Object userData)
Notify of an event

Parameters:
event - the event
userData - any user data, e.g. the exception on a failure

parseJndiSuffix

protected String parseJndiSuffix(String jndiname,
                                 String defautSuffix)
Parse the JNDI suffix from the given JNDI name.

Parameters:
jndiname - The JNDI name used to lookup the destination.
defautSuffix - Description of Parameter
Returns:
The parsed suffix or the defaultSuffix

toString

public String toString()
Return a string representation of the current config state.

Overrides:
toString in class Object


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.