Spring & Custom Engine

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Spring & Custom Engine

Gregg D Bolinger
I am integrating Spring into my Test Tapestry app and I am using the guide
in Spring in Action to do so. The snag I have is that the RequestContext has
been depricated in 4.0.Looking at the Tapestry docs for 4.0 I am wondering
if the method Spring In Action suggests is the best method anymore. Below is
the custom engine class they suggest creating.

public class SpringTapestryEngine extends BaseEngine {
private static final String SPRING_CONTEXT_KEY = "springContext";
protected void setupForRequest(RequestContext context) {
super.setupForRequest(context);
Map global = (Map) getGlobal();
ApplicationContext appContext =
(ApplicationContext)global.get(SPRING_CONTEXT_KEY);
if (appContext == null) {
ServletContext servletContext = context.getServlet().getServletContext();
appContext = WebApplicationContextUtils.getWebApplicationContext
(servletContext);
global.put(SPRING_CONTEXT_KEY, appContext);
}
}
}

I am wondering if it might be better to do something similar but as an ASO.
If so, could someone guide me on setting up the hivemodule and getting this
to work? I'd really appreciate it.

Thanks.

Gregg Bolinger
Reply | Threaded
Open this post in threaded view
|

Re: Spring & Custom Engine

Gregg D Bolinger
Ok, so what I've done temorarily is created a singleton class to load my
applicationContext.xml file via the classpath. I don't like doing it this
way because it seems managed outside of the container. I'd like the Tapestry
system to manage it for me.

FYI - I am using Spring for DAO stuff using iBatis.

Gregg

On 5/10/05, Gregg D Bolinger <[hidden email]> wrote:

>
> I am integrating Spring into my Test Tapestry app and I am using the guide
> in Spring in Action to do so. The snag I have is that the RequestContext has
> been depricated in 4.0.Looking at the Tapestry docs for 4.0 I am wondering
> if the method Spring In Action suggests is the best method anymore. Below is
> the custom engine class they suggest creating.
>
> public class SpringTapestryEngine extends BaseEngine {
> private static final String SPRING_CONTEXT_KEY = "springContext";
> protected void setupForRequest(RequestContext context) {
> super.setupForRequest(context);
> Map global = (Map) getGlobal();
> ApplicationContext appContext =
> (ApplicationContext)global.get(SPRING_CONTEXT_KEY);
> if (appContext == null) {
> ServletContext servletContext = context.getServlet().getServletContext();
> appContext = WebApplicationContextUtils.getWebApplicationContext
> (servletContext);
> global.put(SPRING_CONTEXT_KEY, appContext);
> }
> }
> }
>
> I am wondering if it might be better to do something similar but as an
> ASO. If so, could someone guide me on setting up the hivemodule and getting
> this to work? I'd really appreciate it.
>
> Thanks.
>
> Gregg Bolinger
>
Reply | Threaded
Open this post in threaded view
|

RE: Spring & Custom Engine

Nanda Firdausi
In reply to this post by Gregg D Bolinger
I don't know whether this is suitable or not, but have you seen:
http://wiki.apache.org/jakarta-tapestry/Tapestry31Spring?

--

> -----Original Message-----
> From: Gregg D Bolinger [mailto:[hidden email]]
> Sent: 11 Mei 2005 6:18
> To: Tapestry users
> Subject: Spring & Custom Engine
>
> I am integrating Spring into my Test Tapestry app and I am
> using the guide in Spring in Action to do so. The snag I have
> is that the RequestContext has been depricated in 4.0.Looking
> at the Tapestry docs for 4.0 I am wondering if the method
> Spring In Action suggests is the best method anymore. Below
> is the custom engine class they suggest creating.
>
> public class SpringTapestryEngine extends BaseEngine {
> private static final String SPRING_CONTEXT_KEY =
> "springContext"; protected void
> setupForRequest(RequestContext context) {
> super.setupForRequest(context); Map global = (Map)
> getGlobal(); ApplicationContext appContext =
> (ApplicationContext)global.get(SPRING_CONTEXT_KEY);
> if (appContext == null) {
> ServletContext servletContext =
> context.getServlet().getServletContext();
> appContext = WebApplicationContextUtils.getWebApplicationContext
> (servletContext);
> global.put(SPRING_CONTEXT_KEY, appContext); } } }
>
> I am wondering if it might be better to do something similar
> but as an ASO.
> If so, could someone guide me on setting up the hivemodule
> and getting this to work? I'd really appreciate it.
>
> Thanks.
>
> Gregg Bolinger
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Fwd: Spring & Custom Engine

Gregg D Bolinger
Ok, so I have followed the tutorial and everything seems to be loading up
correclty. So now my question is this. I have a UserService that uses my
UserDAO to login a user to the system. How in my java code to gain access to
the WebApplicationContext that I loaded up in hivemodule using the 2 classes
in the tutorial?

Thanks.

Gregg

On 5/11/05, Gregg D Bolinger <[hidden email]> wrote:

>
> Thanks. I didn't see that. I'll take a look and see if it works out for
> me.
>
> Gregg
>
> On 5/11/05, Nanda Firdausi < [hidden email]> wrote:
> >
> > I don't know whether this is suitable or not, but have you seen:
> > http://wiki.apache.org/jakarta-tapestry/Tapestry31Spring ?
> >
> > --
> >
> > > -----Original Message-----
> > > From: Gregg D Bolinger [mailto:[hidden email]]
> > > Sent: 11 Mei 2005 6:18
> > > To: Tapestry users
> > > Subject: Spring & Custom Engine
> > >
> > > I am integrating Spring into my Test Tapestry app and I am
> > > using the guide in Spring in Action to do so. The snag I have
> > > is that the RequestContext has been depricated in 4.0.Looking
> > > at the Tapestry docs for 4.0 I am wondering if the method
> > > Spring In Action suggests is the best method anymore. Below
> > > is the custom engine class they suggest creating.
> > >
> > > public class SpringTapestryEngine extends BaseEngine {
> > > private static final String SPRING_CONTEXT_KEY =
> > > "springContext"; protected void
> > > setupForRequest(RequestContext context) {
> > > super.setupForRequest(context); Map global = (Map)
> > > getGlobal(); ApplicationContext appContext =
> > > (ApplicationContext)global.get(SPRING_CONTEXT_KEY);
> > > if (appContext == null) {
> > > ServletContext servletContext =
> > > context.getServlet().getServletContext();
> > > appContext = WebApplicationContextUtils.getWebApplicationContext
> > > (servletContext);
> > > global.put(SPRING_CONTEXT_KEY, appContext); } } }
> > >
> > > I am wondering if it might be better to do something similar
> > > but as an ASO.
> > > If so, could someone guide me on setting up the hivemodule
> > > and getting this to work? I'd really appreciate it.
> > >
> > > Thanks.
> > >
> > > Gregg Bolinger
> > >
> >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Spring & Custom Engine

Gregg D Bolinger
Ok, here is an update. I implemented all the files in the following guide:

http://wiki.apache.org/jakarta-tapestry/Tapestry31Spring?

I defined a bean in Spring like this:

<bean id="userService" class="
org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
 <property name="transactionManager">
 <ref bean="transactionManager"/>
 </property>
 <property name="target">
 <ref bean="userServiceTarget"/>
 </property>
 <property name="transactionAttributes">
 <props>
 <prop key="getUser">PROPAGATION_REQUIRED</prop>
 </props>
 </property>
 </bean>

I then injected that into my .page file like so:

<inject property="userService" object="spring:userService"/>

And in my java file I have the following:

public abstract UserService getUserService();
...
...
UserService userService = getUserService();

And then when I access this page, I get the following:

java.lang.StackOverflowError
        $SpringBeanFactoryHolder_103cc922e69.getBeanFactory($SpringBeanFactoryHolder_103cc922e69.java)
        $BeanFactory_103cc922e6b._targetServiceProperty($BeanFactory_103cc922e6b.java)
        $BeanFactory_103cc922e6b.getBean($BeanFactory_103cc922e6b.java)
        $BeanFactory_103cc922e67.getBean($BeanFactory_103cc922e67.java)
        $BeanFactory_103cc922e6b.getBean($BeanFactory_103cc922e6b.java)
        $BeanFactory_103cc922e67.getBean($BeanFactory_103cc922e67.java)
        $BeanFactory_103cc922e6b.getBean($BeanFactory_103cc922e6b.java)
        $BeanFactory_103cc922e67.getBean($BeanFactory_103cc922e67.java)

Any ideas?

Gregg Bolinger

On 5/11/05, Gregg D Bolinger <[hidden email]> wrote:

>
>
> Ok, so I have followed the tutorial and everything seems to be loading up
> correclty. So now my question is this. I have a UserService that uses my
> UserDAO to login a user to the system. How in my java code to gain access to
> the WebApplicationContext that I loaded up in hivemodule using the 2 classes
> in the tutorial?
>
> Thanks.
>
> Gregg
>
> On 5/11/05, Gregg D Bolinger < [hidden email]> wrote:
> >
> > Thanks. I didn't see that. I'll take a look and see if it works out for
> > me.
> >
> > Gregg
> >
> > On 5/11/05, Nanda Firdausi < [hidden email]> wrote:
> > >
> > > I don't know whether this is suitable or not, but have you seen:
> > > http://wiki.apache.org/jakarta-tapestry/Tapestry31Spring ?
> > >
> > > --
> > >
> > > > -----Original Message-----
> > > > From: Gregg D Bolinger [mailto:[hidden email]]
> > > > Sent: 11 Mei 2005 6:18
> > > > To: Tapestry users
> > > > Subject: Spring & Custom Engine
> > > >
> > > > I am integrating Spring into my Test Tapestry app and I am
> > > > using the guide in Spring in Action to do so. The snag I have
> > > > is that the RequestContext has been depricated in 4.0.Looking
> > > > at the Tapestry docs for 4.0 I am wondering if the method
> > > > Spring In Action suggests is the best method anymore. Below
> > > > is the custom engine class they suggest creating.
> > > >
> > > > public class SpringTapestryEngine extends BaseEngine {
> > > > private static final String SPRING_CONTEXT_KEY =
> > > > "springContext"; protected void
> > > > setupForRequest(RequestContext context) {
> > > > super.setupForRequest(context); Map global = (Map)
> > > > getGlobal(); ApplicationContext appContext =
> > > > (ApplicationContext)global.get(SPRING_CONTEXT_KEY);
> > > > if (appContext == null) {
> > > > ServletContext servletContext =
> > > > context.getServlet().getServletContext();
> > > > appContext = WebApplicationContextUtils.getWebApplicationContext
> > > > (servletContext);
> > > > global.put(SPRING_CONTEXT_KEY, appContext); } } }
> > > >
> > > > I am wondering if it might be better to do something similar
> > > > but as an ASO.
> > > > If so, could someone guide me on setting up the hivemodule
> > > > and getting this to work? I'd really appreciate it.
> > > >
> > > > Thanks.
> > > >
> > > > Gregg Bolinger
> > > >
> > >
> > >
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Spring & Custom Engine

Gregg D Bolinger
Anyone have any input on this? I haven't been able to get this figured out.

Gregg

On 5/11/05, Gregg D Bolinger <[hidden email]> wrote:

>
> Ok, here is an update. I implemented all the files in the following guide:
>
> http://wiki.apache.org/jakarta-tapestry/Tapestry31Spring?
>
> I defined a bean in Spring like this:
>
> <bean id="userService" class="
> org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
>  <property name="transactionManager">
>  <ref bean="transactionManager"/>
>  </property>
>  <property name="target">
>  <ref bean="userServiceTarget"/>
>  </property>
>  <property name="transactionAttributes">
>  <props>
>  <prop key="getUser">PROPAGATION_REQUIRED</prop>
>  </props>
>  </property>
>  </bean>
>
> I then injected that into my .page file like so:
>
> <inject property="userService" object="spring:userService"/>
>
> And in my java file I have the following:
>
> public abstract UserService getUserService();
> ...
> ...
> UserService userService = getUserService();
>
> And then when I access this page, I get the following:
>
> java.lang.StackOverflowError
> $SpringBeanFactoryHolder_103cc922e69.getBeanFactory($SpringBeanFactoryHolder_103cc922e69.java)
> $BeanFactory_103cc922e6b._targetServiceProperty($BeanFactory_103cc922e6b.java)
>
> $BeanFactory_103cc922e6b.getBean($BeanFactory_103cc922e6b.java)
> $BeanFactory_103cc922e67.getBean($BeanFactory_103cc922e67.java)
> $BeanFactory_103cc922e6b.getBean($BeanFactory_103cc922e6b.java)
> $BeanFactory_103cc922e67.getBean($BeanFactory_103cc922e67.java)
>
> $BeanFactory_103cc922e6b.getBean($BeanFactory_103cc922e6b.java)
> $BeanFactory_103cc922e67.getBean($BeanFactory_103cc922e67.java)
>
> Any ideas?
>
> Gregg Bolinger
>
> On 5/11/05, Gregg D Bolinger <[hidden email]> wrote:
> >
> >
> > Ok, so I have followed the tutorial and everything seems to be loading
> > up correclty. So now my question is this. I have a UserService that uses my
> > UserDAO to login a user to the system. How in my java code to gain access to
> > the WebApplicationContext that I loaded up in hivemodule using the 2 classes
> > in the tutorial?
> >
> > Thanks.
> >
> > Gregg
> >
> > On 5/11/05, Gregg D Bolinger < [hidden email]> wrote:
> > >
> > > Thanks. I didn't see that. I'll take a look and see if it works out
> > > for me.
> > >
> > > Gregg
> > >
> > > On 5/11/05, Nanda Firdausi < [hidden email]> wrote:
> > > >
> > > > I don't know whether this is suitable or not, but have you seen:
> > > > http://wiki.apache.org/jakarta-tapestry/Tapestry31Spring ?
> > > >
> > > > --
> > > >
> > > > > -----Original Message-----
> > > > > From: Gregg D Bolinger [mailto:[hidden email]]
> > > > > Sent: 11 Mei 2005 6:18
> > > > > To: Tapestry users
> > > > > Subject: Spring & Custom Engine
> > > > >
> > > > > I am integrating Spring into my Test Tapestry app and I am
> > > > > using the guide in Spring in Action to do so. The snag I have
> > > > > is that the RequestContext has been depricated in 4.0.Looking
> > > > > at the Tapestry docs for 4.0 I am wondering if the method
> > > > > Spring In Action suggests is the best method anymore. Below
> > > > > is the custom engine class they suggest creating.
> > > > >
> > > > > public class SpringTapestryEngine extends BaseEngine {
> > > > > private static final String SPRING_CONTEXT_KEY =
> > > > > "springContext"; protected void
> > > > > setupForRequest(RequestContext context) {
> > > > > super.setupForRequest(context); Map global = (Map)
> > > > > getGlobal(); ApplicationContext appContext =
> > > > > (ApplicationContext)global.get(SPRING_CONTEXT_KEY);
> > > > > if (appContext == null) {
> > > > > ServletContext servletContext =
> > > > > context.getServlet().getServletContext();
> > > > > appContext = WebApplicationContextUtils.getWebApplicationContext
> > > > > (servletContext);
> > > > > global.put(SPRING_CONTEXT_KEY, appContext); } } }
> > > > >
> > > > > I am wondering if it might be better to do something similar
> > > > > but as an ASO.
> > > > > If so, could someone guide me on setting up the hivemodule
> > > > > and getting this to work? I'd really appreciate it.
> > > > >
> > > > > Thanks.
> > > > >
> > > > > Gregg Bolinger
> > > > >
> > > >
> > > >
> > >
> >  
>
Reply | Threaded
Open this post in threaded view
|

Re: Spring & Custom Engine

Pablo Ruggia
In reply to this post by Gregg D Bolinger
On 5/11/05, Gregg D Bolinger <[hidden email]> wrote:
> Ok, so I have followed the tutorial and everything seems to be loading up
> correclty. So now my question is this. I have a UserService that uses my
> UserDAO to login a user to the system. How in my java code to gain access to
> the WebApplicationContext that I loaded up in hivemodule using the 2 classes
> in the tutorial?

Why don't you define a bean in your context that implements the
ApplicationContextAware interface ? When context is loaded, it will
call setApplicationContext on this bean. You can maka a static
property in this Bean and access it wherever in your application.
I've been doing this on tapestry 3.0 and it works pretty nice.


>
> Thanks.
>
> Gregg
>
> On 5/11/05, Gregg D Bolinger <[hidden email]> wrote:
> >
> > Thanks. I didn't see that. I'll take a look and see if it works out for
> > me.
> >
> > Gregg
> >
> > On 5/11/05, Nanda Firdausi < [hidden email]> wrote:
> > >
> > > I don't know whether this is suitable or not, but have you seen:
> > > http://wiki.apache.org/jakarta-tapestry/Tapestry31Spring ?
> > >
> > > --
> > >
> > > > -----Original Message-----
> > > > From: Gregg D Bolinger [mailto:[hidden email]]
> > > > Sent: 11 Mei 2005 6:18
> > > > To: Tapestry users
> > > > Subject: Spring & Custom Engine
> > > >
> > > > I am integrating Spring into my Test Tapestry app and I am
> > > > using the guide in Spring in Action to do so. The snag I have
> > > > is that the RequestContext has been depricated in 4.0.Looking
> > > > at the Tapestry docs for 4.0 I am wondering if the method
> > > > Spring In Action suggests is the best method anymore. Below
> > > > is the custom engine class they suggest creating.
> > > >
> > > > public class SpringTapestryEngine extends BaseEngine {
> > > > private static final String SPRING_CONTEXT_KEY =
> > > > "springContext"; protected void
> > > > setupForRequest(RequestContext context) {
> > > > super.setupForRequest(context); Map global = (Map)
> > > > getGlobal(); ApplicationContext appContext =
> > > > (ApplicationContext)global.get(SPRING_CONTEXT_KEY);
> > > > if (appContext == null) {
> > > > ServletContext servletContext =
> > > > context.getServlet().getServletContext();
> > > > appContext = WebApplicationContextUtils.getWebApplicationContext
> > > > (servletContext);
> > > > global.put(SPRING_CONTEXT_KEY, appContext); } } }
> > > >
> > > > I am wondering if it might be better to do something similar
> > > > but as an ASO.
> > > > If so, could someone guide me on setting up the hivemodule
> > > > and getting this to work? I'd really appreciate it.
> > > >
> > > > Thanks.
> > > >
> > > > Gregg Bolinger
> > > >
> > >
> > >
> >
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]