Saturday May 31, 2003
Hibernate PlugIn for Struts I don't know that there's a need for a Hibernate PlugIn for Struts, but I wrote one today just for kicks. Pretty simple stuff that only requires you to have hibernate.cfg.xml in your WEB-INF/classes directory, and to add the following to your struts-config.xml.
<plug-in className="org.appfuse.webapp.util.HibernatePlugIn"/>
Then create the file org.appfuse.webapp.util.HibernatePlugIn as follows:
public class HibernatePlugIn implements PlugIn {
//~ Instance fields ========================================================
private Log log = LogFactory.getLog(HibernatePlugIn.class);
//~ Methods ================================================================
public void init(ActionServlet servlet, ModuleConfig config)
throws ServletException {
try {
SessionFactory sf =
new Configuration().configure().buildSessionFactory();
if (log.isDebugEnabled()) {
log.debug("Hibernate configuration completed.");
}
} catch (HibernateException h) {
log.fatal("Error configuring Hibernate!", h);
}
}
public void destroy() {}
}
This doesn't seem to have any advantages over using a StartupListener, but it would be pretty sweet if it was included with Struts (or Hibernate), so you could simply put it in struts-config.xml and be done with it. Posted in Java at May 31 2003, 11:31:41 AM MDT 2 Comments
Search This Site
Recent Entries
- Choosing an Ajax Framework
- R.I.P. Giant FCR3
- Happy Birthday Mom!
- 2008 - A Year in Review
- Portland Tech Meetup Tomorrow Night
- My "almost slept in a snow cave" Adventure with Clint Foster
- My Christmas Travel Adventure
- AppFuse Light converted to Maven modules, upgraded to Tapestry 5 and Stripes 1.5
- Dojo/Comet support in Java Web Frameworks
- Abbie is a Blue Skier!