You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by panpan <xi...@yahoo.com> on 2007/07/09 17:23:54 UTC

[S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

I'm new to Spring and Struts2 and currently working on an existing
project(Spring 1.2.8+ struts+hibernate 3) which is upgrading to struts2.
Need to add OpenViewInSessionInterceptor to the project to enalbe the lazy
loaing in the presentation layor. I've searched the forum and didn't get the
answer.

I would appreciate any inputs.

-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11503872
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by panpan <xi...@yahoo.com>.
Thank you very much Tony. I'll try to write my own interceptor.



Toni Lyytikäinen wrote:
> 
> I took a look at that, but it's not actually written for Struts but for
> WebWork 2.x and the AroundInterceptor class it extends is not included in
> Struts 2. I don't know what that page is doing in Struts documentation,
> since it won't even compile with vanilla Struts 2.
> 
> On 7/9/07, panpan <xi...@yahoo.com> wrote:
>>
>>
>> Thank you a lot! Toni. That answer cleared my question.
>>
>> Have you noticed there is Non-IoC version of OpenSessionInViewInterceptor
>> in
>> the Apache Struts 2 Documents. Please click the below link:
>>
>>
>> http://struts.apache.org/2.x/docs/non-ioc-version-of-opensessioninviewinterceptor.html
>>
>> I don't know if this one work?
>>
>>
>>
>> Toni Lyytikäinen wrote:
>> >
>> > Sorry, I must have read the post too quickly and assumed you were
>> talking
>> > about the filter, because I haven't really seen a working OSIV
>> interceptor
>> > for Struts 2. If you want to use an interceptor, you'll probably have
>> to
>> > write one yourself for Struts 2. I don't think the one in Spring can be
>> > configured to work with the interceptor stack in Struts 2 because it's
>> so
>> > heavily tied to Spring interfaces and concepts.
>> >
>> > On 7/9/07, panpan <xi...@yahoo.com> wrote:
>> >>
>> >>
>> >> Thank you Toni for your example.
>> >> I'm just wondering about the OpenViewInSessionInterceptor. Don't know
>> how
>> >> to
>> >> configure it in struts2.
>> >>
>> >> Thanks again!
>> >>
>> >>
>> >>
>> >> Toni Lyytikäinen wrote:
>> >> >
>> >> > I can't really say about Spring 1.2.8 because I've only ever used
>> 2.0
>> ,
>> >> but
>> >> > here's what I did:
>> >> >
>> >> > in web.xml:
>> >> >
>> >> > <web-app>
>> >> > <filter>
>> >> >   <filter-name>OSIVFilter</filter-name>
>> >> >   <filter-class>
>> >> > org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
>> >> > </filter-class>
>> >> > </filter>
>> >> > ...
>> >> > <filter-mapping>
>> >> >   <filter-name>OSIVFilter</filter-name>
>> >> >   <url-pattern>/*</url-pattern>
>> >> > </filter-mapping>
>> >> > <filter-mapping>
>> >> >   <filter-name>struts2</filter-name>
>> >> >   <url-pattern>/*</url-pattern>
>> >> > </filter-mapping>
>> >> > <listener>
>> >> >   <listener-class>
>> org.springframework.web.context.ContextLoaderListener
>> >> > </listener-class>
>> >> > </listener>
>> >> > <context-param>
>> >> >   <param-name>contextConfigLocation</param-name>
>> >> >   <param-value>/WEB-INF/applicationContext*.xml</param-value>
>> >> > </context-param>
>> >> > ..
>> >> > </web-app>
>> >> >
>> >> > Of course you also need to have your (Hibernate) SessionFactory set
>> in
>> >> > Spring's applicationContext-file.
>> >> >
>> >> >
>> >> > On 7/9/07, panpan <xi...@yahoo.com> wrote:
>> >> >>
>> >> >>
>> >> >> I'm new to Spring and Struts2 and currently working on an existing
>> >> >> project(Spring 1.2.8+ struts+hibernate 3) which is upgrading to
>> >> struts2.
>> >> >> Need to add OpenViewInSessionInterceptor to the project to enalbe
>> the
>> >> >> lazy
>> >> >> loaing in the presentation layor. I've searched the forum and
>> didn't
>> >> get
>> >> >> the
>> >> >> answer.
>> >> >>
>> >> >> I would appreciate any inputs.
>> >> >>
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11503872
>> >> >> Sent from the Struts - User mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >>
>> ---------------------------------------------------------------------
>> >> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> >> For additional commands, e-mail: user-help@struts.apache.org
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11504395
>> >> Sent from the Struts - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11505610
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11506423
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by Toni Lyytikäinen <to...@gmail.com>.
I took a look at that, but it's not actually written for Struts but for
WebWork 2.x and the AroundInterceptor class it extends is not included in
Struts 2. I don't know what that page is doing in Struts documentation,
since it won't even compile with vanilla Struts 2.

On 7/9/07, panpan <xi...@yahoo.com> wrote:
>
>
> Thank you a lot! Toni. That answer cleared my question.
>
> Have you noticed there is Non-IoC version of OpenSessionInViewInterceptor
> in
> the Apache Struts 2 Documents. Please click the below link:
>
>
> http://struts.apache.org/2.x/docs/non-ioc-version-of-opensessioninviewinterceptor.html
>
> I don't know if this one work?
>
>
>
> Toni Lyytikäinen wrote:
> >
> > Sorry, I must have read the post too quickly and assumed you were
> talking
> > about the filter, because I haven't really seen a working OSIV
> interceptor
> > for Struts 2. If you want to use an interceptor, you'll probably have to
> > write one yourself for Struts 2. I don't think the one in Spring can be
> > configured to work with the interceptor stack in Struts 2 because it's
> so
> > heavily tied to Spring interfaces and concepts.
> >
> > On 7/9/07, panpan <xi...@yahoo.com> wrote:
> >>
> >>
> >> Thank you Toni for your example.
> >> I'm just wondering about the OpenViewInSessionInterceptor. Don't know
> how
> >> to
> >> configure it in struts2.
> >>
> >> Thanks again!
> >>
> >>
> >>
> >> Toni Lyytikäinen wrote:
> >> >
> >> > I can't really say about Spring 1.2.8 because I've only ever used 2.0
> ,
> >> but
> >> > here's what I did:
> >> >
> >> > in web.xml:
> >> >
> >> > <web-app>
> >> > <filter>
> >> >   <filter-name>OSIVFilter</filter-name>
> >> >   <filter-class>
> >> > org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
> >> > </filter-class>
> >> > </filter>
> >> > ...
> >> > <filter-mapping>
> >> >   <filter-name>OSIVFilter</filter-name>
> >> >   <url-pattern>/*</url-pattern>
> >> > </filter-mapping>
> >> > <filter-mapping>
> >> >   <filter-name>struts2</filter-name>
> >> >   <url-pattern>/*</url-pattern>
> >> > </filter-mapping>
> >> > <listener>
> >> >   <listener-class>
> org.springframework.web.context.ContextLoaderListener
> >> > </listener-class>
> >> > </listener>
> >> > <context-param>
> >> >   <param-name>contextConfigLocation</param-name>
> >> >   <param-value>/WEB-INF/applicationContext*.xml</param-value>
> >> > </context-param>
> >> > ..
> >> > </web-app>
> >> >
> >> > Of course you also need to have your (Hibernate) SessionFactory set
> in
> >> > Spring's applicationContext-file.
> >> >
> >> >
> >> > On 7/9/07, panpan <xi...@yahoo.com> wrote:
> >> >>
> >> >>
> >> >> I'm new to Spring and Struts2 and currently working on an existing
> >> >> project(Spring 1.2.8+ struts+hibernate 3) which is upgrading to
> >> struts2.
> >> >> Need to add OpenViewInSessionInterceptor to the project to enalbe
> the
> >> >> lazy
> >> >> loaing in the presentation layor. I've searched the forum and didn't
> >> get
> >> >> the
> >> >> answer.
> >> >>
> >> >> I would appreciate any inputs.
> >> >>
> >> >> --
> >> >> View this message in context:
> >> >>
> >>
> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11503872
> >> >> Sent from the Struts - User mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >>
> ---------------------------------------------------------------------
> >> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> >> For additional commands, e-mail: user-help@struts.apache.org
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11504395
> >> Sent from the Struts - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11505610
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by panpan <xi...@yahoo.com>.
Thank you a lot! Toni. That answer cleared my question.

Have you noticed there is Non-IoC version of OpenSessionInViewInterceptor in
the Apache Struts 2 Documents. Please click the below link:

http://struts.apache.org/2.x/docs/non-ioc-version-of-opensessioninviewinterceptor.html

I don't know if this one work?



Toni Lyytikäinen wrote:
> 
> Sorry, I must have read the post too quickly and assumed you were talking
> about the filter, because I haven't really seen a working OSIV interceptor
> for Struts 2. If you want to use an interceptor, you'll probably have to
> write one yourself for Struts 2. I don't think the one in Spring can be
> configured to work with the interceptor stack in Struts 2 because it's so
> heavily tied to Spring interfaces and concepts.
> 
> On 7/9/07, panpan <xi...@yahoo.com> wrote:
>>
>>
>> Thank you Toni for your example.
>> I'm just wondering about the OpenViewInSessionInterceptor. Don't know how
>> to
>> configure it in struts2.
>>
>> Thanks again!
>>
>>
>>
>> Toni Lyytikäinen wrote:
>> >
>> > I can't really say about Spring 1.2.8 because I've only ever used 2.0,
>> but
>> > here's what I did:
>> >
>> > in web.xml:
>> >
>> > <web-app>
>> > <filter>
>> >   <filter-name>OSIVFilter</filter-name>
>> >   <filter-class>
>> > org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
>> > </filter-class>
>> > </filter>
>> > ...
>> > <filter-mapping>
>> >   <filter-name>OSIVFilter</filter-name>
>> >   <url-pattern>/*</url-pattern>
>> > </filter-mapping>
>> > <filter-mapping>
>> >   <filter-name>struts2</filter-name>
>> >   <url-pattern>/*</url-pattern>
>> > </filter-mapping>
>> > <listener>
>> >   <listener-class>org.springframework.web.context.ContextLoaderListener
>> > </listener-class>
>> > </listener>
>> > <context-param>
>> >   <param-name>contextConfigLocation</param-name>
>> >   <param-value>/WEB-INF/applicationContext*.xml</param-value>
>> > </context-param>
>> > ..
>> > </web-app>
>> >
>> > Of course you also need to have your (Hibernate) SessionFactory set in
>> > Spring's applicationContext-file.
>> >
>> >
>> > On 7/9/07, panpan <xi...@yahoo.com> wrote:
>> >>
>> >>
>> >> I'm new to Spring and Struts2 and currently working on an existing
>> >> project(Spring 1.2.8+ struts+hibernate 3) which is upgrading to
>> struts2.
>> >> Need to add OpenViewInSessionInterceptor to the project to enalbe the
>> >> lazy
>> >> loaing in the presentation layor. I've searched the forum and didn't
>> get
>> >> the
>> >> answer.
>> >>
>> >> I would appreciate any inputs.
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11503872
>> >> Sent from the Struts - User mailing list archive at Nabble.com.
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> >> For additional commands, e-mail: user-help@struts.apache.org
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11504395
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11505610
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by Toni Lyytikäinen <to...@gmail.com>.
Sorry, I must have read the post too quickly and assumed you were talking
about the filter, because I haven't really seen a working OSIV interceptor
for Struts 2. If you want to use an interceptor, you'll probably have to
write one yourself for Struts 2. I don't think the one in Spring can be
configured to work with the interceptor stack in Struts 2 because it's so
heavily tied to Spring interfaces and concepts.

On 7/9/07, panpan <xi...@yahoo.com> wrote:
>
>
> Thank you Toni for your example.
> I'm just wondering about the OpenViewInSessionInterceptor. Don't know how
> to
> configure it in struts2.
>
> Thanks again!
>
>
>
> Toni Lyytikäinen wrote:
> >
> > I can't really say about Spring 1.2.8 because I've only ever used 2.0,
> but
> > here's what I did:
> >
> > in web.xml:
> >
> > <web-app>
> > <filter>
> >   <filter-name>OSIVFilter</filter-name>
> >   <filter-class>
> > org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
> > </filter-class>
> > </filter>
> > ...
> > <filter-mapping>
> >   <filter-name>OSIVFilter</filter-name>
> >   <url-pattern>/*</url-pattern>
> > </filter-mapping>
> > <filter-mapping>
> >   <filter-name>struts2</filter-name>
> >   <url-pattern>/*</url-pattern>
> > </filter-mapping>
> > <listener>
> >   <listener-class>org.springframework.web.context.ContextLoaderListener
> > </listener-class>
> > </listener>
> > <context-param>
> >   <param-name>contextConfigLocation</param-name>
> >   <param-value>/WEB-INF/applicationContext*.xml</param-value>
> > </context-param>
> > ..
> > </web-app>
> >
> > Of course you also need to have your (Hibernate) SessionFactory set in
> > Spring's applicationContext-file.
> >
> >
> > On 7/9/07, panpan <xi...@yahoo.com> wrote:
> >>
> >>
> >> I'm new to Spring and Struts2 and currently working on an existing
> >> project(Spring 1.2.8+ struts+hibernate 3) which is upgrading to
> struts2.
> >> Need to add OpenViewInSessionInterceptor to the project to enalbe the
> >> lazy
> >> loaing in the presentation layor. I've searched the forum and didn't
> get
> >> the
> >> answer.
> >>
> >> I would appreciate any inputs.
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11503872
> >> Sent from the Struts - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11504395
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by panpan <xi...@yahoo.com>.
That's great! I got pretty clear pictures now. Thanks again cilquirm.


cilquirm wrote:
> 
> 
> 
> panpan wrote:
>> 
>> The session is open, why do I need to reattach them?
>> 
> 
> You wouldn't need to if you loaded and discarded your objects in a single
> request, but let's say you have objects that lived around longer than a
> single request ( i.e., a User object in your http session ).   You might
> have  reattached this object to the session every time you wanted to make
> a modification to it, because you were creating hibernate sessions on the
> fly.  With OSFV,  you might end up with errors because after the first
> time, the object is already attached to the session.  
> 
> That's probably the most common use case.
> 
> 
> panpan wrote:
>> 
>>  And could you please be more specific about the 'watch transaction
>> boundaries'. Sorry, that might be stupid questions.
>> 
> 
> What i meant by watch transaction boundaries is simply take note where and
> how you decide to mark off a transaction.  For example, if you weren't
> using Spring's declarative ( or aop-based ) transaction management, you
> might have a session.beginTransaction() in one method, and a
> session.endTransation() in another method.  If you were creating hib
> sessions on the fly, if you rolled back, you can simply wipe out your
> session and create a new one and go on your (relatively) merry way.  With
> OSFV, that session that you rolled back against is still there, so maybe
> your objects that you haven't persisted are not in the db, but still
> associated with a session.    The same thing can obviously occur with
> Spring's transaction management as well, but at the heart of it, I meant
> that's something to keep in mind.
> 
> 
> 
> panpan wrote:
>> 
>> Really appreciate your help and time.
>> 
> 
> Always a pleasure.
> 
> -a
> 

-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11508705
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by cilquirm <aa...@gmail.com>.


panpan wrote:
> 
> The session is open, why do I need to reattach them?
> 

You wouldn't need to if you loaded and discarded your objects in a single
request, but let's say you have objects that lived around longer than a
single request ( i.e., a User object in your http session ).   You might
have  reattached this object to the session every time you wanted to make a
modification to it, because you were creating hibernate sessions on the fly. 
With OSFV,  you might end up with errors because after the first time, the
object is already attached to the session.  

That's probably the most common use case.


panpan wrote:
> 
>  And could you please be more specific about the 'watch transaction
> boundaries'. Sorry, that might be stupid questions.
> 

What i meant by watch transaction boundaries is simply take note where and
how you decide to mark off a transaction.  For example, if you weren't using
Spring's declarative ( or aop-based ) transaction management, you might have
a session.beginTransaction() in one method, and a session.endTransation() in
another method.  If you were creating hib sessions on the fly, if you rolled
back, you can simply wipe out your session and create a new one and go on
your (relatively) merry way.  With OSFV, that session that you rolled back
against is still there, so maybe your objects that you haven't persisted are
not in the db, but still associated with a session.    The same thing can
obviously occur with Spring's transaction management as well, but at the
heart of it, I meant that's something to keep in mind.



panpan wrote:
> 
> Really appreciate your help and time.
> 

Always a pleasure.

-a
-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11508627
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by panpan <xi...@yahoo.com>.
Cilquirm. That's really helpful! Thans a lot!

I can understand the most part your post and I still have question for the
last sentense.

"For those that you do, reattach them early on, and watch your transaction
boundaries. "

The session is open, why do I need to reattach them? And could you please be
more specific about the 'watch transaction boundaries'. Sorry, that might be
stupid questions.

Really appreciate your help and time.





cilquirm wrote:
> 
> Assuming your S2 actions are 'pathed' differently ( i.e. s2 actions are
> mapped to .action , while s1 actions are mapped to .do ), then specifying
> the url pattern only for s2 actions ( /*.action ) will have the intended
> effect.
> 
> As far as side effects go, it's really dependent on your application.  The
> ones they mention on the docs relate to  moving an application that hasn't
> been using open session in view to that pattern.  You may have objects
> that you keep around for a long time ( i.e.  in a  http session ), which
> you then reattach to the session when you want to do do work against it. 
> When you have ad-hoc session management, you might have gotten away with
> reattaching/detaching/flushing/updating whenever you feel like it because
> you're creating a new hib session whenever you need to..  
> 
> With OSFV, since the session is already created upon request, you may end
> up with a couple exceptions because the session is always there and those
> operations ( depending on when you do it, and in what order ) may throw
> exceptions.  
> 
> At best I can tell you, as the docs do, is to minimize the objects you
> keep around for a while.  For those that you do, reattach them early on,
> and watch your transaction boundaries.  
> 
> Ask away if you have particular questions :-)
> 
> hth,
> -a
> 
> panpan wrote:
>> 
>> Thank you cilquirm. I think i'm a little bit confused and the filter is
>> the one I needed.
>> There is one thing which is unclear to me. If I only apply the filter to
>> the new developed struts2 action, it will not affect the rest existed
>> application(struts1), right? I saw there are some side effect of using
>> the OSVF in the Spring docs. Do you have any good idea how to avoid those
>> side effects?
>> Thanks again!
>> 
>>  
>> 
>> 
>> cilquirm wrote:
>>> 
>>> I think you may be confusing Struts2 (S2) interceptors with Spring
>>> Interceptors.
>>> The two are not the same.
>>> 
>>> S2 interceptors provide some "aop-like" functionality by allowing code
>>> to modify request processing in some fashion; however it's not truly
>>> based around an aop standard ( i.e. aopallliance ) ( s2 devs, please
>>> feel free to correct and chide me. )
>>> 
>>> The OpenSessionInViewInterceptor ( OSVI ) is an analog to the
>>> OpenSessionInViewFilter (OSVF), but I belive it's primarily used for
>>> SpringMVC ( and possibly related, like Grails ).
>>> 
>>> OSVF is more generic and designed to be used in a larger number of
>>> frameworks.
>>> I believe, in this case, what you probably want is the filter.
>>> 
>>> hth,
>>> -a
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> panpan wrote:
>>>> 
>>>> Thank you Toni for your example.
>>>> I'm just wondering about the OpenViewInSessionInterceptor. Don't know
>>>> how to configure it in struts2.
>>>> 
>>>> Thanks again!
>>>> 
>>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11508283
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by cilquirm <aa...@gmail.com>.
Assuming your S2 actions are 'pathed' differently ( i.e. s2 actions are
mapped to .action , while s1 actions are mapped to .do ), then specifying
the url pattern only for s2 actions ( /*.action ) will have the intended
effect.

As far as side effects go, it's really dependent on your application.  The
ones they mention on the docs relate to  moving an application that hasn't
been using open session in view to that pattern.  You may have objects that
you keep around for a long time ( i.e.  in a  http session ), which you then
reattach to the session when you want to do do work against it.  When you
have ad-hoc session management, you might have gotten away with
reattaching/detaching/flushing/updating whenever you feel like it because
you're creating a new hib session whenever you need to..  

With OSFV, since the session is already created upon request, you may end up
with a couple exceptions because the session is always there and those
operations ( depending on when you do it, and in what order ) may throw
exceptions.  

At best I can tell you, as the docs do, is to minimize the objects you keep
around for a while.  For those that you do, reattach them early on, and
watch your transaction boundaries.  

Ask away if you have particular questions :-)

hth,
-a

panpan wrote:
> 
> Thank you cilquirm. I think i'm a little bit confused and the filter is
> the one I needed.
> There is one thing which is unclear to me. If I only apply the filter to
> the new developed struts2 action, it will not affect the rest existed
> application(struts1), right? I saw there are some side effect of using the
> OSVF in the Spring docs. Do you have any good idea how to avoid those side
> effects?
> Thanks again!
> 
>  
> 
> 
> cilquirm wrote:
>> 
>> I think you may be confusing Struts2 (S2) interceptors with Spring
>> Interceptors.
>> The two are not the same.
>> 
>> S2 interceptors provide some "aop-like" functionality by allowing code to
>> modify request processing in some fashion; however it's not truly based
>> around an aop standard ( i.e. aopallliance ) ( s2 devs, please feel free
>> to correct and chide me. )
>> 
>> The OpenSessionInViewInterceptor ( OSVI ) is an analog to the
>> OpenSessionInViewFilter (OSVF), but I belive it's primarily used for
>> SpringMVC ( and possibly related, like Grails ).
>> 
>> OSVF is more generic and designed to be used in a larger number of
>> frameworks.
>> I believe, in this case, what you probably want is the filter.
>> 
>> hth,
>> -a
>> 
>> 
>> 
>> 
>> 
>> 
>> panpan wrote:
>>> 
>>> Thank you Toni for your example.
>>> I'm just wondering about the OpenViewInSessionInterceptor. Don't know
>>> how to configure it in struts2.
>>> 
>>> Thanks again!
>>> 
>>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11507548
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by panpan <xi...@yahoo.com>.
Thank you cilquirm. I think i'm a little bit confused and the filter is the
one I needed.
There is one thing which is unclear to me. If I only apply the filter to the
new developed struts2 action, it will not affect the rest existed
application(struts1), right? I saw there are some side effect of using the
OSVF in the Spring docs. Do you have any good idea how to avoid those side
effects?
Thanks again!

 


cilquirm wrote:
> 
> I think you may be confusing Struts2 (S2) interceptors with Spring
> Interceptors.
> The two are not the same.
> 
> S2 interceptors provide some "aop-like" functionality by allowing code to
> modify request processing in some fashion; however it's not truly based
> around an aop standard ( i.e. aopallliance ) ( s2 devs, please feel free
> to correct and chide me. )
> 
> The OpenSessionInViewInterceptor ( OSVI ) is an analog to the
> OpenSessionInViewFilter (OSVF), but I belive it's primarily used for
> SpringMVC ( and possibly related, like Grails ).
> 
> OSVF is more generic and designed to be used in a larger number of
> frameworks.
> I believe, in this case, what you probably want is the filter.
> 
> hth,
> -a
> 
> 
> 
> 
> 
> 
> panpan wrote:
>> 
>> Thank you Toni for your example.
>> I'm just wondering about the OpenViewInSessionInterceptor. Don't know how
>> to configure it in struts2.
>> 
>> Thanks again!
>> 
>> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11507143
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by cilquirm <aa...@gmail.com>.
I think you may be confusing Struts2 (S2) interceptors with Spring
Interceptors.
The two are not the same.

S2 interceptors provide some "aop-like" functionality by allowing code to
modify request processing in some fashion; however it's not truly based
around an aop standard ( i.e. aopallliance ) ( s2 devs, please feel free to
correct and chide me. )

The OpenSessionInViewInterceptor ( OSVI ) is an analog to the
OpenSessionInViewFilter (OSVF), but I belive it's primarily used for
SpringMVC ( and possibly related, like Grails ).

OSVF is more generic and designed to be used in a larger number of
frameworks.
I believe, in this case, what you probably want is the filter.

hth,
-a






panpan wrote:
> 
> Thank you Toni for your example.
> I'm just wondering about the OpenViewInSessionInterceptor. Don't know how
> to configure it in struts2.
> 
> Thanks again!
> 
> 
-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11506464
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by panpan <xi...@yahoo.com>.
Thank you Toni for your example.
I'm just wondering about the OpenViewInSessionInterceptor. Don't know how to
configure it in struts2.

Thanks again!



Toni Lyytikäinen wrote:
> 
> I can't really say about Spring 1.2.8 because I've only ever used 2.0, but
> here's what I did:
> 
> in web.xml:
> 
> <web-app>
> <filter>
>   <filter-name>OSIVFilter</filter-name>
>   <filter-class>
> org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
> </filter-class>
> </filter>
> ...
> <filter-mapping>
>   <filter-name>OSIVFilter</filter-name>
>   <url-pattern>/*</url-pattern>
> </filter-mapping>
> <filter-mapping>
>   <filter-name>struts2</filter-name>
>   <url-pattern>/*</url-pattern>
> </filter-mapping>
> <listener>
>   <listener-class>org.springframework.web.context.ContextLoaderListener
> </listener-class>
> </listener>
> <context-param>
>   <param-name>contextConfigLocation</param-name>
>   <param-value>/WEB-INF/applicationContext*.xml</param-value>
> </context-param>
> ..
> </web-app>
> 
> Of course you also need to have your (Hibernate) SessionFactory set in
> Spring's applicationContext-file.
> 
> 
> On 7/9/07, panpan <xi...@yahoo.com> wrote:
>>
>>
>> I'm new to Spring and Struts2 and currently working on an existing
>> project(Spring 1.2.8+ struts+hibernate 3) which is upgrading to struts2.
>> Need to add OpenViewInSessionInterceptor to the project to enalbe the
>> lazy
>> loaing in the presentation layor. I've searched the forum and didn't get
>> the
>> answer.
>>
>> I would appreciate any inputs.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11503872
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11504395
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] how to configure Spring's OpenViewInSessionInterceptor for struts2

Posted by Toni Lyytikäinen <to...@gmail.com>.
I can't really say about Spring 1.2.8 because I've only ever used 2.0, but
here's what I did:

in web.xml:

<web-app>
<filter>
  <filter-name>OSIVFilter</filter-name>
  <filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
...
<filter-mapping>
  <filter-name>OSIVFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>
..
</web-app>

Of course you also need to have your (Hibernate) SessionFactory set in
Spring's applicationContext-file.


On 7/9/07, panpan <xi...@yahoo.com> wrote:
>
>
> I'm new to Spring and Struts2 and currently working on an existing
> project(Spring 1.2.8+ struts+hibernate 3) which is upgrading to struts2.
> Need to add OpenViewInSessionInterceptor to the project to enalbe the lazy
> loaing in the presentation layor. I've searched the forum and didn't get
> the
> answer.
>
> I would appreciate any inputs.
>
> --
> View this message in context:
> http://www.nabble.com/-S2--how-to-configure-Spring%27s-OpenViewInSessionInterceptor-for-struts2-tf4050042.html#a11503872
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>