org.iges.anagram.service
Class Service

java.lang.Object
  |
  +--org.iges.anagram.AbstractModule
        |
        +--org.iges.anagram.service.Service
All Implemented Interfaces:
Module
Direct Known Subclasses:
AdminService, ASCIIDataService, BinaryDataService, DASService, DDSService, DirectoryService, ErrorService, HelpService, InfoService, UploadService, XMLCatalogService

public abstract class Service
extends AbstractModule

A handler for a particular type of client request. All server output to the network is generated by the service modules.


Field Summary
protected  boolean enabled
           
protected  java.lang.String moduleID
           
protected  java.text.SimpleDateFormat updateFormat
           
 
Fields inherited from class org.iges.anagram.AbstractModule
log, moduleName, parent, server
 
Constructor Summary
Service()
           
 
Method Summary
protected  java.lang.String getBaseURL(ClientRequest clientRequest)
          Convenience method that determines the base URL of the server, using the current request.
protected  DataHandle getDataFromPath(ClientRequest clientRequest)
          Convenience method for data services, which ensures that the client request contains a usable data handle.
 java.lang.String getModuleID()
          Returns an ID for this module.
abstract  java.lang.String getServiceName()
          Returns the name of this service.
abstract  void handle(ClientRequest request)
          Performs the service provided by this module.
 boolean isEnabled()
          Returns whether this service should be invoked or not.
protected  void printFooter(java.io.PrintStream p, Handle path, long updateTime, java.lang.String baseURL)
          Used to provide a consistent "look and feel" to pages served by the server.
protected  void printHeader(java.io.PrintStream p, java.lang.String windowTitle, java.lang.String pageTitle, Handle path, java.lang.String baseURL)
          Used to provide a consistent "look and feel" to pages served by the server.
 void setEnabled(boolean enabled)
          Sets the enabled property of this service.
protected  java.io.PrintStream startHTML(ClientRequest clientRequest)
          Convenience method that opens the response stream to the client and sets the content type to HTML.
 
Methods inherited from class org.iges.anagram.AbstractModule
configModule, configure, debug, debug, error, fail, fail, fail, getModuleName, info, init, toString, verbose, verbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

updateFormat

protected java.text.SimpleDateFormat updateFormat

enabled

protected boolean enabled

moduleID

protected java.lang.String moduleID
Constructor Detail

Service

public Service()
Method Detail

getModuleID

public java.lang.String getModuleID()
Description copied from interface: Module
Returns an ID for this module. This ID should be a legal XML tag name. It has two uses: as a tag name in the server's configuration file, and as the final element of the complete module name.

Specified by:
getModuleID in interface Module
Specified by:
getModuleID in class AbstractModule

setEnabled

public void setEnabled(boolean enabled)
Sets the enabled property of this service. If false, indicates to the dispatch filter that the service should not be invoked.


isEnabled

public boolean isEnabled()
Returns whether this service should be invoked or not.


getServiceName

public abstract java.lang.String getServiceName()
Returns the name of this service. Used to build the module ID, and to map URLs to services.


handle

public abstract void handle(ClientRequest request)
                     throws ModuleException
Performs the service provided by this module.

Parameters:
request - The request to be handled
Throws:
ModuleException - if the service fails for any reason

getBaseURL

protected java.lang.String getBaseURL(ClientRequest clientRequest)
Convenience method that determines the base URL of the server, using the current request.


startHTML

protected java.io.PrintStream startHTML(ClientRequest clientRequest)
Convenience method that opens the response stream to the client and sets the content type to HTML.


printHeader

protected void printHeader(java.io.PrintStream p,
                           java.lang.String windowTitle,
                           java.lang.String pageTitle,
                           Handle path,
                           java.lang.String baseURL)
Used to provide a consistent "look and feel" to pages served by the server. Provides the opening portion of an HTML page response.

Parameters:
windowTitle - A title to appear in the window's title bar
pageTitle - A title to appear at the top of the page (can be HTML)
path - The handle associated with this request. If non-null, a hierarchical set of links up to the parents of this handle will be printed next to the link to the server home page
baseURL - The server's base URL. This must be specified with each request, as it is not guaranteed to be constant.

printFooter

protected void printFooter(java.io.PrintStream p,
                           Handle path,
                           long updateTime,
                           java.lang.String baseURL)
Used to provide a consistent "look and feel" to pages served by the server. Provides the closing portion of an HTML page response.

Parameters:
path - The handle associated with this request. If non-null, a hierarchical set of links up to the parents of this handle will be printed next to the link to the server home page
updateTime - Te last update time for the page, or zero if not applicable
baseURL - The server's base URL. This must be specified with each request, as it is not guaranteed to be constant.

getDataFromPath

protected DataHandle getDataFromPath(ClientRequest clientRequest)
                              throws ModuleException
Convenience method for data services, which ensures that the client request contains a usable data handle.

Throws:
ModuleException - If the handle is null, a directory, forbidden by the client's privilege set, or flagged as unavailable