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
- Fantastic Fun in Jackson Hole
- How We Hired a Team of 10 in 2 Months
- Jack's Skiing Like A Madman!
- My Future of Web Frameworks Presentation
- My Guest Room Remodel is finished!
- Web Application Testing with Selenium by Jason Huggins
- Web Application Testing with Selenium at Agile Denver next Monday
- 17" MacBook Pro Stolen from Living Room
- Using JRebel with IntelliJ IDEA on OS X
- Reviews for Grails: A Quick-Start Guide and Kanban and Scrum