|
|||||||||
| Home >> All >> org >> objectstyle >> cayenne >> [ conf overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.objectstyle.cayenne.conf
Class WebApplicationListener

java.lang.Objectorg.objectstyle.cayenne.conf.WebApplicationListener
- All Implemented Interfaces:
- java.util.EventListener, javax.servlet.http.HttpSessionListener, javax.servlet.ServletContextListener
- public class WebApplicationListener
- extends java.lang.Object
- implements javax.servlet.http.HttpSessionListener, javax.servlet.ServletContextListener
- extends java.lang.Object
WebApplicationListener utilizes Servlet specification 2.3 features to react on webapplication container events inializing Cayenne.
It performs the following tasks:
- Loads Cayenne configuration when the application is started within container.
- Assigns new DataContext to every new session created within the application.
CayenneWebappListener must be configured in web.xml deployment
descriptor as a listener of context and session events:
<listener>
<listener-class>org.objectstyle.cayenne.conf.WebApplicationListener</listener-class>
</listener>
Note that to set WebApplicationListener 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 your code.
| Constructor Summary | |
WebApplicationListener()
|
|
| Method Summary | |
void |
contextDestroyed(javax.servlet.ServletContextEvent sce)
Currently does nothing. |
void |
contextInitialized(javax.servlet.ServletContextEvent sce)
Establishes a Cayenne shared Configuration object that can later be obtained by calling Configuration.getSharedConfiguration(). |
protected Configuration |
getConfiguration()
Returns the current configuration. |
protected Configuration |
newConfiguration(javax.servlet.ServletContext sc)
Return an instance of Configuration that will be initialized as the shared configuration. |
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. |
protected void |
setConfiguration(Configuration configuration)
Initializes the configuration. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
WebApplicationListener
public WebApplicationListener()
| Method Detail |
contextInitialized
public void contextInitialized(javax.servlet.ServletContextEvent sce)
- Establishes a Cayenne shared Configuration object that can later be obtained by calling
Configuration.getSharedConfiguration(). This method is a part of ServletContextListener interface and is called on application startup.- Specified by:
contextInitializedin interfacejavax.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:
contextDestroyedin interfacejavax.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:
sessionCreatedin interfacejavax.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:
sessionDestroyedin interfacejavax.servlet.http.HttpSessionListener
newConfiguration
protected Configuration newConfiguration(javax.servlet.ServletContext sc)
- Return an instance of Configuration that will be initialized as the shared configuration.
Provides an extension point for the developer to provide their own custom configuration.
setConfiguration
protected void setConfiguration(Configuration configuration)
- Initializes the configuration.
getConfiguration
protected Configuration getConfiguration()
- Returns the current configuration.
|
|||||||||
| Home >> All >> org >> objectstyle >> cayenne >> [ conf overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.objectstyle.cayenne.conf.WebApplicationListener