Class EnterpriseBeanstalk
- java.lang.Object
-
- org.apache.synapse.commons.beanstalk.enterprise.EnterpriseBeanstalk
-
public class EnterpriseBeanstalk extends Object
An enterprise beanstalk is used to retrieve Enterprise JavaBean (EJB) client stubs. This class supports stateless and stateful session beans. Enterprise beanstalks can be configured in synapse.properties file. Parameters of the JNDI service to be looked up for EJBs should be provided in that configuration. Enterprise beanstalks cache EJB client stubs to improve efficiency by omitting excessive JNDI look ups. Cache timeout for both stateless and stateful session beans could be configured separately.
-
-
Constructor Summary
Constructors Constructor Description EnterpriseBeanstalk(String name, Properties props, ScheduledExecutorService scheduler)
Constructs a new enterprise beanstalk with the given name and properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
Destroys the beanstalk by un-registering MBeans and cleaning up other resources.Object
getEnterpriseBean(String className, String sessionId, String jndiName)
Returns a client stub for the EJB with the given class name, bean id and jndi name.String
getName()
Returns the name of the beanstalk.void
init()
Initialize the current beanstalk by creating the JNDI context, registering the MBean etc.Object
removeEnterpriseBean(String className, String sessionId)
Remove the specified client stub from the cache.void
removeExpiredBeans()
Removes expired stateless and stateful bean stubs from the cache.
-
-
-
Constructor Detail
-
EnterpriseBeanstalk
public EnterpriseBeanstalk(String name, Properties props, ScheduledExecutorService scheduler)
Constructs a new enterprise beanstalk with the given name and properties.- Parameters:
name
- Name of the enterprise beanstalk.props
- Configuration properties. This should include properties of the JNDI service to be looked up for EJBs.scheduler
- ScheduledExecutorService for cleaning up timed-out stubs.
-
-
Method Detail
-
init
public void init()
Initialize the current beanstalk by creating the JNDI context, registering the MBean etc.
-
destroy
public void destroy()
Destroys the beanstalk by un-registering MBeans and cleaning up other resources.
-
getName
public String getName()
Returns the name of the beanstalk.- Returns:
- Name of the beanstalk.
-
getEnterpriseBean
public Object getEnterpriseBean(String className, String sessionId, String jndiName)
Returns a client stub for the EJB with the given class name, bean id and jndi name. If the stub is already available in the cache, it is retrieved from there. Otherwise, a JNDI lookup is performed with the given JNDI name.- Parameters:
className
- Fully qualified name of the remote interface of the session bean.sessionId
- Session id for stateful beans. null for stateless ones.jndiName
- JNDI name of the EJB. null could be used if the bean is already available in the cache.- Returns:
- Retrieved EJB client stub. null if the EJB is not found.
-
removeEnterpriseBean
public Object removeEnterpriseBean(String className, String sessionId)
Remove the specified client stub from the cache. If the stub is not removed using this method it will be automatically removed from the beanstalk after it times out.- Parameters:
className
- Fully qualified name of the remote interface of the session beansessionId
- Session id for stateful session beans, null for stateless ones.- Returns:
- EJB client stub that was removed from the beanstalk.
-
removeExpiredBeans
public void removeExpiredBeans()
Removes expired stateless and stateful bean stubs from the cache. Timeouts are configurable.
-
-