Name |
Hibernate Session Plugin for Struts 2 |
---|---|
Publisher |
|
License |
Open Source (ASL2) |
Version |
1.0 |
Compatibility |
Struts 2.0.9+ |
Homepage |
http://code.google.com/p/hibernatesession-plugin-for-struts2/ |
Download |
http://code.google.com/p/hibernatesession-plugin-for-struts2/downloads/list |
Overview
Hibernate Session Plugin for Struts 2 There is the best practice the use of design pattern "open session in view" for WEB applications with Hibernate.This Plugin offers a Interceptor that open a Hibernate Session, put this in the Action Value Stack and close (or not) this after Action invokation.
Features
- Interceptor for "open session in view" pattern with Hibernate
Usage
The Interceptor class is com.googlecode.s2hibernate.struts2.plugin.s2hibernatesession.HibernateSessionInterceptor.
Parameters:
- sessionFactoryClass- Project Hibernate Session Factory
Example: com.myproject.hibernate.HibernateSessionFactory?
- sessionSource - Getter in the class named in sessionFactoryClass that returns a Hibernate Sessoin
Example: session (indicates the getSessao() method) - target - Target object in Action
Examples: hibernateSession; facade.hibernateSession
- staticGetSessionMethod - Is the method named in sessionSource static?. Optional. Default true.
- closeSessionAfterInvoke - Close the Hibernate Session after Action invokation? Optional. Default true.
Example
Example 1: <package name="principal" extends="struts-default" namespace="/"> <interceptors> <interceptor name="hibernateInterceptor" class="com.googlecode.s2hibernate.struts2.plugin.s2hibernatesession.HibernateSessionInterceptor"> <param name="target">facade.session</param> <param name="sessionFactoryClass">hibernate.factory.HibernateSessionFactory</param> <param name="sessionSource">session</param> <param name="staticGetSessionMethod">true</param> <param name="closeSessionAfterInvoke">true</param> </interceptor> </interceptors> <action name="teste" class="actions.TestAction"> <interceptor-ref name="hibernateInterceptor"/> <result>/resultpage.jsp</result> </action> </package> Example 2: <package name="principal" extends="struts-default" namespace="/"> <interceptors> <interceptor name="hibernateInterceptor" class="com.googlecode.s2hibernate.struts2.plugin.s2hibernatesession.HibernateSessionInterceptor"> <param name="target">facade.session</param> <param name="sessionFactoryClass">hibernate.factory.HibernateSessionFactory</param> <param name="sessionSource">session</param> </interceptor> <interceptor-stack name="basicStackWithHibernateSession"> <interceptor-ref name="hibernateInterceptor"/> <interceptor-ref name="basicStack"/> </interceptor-stack> <interceptor-stack name="defaultStackWithHibernateSession"> <interceptor-ref name="hibernateInterceptor"/> <interceptor-ref name="defaultStack"/> </interceptor-stack> </interceptors> <action name="enterData" class="actions.TestAction"> <interceptor-ref name="basicStackWithHibernateSession"/> <result>/inputpage.jsp</result> </action> <action name="submitData" class="actions.TestAction" method="doit"> <interceptor-ref name="defaultStackWithHibernateSession"/> <result>/resultpage.jsp</result> </action> </package>
Installation
This plugin can be installed by copying the plugin jar into your application's /WEB-INF/lib
directory. No other files need to be copied or created.
Version History
Version |
Date |
Author |
Notes |
---|---|---|---|
1.0 |
Oct 08, 2008 |
Initial release |