org.ow2.jonas.lib.ejb21
Class JMdbEndpointFactory

java.lang.Object
  extended by org.ow2.jonas.lib.ejb21.JFactory
      extended by org.ow2.jonas.lib.ejb21.JMdbEndpointFactory
All Implemented Interfaces:
MessageEndpointFactory, BeanFactory

public class JMdbEndpointFactory
extends JFactory
implements MessageEndpointFactory

This class is a factory for a Message Driven Bean Endpoints There is one such class per MDB class. Contains all information related to the bean

Author:
Eric Hardesty

Field Summary
 
Fields inherited from class org.ow2.jonas.lib.ejb21.JFactory
beanclass, cont, dd, dispatcher, ejb10Env, ejbname, ejbTimeoutSignature, isClusterReplicated, JNDICtx, myTimerService, naming, passivationDir, stopped, timerTxAttr, tm, txbeanmanaged, wm
 
Constructor Summary
JMdbEndpointFactory(MessageDrivenDesc dd, JContainer cont, ActivationSpec as, ResourceService rserv)
          Constructor
JMdbEndpointFactory(MessageDrivenDesc dd, String destination, JContainer cont, ActivationSpec as, ResourceService rserv)
          Constructor
 
Method Summary
 void checkTransaction(RequestCtx rctx)
          For Message Driven Beans, only 2 cases are possible: TX_REQUIRED or TX_NOT_SUPPORTED
 MessageEndpoint createEndpoint(XAResource xaResource)
          Create the message endpoint
 int getCacheSize()
           
 JHome getHome()
          returns the home if exist or null if not
 JLocalHome getLocalHome()
          returns the local home if exist or null if not
 int getMaxCacheSize()
           
 JMessageEndpoint getMessageEndpoint()
          Return an MessageEndpoint from the pool.
 int getMinPoolSize()
           
 int getPoolSize()
          Get the size of the instance pool for this bean
 TimerService getTimerService()
          Obtains the TimerService associated for this Bean
 int getTransactionAttribute()
           
 void initInstancePool()
          Init pool of instances
 boolean isDeliveryTransacted(Method method)
          Determine if the method is transacted
 void notifyTimeout(Timer timer)
          Notify a timeout for this bean
 void reduceCache()
          Reduce number of instances in memory in the free list we reduce to the minPoolSize
 void releaseEndpoint(JMessageEndpoint ep)
          put the JMessageEndpoint back to the pool
 void stop()
          stop this EJB.
 void storeInstances(Transaction tx)
          Store intances modified (used before finder ou select methods)
 void syncDirty(boolean notused)
          synchronize bean instances if needed
 
Methods inherited from class org.ow2.jonas.lib.ejb21.JFactory
checkJonasVersion, checkSecurity, checkTransactionContainer, getContainer, getDeploymentDescriptor, getDispatcher, getEjb10Environment, getEJBName, getEjbTimeoutSignature, getEnv, getFileList, getInitialContext, getPassivationDir, getResourceCheckerManager, getTimerTxAttribute, getTransactionManager, getWorkManager, init, isClassAvailable, isStopped, isTxBeanManaged, myClassLoader, postInvoke, postInvokeRemote, preInvoke, preInvokeRemote, resetComponentContext, restartTimers, setComponentContext, setDispatcher, setResourceCheckerManager, stopContainer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JMdbEndpointFactory

public JMdbEndpointFactory(MessageDrivenDesc dd,
                           JContainer cont,
                           ActivationSpec as,
                           ResourceService rserv)
Constructor

Parameters:
dd - Message Driven Descriptor
cont - Container where this bean is defined
as - ActivationSpec to link the Container to

JMdbEndpointFactory

public JMdbEndpointFactory(MessageDrivenDesc dd,
                           String destination,
                           JContainer cont,
                           ActivationSpec as,
                           ResourceService rserv)
Constructor

Parameters:
dd - Message Driven Descriptor
destination - String of desired destination
cont - Container where this bean is defined
as - ActivationSpec to link the Container to
Method Detail

initInstancePool

public void initInstancePool()
Init pool of instances

Specified by:
initInstancePool in interface BeanFactory
Specified by:
initInstancePool in class JFactory

getPoolSize

public int getPoolSize()
Description copied from interface: BeanFactory
Get the size of the instance pool for this bean

Specified by:
getPoolSize in interface BeanFactory
Specified by:
getPoolSize in class JFactory
Returns:
the size of the EndpointPool

stop

public void stop()
stop this EJB. call deactivate on the Endpoint Stop the threads and remove the beans

Specified by:
stop in interface BeanFactory

syncDirty

public void syncDirty(boolean notused)
synchronize bean instances if needed

Specified by:
syncDirty in interface BeanFactory
Parameters:
notused - True if store even if passivation timeout not elapsed

getHome

public JHome getHome()
Description copied from interface: BeanFactory
returns the home if exist or null if not

Specified by:
getHome in interface BeanFactory
Returns:
the home if exist

getLocalHome

public JLocalHome getLocalHome()
Description copied from interface: BeanFactory
returns the local home if exist or null if not

Specified by:
getLocalHome in interface BeanFactory
Returns:
the local home if exist

createEndpoint

public MessageEndpoint createEndpoint(XAResource xaResource)
                               throws UnavailableException
Create the message endpoint

Specified by:
createEndpoint in interface MessageEndpointFactory
Parameters:
xaResource - XAResource object to attach
Returns:
MessageEndpoint to deliver messages to
Throws:
UnavailableException - exception to throw

isDeliveryTransacted

public boolean isDeliveryTransacted(Method method)
                             throws NoSuchMethodException
Determine if the method is transacted

Specified by:
isDeliveryTransacted in interface MessageEndpointFactory
Parameters:
method - Method to check
Returns:
boolean whether the specified method is transacted
Throws:
NoSuchMethodException - exception to throw

getMessageEndpoint

public JMessageEndpoint getMessageEndpoint()
                                    throws Exception
Return an MessageEndpoint from the pool. If pool is empty, creates a new one.

Returns:
an MessageEndpoint from the pool.
Throws:
Exception - - if an application server fails to return an MessageEndpoint out of its pool.

releaseEndpoint

public void releaseEndpoint(JMessageEndpoint ep)
put the JMessageEndpoint back to the pool

Parameters:
ep - the MessageEndpoint

getTimerService

public TimerService getTimerService()
Obtains the TimerService associated for this Bean

Specified by:
getTimerService in class JFactory
Returns:
a JTimerService instance.

getMinPoolSize

public int getMinPoolSize()
Overrides:
getMinPoolSize in class JFactory
Returns:
min pool size for Jmx

getMaxCacheSize

public int getMaxCacheSize()
Overrides:
getMaxCacheSize in class JFactory
Returns:
max cache size for Jmx

getCacheSize

public int getCacheSize()
Overrides:
getCacheSize in class JFactory
Returns:
current cache size ( = nb of instance created) for Jmx

getTransactionAttribute

public int getTransactionAttribute()
Returns:
the Transaction Attribute

checkTransaction

public void checkTransaction(RequestCtx rctx)
For Message Driven Beans, only 2 cases are possible: TX_REQUIRED or TX_NOT_SUPPORTED

Parameters:
rctx - The Request Context

reduceCache

public void reduceCache()
Reduce number of instances in memory in the free list we reduce to the minPoolSize

Specified by:
reduceCache in interface BeanFactory

notifyTimeout

public void notifyTimeout(Timer timer)
Notify a timeout for this bean

Parameters:
timer - timer whose expiration caused this notification.

storeInstances

public void storeInstances(Transaction tx)
Description copied from interface: BeanFactory
Store intances modified (used before finder ou select methods)

Specified by:
storeInstances in interface BeanFactory


Copyright © 2010 OW2 Consortium. All Rights Reserved.