|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zkplus.hibernate.HibernateSessionFactoryListener
public class HibernateSessionFactoryListener
Listener to init and cleanup the hibernate session factory automatically.
This listener is used with OpenSessionInViewListener and
HibernateUtil, or it will not work.
In WEB-INF/zk.xml, add following lines:
<listener>
<description>Hibernate SessionFactory Lifecycle</description>
<listener-class>org.zkoss.zkplus.hibernate.HibernateSessionFactoryListener</listener-class>
</listener>
Since ZK 3.0.1, if your hibernate configuration file name is not the default "hibernate.cfg.xml", you can specify it in WEB-INF/zk.xml. Just add following lines:
<preference>
<name>HibernateUtil.config</name>
<value>YOUR-HIBERNATE-CONFIG-FILENAME</value>
Sometimes, when using ZK with other backend framework, the Hibernate's SessionFactory
might has to be created earlier. Therefore, since ZK 3.0.1, we have implemented this
listener to be also a ServletContextListener that you can
choose to specify it in web.xml instead and make it initialized right when your applcation
is deployed.
In WEB-INF/web.xml, add following lines:
<context-param>
<param-name>HibernateUtil.config</param-name>
<param-value>YOUR-HIBERNATE-CONFIG-FILENAME</param-value>
</context-param>
<listener>
<listener-class>org.zkoss.zkplus.hibernate.HibernateSessionFactoryListener</listener-class>
</listener>
Applicable to Hibernate version 3.2.ga or later
| Constructor Summary | |
|---|---|
HibernateSessionFactoryListener()
Deprecated. |
|
| Method Summary | |
|---|---|
void |
cleanup(org.zkoss.zk.ui.WebApp wapp)
Deprecated. |
void |
contextDestroyed(javax.servlet.ServletContextEvent sce)
Deprecated. |
void |
contextInitialized(javax.servlet.ServletContextEvent sce)
Deprecated. |
void |
init(org.zkoss.zk.ui.WebApp app)
Deprecated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HibernateSessionFactoryListener()
| Method Detail |
|---|
public void init(org.zkoss.zk.ui.WebApp app)
init in interface org.zkoss.zk.ui.util.WebAppInitpublic void cleanup(org.zkoss.zk.ui.WebApp wapp)
cleanup in interface org.zkoss.zk.ui.util.WebAppCleanuppublic void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed in interface javax.servlet.ServletContextListenerpublic void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized in interface javax.servlet.ServletContextListener
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||