Program guide > (deprecated) Partitioning facility > Partitioning facility programming > HTTP partitions

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

An example

Listed below are the entire contents of the sample HTTP partitioning facility application servlet.

      public class ListPartitions extends HttpServlet implements Servlet, 
  HttpPartitionNotification {
    private static String className = "ListPartitions";
    private static String appName = "http.wpf.sample";
    private static HttpPartitionManager httpPartitionManager = 
    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);
  public void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
       ServletOutputStream out = resp.getOutputStream();
       out.println("<head><title>Hello World</title></head>");
       out.println("<h2>Hello World</h2><h2>");
    public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
  public static String listPartitions() {
        HttpPartitionManager httpPartitionManager = 
    Vector partitions = httpPartitionManager.getActivePartitions
    String output = "Number of Partitions: "+partitions.size()+":
     for (int i=0; i< partitions.size(); i++)
    output = output.concat(partitions.elementAt(i) + "\n");
    return output;
public Vector getPartitions() {
        System.out.println(className+": getPartitions ");
        Vector myVect = new Vector();
      System.out.println(className+": getPartitions number of partitions: 
      return myVect;   // Do not override partitions 
public HttpPartitionExpression[] getExpressions() {
        System.out.println(className+": getExpressions ");
        HttpPartitionExpression[] expressions = new HttpPartitionExpression[2];
        expressions[0] = httpPartitionManager.createHttpPartitionExpression
    ("(user=)(.*)&", "$2");
        expressions[1] = httpPartitionManager.createHttpPartitionExpression
    ("(user=)(.*)$", "$2");
        System.out.println(className+": getExpressions number of expressions 
        return expressions;   // Do not override expressions
public boolean loadEvent(String partitionName) {
         * now is a good time to start caching relevant data
        System.out.println(className+": load "+partitionName);
        return true;
public void unloadEvent(String partitionName)
         * now is a good time to flush relevant cached data
        System.out.println(className+": unload "+partitionName);
public boolean isPartitionAlive(String partitionName)
         * can check if a partition is still active
        System.out.println(className+": isPartitionAlive ");
        return true;

This example illustrates how the HttpPartitionManager is used to specify two partition names (lou and jian in this case) and two request expressions using the getPartitions() and getExpressions() methods of the notification interface. If this servlet were not to specify these (if, for example, they were provided in an accompanying partitions.xml file or specified by the enterprise bean), these methods would return null.

Parent topic:

HTTP partitions

Related concepts

HTTP partitions