org.openejb.webadmin
Class WebAdminBean

java.lang.Object
  extended by org.openejb.webadmin.WebAdminBean
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean, HttpBean
Direct Known Subclasses:
CMPMappingBean, ConfigBean, DeployBean, DeploymentListBean, EJBGenBean, HomeBean, InvokeObjectBean, ListLogsBean, PropertiesBean, ViewClassBean, ViewEjbBean, ViewJndiBean

public abstract class WebAdminBean
extends java.lang.Object
implements HttpBean

This is the template web admin bean to extend from. It contains all the functionality for the webadministration. To use this class, simply sub-class it:

public class MyBean extends WebAdminBean { ... }

and declare the following methods:

public void ejbCreate() {}
public void preProcess(HttpRequest request, HttpResponse response) throws IOException {}
public void postProcess(HttpRequest request, HttpResponse response) throws IOException {}
public void writeBody(PrintWriter body) throws IOException {}
public void writeHtmlTitle(PrintWriter body) throws IOException {}
public void writePageTitle(PrintWriter body) throws IOException {}
public void writeSubMenuItems(PrintWriter body) throws IOException {}

Author:
David Blevins, Tim Urberg
See Also:
Serialized Form

Field Summary
protected  javax.ejb.SessionContext ejbContext
          used for the session context
protected static java.lang.String footer
          the footer
static java.lang.String HTML_TITLE
          the standard title
protected  HttpRequest request
          the HTTP request
protected  HttpResponse response
          the HTTP response
protected  java.lang.String section
          the menu section
static java.util.HashMap sections
          the navigation sections
static int SUBSTITUTE
          the substitue
 
Constructor Summary
WebAdminBean()
           
 
Method Summary
 void ejbActivate()
          called on a stateful sessionbean after the bean is deserialized from storage and put back into use.
 void ejbCreate()
          called with the bean is created
 void ejbPassivate()
          called on a stateful sessionbean before the bean is removed from memory and serialized to a temporary store.
 void ejbRemove()
          called when the bean is about to be garbage collected
 java.lang.String formatSubMenuItem(java.lang.String itemName, java.lang.String url)
          formats a sub menu item for the left navigation
static java.lang.String getFooter()
          gets a footer for the document
 java.io.InputStream getTemplate()
          gets an html template which is the content of the pages written to the browser
 java.util.HashMap initNavSections()
          initalizes the left and top menu navigation
 void onMessage(HttpRequest request, HttpResponse response)
          the main method of this bean, it takes care of the processing
abstract  void postProcess(HttpRequest request, HttpResponse response)
          called after all content is written to the browser
abstract  void preProcess(HttpRequest request, HttpResponse response)
          called before any content is written to the browser
protected  void printRow(java.lang.String col1, java.lang.String col2, java.io.PrintWriter out)
          prints a table row similar to this <tr> <td>some info</td> <td>some more info</td> </tr>
protected  void printRow(java.lang.String col1, java.lang.String col2, java.lang.String col3, java.io.PrintWriter out)
          prints a table row similar to this <tr> <td>some info</td> <td>some more info</td> <td>yet some more info</td> </tr>
 void setSessionContext(javax.ejb.SessionContext sessionContext)
          sets the session context
abstract  void writeBody(java.io.PrintWriter body)
          writes the main body content to the broswer.
 void writeFooter(java.io.PrintWriter body)
          Write the footer
abstract  void writeHtmlTitle(java.io.PrintWriter body)
          Write the TITLE of the HTML document.
 void writeLeftNavBar(java.io.PrintWriter body)
          Write the left navigation bar of the page.
abstract  void writePageTitle(java.io.PrintWriter body)
          Write the title of the page.
 void writeTemplate(java.io.PrintWriter out, java.io.InputStream template)
          writes a template from the input stream to the output stream
 void writeTopNavBar(java.io.PrintWriter body)
          Write the top navigation bar of the page.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ejbContext

protected javax.ejb.SessionContext ejbContext
used for the session context


SUBSTITUTE

public static final int SUBSTITUTE
the substitue

See Also:
Constant Field Values

sections

public static java.util.HashMap sections
the navigation sections


section

protected java.lang.String section
the menu section


request

protected HttpRequest request
the HTTP request


response

protected HttpResponse response
the HTTP response


HTML_TITLE

public static final java.lang.String HTML_TITLE
the standard title

See Also:
Constant Field Values

footer

protected static java.lang.String footer
the footer

Constructor Detail

WebAdminBean

public WebAdminBean()
Method Detail

onMessage

public void onMessage(HttpRequest request,
                      HttpResponse response)
               throws java.io.IOException
the main method of this bean, it takes care of the processing

Specified by:
onMessage in interface HttpBean
Parameters:
request - the http request
response - the http response
Throws:
java.io.IOException - if an exception is thrown

preProcess

public abstract void preProcess(HttpRequest request,
                                HttpResponse response)
                         throws java.io.IOException
called before any content is written to the browser

Parameters:
request - the http request
response - the http response
Throws:
java.io.IOException - if an exception is thrown

postProcess

public abstract void postProcess(HttpRequest request,
                                 HttpResponse response)
                          throws java.io.IOException
called after all content is written to the browser

Parameters:
request - the http request
response - the http response
Throws:
java.io.IOException - if an exception is thrown

writeHtmlTitle

public abstract void writeHtmlTitle(java.io.PrintWriter body)
                             throws java.io.IOException
Write the TITLE of the HTML document. This is the part that goes into the <head><title> </title></head> tags

Parameters:
body - the output to write to
Throws:
java.io.IOException - of an exception is thrown

writePageTitle

public abstract void writePageTitle(java.io.PrintWriter body)
                             throws java.io.IOException
Write the title of the page. This is displayed right above the main block of content.

Parameters:
body - the output to write to
Throws:
java.io.IOException - if an exception is thrown

writeTopNavBar

public void writeTopNavBar(java.io.PrintWriter body)
                    throws java.io.IOException
Write the top navigation bar of the page. This should look somthing like the one below: <a href="system?show=server"> <span class="menuTopOff">Remote Server</span> </a>       <a href="system?show=containers"> <span class="menuTopOff">Containers</span> </a>       <a href="system?show=deployments"> <span class="menuTopOff">Deployments</span> </a>       <a href="system?show=logs"> <span class="menuTopOff">Logs</span> </a>      

Parameters:
body - the output to write to
Throws:
java.io.IOException - if an exception is thrown

writeLeftNavBar

public void writeLeftNavBar(java.io.PrintWriter body)
                     throws java.io.IOException
Write the left navigation bar of the page. This should look somthing like the one below: <tr> <td valign="top" align="left"> <span class="subMenuOn"> Admin </span> </td> </tr> <tr> <td valign="top" align="left"> <a href="system?show=status"><span class="subMenuOff">    Status </span> </a></td> </tr> <tr> <<td valign="top" align="left"> <a href="system?show=deployments"><span class="subMenuOff">    Deployments </span> </a></td> </tr>

Parameters:
body - the output to write to
Throws:
java.io.IOException - if an exception is thrown

formatSubMenuItem

public java.lang.String formatSubMenuItem(java.lang.String itemName,
                                          java.lang.String url)
formats a sub menu item for the left navigation

Parameters:
itemName - the name for display
url - the url to link
Returns:
the html that is formatted

writeBody

public abstract void writeBody(java.io.PrintWriter body)
                        throws java.io.IOException
writes the main body content to the broswer. This content is inside a <p> block

Parameters:
body - the output to write to
Throws:
java.io.IOException - if an exception is thrown

writeFooter

public void writeFooter(java.io.PrintWriter body)
                 throws java.io.IOException
Write the footer

Parameters:
body - the output to write to
Throws:
java.io.IOException - if an exception is thrown

getFooter

public static java.lang.String getFooter()
gets a footer for the document

Returns:
the footer string

writeTemplate

public void writeTemplate(java.io.PrintWriter out,
                          java.io.InputStream template)
                   throws java.io.IOException
writes a template from the input stream to the output stream

Parameters:
out - the output to write to
template - the template to read
Throws:
java.io.IOException - if an exception is thrown

getTemplate

public java.io.InputStream getTemplate()
                                throws java.io.IOException
gets an html template which is the content of the pages written to the browser

Returns:
the template
Throws:
java.io.IOException - if an exception is thrown

initNavSections

public java.util.HashMap initNavSections()
initalizes the left and top menu navigation


printRow

protected void printRow(java.lang.String col1,
                        java.lang.String col2,
                        java.io.PrintWriter out)
                 throws java.io.IOException
prints a table row similar to this <tr> <td>some info</td> <td>some more info</td> </tr>

Parameters:
col1 - the first column
col2 - the second column
out - the output to write to
Throws:
java.io.IOException - if an exception is thrown

printRow

protected void printRow(java.lang.String col1,
                        java.lang.String col2,
                        java.lang.String col3,
                        java.io.PrintWriter out)
                 throws java.io.IOException
prints a table row similar to this <tr> <td>some info</td> <td>some more info</td> <td>yet some more info</td> </tr>

Parameters:
col1 - the first column
col2 - the second column
col3 - the third column
out - the output to write to
Throws:
java.io.IOException - if an exception is thrown

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
called with the bean is created

Throws:
javax.ejb.CreateException - if the bean cannot be created

ejbActivate

public void ejbActivate()
called on a stateful sessionbean after the bean is deserialized from storage and put back into use.

Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
called on a stateful sessionbean before the bean is removed from memory and serialized to a temporary store. This method is never called on a stateless sessionbean

Specified by:
ejbPassivate in interface javax.ejb.SessionBean

ejbRemove

public void ejbRemove()
called when the bean is about to be garbage collected

Specified by:
ejbRemove in interface javax.ejb.SessionBean

setSessionContext

public void setSessionContext(javax.ejb.SessionContext sessionContext)
sets the session context

Specified by:
setSessionContext in interface javax.ejb.SessionBean
Parameters:
sessionContext - the session context


Copyright © 1999-2011 OpenEJB. All Rights Reserved.