org.apache.struts.webapp.example.memory
Class MemoryDatabasePlugIn

java.lang.Object
  extended byorg.apache.struts.webapp.example.memory.MemoryDatabasePlugIn
All Implemented Interfaces:
org.apache.struts.action.PlugIn

public final class MemoryDatabasePlugIn
extends Object
implements org.apache.struts.action.PlugIn

MemoryDatabasePlugIn initializes and finalizes the persistent storage of User and Subscription information for the Struts Demonstration Application, using an in-memory database backed by an XML file.

IMPLEMENTATION WARNING - If this web application is run from a WAR file, or in another environment where reading and writing of the web application resource is impossible, the initial contents will be copied to a file in the web application temporary directory provided by the container. This is for demonstration purposes only - you should NOT assume that files written here will survive a restart of your servlet container.

Version:
$Id $

Field Summary
private  MemoryUserDatabase database
          The MemoryUserDatabaseobject we construct and make available.
private  org.apache.commons.logging.Log log
          Logging output for this plug in instance.
private  String pathname
          The web application resource path of our persistent database storage file.
private  org.apache.struts.action.ActionServlet servlet
          The ActionServletowning this application.
 
Constructor Summary
MemoryDatabasePlugIn()
           
 
Method Summary
private  String calculatePath()
          Calculate and return an absolute pathname to the XML file to contain our persistent storage information.
 void destroy()
          Gracefully shut down this database, releasing any resources that were allocated at initialization.
 String getPathname()
           
 void init(org.apache.struts.action.ActionServlet servlet, org.apache.struts.config.ModuleConfig config)
          Initialize and load our initial database from persistent storage.
 void setPathname(String pathname)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

database

private MemoryUserDatabase database
The MemoryUserDatabaseobject we construct and make available.


log

private org.apache.commons.logging.Log log
Logging output for this plug in instance.


servlet

private org.apache.struts.action.ActionServlet servlet
The ActionServletowning this application.


pathname

private String pathname
The web application resource path of our persistent database storage file.

Constructor Detail

MemoryDatabasePlugIn

public MemoryDatabasePlugIn()
Method Detail

getPathname

public String getPathname()

setPathname

public void setPathname(String pathname)

destroy

public void destroy()
Gracefully shut down this database, releasing any resources that were allocated at initialization.

Specified by:
destroy in interface org.apache.struts.action.PlugIn

init

public void init(org.apache.struts.action.ActionServlet servlet,
                 org.apache.struts.config.ModuleConfig config)
          throws javax.servlet.ServletException
Initialize and load our initial database from persistent storage.

Specified by:
init in interface org.apache.struts.action.PlugIn
Parameters:
servlet - The ActionServlet for this web application
config - The ApplicationConfig for our owning module
Throws:
javax.servlet.ServletException - if we cannot configure ourselves correctly

calculatePath

private String calculatePath()
                      throws Exception
Calculate and return an absolute pathname to the XML file to contain our persistent storage information.

Throws:
Exception - if an input/output error occurs


Copyright © 1999-2005 Apache Software Foundation. All Rights Reserved.