Blame |
Last modification |
View Log
| RSS feed
package pt.estgp.es.exemplos.hibernate.web;
import org.apache.log4j.Logger;
import pt.estgp.es.exemplos.hibernate.HibernateUtils;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import javax.servlet.http.HttpSessionBindingEvent;
public class HibernateStarterListener
implements ServletContextListener,
HttpSessionListener, HttpSessionAttributeListener
{
private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger =
1.5.0/docs/api/java/util/logging/Logger.html">Logger.
getLogger(HibernateStarterListener.
class);
// Public constructor is required by servlet spec
public HibernateStarterListener
() {
}
// -------------------------------------------------------
// ServletContextListener implementation
// -------------------------------------------------------
public void contextInitialized
(ServletContextEvent sce
) {
/* This method is called when the servlet context is
initialized(when the Web application is deployed).
You can initialize servlet context related data here.
*/
logger.
info("Iniciando o Hibernate");
HibernateUtils.
getCurrentSession();
}
public void contextDestroyed
(ServletContextEvent sce
) {
/* This method is invoked when the Servlet Context
(the Web application) is undeployed or
Application Server shuts down.
*/
}
// -------------------------------------------------------
// HttpSessionListener implementation
// -------------------------------------------------------
public void sessionCreated
(HttpSessionEvent se
) {
/* Session is created. */
}
public void sessionDestroyed
(HttpSessionEvent se
) {
/* Session is destroyed. */
}
// -------------------------------------------------------
// HttpSessionAttributeListener implementation
// -------------------------------------------------------
public void attributeAdded
(HttpSessionBindingEvent sbe
) {
/* This method is called when an attribute
is added to a session.
*/
}
public void attributeRemoved
(HttpSessionBindingEvent sbe
) {
/* This method is called when an attribute
is removed from a session.
*/
}
public void attributeReplaced
(HttpSessionBindingEvent sbe
) {
/* This method is invoked when an attibute
is replaced in a session.
*/
}
}