Class EnterpriseBeanstalk
java.lang.Object
org.apache.synapse.commons.beanstalk.enterprise.EnterpriseBeanstalk
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
ConstructorsConstructorDescriptionEnterpriseBeanstalk(String name, Properties props, ScheduledExecutorService scheduler) Constructs a new enterprise beanstalk with the given name and properties. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroys the beanstalk by un-registering MBeans and cleaning up other resources.getEnterpriseBean(String className, String sessionId, String jndiName) Returns a client stub for the EJB with the given class name, bean id and jndi name.getName()Returns the name of the beanstalk.voidinit()Initialize the current beanstalk by creating the JNDI context, registering the MBean etc.removeEnterpriseBean(String className, String sessionId) Remove the specified client stub from the cache.voidRemoves expired stateless and stateful bean stubs from the cache.
-
Constructor Details
-
EnterpriseBeanstalk
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 Details
-
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
Returns the name of the beanstalk.- Returns:
- Name of the beanstalk.
-
getEnterpriseBean
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
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.
-