org.apache.cayenne.conf
Class ServletUtil

java.lang.Object
  extended by org.apache.cayenne.conf.ServletUtil

public class ServletUtil
extends Object

Configuration class that uses ServletContext to locate resources. This class is intended for use in J2EE servlet containers. It is compatible with containers following servlet specification version 2.2 and newer (e.g. Tomcat can be used starting from version 3).

ServletConfiguration resolves configuration file locations relative to the web application "WEB-INF" directory, and does not require them to be in the CLASSPATH (though CLASSPATH locations such as "/WEB-INF/classes" and "/WEB-INF/lib/some.jar" are supported as well). By default search for cayenne.xml is done in /WEB-INF/ folder. To specify an arbitrary context path in the web application (e.g. "/WEB-INF/cayenne"), use cayenne.configuration.path context parameters in web.xml.

Since:
1.2

Field Summary
static String CONFIGURATION_PATH_KEY
          A name of the web application initialization parameter used to specify extra paths where Cayenne XML files might be located.
static String DATA_CONTEXT_KEY
          Used by BasicServletConfiguration as a session attribute for DataContext.
 
Constructor Summary
ServletUtil()
           
 
Method Summary
protected static ResourceLocator createLocator(javax.servlet.ServletContext context)
          A helper method to create default ResourceLocator.
static DataContext getSessionContext(javax.servlet.http.HttpSession session)
          Returns default Cayenne DataContext associated with the HttpSession, creating it on the fly and storing in the session if needed.
static Configuration initializeSharedConfiguration(javax.servlet.ServletContext context)
          Creates a new ServletConfiguration and sets is as a Configuration signleton.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_PATH_KEY

public static final String CONFIGURATION_PATH_KEY
A name of the web application initialization parameter used to specify extra paths where Cayenne XML files might be located. E.g. "/WEB-INF/cayenne".

See Also:
Constant Field Values

DATA_CONTEXT_KEY

public static final String DATA_CONTEXT_KEY
Used by BasicServletConfiguration as a session attribute for DataContext.

See Also:
Constant Field Values
Constructor Detail

ServletUtil

public ServletUtil()
Method Detail

initializeSharedConfiguration

public static Configuration initializeSharedConfiguration(javax.servlet.ServletContext context)
Creates a new ServletConfiguration and sets is as a Configuration signleton.


createLocator

protected static ResourceLocator createLocator(javax.servlet.ServletContext context)
A helper method to create default ResourceLocator.


getSessionContext

public static DataContext getSessionContext(javax.servlet.http.HttpSession session)
Returns default Cayenne DataContext associated with the HttpSession, creating it on the fly and storing in the session if needed.



Copyright © 2001-2011 Apache Cayenne. All Rights Reserved.