The servlet API consists of a method for receiving partition
callbacks (regarding partition events) using the HttpPartitionNotification
interface. The notification interface is as follows:
public interface HttpPartitionNotification {
/*
* Fetch the vector of partition strings from the web module.
*/
public Vector getPartitions();
/*
* Fetch the array of expressions from the web module.
*/
public HttpPartitionExpression[] getExpressions();
/*
* Queries the web module to determine if the specified partition
is still alive.
*/
public boolean isPartitionAlive(String partitionName);
/*
* Indicates that this partition has been loaded by WPF.
*/
public boolean loadEvent(String partitionName);
/*
* Indicates that this partition has been loaded by WPF.
*/
public void unloadEvent(String partitionName);
}
Though this interface is very similar to that supported by the partitioning facility function, there are some minor differences.
The most notable of these is the inclusion of a
getExpressions() method
that is used by the HTTP partitioning function to gather the request
expressions that will be used with this application. A servlet can
register itself (or some other class) to receive notifications by
invoking the
HttpPartitionManager.registerNotfication() method,
for example, in its
init() method:
public void init() throws ServletException {
System.out.println(className+": Registering notification ");
httpPartitionManager.registerNotification(appName, this);
}
public void destroy() {
System.out.println(className+": Deregistering notification ");
httpPartitionManager.deregisterNotification(appName, this);
}
This example also illustrates the use of the
HttpPartitionManager.deregisterNotfication() method
in the servlet's
destroy() method. For correctness, all
registered notifications must be deregistered.