You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by 3kkkdang <cv...@hotmail.com> on 2011/04/01 17:13:20 UTC

Re: Java based spring configuration

I will do this:
extends TapestrFilter,  in its constructor use WebApplicationContextUtils to
get spring context and set this context as ASO static property.  finally in
tapestry page class, get spring context through ASO.  

never got chance to try this, it might work.  any comments?

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Java-based-spring-configuration-tp3394086p4275778.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Java based spring configuration

Posted by Taha Hafeez <ta...@gmail.com>.
Hi

We are also in the final stage of migrating a wicket-spring-hibernate
application into tapestry-tapestryioc-hibernate application. We are very
happy with the new it. With Transactional, we had to create a simple module
of our own...

regards
Taha

On Mon, Apr 4, 2011 at 6:24 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Fri, 01 Apr 2011 19:35:52 -0300, Magnus Kvalheim <ma...@kvalheim.dk>
> wrote:
>
>  Why is it that the tapestry module is only for web - can't it
>> be re-factored/reconfigured so that it can be more closely integrated with
>> spring applications...
>>
>
> Tapestry-IoC is not only for web: it's absolutely independent from
> Tapestry-core (the web framework) and can be used for non-Web apps very
> well. You just need to instantiate the Registry yourself, but it's very
> easy.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Java based spring configuration

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 01 Apr 2011 19:35:52 -0300, Magnus Kvalheim <ma...@kvalheim.dk>  
wrote:

> Why is it that the tapestry module is only for web - can't it
> be re-factored/reconfigured so that it can be more closely integrated  
> with spring applications...

Tapestry-IoC is not only for web: it's absolutely independent from  
Tapestry-core (the web framework) and can be used for non-Web apps very  
well. You just need to instantiate the Registry yourself, but it's very  
easy.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Java based spring configuration

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 05 May 2011 09:43:18 -0300, Magnus Kvalheim <ma...@kvalheim.dk>  
wrote:

> Hi Thiago - thanks for your answer,

Hi! You're welcome!

> Think an implementation similar to tapestry-spring would the better
> alternative of the two.

Agreed.

> It's not completely clear to me what the difference is between an
> ObjectProvider and ObjectCreator.

ObjectProvider is used inside Tapestry to provide injection when the  
injected value is not a Tapestry-IoC service (bean).
I don't think ObjectCreator would be used in what you're trying to do, but  
I never tried something like that and I can be completely wrong. :)

> What do tapestry do with the beans after the're provided - are they  
> cached? (they seem to be cached as the provider is not called again)
> And what about scopes? Again tapestry-spring give default(singleton)  
> scope to all, but can't see getServiceScope is called while debugging.

Tapestry-Spring, as stated in  
http://tapestry.apache.org/integrating-with-spring-framework.html, just  
handles singleton scopes correctly, so I guess they're cached.

> Weld is bundled with glassfish so the BeanManager should be available  
> from jndi by the time tapestry starts up and loads the tapestry-cdi  
> module.
> (In other environments it's possible to bootstrap manually - or use the  
> weld servlet listener, org.jboss.weld.environment.servlet.Listener)

The first option I'd try would be to have Tapestry to bootstrap Weld, as  
it seems the easiest option.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Java based spring configuration

Posted by Magnus Kvalheim <ma...@kvalheim.dk>.
Hi Thiago - thanks for your answer,
See comments below...

On Wed, May 4, 2011 at 6:06 PM, Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Wed, 04 May 2011 12:51:05 -0300, Magnus Kvalheim <ma...@kvalheim.dk>
> wrote:
>
>
>>  How would I make that play with Tapestry?
>> *=Server=*
>> * Use a JEE 6 Web Profile compliant server (like Glassfish).
>> * Does anyone have experience with development? Does Tapestry live reload
>> work?
>>
>
> Live reload of Tapestry classes (pages, components and mixins) would work.
> Live reload of services (beans) wouldn't.
>

Sounds good - have yet to try development from anything other than jetty..

>
>  *=Injecting beans from CDI=*
>>
>> Following this path my beans and ejb's are now managed by CDI(Weld).
>> How would I get access to these beans in Tapestry?
>>
>
> You can hook other IoC containers (CDI, Spring, EJB, etc) into
> Tapestry-IoC, so you can use Tapestry's @Inject or JSR 330 @Inject normally
> and get these outside-provided beans as if they were T-IoC ones. JumpStart
> code does this for EJB and tapestry-spring for Spring, so you can take a
> look at them for insipiration.
>
> http://jumpstart.doublenegative.com.au/jumpstart/examples/state/ejb3
>
>
> http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-spring/src/main/java/org/apache/tapestry5/spring/TapestrySpringFilter.java?view=markup
>
> http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java?view=markup


Think an implementation similar to tapestry-spring would the better
alternative of the two.
And looking at BeanManager the implementation would not be as different than
from tapestry-spring.
http://docs.jboss.org/cdi/api/1.0/javax/enterprise/inject/spi/BeanManager.html

It's not completely clear to me what the difference is between an
ObjectProvider and ObjectCreator.
Tried debugging tapestry-spring and the cant' see the ObjectCreator is used
for SpringBeanServiceDef's at all.
Both implementations lookup beans in springs applicationcontext, but only
the ObjectProvider actually locates them.

What do tapestry do with the beans after the're provided - are they cached
? (they seem to be cached as the provider is not called again)

And what about scopes? Again tapestry-spring give default(singleton) scope
to all, but can't see getServiceScope is called while debugging.

>
>
>  I've seen long discussions on the list about tapestry and jsr 299 and 330.
>> Believe Igor has committed something for 330. Don't know if there are any
>> plans for jsr 299 though (as portable extension?).
>>
>
> I don't know of any plans, but I'd love to see it. I just don't try to do
> that myself due to lack of time . . . :(
>

Yes, have the same problem - but will try to give it a go once I get my head
around it. Not too familiar with tapestry internals though...

Weld is bundled with glassfish so the BeanManager should be available from
jndi by the time tapestry starts up and loads the tapestry-cdi module.
(In other environments it's possible to bootstrap manually - or use the weld
servlet listener, org.jboss.weld.environment.servlet.Listener)

Thoughts?

>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Java based spring configuration

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Wed, 04 May 2011 12:51:05 -0300, Magnus Kvalheim <ma...@kvalheim.dk>  
wrote:

> Hi Adam,

Hi!

> In fact at this point the main reason(s) I have for still using it is for
> it's transaction management.
> And as our apps run in a servlet container(tomcat) I've not really
> considered ejb's as an alternative.

EJB 3.1 can be run outside a JavaEE container. (at least OpenEJB can).

> How would I make that play with Tapestry?
> *=Server=*
> * Use a JEE 6 Web Profile compliant server (like Glassfish).
> * Does anyone have experience with development? Does Tapestry live reload
> work?

Live reload of Tapestry classes (pages, components and mixins) would work.
Live reload of services (beans) wouldn't.

> *=Injecting beans from CDI=*
> Following this path my beans and ejb's are now managed by CDI(Weld).
> How would I get access to these beans in Tapestry?

You can hook other IoC containers (CDI, Spring, EJB, etc) into  
Tapestry-IoC, so you can use Tapestry's @Inject or JSR 330 @Inject  
normally and get these outside-provided beans as if they were T-IoC ones.  
JumpStart code does this for EJB and tapestry-spring for Spring, so you  
can take a look at them for insipiration.

http://jumpstart.doublenegative.com.au/jumpstart/examples/state/ejb3

http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-spring/src/main/java/org/apache/tapestry5/spring/TapestrySpringFilter.java?view=markup
http://svn.apache.org/viewvc/tapestry/tapestry5/branches/maint-5-2/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java?view=markup

> I've seen long discussions on the list about tapestry and jsr 299 and  
> 330.
> Believe Igor has committed something for 330. Don't know if there are any
> plans for jsr 299 though (as portable extension?).

I don't know of any plans, but I'd love to see it. I just don't try to do  
that myself due to lack of time . . . :(

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Java based spring configuration

Posted by Magnus Kvalheim <ma...@kvalheim.dk>.
Hi Adam,

Sorry, for (very)late response. Got tied up with some other tasks and forgot
all about it...

It's not like I'm in love with Spring.
In fact at this point the main reason(s) I have for still using it is for
it's transaction management.
And as our apps run in a servlet container(tomcat) I've not really
considered ejb's as an alternative.

Your comment about ejb's got me interested and I started doing some
research.
Turns out JEE 6 Web Profile looks pretty interesting (with glassfish).

We mostly use spring for dependency injection and transaction management.
As an experiment I replaced all spring annotations with 'jee' ones.
* @Autowired->@Inject
* @Component->@Named
* @Transactional->@TransactionAttribute

Spring happily uses the annotations as long as the're on the classpath.

Then I refactored our spring java configuration to a separate module and did
all wiring from there. This is now a drop in module.
In a jee 6 server I would exclude the spring module and everything will be
wired up by CDI.

For me this is quite interesting and means I now have zero dependencies on
spring in our app modules.
All business code uses standard jee/jsr's, but spring is still used under
the hood.


I could stop here, but what if I wanted to take the final step and move to a
jee 6 compliant server.
How would I make that play with Tapestry?
*=Server=*
* Use a JEE 6 Web Profile compliant server (like Glassfish).
* Does anyone have experience with development? Does Tapestry live reload
work?

*=Injecting beans from CDI=*
Following this path my beans and ejb's are now managed by CDI(Weld).
How would I get access to these beans in Tapestry?

I've seen long discussions on the list about tapestry and jsr 299 and 330.
Believe Igor has committed something for 330. Don't know if there are any
plans for jsr 299 though (as portable extension?).


Sorry - this turned out quite lengthy, but to summarize:
How do you use tapestry in a jee server with cdi? (Or even just cdi)

cheers
Magnus

On Sat, Apr 2, 2011 at 3:44 PM, Adam Zimowski <zi...@gmail.com> wrote:

> > I need spring [...] for things like jpa support and transactions and
> other things ...
>
> I guess you're not an EJB fan :-) You don't need spring. In fact, our
> Ecom app runs on pure Tapestry+TapIOC (plus Apache commons lang) with
> EJB3 in the middle tier doing all the heavy lifting you're talking
> about (Transactions, Hibernate/JPA, Endeca, PeopleSoft, and much more)
>
> We used to heavily rely on Spring in the previous Struts-based version
> of our app, but since we've moved to Tapestry, we kissed Spring good
> bye and nobody misses it here :)
>
> Adam
>
> On Fri, Apr 1, 2011 at 5:35 PM, Magnus Kvalheim <ma...@kvalheim.dk>
> wrote:
> > Hi thanks for your reply,
> >
> > Looking back on my original mail I now realize I've been unclear...
> >
> > To clarify: What I do want to achieve is to
> > + Not rely on xml for configuration
> > + Inject spring beans into tapestry
> > (+) Injecting tapestry services into spring is desired
> >
> > Your suggestion would probably work, but it's not what I want as I's like
> to
> > use the @Inject for spring beans.
> > Sorry for the confusion...
> >
> >
> > On another note...
> >
> > Tapestry IOC is much more desirable than spring in many ways.
> > I need spring (at least I believe I do) for things like jpa support and
> > transactions and other things, but the bootstrapping in tapestry of
> modules,
> > contributions, decoration.++ is something I would like to get into 'core'
> > and not just 'web'.
> >
> > Why is it that the tapestry module is only for web - can't it
> > be re-factored/reconfigured so that it can be more closely integrated
> with
> > spring applications...
> >
> > I'd love to fully embrace tapestry IOC for my core infrastructure, but
> cant
> > see how I'd get the same functionality - especially in terms of
> transaction
> > management (I'd like to hear from those who have made the transition, and
> > how they did it).
> > Is it's possible(I believe it is) to make an enhanced tapestry-spring
> module
> > which is not only for web, but can integrate tighter with spring - I
> think
> > it would be a great win.
> > (Probably there is way to implement tapestry ioc contributions, advisors
> > etc.. for spring beans as well...)
> >
> > I'd like to hear some feedback to check if I'm completely off base here -
> or
> > if it's indeed a good idea...
> > I know I'd rather configure spring from tapestry ioc if I could...
> >
> > Thoughts?
> >
> > cheers
> > Magnus
> >
> >
> > On Fri, Apr 1, 2011 at 5:13 PM, 3kkkdang <cv...@hotmail.com> wrote:
> >
> >> I will do this:
> >> extends TapestrFilter,  in its constructor use
> WebApplicationContextUtils
> >> to
> >> get spring context and set this context as ASO static property.  finally
> in
> >> tapestry page class, get spring context through ASO.
> >>
> >> never got chance to try this, it might work.  any comments?
> >>
> >> --
> >> View this message in context:
> >>
> http://tapestry.1045711.n5.nabble.com/Java-based-spring-configuration-tp3394086p4275778.html
> >> Sent from the Tapestry - User mailing list archive at Nabble.com.
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Java based spring configuration

Posted by Adam Zimowski <zi...@gmail.com>.
> I need spring [...] for things like jpa support and transactions and other things ...

I guess you're not an EJB fan :-) You don't need spring. In fact, our
Ecom app runs on pure Tapestry+TapIOC (plus Apache commons lang) with
EJB3 in the middle tier doing all the heavy lifting you're talking
about (Transactions, Hibernate/JPA, Endeca, PeopleSoft, and much more)

We used to heavily rely on Spring in the previous Struts-based version
of our app, but since we've moved to Tapestry, we kissed Spring good
bye and nobody misses it here :)

Adam

On Fri, Apr 1, 2011 at 5:35 PM, Magnus Kvalheim <ma...@kvalheim.dk> wrote:
> Hi thanks for your reply,
>
> Looking back on my original mail I now realize I've been unclear...
>
> To clarify: What I do want to achieve is to
> + Not rely on xml for configuration
> + Inject spring beans into tapestry
> (+) Injecting tapestry services into spring is desired
>
> Your suggestion would probably work, but it's not what I want as I's like to
> use the @Inject for spring beans.
> Sorry for the confusion...
>
>
> On another note...
>
> Tapestry IOC is much more desirable than spring in many ways.
> I need spring (at least I believe I do) for things like jpa support and
> transactions and other things, but the bootstrapping in tapestry of modules,
> contributions, decoration.++ is something I would like to get into 'core'
> and not just 'web'.
>
> Why is it that the tapestry module is only for web - can't it
> be re-factored/reconfigured so that it can be more closely integrated with
> spring applications...
>
> I'd love to fully embrace tapestry IOC for my core infrastructure, but cant
> see how I'd get the same functionality - especially in terms of transaction
> management (I'd like to hear from those who have made the transition, and
> how they did it).
> Is it's possible(I believe it is) to make an enhanced tapestry-spring module
> which is not only for web, but can integrate tighter with spring - I think
> it would be a great win.
> (Probably there is way to implement tapestry ioc contributions, advisors
> etc.. for spring beans as well...)
>
> I'd like to hear some feedback to check if I'm completely off base here - or
> if it's indeed a good idea...
> I know I'd rather configure spring from tapestry ioc if I could...
>
> Thoughts?
>
> cheers
> Magnus
>
>
> On Fri, Apr 1, 2011 at 5:13 PM, 3kkkdang <cv...@hotmail.com> wrote:
>
>> I will do this:
>> extends TapestrFilter,  in its constructor use WebApplicationContextUtils
>> to
>> get spring context and set this context as ASO static property.  finally in
>> tapestry page class, get spring context through ASO.
>>
>> never got chance to try this, it might work.  any comments?
>>
>> --
>> View this message in context:
>> http://tapestry.1045711.n5.nabble.com/Java-based-spring-configuration-tp3394086p4275778.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Java based spring configuration

Posted by Magnus Kvalheim <ma...@kvalheim.dk>.
Hi thanks for your reply,

Looking back on my original mail I now realize I've been unclear...

To clarify: What I do want to achieve is to
+ Not rely on xml for configuration
+ Inject spring beans into tapestry
(+) Injecting tapestry services into spring is desired

Your suggestion would probably work, but it's not what I want as I's like to
use the @Inject for spring beans.
Sorry for the confusion...


On another note...

Tapestry IOC is much more desirable than spring in many ways.
I need spring (at least I believe I do) for things like jpa support and
transactions and other things, but the bootstrapping in tapestry of modules,
contributions, decoration.++ is something I would like to get into 'core'
and not just 'web'.

Why is it that the tapestry module is only for web - can't it
be re-factored/reconfigured so that it can be more closely integrated with
spring applications...

I'd love to fully embrace tapestry IOC for my core infrastructure, but cant
see how I'd get the same functionality - especially in terms of transaction
management (I'd like to hear from those who have made the transition, and
how they did it).
Is it's possible(I believe it is) to make an enhanced tapestry-spring module
which is not only for web, but can integrate tighter with spring - I think
it would be a great win.
(Probably there is way to implement tapestry ioc contributions, advisors
etc.. for spring beans as well...)

I'd like to hear some feedback to check if I'm completely off base here - or
if it's indeed a good idea...
I know I'd rather configure spring from tapestry ioc if I could...

Thoughts?

cheers
Magnus


On Fri, Apr 1, 2011 at 5:13 PM, 3kkkdang <cv...@hotmail.com> wrote:

> I will do this:
> extends TapestrFilter,  in its constructor use WebApplicationContextUtils
> to
> get spring context and set this context as ASO static property.  finally in
> tapestry page class, get spring context through ASO.
>
> never got chance to try this, it might work.  any comments?
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Java-based-spring-configuration-tp3394086p4275778.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Java based spring configuration

Posted by thana <ka...@dossier.no>.
Its possibly using problem with Spring 3.1 M1., in tapestry (2.5.4, 2.5.5). 

I have tried with following in web.xml: 

	
   <listener>
       
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>


<context-param>
       <param-name>tapestry.use-external-spring-context</param-name>
       <param-value>true</param-value>
    </context-param>


	<filter>
		<filter-name>tapestry5</filter-name>
	
<filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
	</filter>

bit this does not help., shall i register this as a bug ? or are there any
fix for this ?



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Java-based-spring-configuration-tp3394086p4343320.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org