com.xmlserv.app
Class AppBase

java.lang.Object
  |
  +--com.xmlserv.main.XMLServBackendImpl
        |
        +--com.xmlserv.app.AppBase
All Implemented Interfaces:
XMLServBackend
Direct Known Subclasses:
AclDelete, AclEdit, AclList, AclSave, AdminMessageEdit, AdminMessageSend, AgendaDelete, AgendaEdit, AgendaList, AgendaSave, AppLogList, BasketAdd, BasketCleanup, BasketClear, BasketClose, BasketComplete, BasketDelete, BasketDrop, BasketList, BasketOpen, BasketReceiptShow, BasketRename, BasketSend, CommentDelete, CommentEdit, CommentSave, CommentThread, ContentGroupDelete, ContentGroupEdit, ContentGroupList, ContentGroupSave, Download, EditAnswer, EditionDelete, EditionEdit, EditionList, EditionSave, EditionShow, EditQuestion, FaqList, GalleryMain, GuestlistEdit, GuestlistSave, ImageDelete, ImageEdit, ImageGet, ImageGetAlt, ImageSave, ImageTextDownload, ImageUpload, LinkDelete, LinkEdit, LinkList, LinkSave, LinkShow, LocationEdit, LocationSave, Logout, LotteryDelete, LotteryEdit, LotteryList, LotteryResult, LotterySave, LotteryShow, LotterySubmit, MailinglistDelete, MailinglistEdit, MailinglistList, MailinglistSave, MemberList, MemberShow, Menu, NewsDelete, NewsEdit, NewsList, NewsOverview, NewsSave, NewsShow, OpenQuestionsList, PhoneBookChangeEdit, PhoneBookChangeSubmit, PhoneBookDelete, PhoneBookEdit, PhoneBookList, PhoneBookSave, PollDelete, PollSave, PollShow, ResourceAclEdit, ResourceAclSave, RoleEdit, RoleGroupDelete, RoleGroupEdit, RoleGroupList, RoleGroupSave, RoleList, RoleSave, SaveAnswer, SaveQuestion, SimplePollEdit, SimplePollList, SimplePollResult, SimplePollSave, SimplePollSubmit, StatisticsMain, UploadForm, UserCreate, UserDelete, UserEdit, UserList, UserLogout, UserSave

public abstract class AppBase
extends XMLServBackendImpl

This abstract class is intended as the baseclass for all applications running under XMLServ. It creates a reference to a PostgreSQL connection pool object which should be used by subclasses instead of individual connections.
Subclasses must still implement the process(context, req, secman) method as when subclassing XMLServBackendImpl directly.

Version:
$Id: AppBase.java,v 1.19 2002/11/21 21:12:50 muecke Exp $
Author:
Wolfram Saringer

Constructor Summary
AppBase()
          Empty constructor.
 
Method Summary
protected  java.sql.Connection checkoutConn()
          Aggregation method delegated to PGConnectionPool.
 void destroy()
          Prepare object to go out of service.
protected  javax.xml.transform.Source errorPage(java.lang.String msg)
          Create an ErrorPage.
protected  javax.xml.transform.Source errorPage(java.lang.String msg, java.lang.String code)
          Create an ErrorPage with an error code.
 java.lang.String getUrl(javax.servlet.http.HttpServletRequest req)
           
 void init()
          Initialize object when application is loaded by BackendRepository.
protected  org.jdom.Element newElement(java.lang.String name, java.lang.String content)
          Produce simple Element with text content.
 javax.xml.transform.Source process(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, SecurityManager securitymanager)
          This variant of the main method is called when the BackendHandle indicates that this Backend produces binary data which should be sent to the client without further processing.
 org.jdom.Document process(javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest req, SecurityManager securitymanager)
          This is the method to override in subclasses.
 org.jdom.Document redirect(javax.servlet.http.HttpServletRequest req)
          Utility method to implement consistent redirection behaviour.
 void redirect(com.oreilly.servlet.MultipartRequest mreq, javax.servlet.http.HttpServletRequest sreq)
          Utility method to implement consistent redirection behaviour.
protected  void returnConn(java.sql.Connection conn)
          Aggregation method delegated to PGConnectionPool.
 
Methods inherited from class com.xmlserv.main.XMLServBackendImpl
addParam, getParam, getReqCount, getStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AppBase

public AppBase()
Empty constructor.
Method Detail

init

public void init()
          throws javax.servlet.ServletException
Initialize object when application is loaded by BackendRepository. This initializes the connection pool shared across all instances if not already present.
Overrides:
init in class XMLServBackendImpl
Throws:
javax.servlet.ServletException - On any error.
See Also:
PGConnectionPool

destroy

public void destroy()
Prepare object to go out of service. This deletes the shared connection pool if present.
Overrides:
destroy in class XMLServBackendImpl

process

public org.jdom.Document process(javax.servlet.ServletContext context,
                                 javax.servlet.http.HttpServletRequest req,
                                 SecurityManager securitymanager)
                          throws XMLServException,
                                 javax.servlet.ServletException,
                                 java.io.IOException
Description copied from class: XMLServBackendImpl
This is the method to override in subclasses.
Overrides:
process in class XMLServBackendImpl
Following copied from class: com.xmlserv.main.XMLServBackendImpl
Parameters:
context - The servlet context.
req - The HTTP request.
securitymanager - The SecurityManager instance associated with this object.
Returns:
An XML document.
Throws:
XMLServException - Indicates an error condition in the business logic.
javax.servlet.ServletException - A generic failure.
java.io.IOException - Any I/O error condition.

process

public javax.xml.transform.Source process(javax.servlet.ServletContext context,
                                          javax.servlet.http.HttpServletRequest req,
                                          javax.servlet.http.HttpServletResponse res,
                                          SecurityManager securitymanager)
                                   throws XMLServException,
                                          javax.servlet.ServletException,
                                          java.io.IOException
Description copied from interface: XMLServBackend
This variant of the main method is called when the BackendHandle indicates that this Backend produces binary data which should be sent to the client without further processing.
Overrides:
process in class XMLServBackendImpl
Following copied from interface: com.xmlserv.main.XMLServBackend
Returns:
Always null.

redirect

public org.jdom.Document redirect(javax.servlet.http.HttpServletRequest req)
                           throws RedirectException
Utility method to implement consistent redirection behaviour. Redirects to location given by request parameter target if present, to Referer otherwise.

redirect

public void redirect(com.oreilly.servlet.MultipartRequest mreq,
                     javax.servlet.http.HttpServletRequest sreq)
              throws RedirectException
Utility method to implement consistent redirection behaviour. Redirects to location given by request parameter target if present, to Referer otherwise.

getUrl

public java.lang.String getUrl(javax.servlet.http.HttpServletRequest req)

newElement

protected org.jdom.Element newElement(java.lang.String name,
                                      java.lang.String content)
Produce simple Element with text content.
Parameters:
name - The name of the XML Element.
content - The text content for the Element.
Returns:
The prepared Element.

checkoutConn

protected java.sql.Connection checkoutConn()
                                    throws java.sql.SQLException
Aggregation method delegated to PGConnectionPool.
Returns:
The Connection object from the pool.
Throws:
java.sql.SQLException - Error checking out Connection.

returnConn

protected void returnConn(java.sql.Connection conn)
Aggregation method delegated to PGConnectionPool.
Parameters:
conn - The Connection object to return to the pool.
Throws:
java.sql.SQLException - Error returning Connection.

errorPage

protected javax.xml.transform.Source errorPage(java.lang.String msg)
                                        throws javax.servlet.ServletException,
                                               java.io.IOException
Create an ErrorPage.
Parameters:
msg - The error message.
Returns:
The XML document.
Throws:
javax.servlet.ServletException - Any processing error.
java.io.IOException - Should not happen.
See Also:
ErrorPage

errorPage

protected javax.xml.transform.Source errorPage(java.lang.String msg,
                                               java.lang.String code)
                                        throws javax.servlet.ServletException,
                                               java.io.IOException
Create an ErrorPage with an error code.
Parameters:
msg - The error message.
code - The Error code.
Returns:
The XML document.
Throws:
javax.servlet.ServletException - Any processing error.
java.io.IOException - Should not happen.
See Also:
ErrorPage