Matt RaibleMatt Raible is a Web Developer and Java Champion. Connect with him on LinkedIn.

The Angular Mini-Book The Angular Mini-Book is a guide to getting started with Angular. You'll learn how to develop a bare-bones application, test it, and deploy it. Then you'll move on to adding Bootstrap, Angular Material, continuous integration, and authentication.

Spring Boot is a popular framework for building REST APIs. You'll learn how to integrate Angular with Spring Boot and use security best practices like HTTPS and a content security policy.

For book updates, follow @angular_book on Twitter.

The JHipster Mini-Book The JHipster Mini-Book is a guide to getting started with hip technologies today: Angular, Bootstrap, and Spring Boot. All of these frameworks are wrapped up in an easy-to-use project called JHipster.

This book shows you how to build an app with JHipster, and guides you through the plethora of tools, techniques and options you can use. Furthermore, it explains the UI and API building blocks so you understand the underpinnings of your great application.

For book updates, follow @jhipster-book on Twitter.

10+ YEARS


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

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
Comments:

Why do you want to tie your database layer into your UI layer? That really isn't smart if you want your app to be flexible.

Posted by No one on May 31, 2003 at 07:04 PM MDT #

Because I'm opening a Hibernate session in the view - as this design pattern suggests. Also, Hibernate needs to be initialized when the app starts if you want to use a JNDI connection.

Posted by Matt Raible on May 31, 2003 at 07:14 PM MDT #

Post a Comment:
  • HTML Syntax: Allowed