org.apache.synapse.commons.beanstalk.enterprise

## Class EnterpriseBeanstalk

- java.lang.Object
- - org.apache.synapse.commons.beanstalk.enterprise.EnterpriseBeanstalk

-     public class EnterpriseBeanstalk
      extends java.lang.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 and Description
    `EnterpriseBeanstalk(java.lang.String name, java.util.Properties props, java.util.concurrent.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 and Description
    --- | ---
    `void` | `destroy()` Destroys the beanstalk by un-registering MBeans and cleaning up other resources.
    `java.lang.Object` | `getEnterpriseBean(java.lang.String className, java.lang.String sessionId, java.lang.String jndiName)` Returns a client stub for the EJB with the given class name, bean id and jndi name.
    `java.lang.String` | `getName()` Returns the name of the beanstalk.
    `void` | `init()` Initialize the current beanstalk by creating the JNDI context, registering the MBean etc.
    `java.lang.Object` | `removeEnterpriseBean(java.lang.String className, java.lang.String sessionId)` Remove the specified client stub from the cache.
    `void` | `removeExpiredBeans()` Removes expired stateless and stateful bean stubs from the cache.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### EnterpriseBeanstalk

          public EnterpriseBeanstalk(java.lang.String name,
                                     java.util.Properties props,
                                     java.util.concurrent.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 java.lang.String getName()

      Returns the name of the beanstalk.
      Returns:
        Name of the beanstalk.

    - #### getEnterpriseBean

          public java.lang.Object getEnterpriseBean(java.lang.String className,
                                                    java.lang.String sessionId,
                                                    java.lang.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 java.lang.Object removeEnterpriseBean(java.lang.String className,
                                                       java.lang.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 bean
        `sessionId` - 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.

Copyright © 2005-2022 Apache Software Foundation. All Rights Reserved.