Program guide > (deprecated) Partitioning facility > Partitioning facility programming > HTTP partitions > The EJB API and extending the HttpPartitionBean


Deprecated feature: The partitioning facility (WPF) feature is deprecated. You can configure partitioning with WebSphere eXtreme Scale.


HttpPartitionBean details

The following details the contents of the HttpPartitionBean. As is, the default HttpPartitionBean provides the minimal functionality required for HTTP partitioning. When using only the Servlet API to interact with partitions, no modification is required in this code. This simple PSSB only needs to be supplied with the application.

public class HttpPartitionBean implements javax.ejb.SessionBean {
    private javax.ejb.SessionContext mySessionCtx;
    private PartitionManager partitionManager;
    private HttpPartitionManager httpPartitionManager;

/**
* getSessionContext
*/
public javax.ejb.SessionContext getSessionContext() {
    return mySessionCtx;
}
/**
* setSessionContext
*/
public void setSessionContext(javax.ejb.SessionContext ctx) {
    mySessionCtx = ctx;
    try
    {
        InitialContext ic = new InitialContext();
        partitionManager = (PartitionManager)ic.lookup(PartitionManager.
    JNDI_NAME);
        httpPartitionManager = HttpPartitionManager.instance;
        partitionManager.setHttpPartitionManager(httpPartitionManager);
        String appName = partitionManager.getApplicationName();
        httpPartitionManager.setPartitionManager(appName, 
     partitionManager);
    }
    catch(Exception e)
    {
        throw new EJBException(e);
    }
}
/**
 * ejbCreate
*/
public void ejbCreate() throws javax.ejb.CreateException {
}
        /**
        * ejbActivate
        */
public void ejbActivate() {
 }
/**
* ejbPassivate
*/
public void ejbPassivate() {
}
/**
* ejbRemove
*/
public void ejbRemove() {
}

/**
 * @return
 */
public PartitionDefinition[] getPartitions() {    
    return new PartitionDefinition[0];
}

/**
 * This is called when a specific partition is assigned to this 
  server process.
 * @param partitionName
 * @return
 */    
public boolean partitionLoadEvent(String partitionName)
 {
    return false;
   }
   
  /**
   * This is called when previously assigned partition is withdrawn 
   from this server.
   * @param partitionName
    */    
  public void partitionUnloadEvent(String partitionName)
   {
  }
   
  /**
   * This may be called periodically to verify that this server 
   is functioning correctly if
   * it was assigned a partition.
    * @param partitionName
    * @return
   */    
   public boolean isPartitionAlive(String partitionName)
   {
    return false;
    }
    }

The getPartitions() method shown in line 254 simply returns an empty partition definition array since this enterprise bean is not specifying any partitions. If this enterprise bean returned partitions, the setPartitions() method would need to be called on the HttpPartitionManager. Additionally, the enterprise bean could specify HTTP request expressions by invoking the setExpressions() method.

However, that once established with the HttpPartitionBean.getPartitions() (of the session bean), any subsequent partitions must be added with the HttpPartitionManager.addPartition() method.


Parent topic:

The EJB API and extending the HttpPartitionBean


Related concepts

The EJB API and extending the HttpPartitionBean