org.melati.servlet
Class ConfigServlet

Package class diagram package ConfigServlet
java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.melati.servlet.ConfigServlet
All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
Direct Known Subclasses:
CharsetServletTest, ConfigServletTest, ExitServlet, PoemServlet, SessionAnalysisServlet

public abstract class ConfigServlet
extends javax.servlet.http.HttpServlet

Config Servlet is the simplest way to use Melati. All a ConfigServlet does is to configure a melati and combine the doGet and doPost methods. Importantly it does not establish a poem session leaving you to do this for yourself. If you want a poem session established, please extend PoemServlet. ConfigServlet does set up a basic PoemContext with the Method set, but not the POEM logicaldatabase, table or troid. The URL is expected to take one of the following form:

http://h/s/meth
the method is broken out of the path info and passed to your application code in the Melati and PoemContext parameter
h host name, such as www.melati.org
s servlet-determining part, such as melati/org.melati.admin.Admin
meth A freeform string telling your servlet what it is meant to do. This is automatically made available in templates as $melati.Method.
You can change the way these things are determined by overriding poemContext(Melati).

See Also:
Serialized Form

Field Summary
protected  MelatiConfig melatiConfig
           
protected  String sysAdminEmail
           
protected  String sysAdminName
           
 
Constructor Summary
ConfigServlet()
           
 
Method Summary
protected abstract  void doConfiguredRequest(Melati melati)
          Instantiate this method to build up your own output.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handles GET.
 void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Handle a POST.
 void error(Melati melati, Exception e)
          Send an error message.
 String getSysAdminEmail()
          This method SHOULD be overidden.
 String getSysAdminName()
          This method SHOULD be overidden.
protected  int httpStatusCode(Exception e)
           
 void init(javax.servlet.ServletConfig config)
          Inititialise Melati.
protected  MelatiConfig melatiConfig()
          To override any setting from org.melati.MelatiConfig.properties, simply override this method and return a valid MelatiConfig.
protected  PoemContext poemContext(Melati melati)
           
protected  void setSysAdminEmail(String sysAdminEmail)
           
protected  void setSysAdminName(String sysAdminName)
           
 void writeConnectionPendingException(PrintWriter out, Exception e)
          Print the ConnectionPendingException directly to the client.
 void writeError(PrintWriter out, Exception e)
          Print an error directly to the client.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

melatiConfig

protected MelatiConfig melatiConfig

sysAdminName

protected String sysAdminName

sysAdminEmail

protected String sysAdminEmail
Constructor Detail

ConfigServlet

public ConfigServlet()
Method Detail

init

public void init(javax.servlet.ServletConfig config)
          throws javax.servlet.ServletException
Inititialise Melati.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
config - a ServletConfig
Throws:
javax.servlet.ServletException - is anything goes wrong

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
Handles GET.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - the incoming HttpServletRequest
response - the outgoing HttpServletResponse

doPost

public void doPost(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
Handle a POST.

Overrides:
doPost in class javax.servlet.http.HttpServlet
Parameters:
request - the incoming HttpServletRequest
response - the outgoing HttpServletResponse

error

public void error(Melati melati,
                  Exception e)
Send an error message.

Parameters:
melati - the Melati
e - the Exception to report

httpStatusCode

protected int httpStatusCode(Exception e)

writeError

public void writeError(PrintWriter out,
                       Exception e)
Print an error directly to the client. This is rarely called, eg when the template engine fails to render the default error template.

Parameters:
out - the PrintWriter to print to
e - the Exception to report

writeConnectionPendingException

public void writeConnectionPendingException(PrintWriter out,
                                            Exception e)
Print the ConnectionPendingException directly to the client. This is called if a request is made whilst the system is still being initialised.

Parameters:
out - the PrintWriter to print to
e - the Exception to report

getSysAdminName

public String getSysAdminName()
This method SHOULD be overidden.

Returns:
the System Administrators name.

getSysAdminEmail

public String getSysAdminEmail()
This method SHOULD be overidden.

Returns:
the System Administrators email address.

setSysAdminEmail

protected void setSysAdminEmail(String sysAdminEmail)
Parameters:
sysAdminEmail - The sysAdminEmail to set.

setSysAdminName

protected void setSysAdminName(String sysAdminName)
Parameters:
sysAdminName - The sysAdminName to set.

poemContext

protected PoemContext poemContext(Melati melati)
                           throws PathInfoException
Throws:
PathInfoException

melatiConfig

protected MelatiConfig melatiConfig()
To override any setting from org.melati.MelatiConfig.properties, simply override this method and return a valid MelatiConfig. eg to use a different AccessHandler from the default:
   protected MelatiConfig melatiConfig() throws MelatiException {
     MelatiConfig config = super.melatiConfig();
     config.setAccessHandler(new YourAccessHandler());
     return config;
   }
 

Returns:
a new MelatiConfig

doConfiguredRequest

protected abstract void doConfiguredRequest(Melati melati)
                                     throws Exception
Instantiate this method to build up your own output.

Parameters:
melati -
Throws:
Exception - if anything goes wrong


Copyright © 2000-2010 PanEris. All Rights Reserved.