com.primix.vlib
Class VirtualLibraryEngine

java.lang.Object
  |
  +--com.primix.tapestry.engine.AbstractEngine
        |
        +--com.primix.tapestry.engine.SimpleEngine
              |
              +--com.primix.vlib.VirtualLibraryEngine
All Implemented Interfaces:
java.util.EventListener, java.io.Externalizable, HttpSessionBindingListener, IEngine, java.io.Serializable

public class VirtualLibraryEngine
extends SimpleEngine

The engine for the Primix Virtual Library. This exists to implement the external service, which allows the ViewBook and PersonPage pages to be bookmarked, and to provide a way for shutting down the application when the user logs out.

Version:
$Id: VirtualLibraryEngine.java,v 1.15 2001/08/07 20:12:27 hship Exp $
Author:
Howard Ship
See Also:
Serialized Form

Inner Class Summary
 class VirtualLibraryEngine.ExternalService
          The external service is used to make the ViewBook and PersonPage pages bookmarkable.
 
Field Summary
static Category CAT
           
static java.lang.String EXTERNAL_SERVICE
          The name ("external") of a service that exposes books or persons in such as way that they are bookmarkable.
 
Fields inherited from class com.primix.tapestry.engine.AbstractEngine
HELPER_BEAN_POOL_NAME, PAGE_SOURCE_NAME, pageSource, SCRIPT_SOURCE_NAME, specification, SPECIFICATION_SOURCE_NAME, specificationSource, TEMPLATE_SOURCE_NAME, templateSource, VISIT_CLASS_PROPERTY_NAME
 
Fields inherited from interface com.primix.tapestry.IEngine
EXCEPTION_PAGE, HOME_PAGE, STALE_LINK_PAGE, STALE_SESSION_PAGE
 
Constructor Summary
VirtualLibraryEngine()
           
 
Method Summary
protected  void cleanupAfterRequest(IRequestCycle cycle)
          Removes the operations bean instance, if accessed this request cycle.
 void clearCache()
          Invoked from Visit.clearCache() (and at the end of the request cycle) to clear the publisher and person IPropertySelectionModel models.
protected  IEngineService constructService(java.lang.String name)
          Supports construction of the external service.
 IBookQuery createNewQuery()
          Creates a new IBookQuery EJB instance.
 java.lang.Object createVisit(IRequestCycle cycle)
          Creates an instance of Visit.
 java.lang.Object findNamedObject(java.lang.String name, java.lang.Class expectedClass)
           
 IBookQueryHome getBookQueryHome()
           
 IOperations getOperations()
          Returns an instance of the Vlib Operations beans, which is a stateless session bean for performing certain operations.
 IOperationsHome getOperationsHome()
           
 IPropertySelectionModel getPersonModel()
          Returns a model that contains all the known Person's, sorted by last name, then first.
 IPropertySelectionModel getPublisherModel()
          Builds a model for entering in a publisher name, including an intial blank option.
 Context getRootNamingContext()
           
 boolean isDebugEnabled()
           
 void logout()
          Sets the visit property to null, and sets a flag that invalidates the HttpSession at the end of the request cycle.
 void namingFailure(java.lang.String message, NamingException ex, boolean throwException)
          As with #rmiFailure(RemoteException), but for NamingException.
 void presentError(java.lang.String error, IRequestCycle cycle)
          Invoked in various places to present an error message to the user.
 void rmiFailure(java.lang.String message, java.rmi.RemoteException ex, boolean throwException)
          Invoked after an operation on a home or remote interface throws a RemoteException; this clears any cache of home and remote interfaces.
protected  void serviceExternal(IRequestCycle cycle, java.lang.String[] parameters, ResponseOutputStream output)
          Performs the actual servicing of the external service.
 
Methods inherited from class com.primix.tapestry.engine.SimpleEngine
createPageRecorder, forgetPage, getActivePageNames, getPageRecorder, readExternal, writeExternal
 
Methods inherited from class com.primix.tapestry.engine.AbstractEngine
activateExceptionPage, cleanupEngine, clearCachedData, extendDescription, getContextPath, getHasVisit, getHelperBeanPool, getListeners, getLocale, getMonitor, getPageSource, getResourceResolver, getScriptSource, getService, getServletPath, getSpecification, getSpecificationSource, getTemplateSource, getVisit, getVisit, handleStaleLinkException, handleStaleSessionException, isResetServiceEnabled, isStateful, redirect, redirectOut, render, reportException, restart, service, serviceAction, serviceDirect, servicePage, serviceReset, setLocale, setStateful, setupForRequest, setVisit, toString, valueBound, valueUnbound
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CAT

public static final Category CAT

EXTERNAL_SERVICE

public static final java.lang.String EXTERNAL_SERVICE
The name ("external") of a service that exposes books or persons in such as way that they are bookmarkable.
Constructor Detail

VirtualLibraryEngine

public VirtualLibraryEngine()
Method Detail

createVisit

public java.lang.Object createVisit(IRequestCycle cycle)
Creates an instance of Visit.
Overrides:
createVisit in class AbstractEngine

cleanupAfterRequest

protected void cleanupAfterRequest(IRequestCycle cycle)
Removes the operations bean instance, if accessed this request cycle.

May invalidate the HttpSession (see logout()).

Overrides:
cleanupAfterRequest in class SimpleEngine

constructService

protected IEngineService constructService(java.lang.String name)
Supports construction of the external service.
Overrides:
constructService in class AbstractEngine

serviceExternal

protected void serviceExternal(IRequestCycle cycle,
                               java.lang.String[] parameters,
                               ResponseOutputStream output)
                        throws RequestCycleException,
                               ServletException,
                               java.io.IOException
Performs the actual servicing of the external service.

logout

public void logout()
Sets the visit property to null, and sets a flag that invalidates the HttpSession at the end of the request cycle.

isDebugEnabled

public boolean isDebugEnabled()

getBookQueryHome

public IBookQueryHome getBookQueryHome()

getOperationsHome

public IOperationsHome getOperationsHome()

getOperations

public IOperations getOperations()
Returns an instance of the Vlib Operations beans, which is a stateless session bean for performing certain operations.

The bean is automatically removed at the end of the request cycle.


findNamedObject

public java.lang.Object findNamedObject(java.lang.String name,
                                        java.lang.Class expectedClass)

getRootNamingContext

public Context getRootNamingContext()

getPublisherModel

public IPropertySelectionModel getPublisherModel()
Builds a model for entering in a publisher name, including an intial blank option. Problem: thie model is held for a long while, so it won't reflect publishers added by this user or others. Solution: coming; perhaps we'll age-out the model after a few minutes.

clearCache

public void clearCache()
Invoked from Visit.clearCache() (and at the end of the request cycle) to clear the publisher and person IPropertySelectionModel models.

getPersonModel

public IPropertySelectionModel getPersonModel()
Returns a model that contains all the known Person's, sorted by last name, then first. The label for the model matches the user's natural name.

createNewQuery

public IBookQuery createNewQuery()
Creates a new IBookQuery EJB instance.

presentError

public void presentError(java.lang.String error,
                         IRequestCycle cycle)
Invoked in various places to present an error message to the user. This sets the error property of either the Home or MyLibrary page (the latter only if the user is logged in), and sets the selected page for rendering the response.

rmiFailure

public void rmiFailure(java.lang.String message,
                       java.rmi.RemoteException ex,
                       boolean throwException)
Invoked after an operation on a home or remote interface throws a RemoteException; this clears any cache of home and remote interfaces.
Parameters:
message - the message for the exception, or for the log message
ex - the exception thrown
throwException - if true, an ApplicationRuntimeException is thrown after the message is logged.

namingFailure

public void namingFailure(java.lang.String message,
                          NamingException ex,
                          boolean throwException)
As with #rmiFailure(RemoteException), but for NamingException.