GenericService already implements AdminServlet by creating an instance of ServiceAdminServlet when asked for the administration servlet. Subclasses of GenericService should override createAdminServlet. For example:

protected Servlet createAdminServlet ()
  {
    class AdminServlet extends ServiceAdminServlet {
      public AdminServlet (Object pService) {
        super (pService, getNucleus ());
      }

      protected void printAdmin (HttpServletRequest pRequest,
                                 HttpServletResponse pResponse,
                                 ServletOutputStream pOut)
           throws ServletException, IOException
      {
        pOut.println ("<h1>This is my special admin section</h1>");
      }
    }

    return new AdminServlet (this);
  }

This implementation uses an inner class that extends ServiceAdminServlet. The inner class overrides printAdmin to print out a line of HTML. The default servlet calls printAdmin to insert service-specific HTML between the listing of child components and the listing of property values. This is the easiest way for a service to provide its own administrative servlet.


Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved. Legal Notices