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
- Secure JSON Services with Play Scala and SecureSocial
- My What's New in Spring 3.1 Presentation
- Twitter's Open Source Summit: Bootstrap 2.0 Edition
- Refreshing AppFuse's UI with Twitter Bootstrap
- 2011 - A Year in Review
- Upgrading AppFuse to Spring Security 3.1 and Spring 3.1
- What have I been working on at Taleo?
- Our Engaging Trip to Paris and Antwerp
- My HTML5 with Play Scala, CoffeeScript and Jade Presentation from Devoxx 2011
- Deploying Java and Play Framework Apps to the Cloud with James Ward
Posted by No one on May 31, 2003 at 01:04 PM MDT #
Posted by Matt Raible on May 31, 2003 at 01:14 PM MDT #