org.jboss.ejb.plugins.jms
Class JMSContainerInvoker

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.ejb.plugins.jms.JMSContainerInvoker
All Implemented Interfaces:
AllowedOperationsFlags (src) , ContainerPlugin (src) , EJBProxyFactory (src) , GenericEntityObjectFactory (src) , MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , Service (src) , ServiceMBean (src)

public class JMSContainerInvoker
extends ServiceMBeanSupport (src)
implements EJBProxyFactory (src)

EJBProxyFactory for JMS MessageDrivenBeans


Nested Class Summary
 
Nested classes inherited from class org.jboss.ejb.GenericEntityObjectFactory (src)
GenericEntityObjectFactory.UTIL (src)
 
Field Summary
protected  int acknowledgeMode
          JMS acknowledge mode, used when session is not XA.
protected  Connection (src) connection
          The JMS connection.
protected  ConnectionConsumer (src) connectionConsumer
          The JMS connection consumer.
protected  Container (src) container
          The container.
protected  boolean createJBossMQDestination
           
protected static java.lang.String DEFAULT_DESTINATION_TYPE
          Default destination type.
protected  boolean deliveryActive
           
protected  org.w3c.dom.Element dlqConfig
          DLQConfig element from MDBConfig element from jboss.xml.
protected  DLQHandler (src) dlqHandler
          Dead letter queue handler.
protected  org.jboss.ejb.plugins.jms.JMSContainerInvoker.ExceptionListenerImpl exListener
           
protected  java.lang.String invokerBinding
           
protected  InvokerProxyBindingMetaData (src) 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 java.lang.reflect.Method ON_MESSAGE
          MessageListener.onMessage(javax.jms.Message) reference.
protected  boolean optimize
           
protected  ServerSessionPool (src) pool
           
protected  java.lang.String providerAdapterJNDI
          JNDI name of the provider adapter.
protected  long reconnectInterval
          Time to wait before retrying to reconnect a lost connection.
protected  java.lang.String serverSessionPoolFactoryJNDI
          JNDI name of the server session factory.
protected  TransactionManager (src) tm
           
protected  boolean useDLQ
          If Dead letter queue should be used or not.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.ejb.AllowedOperationsFlags (src)
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 (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
JMSContainerInvoker()
           
 
Method Summary
protected  Destination (src) createDestination(java.lang.Class type, javax.naming.Context ctx, java.lang.String jndiName, java.lang.String jndiSuffix)
          Create and or lookup a JMS destination.
protected  void createService()
          Initialize the container invoker.
protected  ServerSessionPool (src) createSessionPool(Destination (src)  destination, Connection (src)  connection, int minSession, int maxSession, long keepAlive, boolean isTransacted, int ack, MessageListener (src)  listener)
          Create a server session pool for the given connection.
protected  void destroyService()
          Sub-classes should override this method to provide custum 'destroy' logic.
protected  java.lang.String getActivationConfigProperty(java.lang.String property)
           
 boolean getCreateJBossMQDestination()
           
 boolean getDeliveryActive()
           
protected  java.lang.String getDestinationType(javax.naming.Context ctx, java.lang.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.
 java.lang.Object getEJBHome()
          Always throws an Error
 EJBMetaData (src) getEJBMetaData()
          Always throws an Error
 java.util.Collection getEntityCollection(java.util.Collection ids)
          Always throws an Error
 java.lang.Object getEntityEJBObject(java.lang.Object id)
          Always throws an Error
protected  JMSProviderAdapter (src) getJMSProviderAdapter()
          Return the JMSProviderAdapter that should be used.
 long getKeepAliveMillis()
           
 int getMaxMessages()
           
 int getMaxPoolSize()
           
 MessageDrivenMetaData (src) getMetaData()
           
 int getMinPoolSize()
           
 java.lang.Object getStatefulSessionEJBObject(java.lang.Object id)
          Always throws an Error
 java.lang.Object getStatelessSessionEJBObject()
          Always throws an Error
 void importXml(org.w3c.dom.Element element)
          XmlLoadable implementation.
protected  void innerStop()
          Stop done from inside, we should not stop the exceptionListener in inner stop.
 java.lang.Object invoke(java.lang.Object id, java.lang.reflect.Method m, java.lang.Object[] args, Transaction (src)  tx, java.security.Principal identity, java.lang.Object credential)
           
 boolean isIdentical(Container (src)  container, Invocation (src)  mi)
          Protocol specific isIdentical implementation
 boolean isOptimized()
          Gets the Optimized attribute of the JMSContainerInvoker object
protected  java.lang.String parseJndiSuffix(java.lang.String jndiname, java.lang.String defautSuffix)
          Parse the JNDI suffix from the given JNDI name.
protected  void sendNotification(java.lang.String event, java.lang.Object userData)
          Notify of an event
 void setContainer(Container (src)  container)
          Set the container for which this is an invoker to.
 void setInvokerBinding(java.lang.String binding)
          Set the invoker jndi binding
 void setInvokerMetaData(InvokerProxyBindingMetaData (src)  imd)
          Set the invoker meta data so that the ProxyFactory can initialize properly
 void setKeepAliveMillis(long keepAlive)
           
 void setMaxMessages(int maxMessages)
           
 void setMaxPoolSize(int maxPoolSize)
           
 void setMinPoolSize(int minPoolSize)
           
 void setOptimized(boolean optimize)
          Sets the Optimized attribute of the JMSContainerInvoker object
 void startDelivery()
           
protected  void startService()
          Sub-classes should override this method to provide custum 'start' logic.
 void stopDelivery()
           
protected  void stopService()
          Sub-classes should override this method to provide custum 'stop' logic.
 java.lang.String toString()
          Return a string representation of the current config state.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, destroy, 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 (src)
addNotificationListener, getNotificationInfo, handleNotification, 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 (src)
create, destroy, start, stop
 

Field Detail

ON_MESSAGE

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


DEFAULT_DESTINATION_TYPE

protected static final java.lang.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 (src)

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 java.lang.String providerAdapterJNDI
JNDI name of the provider adapter.

See Also:
JMSProviderAdapter (src)

serverSessionPoolFactoryJNDI

protected java.lang.String serverSessionPoolFactoryJNDI
JNDI name of the server session factory.

See Also:
ServerSessionPoolFactory (src)

acknowledgeMode

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


isContainerManagedTx

protected boolean isContainerManagedTx

isNotSupportedTx

protected boolean isNotSupportedTx

container

protected Container (src)  container
The container.


connection

protected Connection (src)  connection
The JMS connection.


connectionConsumer

protected ConnectionConsumer (src)  connectionConsumer
The JMS connection consumer.


tm

protected TransactionManager (src)  tm

pool

protected ServerSessionPool (src)  pool

exListener

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

dlqHandler

protected DLQHandler (src)  dlqHandler
Dead letter queue handler.


dlqConfig

protected org.w3c.dom.Element dlqConfig
DLQConfig element from MDBConfig element from jboss.xml.


invokerMetaData

protected InvokerProxyBindingMetaData (src)  invokerMetaData

invokerBinding

protected java.lang.String invokerBinding

deliveryActive

protected boolean deliveryActive

createJBossMQDestination

protected boolean createJBossMQDestination
Constructor Detail

JMSContainerInvoker

public JMSContainerInvoker()
Method Detail

setInvokerMetaData

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

Specified by:
setInvokerMetaData in interface EJBProxyFactory (src)

setInvokerBinding

public void setInvokerBinding(java.lang.String binding)
Set the invoker jndi binding

Specified by:
setInvokerBinding in interface EJBProxyFactory (src)

setContainer

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

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

getMinPoolSize

public int getMinPoolSize()

setMinPoolSize

public void setMinPoolSize(int minPoolSize)

getMaxPoolSize

public int getMaxPoolSize()

setMaxPoolSize

public void setMaxPoolSize(int maxPoolSize)

getKeepAliveMillis

public long getKeepAliveMillis()

setKeepAliveMillis

public void setKeepAliveMillis(long keepAlive)

getMaxMessages

public int getMaxMessages()

setMaxMessages

public void setMaxMessages(int maxMessages)

getMetaData

public MessageDrivenMetaData (src)  getMetaData()

getDeliveryActive

public boolean getDeliveryActive()
Returns:
whether delivery is active

getCreateJBossMQDestination

public boolean getCreateJBossMQDestination()
Returns:
whether we are creating jbossmq destinations

startDelivery

public void startDelivery()
                   throws java.lang.Exception
Throws:
java.lang.Exception

stopDelivery

public void stopDelivery()
                  throws java.lang.Exception
Throws:
java.lang.Exception

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 (src)  container,
                           Invocation (src)  mi)
Description copied from interface: EJBProxyFactory (src)
Protocol specific isIdentical implementation

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

getEJBHome

public java.lang.Object getEJBHome()
Always throws an Error

Specified by:
getEJBHome in interface EJBProxyFactory (src)
Returns:
An implementation of the home interface for this container.
Throws:
java.lang.Error - Not valid for MDB

getEJBMetaData

public EJBMetaData (src)  getEJBMetaData()
Always throws an Error

Specified by:
getEJBMetaData in interface EJBProxyFactory (src)
Returns:
An implementation of the EJBMetaData interface.
Throws:
java.lang.Error - Not valid for MDB

getEntityCollection

public java.util.Collection getEntityCollection(java.util.Collection ids)
Always throws an Error

Specified by:
getEntityCollection in interface EJBProxyFactory (src)
Parameters:
ids - Enumeration of primary keys.
Returns:
A collection of EJBObjects implementing the remote interface for this container.
Throws:
java.lang.Error - Not valid for MDB

getEntityEJBObject

public java.lang.Object getEntityEJBObject(java.lang.Object id)
Always throws an Error

Specified by:
getEntityEJBObject in interface EJBProxyFactory (src)
Parameters:
id - The primary key of the entity.
Returns:
An implementation of the remote interface for this container.
Throws:
java.lang.Error - Not valid for MDB

getStatefulSessionEJBObject

public java.lang.Object getStatefulSessionEJBObject(java.lang.Object id)
Always throws an Error

Specified by:
getStatefulSessionEJBObject in interface EJBProxyFactory (src)
Parameters:
id - The id of the session.
Returns:
An implementation of the remote interface for this container.
Throws:
java.lang.Error - Not valid for MDB

getStatelessSessionEJBObject

public java.lang.Object getStatelessSessionEJBObject()
Always throws an Error

Specified by:
getStatelessSessionEJBObject in interface EJBProxyFactory (src)
Returns:
An implementation of the remote interface for this container.
Throws:
java.lang.Error - Not valid for MDB

isOptimized

public boolean isOptimized()
Gets the Optimized attribute of the JMSContainerInvoker object

Returns:
The Optimized value

importXml

public void importXml(org.w3c.dom.Element element)
               throws java.lang.Exception
XmlLoadable implementation. FIXME - we ought to move all config into MDBConfig, but I do not do that now due to backward compatibility.

Parameters:
element - Description of Parameter
Throws:
DeploymentException (src) - Description of Exception
java.lang.Exception

createService

protected void createService()
                      throws java.lang.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 ServiceMBeanSupport (src)
Throws:
java.lang.Exception - Failed to initalize.

startService

protected void startService()
                     throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'start' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
startService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

stopService

protected void stopService()
                    throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'stop' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
stopService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

innerStop

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


destroyService

protected void destroyService()
                       throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'destroy' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
destroyService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

invoke

public java.lang.Object invoke(java.lang.Object id,
                               java.lang.reflect.Method m,
                               java.lang.Object[] args,
                               Transaction (src)  tx,
                               java.security.Principal identity,
                               java.lang.Object credential)
                        throws java.lang.Exception
Throws:
java.lang.Exception

getDestinationType

protected java.lang.String getDestinationType(javax.naming.Context ctx,
                                              java.lang.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 (src)  getJMSProviderAdapter()
                                            throws javax.naming.NamingException
Return the JMSProviderAdapter that should be used.

Returns:
The JMSProviderAdapter to use.
Throws:
javax.naming.NamingException

createDestination

protected Destination (src)  createDestination(java.lang.Class type,
                                        javax.naming.Context ctx,
                                        java.lang.String jndiName,
                                        java.lang.String jndiSuffix)
                                 throws java.lang.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:
java.lang.IllegalArgumentException - Type is not Queue or Topic.
java.lang.Exception - Description of Exception

getActivationConfigProperty

protected java.lang.String getActivationConfigProperty(java.lang.String property)

createSessionPool

protected ServerSessionPool (src)  createSessionPool(Destination (src)  destination,
                                              Connection (src)  connection,
                                              int minSession,
                                              int maxSession,
                                              long keepAlive,
                                              boolean isTransacted,
                                              int ack,
                                              MessageListener (src)  listener)
                                       throws javax.naming.NamingException,
                                              JMSException (src) 
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:
JMSException (src)
javax.naming.NamingException - Description of Exception

sendNotification

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

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

parseJndiSuffix

protected java.lang.String parseJndiSuffix(java.lang.String jndiname,
                                           java.lang.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 java.lang.String toString()
Return a string representation of the current config state.