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
- Jack's Mohawk
- LinkedIn Cuts 10% (a.k.a. The Journey is Over)
- Happy Birthday Abbie!
- Moving from Spring's XML to Annotations in AppFuse
- Free Maven Training in New Orleans on Election Day
- AppFuse Light ยป AppFuse, Maven Archetypes and Shared Web Assets
- Great Weekend in Montana
- Colorado Software Summit 2008 Wrapup
- RESTful Web Applications with Subbu Allamaraju
- Core Animation with Bill Dudney
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 #