JBoss API: Class JMSContainerInvoker

org.jboss.ejb.plugins.jms
Class JMSContainerInvoker

java.lang.Object
  |
  +--org.jboss.ejb.plugins.jms.JMSContainerInvoker
All Implemented Interfaces:
ContainerInvoker, ContainerPlugin, Service, XmlLoadable

public class JMSContainerInvoker
extends java.lang.Object
implements ContainerInvoker, XmlLoadable

ContainerInvoker for JMS MessageDrivenBeans, based on JRMPContainerInvoker.

Version:
$Revision: 1.12.4.6 $
Author:
Peter Antman ., Rickard Öberg, Sebastien Alborini , Marc Fleury, Jason Dillon

Field Summary
protected  int acknowledgeMode
          JMS acknowledge mode, used when session is not XA.
protected  java.lang.String beanName
          Description of the Field
protected  javax.jms.Connection connection
          The JMS connection.
protected  javax.jms.ConnectionConsumer connectionConsumer
          TH JMS connection consumer.
protected  Container container
          The container.
protected static java.lang.String DEFAULT_DESTINATION_TYPE
          Default destination type.
protected  org.w3c.dom.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
          Description of the Field
protected  boolean isContainerManagedTx
          escription of the Field
protected  boolean isNotSupportedTx
          Description of the Field
protected  int maxMessagesNr
          Maximu number provider is allowed to stuff into a session.
protected  int maxPoolSize
          Maximun pool size of server sessions.
protected static java.lang.reflect.Method ON_MESSAGE
          MessageListener.onMessage(javax.jms.Message) reference.
protected  boolean optimize
          Description of the Field
protected  javax.jms.ServerSessionPool pool
          Description of the Field
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  javax.transaction.TransactionManager tm
          Description of the Field
protected  boolean useDLQ
          If Dead letter queue should be used or not.
 
Constructor Summary
JMSContainerInvoker()
           
 
Method Summary
protected  javax.jms.Destination 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  javax.jms.ServerSessionPool createSessionPool(javax.jms.Connection connection, int maxSession, boolean isTransacted, int ack, javax.jms.MessageListener listener)
          Create a server session pool for the given connection.
 void destroy()
          Take down all fixtures.
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.
 javax.ejb.EJBHome getEJBHome()
          Gets the EJBHome attribute of the JMSContainerInvoker object
 javax.ejb.EJBMetaData getEJBMetaData()
          Gets the EJBMetaData attribute of the JMSContainerInvoker object
 java.util.Collection getEntityCollection(java.util.Collection ids)
          Gets the EntityCollection attribute of the JMSContainerInvoker object
 javax.ejb.EJBObject getEntityEJBObject(java.lang.Object id)
          Gets the EntityEJBObject attribute of the JMSContainerInvoker object
protected  JMSProviderAdapter getJMSProviderAdapter()
          Return the JMSProviderAdapter that should be used.
 javax.ejb.EJBObject getStatefulSessionEJBObject(java.lang.Object id)
          Gets the StatefulSessionEJBObject attribute of the JMSContainerInvoker object
 javax.ejb.EJBObject getStatelessSessionEJBObject()
          Gets the StatelessSessionEJBObject attribute of the JMSContainerInvoker object
 void importXml(org.w3c.dom.Element element)
          XmlLoadable implementation.
 void init()
          Initialize the container invoker.
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, javax.transaction.Transaction tx, java.security.Principal identity, java.lang.Object credential)
          #Description of the Method
 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.
 void setContainer(Container container)
          Set the container for which this is an invoker to.
 void setOptimized(boolean optimize)
          Sets the Optimized attribute of the JMSContainerInvoker object
 void start()
          Start the connection.
 void stop()
          Stop the connection.
 java.lang.String toString()
          Return a string representation of the current config state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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.

optimize

protected boolean optimize
Description of the Field

maxMessagesNr

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

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

serverSessionPoolFactoryJNDI

protected java.lang.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
escription of the Field

isNotSupportedTx

protected boolean isNotSupportedTx
Description of the Field

container

protected Container container
The container.

connection

protected javax.jms.Connection connection
The JMS connection.

connectionConsumer

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

tm

protected javax.transaction.TransactionManager tm
Description of the Field

pool

protected javax.jms.ServerSessionPool pool
Description of the Field

exListener

protected org.jboss.ejb.plugins.jms.JMSContainerInvoker.ExceptionListenerImpl exListener
Description of the Field

beanName

protected java.lang.String beanName
Description of the Field

dlqHandler

protected DLQHandler dlqHandler
Dead letter queue handler.

dlqConfig

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

JMSContainerInvoker

public JMSContainerInvoker()
Method Detail

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.

setOptimized

public void setOptimized(boolean optimize)
Sets the Optimized attribute of the JMSContainerInvoker object
Parameters:
optimize - The new Optimized value

getEJBHome

public javax.ejb.EJBHome getEJBHome()
Gets the EJBHome attribute of the JMSContainerInvoker object
Specified by:
getEJBHome in interface ContainerInvoker
Returns:
The EJBHome value

getEJBMetaData

public javax.ejb.EJBMetaData getEJBMetaData()
Gets the EJBMetaData attribute of the JMSContainerInvoker object
Specified by:
getEJBMetaData in interface ContainerInvoker
Returns:
The EJBMetaData value

getEntityCollection

public java.util.Collection getEntityCollection(java.util.Collection ids)
Gets the EntityCollection attribute of the JMSContainerInvoker object
Specified by:
getEntityCollection in interface ContainerInvoker
Parameters:
ids - Description of Parameter
Returns:
The EntityCollection value

getEntityEJBObject

public javax.ejb.EJBObject getEntityEJBObject(java.lang.Object id)
Gets the EntityEJBObject attribute of the JMSContainerInvoker object
Specified by:
getEntityEJBObject in interface ContainerInvoker
Parameters:
id - Description of Parameter
Returns:
The EntityEJBObject value

getStatefulSessionEJBObject

public javax.ejb.EJBObject getStatefulSessionEJBObject(java.lang.Object id)
Gets the StatefulSessionEJBObject attribute of the JMSContainerInvoker object
Specified by:
getStatefulSessionEJBObject in interface ContainerInvoker
Parameters:
id - Description of Parameter
Returns:
The StatefulSessionEJBObject value

getStatelessSessionEJBObject

public javax.ejb.EJBObject getStatelessSessionEJBObject()
Gets the StatelessSessionEJBObject attribute of the JMSContainerInvoker object
Specified by:
getStatelessSessionEJBObject in interface ContainerInvoker
Returns:
The StatelessSessionEJBObject value

isOptimized

public boolean isOptimized()
Gets the Optimized attribute of the JMSContainerInvoker object
Returns:
The Optimized value

destroy

public void destroy()
Take down all fixtures.
Specified by:
destroy in interface Service

importXml

public void importXml(org.w3c.dom.Element element)
               throws DeploymentException
XmlLoadable implementation. FIXME - we ought to move all config into MDBConfig, but I do not do that now due to backward compatibility.
Specified by:
importXml in interface XmlLoadable
Parameters:
element - Description of Parameter
Throws:
DeploymentException - Description of Exception

init

public void init()
          throws java.lang.Exception
Initialize the container invoker. Sets up a connection, a server session pool and a connection consumer for the configured destination.
Specified by:
init in interface Service
Throws:
java.lang.Exception - Failed to initalize.

invoke

public java.lang.Object invoke(java.lang.Object id,
                               java.lang.reflect.Method m,
                               java.lang.Object[] args,
                               javax.transaction.Transaction tx,
                               java.security.Principal identity,
                               java.lang.Object credential)
                        throws java.lang.Exception
#Description of the Method
Parameters:
id - Description of Parameter
m - Description of Parameter
args - Description of Parameter
tx - Description of Parameter
identity - Description of Parameter
credential - Description of Parameter
Returns:
Description of the Returned Value
Throws:
java.lang.Exception - Description of Exception

start

public void start()
           throws java.lang.Exception
Start the connection.
Specified by:
start in interface Service
Throws:
java.lang.Exception - Description of Exception

stop

public void stop()
Stop the connection.
Specified by:
stop in interface Service

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 getJMSProviderAdapter()
                                            throws javax.naming.NamingException
Return the JMSProviderAdapter that should be used.
Returns:
The JMSProviderAdapter to use.
Throws:
javax.naming.NamingException - Description of Exception

createDestination

protected javax.jms.Destination 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

createSessionPool

protected javax.jms.ServerSessionPool createSessionPool(javax.jms.Connection connection,
                                                        int maxSession,
                                                        boolean isTransacted,
                                                        int ack,
                                                        javax.jms.MessageListener listener)
                                                 throws javax.naming.NamingException,
                                                        javax.jms.JMSException
Create a server session pool for the given connection.
Parameters:
connection - The connection to use.
maxSession - The maximum number of sessions.
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 -  
javax.naming.NamingException - Description of Exception

innerStop

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

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.
Overrides:
toString in class java.lang.Object


Copyright © 2000 The JBoss Organization. All Rights Reserved.