Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.objectstyle.cayenne.conf
Class ServletConfiguration  view ServletConfiguration download ServletConfiguration.java

java.lang.Object
  extended byorg.objectstyle.cayenne.conf.Configuration
      extended byorg.objectstyle.cayenne.conf.DefaultConfiguration
          extended byorg.objectstyle.cayenne.conf.BasicServletConfiguration
              extended byorg.objectstyle.cayenne.conf.ServletConfiguration
All Implemented Interfaces:
java.util.EventListener, javax.servlet.http.HttpSessionListener, javax.servlet.ServletContextListener

public class ServletConfiguration
extends BasicServletConfiguration
implements javax.servlet.http.HttpSessionListener, javax.servlet.ServletContextListener

ServletConfiguration is a Configuration that uses ServletContext to locate resources. This class can only be used in a context of a servlet/jsp container. It resolves configuration file paths relative to the web application "WEB-INF" directory.

It performs the following tasks:

ServletConfiguration must be configured in web.xml deployment descriptor as a listener of context and session events:

<listener>
     <listener-class>org.objectstyle.cayenne.conf.ServletConfiguration</listener-class>
</listener>

Note that to set ServletConfiguration as a listener of web application events, you must use servlet containers compatible with Servlet Specification 2.3 (such as Tomcat 4.0). Listeners were only added to servlet specification in 2.3. If you are using an older container. You will need to configure Cayenne in you code.


Nested Class Summary
 
Nested classes inherited from class org.objectstyle.cayenne.conf.Configuration
 
Field Summary
static java.lang.String DATA_CONTEXT_KEY
           
 
Fields inherited from class org.objectstyle.cayenne.conf.BasicServletConfiguration
CONFIGURATION_PATH_KEY, servletContext
 
Fields inherited from class org.objectstyle.cayenne.conf.DefaultConfiguration
 
Fields inherited from class org.objectstyle.cayenne.conf.Configuration
configurationShutdownHook, dataDomains, dataDomainsRef, DEFAULT_CONFIGURATION_CLASS, DEFAULT_DOMAIN_FILE, DEFAULT_LOGGING_PROPS_FILE, domainConfigurationName, ignoringLoadFailures, loadStatus, overrideFactory, resourceLoader, sharedConfiguration
 
Constructor Summary
ServletConfiguration()
           
ServletConfiguration(javax.servlet.ServletContext context)
           
 
Method Summary
 void contextDestroyed(javax.servlet.ServletContextEvent sce)
          Currently does nothing.
 void contextInitialized(javax.servlet.ServletContextEvent sce)
          Sets itself as a Cayenne shared Configuration object that can later be obtained by calling Configuration.getSharedConfig().
static org.objectstyle.cayenne.access.DataContext getDefaultContext(javax.servlet.http.HttpSession s)
          Returns default Cayenne DataContext associated with session s.
 void sessionCreated(javax.servlet.http.HttpSessionEvent se)
          Creates and assigns a new data context based on default domain to the session object associated with this event.
 void sessionDestroyed(javax.servlet.http.HttpSessionEvent se)
          Does nothing.
 
Methods inherited from class org.objectstyle.cayenne.conf.BasicServletConfiguration
canInitialize, getServletContext, initializeConfiguration, setServletContext
 
Methods inherited from class org.objectstyle.cayenne.conf.DefaultConfiguration
addClassPath, didInitialize, getDomainConfiguration, getMapConfiguration, getResourceLocator, initialize, setResourceLocator, toString
 
Methods inherited from class org.objectstyle.cayenne.conf.Configuration
addDomain, bootstrapSharedConfiguration, configureCommonLogging, configureCommonLogging, configureLogging, getDataSourceFactory, getDomain, getDomain, getDomainConfigurationName, getDomains, getLoaderDelegate, getLoadStatus, getLoggingLevel, getResourceLoader, getSharedConfiguration, initializeSharedConfiguration, initializeSharedConfiguration, initializeSharedConfiguration, installConfigurationShutdownHook, isIgnoringLoadFailures, isLoggingConfigured, removeDomain, setDataSourceFactory, setDomainConfigurationName, setIgnoringLoadFailures, setLoadStatus, setLoggingConfigured, setLoggingLevel, shutdown, uninstallConfigurationShutdownHook
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DATA_CONTEXT_KEY

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

ServletConfiguration

public ServletConfiguration()

ServletConfiguration

public ServletConfiguration(javax.servlet.ServletContext context)
Method Detail

getDefaultContext

public static org.objectstyle.cayenne.access.DataContext getDefaultContext(javax.servlet.http.HttpSession s)
Returns default Cayenne DataContext associated with session s.


contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent sce)
Sets itself as a Cayenne shared Configuration object that can later be obtained by calling Configuration.getSharedConfig(). This method is a part of ServletContextListener interface and is called on application startup.

Specified by:
contextInitialized in interface javax.servlet.ServletContextListener

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent sce)
Currently does nothing. In the future it should close down any database connections if they wheren't obtained via JNDI. This method is a part of ServletContextListener interface and is called on application shutdown.

Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener

sessionCreated

public void sessionCreated(javax.servlet.http.HttpSessionEvent se)
Creates and assigns a new data context based on default domain to the session object associated with this event. This method is a part of HttpSessionListener interface and is called every time when a new session is created.

Specified by:
sessionCreated in interface javax.servlet.http.HttpSessionListener

sessionDestroyed

public void sessionDestroyed(javax.servlet.http.HttpSessionEvent se)
Does nothing. This method is a part of HttpSessionListener interface and is called every time when a session is destroyed.

Specified by:
sessionDestroyed in interface javax.servlet.http.HttpSessionListener