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 EJB is not specifying any partitions.
If this EJB returned partitions, the setPartitions() method would need to
be called on the HttpPartitionManager. Additionally, the EJB could specify
HTTP request expressions by invoking the setExpressions() method.
Note: However,
that once established with the HttpPartitionBean.getPartitions() (of the session
bean), any subsequent partitions must be added with the HttpPartitionManager.addPartition()
method.