com.veriplace.web.servlet
Class VeriplaceServletHelper

java.lang.Object
  extended by com.veriplace.web.servlet.VeriplaceServletHelper

public class VeriplaceServletHelper
extends java.lang.Object

Provides static methods for configuring com.veriplace.web objects in a servlet environment. These methods look for the following context-param elements in your web.xml configuration:


Field Summary
static java.lang.String PROPERTIES_FILE_CONTEXT_PARAM
           
static java.lang.String STATE_ATTRIBUTE_CONTEXT_PARAM
           
static java.lang.String VIEW_PREFIX_CONTEXT_PARAM
           
static java.lang.String VIEW_SUFFIX_CONTEXT_PARAM
           
 
Constructor Summary
VeriplaceServletHelper()
           
 
Method Summary
static Veriplace getSharedVeriplaceInstance(Servlet servlet)
          Returns a Veriplace instance for the given servlet, if one has already been created by a previous call to getSharedVeriplaceInstance(Servlet, String, String); otherwise returns null.
static Veriplace getSharedVeriplaceInstance(ServletContext servletContext)
          Creates or returns a Veriplace instance for the given ServletContext, using the properties file whose name is in the context parameter "veriplace.properties-file".
static Veriplace getSharedVeriplaceInstance(ServletContext servletContext, java.util.Properties properties)
          Creates or returns a Veriplace instance for the given ServletContext, which will be shared by all servlets within the same application.
static Veriplace getSharedVeriplaceInstance(ServletContext servletContext, java.lang.String propertiesFileName)
          Creates or returns a Veriplace instance for the given ServletContext, which will be shared by all servlets within the same application.
static Veriplace getSharedVeriplaceInstance(Servlet servlet, java.lang.String propertiesFileName, java.lang.String viewPrefix)
          Creates or returns a Veriplace instance for the given servlet.
static java.util.Properties getSharedVeriplaceProperties(ServletContext servletContext)
          Returns the properties that were used to configure the Veriplace instance for the current servlet.
static ServletStatusViewRenderer getViewRendererFromViewParams(ServletContext sc, java.lang.String paramsName)
          Creates a StatusViewRenderer using a set of servlet context parameters, as follows (where NAME is the string passed to this method): veriplace.views.NAME.prefix: path/prefix to view names (e.g.
protected static void useContext(ServletContext sc, Veriplace v, java.util.Properties properties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTIES_FILE_CONTEXT_PARAM

public static final java.lang.String PROPERTIES_FILE_CONTEXT_PARAM
See Also:
Constant Field Values

VIEW_PREFIX_CONTEXT_PARAM

public static final java.lang.String VIEW_PREFIX_CONTEXT_PARAM
See Also:
Constant Field Values

VIEW_SUFFIX_CONTEXT_PARAM

public static final java.lang.String VIEW_SUFFIX_CONTEXT_PARAM
See Also:
Constant Field Values

STATE_ATTRIBUTE_CONTEXT_PARAM

public static final java.lang.String STATE_ATTRIBUTE_CONTEXT_PARAM
See Also:
Constant Field Values
Constructor Detail

VeriplaceServletHelper

public VeriplaceServletHelper()
Method Detail

getSharedVeriplaceInstance

public static Veriplace getSharedVeriplaceInstance(ServletContext servletContext)
                                            throws java.io.IOException,
                                                   ConfigurationException
Creates or returns a Veriplace instance for the given ServletContext, using the properties file whose name is in the context parameter "veriplace.properties-file".

Parameters:
servletContext - the current ServletContext
Returns:
a Veriplace instance
Throws:
java.io.IOException - if the properties file could not be read
ConfigurationException - if the Veriplace client could not be created

getSharedVeriplaceInstance

public static Veriplace getSharedVeriplaceInstance(ServletContext servletContext,
                                                   java.lang.String propertiesFileName)
                                            throws java.io.IOException,
                                                   ConfigurationException
Creates or returns a Veriplace instance for the given ServletContext, which will be shared by all servlets within the same application.

Parameters:
servletContext - the current ServletContext
propertiesFileName - path of the properties file
Returns:
a Veriplace instance
Throws:
java.io.IOException - if the properties file could not be read
ConfigurationException - if the Veriplace client could not be created

getSharedVeriplaceInstance

public static Veriplace getSharedVeriplaceInstance(ServletContext servletContext,
                                                   java.util.Properties properties)
                                            throws ConfigurationException
Creates or returns a Veriplace instance for the given ServletContext, which will be shared by all servlets within the same application.

Parameters:
servletContext - the current ServletContext
properties - properties for initializing the Veriplace client
Returns:
a Veriplace instance
Throws:
ConfigurationException - if the Veriplace client could not be created

getSharedVeriplaceInstance

public static Veriplace getSharedVeriplaceInstance(Servlet servlet,
                                                   java.lang.String propertiesFileName,
                                                   java.lang.String viewPrefix)
                                            throws java.io.IOException,
                                                   ConfigurationException
Creates or returns a Veriplace instance for the given servlet. The object is associated with the ServletContext, so it is shared by all servlets within the same application. This method is mainly useful for code that is executed by a non-extensible servlet class, such as a JSP.

Parameters:
servlet - an active servlet
propertiesFileName - path of the properties file
viewPrefix - path to any status pages that Veriplace may need to display (a shortcut for initializing this commonly used property of ServletStatusViewRenderer)
Returns:
a Veriplace instance
Throws:
java.io.IOException - if the properties file could not be read
ConfigurationException - if the Veriplace client could not be created

getSharedVeriplaceInstance

public static Veriplace getSharedVeriplaceInstance(Servlet servlet)
                                            throws java.io.IOException,
                                                   ConfigurationException
Returns a Veriplace instance for the given servlet, if one has already been created by a previous call to getSharedVeriplaceInstance(Servlet, String, String); otherwise returns null.

Throws:
java.io.IOException
ConfigurationException

getSharedVeriplaceProperties

public static java.util.Properties getSharedVeriplaceProperties(ServletContext servletContext)
                                                         throws ConfigurationException
Returns the properties that were used to configure the Veriplace instance for the current servlet.

Throws:
ConfigurationException - if the properties file was not specified or could not be read

getViewRendererFromViewParams

public static ServletStatusViewRenderer getViewRendererFromViewParams(ServletContext sc,
                                                                      java.lang.String paramsName)
Creates a StatusViewRenderer using a set of servlet context parameters, as follows (where NAME is the string passed to this method):


useContext

protected static void useContext(ServletContext sc,
                                 Veriplace v,
                                 java.util.Properties properties)