Re: Shale, Spring Tiger Annotations

2006-07-05 Thread Craig McClanahan
On 7/4/06, Enrique Medina Montenegro [EMAIL PROTECTED] wrote:
Hi,I'm starting a new development where I will use MyFaces together with Shale and Spring. I've been reading the documentation regarding the integration between Spring and Shale, in terms of the delegating VariableResolver. Furthermore, I've been reading the documentation regarding Tiger extensions for Shale.
So the point is I want to use both the Spring integration and the Tiger extensions for the same purpose: get my JSF managed beans.And here comes the question. Is it possible to combine both the @Bean annotation and the definition of the bean in the 
applicationContext.xml from Spring? The reason for this question is very simple, and maybe there's a workaround for it without having to use both functionalities all together: I would like to define all my beans within Spring's 
applicationContext.xml, but I don't know how to indicate the scope for those beans, so I was wondering whether the use in conjunction with the @Bean(name=Bean scope=Scope.REQUEST) annotation would help to achieve the desired result.
Currently this combination will not do what you want ... the @Bean annotation focuses only on replacing declarations in a faces-config.xml file (and, implicitly, replacing declarations in applicationContext.xml
 as well). To get what you're after, I would look at a couple of different things:* There's a spring-jsf extensions project at SourceForge that implies it can store Spring beans into a specified scope (I haven't actually tried this one).
* Spring 2 is supposed to have this feature, as part of its JSF integration, out of the box.Craig
Thanks.




Re: Shale, Spring Tiger Annotations

2006-07-05 Thread Craig McClanahan
On 7/4/06, Enrique Medina Montenegro [EMAIL PROTECTED] wrote:
Craig,So in the documentation at the web site regarding Shale-Spring integration, when you show this example:or as a Spring bean in /WEB-INF/applicationContext.xml:


  bean id=domainsclass=com.mycompany.mypackage.MyDomainsImplsingleton=true... configuration of managed properties ...  /bean
What would be the scope for that JSF bean then?The technically correct answer is none of the above :-)The more helpful answer is to understand that singleton=true in a Spring configuration file means the bean will be created only once per application ... which is similar in *effect* to storing it in application scope (you only get one copy), but it isn't actually placed into application scope.
If you said singleton=false instead, this would correspond exactly to a managed bean scope of none ... meaning a new instance would be created every time you asked for it.Craig
On 7/4/06, 
Craig McClanahan 
[EMAIL PROTECTED] wrote:
On 7/4/06, Enrique Medina Montenegro [EMAIL PROTECTED]
 wrote:
Hi,I'm starting a new development where I will use MyFaces together with Shale and Spring. I've been reading the documentation regarding the integration between Spring and Shale, in terms of the delegating VariableResolver. Furthermore, I've been reading the documentation regarding Tiger extensions for Shale.
So the point is I want to use both the Spring integration and the Tiger extensions for the same purpose: get my JSF managed beans.And here comes the question. Is it possible to combine both the @Bean annotation and the definition of the bean in the 
applicationContext.xml from Spring? The reason for this question is very simple, and maybe there's a workaround for it without having to use both functionalities all together: I would like to define all my beans within Spring's 
applicationContext.xml, but I don't know how to indicate the scope for those beans, so I was wondering whether the use in conjunction with the @Bean(name=Bean scope=Scope.REQUEST) annotation would help to achieve the desired result.
Currently this combination will not do what you want ... the @Bean annotation focuses only on replacing declarations in a faces-config.xml file (and, implicitly, replacing declarations in 
applicationContext.xml
 as well). To get what you're after, I would look at a couple of different things:* There's a spring-jsf extensions project at SourceForge that implies it can store Spring beans into a specified scope (I haven't actually tried this one).
* Spring 2 is supposed to have this feature, as part of its JSF integration, out of the box.Craig


Thanks.








Re: Shale, Spring Tiger Annotations

2006-07-05 Thread Enrique Medina Montenegro
Umm, I see.I found something like this in one post, but seems that for Spring 2.0 is no longer valid:
bean id=newWidget class=model.Widget singleton=false jsf:scope=request/Any idea?On 7/5/06, 
Craig McClanahan [EMAIL PROTECTED] wrote:
On 7/4/06, Enrique Medina Montenegro 
[EMAIL PROTECTED] wrote:
Craig,So in the documentation at the web site regarding Shale-Spring integration, when you show this example:or as a Spring bean in /WEB-INF/applicationContext.xml:


  bean id=domainsclass=com.mycompany.mypackage.MyDomainsImplsingleton=true... configuration of managed properties ...  /bean
What would be the scope for that JSF bean then?The technically correct answer is none of the above :-)The more helpful answer is to understand that singleton=true in a Spring configuration file means the bean will be created only once per application ... which is similar in *effect* to storing it in application scope (you only get one copy), but it isn't actually placed into application scope.
If you said singleton=false instead, this would correspond exactly to a managed bean scope of none ... meaning a new instance would be created every time you asked for it.
Craig

On 7/4/06, 
Craig McClanahan 
[EMAIL PROTECTED] wrote:
On 7/4/06, Enrique Medina Montenegro [EMAIL PROTECTED]
 wrote:
Hi,I'm starting a new development where I will use MyFaces together with Shale and Spring. I've been reading the documentation regarding the integration between Spring and Shale, in terms of the delegating VariableResolver. Furthermore, I've been reading the documentation regarding Tiger extensions for Shale.
So the point is I want to use both the Spring integration and the Tiger extensions for the same purpose: get my JSF managed beans.And here comes the question. Is it possible to combine both the @Bean annotation and the definition of the bean in the 
applicationContext.xml from Spring? The reason for this question is very simple, and maybe there's a workaround for it without having to use both functionalities all together: I would like to define all my beans within Spring's 
applicationContext.xml, but I don't know how to indicate the scope for those beans, so I was wondering whether the use in conjunction with the @Bean(name=Bean scope=Scope.REQUEST) annotation would help to achieve the desired result.
Currently this combination will not do what you want ... the @Bean annotation focuses only on replacing declarations in a faces-config.xml file (and, implicitly, replacing declarations in 
applicationContext.xml
 as well). To get what you're after, I would look at a couple of different things:* There's a spring-jsf extensions project at SourceForge that implies it can store Spring beans into a specified scope (I haven't actually tried this one).
* Spring 2 is supposed to have this feature, as part of its JSF integration, out of the box.Craig



Thanks.










Re: Shale, Spring Tiger Annotations

2006-07-05 Thread Craig McClanahan
On 7/5/06, Enrique Medina Montenegro [EMAIL PROTECTED] wrote:
Umm, I see.I found something like this in one post, but seems that for Spring 2.0 is no longer valid:
bean id=newWidget class=model.Widget singleton=false jsf:scope=request/Any idea?Hmm ... sounds like a good question to ask on the Spring forum. The reference manual for Spring 2 talks about using the new generalized support for scopes as being applicable here as well, but I can't seem to find any specific references with respect to web application scopes.
Need to look at the Spring 2 sample apps as well (although it sounds like the kids next door *finally* ran out of fireworks, so maybe this will need to wait until tomorrow :-).Craig
On 7/5/06, 
Craig McClanahan [EMAIL PROTECTED] wrote:

On 7/4/06, Enrique Medina Montenegro 

[EMAIL PROTECTED] wrote:
Craig,So in the documentation at the web site regarding Shale-Spring integration, when you show this example:or as a Spring bean in /WEB-INF/applicationContext.xml:


  bean id=domainsclass=com.mycompany.mypackage.MyDomainsImplsingleton=true... configuration of managed properties ...  /bean
What would be the scope for that JSF bean then?The technically correct answer is none of the above :-)The more helpful answer is to understand that singleton=true in a Spring configuration file means the bean will be created only once per application ... which is similar in *effect* to storing it in application scope (you only get one copy), but it isn't actually placed into application scope.
If you said singleton=false instead, this would correspond exactly to a managed bean scope of none ... meaning a new instance would be created every time you asked for it.

Craig

On 7/4/06, 
Craig McClanahan 
[EMAIL PROTECTED] wrote:
On 7/4/06, Enrique Medina Montenegro [EMAIL PROTECTED]
 wrote:
Hi,I'm starting a new development where I will use MyFaces together with Shale and Spring. I've been reading the documentation regarding the integration between Spring and Shale, in terms of the delegating VariableResolver. Furthermore, I've been reading the documentation regarding Tiger extensions for Shale.
So the point is I want to use both the Spring integration and the Tiger extensions for the same purpose: get my JSF managed beans.And here comes the question. Is it possible to combine both the @Bean annotation and the definition of the bean in the 
applicationContext.xml from Spring? The reason for this question is very simple, and maybe there's a workaround for it without having to use both functionalities all together: I would like to define all my beans within Spring's 
applicationContext.xml, but I don't know how to indicate the scope for those beans, so I was wondering whether the use in conjunction with the @Bean(name=Bean scope=Scope.REQUEST) annotation would help to achieve the desired result.
Currently this combination will not do what you want ... the @Bean annotation focuses only on replacing declarations in a faces-config.xml file (and, implicitly, replacing declarations in 
applicationContext.xml
 as well). To get what you're after, I would look at a couple of different things:* There's a spring-jsf extensions project at SourceForge that implies it can store Spring beans into a specified scope (I haven't actually tried this one).
* Spring 2 is supposed to have this feature, as part of its JSF integration, out of the box.Craig




Thanks.












Re: Shale, Spring Tiger Annotations

2006-07-05 Thread Enrique Medina Montenegro
Found this thread in the Spring forum:http://forum.springframework.org/showthread.php?t=26302highlight=scope
On 7/5/06, Craig McClanahan [EMAIL PROTECTED] wrote:
On 7/5/06, Enrique Medina Montenegro 
[EMAIL PROTECTED] wrote:
Umm, I see.I found something like this in one post, but seems that for Spring 2.0 is no longer valid:
bean id=newWidget class=model.Widget singleton=false jsf:scope=request/Any idea?Hmm ... sounds like a good question to ask on the Spring forum. The reference manual for Spring 2 talks about using the new generalized support for scopes as being applicable here as well, but I can't seem to find any specific references with respect to web application scopes.
Need to look at the Spring 2 sample apps as well (although it sounds like the kids next door *finally* ran out of fireworks, so maybe this will need to wait until tomorrow :-).
Craig
On 7/5/06, 
Craig McClanahan [EMAIL PROTECTED] wrote:


On 7/4/06, Enrique Medina Montenegro 


[EMAIL PROTECTED] wrote:
Craig,So in the documentation at the web site regarding Shale-Spring integration, when you show this example:or as a Spring bean in /WEB-INF/applicationContext.xml:


  bean id=domainsclass=com.mycompany.mypackage.MyDomainsImplsingleton=true... configuration of managed properties ...  /bean
What would be the scope for that JSF bean then?The technically correct answer is none of the above :-)The more helpful answer is to understand that singleton=true in a Spring configuration file means the bean will be created only once per application ... which is similar in *effect* to storing it in application scope (you only get one copy), but it isn't actually placed into application scope.
If you said singleton=false instead, this would correspond exactly to a managed bean scope of none ... meaning a new instance would be created every time you asked for it.


Craig

On 7/4/06, 
Craig McClanahan 
[EMAIL PROTECTED] wrote:
On 7/4/06, Enrique Medina Montenegro [EMAIL PROTECTED]
 wrote:
Hi,I'm starting a new development where I will use MyFaces together with Shale and Spring. I've been reading the documentation regarding the integration between Spring and Shale, in terms of the delegating VariableResolver. Furthermore, I've been reading the documentation regarding Tiger extensions for Shale.
So the point is I want to use both the Spring integration and the Tiger extensions for the same purpose: get my JSF managed beans.And here comes the question. Is it possible to combine both the @Bean annotation and the definition of the bean in the 
applicationContext.xml from Spring? The reason for this question is very simple, and maybe there's a workaround for it without having to use both functionalities all together: I would like to define all my beans within Spring's 
applicationContext.xml, but I don't know how to indicate the scope for those beans, so I was wondering whether the use in conjunction with the @Bean(name=Bean scope=Scope.REQUEST) annotation would help to achieve the desired result.
Currently this combination will not do what you want ... the @Bean annotation focuses only on replacing declarations in a faces-config.xml file (and, implicitly, replacing declarations in 
applicationContext.xml
 as well). To get what you're after, I would look at a couple of different things:* There's a spring-jsf extensions project at SourceForge that implies it can store Spring beans into a specified scope (I haven't actually tried this one).
* Spring 2 is supposed to have this feature, as part of its JSF integration, out of the box.Craig





Thanks.














Re: Shale, Spring Tiger Annotations

2006-07-05 Thread Enrique Medina Montenegro
But if I just define my beans with scope=request or scope=session, then I get an IllegalStateException :-(org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gestorMenuBean' defined in class path resource [com/sabini/librisuite/sabiniContext.xml]: Initialization of bean failed; nested exception is 
java.lang.IllegalStateException: No Scope registered for scope 'session'Caused by: java.lang.IllegalStateException: No Scope registered for scope 'session' at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:285) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference
(BeanDefinitionValueResolver.java:226) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:115) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues
(AbstractAutowireCapableBeanFactory.java:798) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:589) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
(AbstractAutowireCapableBeanFactory.java:389) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:257) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:168) at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:254) at org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:332) at org.springframework.context.support.ClassPathXmlApplicationContext.init(ClassPathXmlApplicationContext.java:92) at org.springframework.context.support.ClassPathXmlApplicationContext
.init(ClassPathXmlApplicationContext.java:77) at org.springframework.test.AbstractSpringContextTests.loadContextLocations(AbstractSpringContextTests.java:130) at org.springframework.test.AbstractDependencyInjectionSpringContextTests.loadContextLocations
(AbstractDependencyInjectionSpringContextTests.java:224) at org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:110) at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp
(AbstractDependencyInjectionSpringContextTests.java:192) at junit.framework.TestCase.runBare(TestCase.java:125) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69) at 
junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run
(TestCase.java:118) at junit.framework.TestSuite.runTest(TestSuite.java:208) at junit.framework.TestSuite.run(TestSuite.java:203) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java
:478) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
On 7/5/06, Enrique Medina Montenegro [EMAIL PROTECTED] wrote:
Found this thread in the Spring forum:http://forum.springframework.org/showthread.php?t=26302highlight=scope

On 7/5/06, Craig McClanahan [EMAIL PROTECTED]
 wrote:
On 7/5/06, Enrique Medina Montenegro 

[EMAIL PROTECTED] wrote:
Umm, I see.I found something like this in one post, but seems that for Spring 2.0 is no longer valid:
bean id=newWidget class=model.Widget singleton=false jsf:scope=request/Any idea?Hmm ... sounds like a good question to ask on the Spring forum. The reference manual for Spring 2 talks about using the new generalized support for scopes as being applicable here as well, but I can't seem to find any specific references with respect to web application scopes.
Need to look at the Spring 2 sample apps as well (although it sounds like the kids next door *finally* ran out of fireworks, so maybe this will need to wait until tomorrow :-).
Craig
On 7/5/06, 
Craig McClanahan [EMAIL PROTECTED] wrote:



On 7/4/06, Enrique Medina Montenegro 



[EMAIL PROTECTED] wrote:
Craig,So in the documentation at the web site regarding Shale-Spring integration, when you show this example:or as a Spring bean in /WEB-INF/applicationContext.xml:


  bean id=domainsclass=com.mycompany.mypackage.MyDomainsImplsingleton=true... configuration of managed properties ...  /bean
What would be the scope for that JSF bean then?The technically correct answer is none of the above :-)The more helpful answer is to understand that singleton=true in a Spring configuration file means the bean will be created only once per application ... which is similar in *effect* to storing 

RE: Shale, Spring Tiger Annotations

2006-07-05 Thread Coloma Escribano, Ignacio









The spring-jsf project is
an outdated alternative to achieve what you want. Im saying from memory, but
Spring 2 introduces what you really need, the DelegatingVariableResolver. The
rest that spring-jsf provides is a bidirectional reachability, that allows you
to reach JSF beans from spring beans (a bad design decision imho, but your
choice).



If you decide to go with
spring 2.0, you need to define your managed bean twice: in the
applicationContext.xml to define the DI stuff, and again in the
faces-config.xml to define the scope of the bean (session, request, application).
The delegatingVariableResolver will look first in Spring, and if it doesn´t
find anything will delegate in the JSF variable resolver.



ApplicationContext:

beans 

    bean id=foo class=com.acme.manager.FooManager 

    /bean

  

/beans



faces-config:



    managed-bean

    managed-bean-namefoo/managed-bean-name

    managed-bean-class com.acme.manager.FooManager/managed-bean-class

    managed-bean-scopesession/managed-bean-scope

  /managed-bean



Note that this is most
probably not what you want. If you want to isolate layers, you should separate
two classes, one for the JSF layer and another for spring (so you don´t end up
with JSF class dependencies in your business layer). Then you can inject one the
other. There is a page about this in the Faces wiki, or in the forums, I dont
remember.

 

    managed-bean

    managed-bean-namefooController/managed-bean-name

    managed-bean-classcom.acme.jsf.FooController/managed-bean-class

    managed-bean-scopesession/managed-bean-scope

    managed-property

  property-namefooDelegate/property-name

        value#{foo}/value

    /managed-property

  /managed-bean



Regards.











De:
Enrique Medina Montenegro
[mailto:[EMAIL PROTECTED] 
Enviado el: miércoles, 05 de julio
de 2006 9:41
Para: MyFaces
 Discussion
Asunto: Re: Shale, Spring 
Tiger Annotations





But if I just define my
beans with scope=request or scope=session, then I get
an IllegalStateException :-(

org.springframework.beans.factory.BeanCreationException: Error creating bean
with name 'gestorMenuBean' defined in class path resource [com/sabini/librisuite/sabiniContext.xml]:
Initialization of bean failed; nested exception is
java.lang.IllegalStateException: No Scope registered for scope 'session'
Caused by: java.lang.IllegalStateException: No Scope registered for scope
'session'
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:285)
 at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:168)
 at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference
(BeanDefinitionValueResolver.java:226)
 at
org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:115)
 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues
(AbstractAutowireCapableBeanFactory.java:798)
 at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:589)
 at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean
(AbstractAutowireCapableBeanFactory.java:389)
 at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:257)
 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:168)
 at
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:254)
 at org.springframework.context.support.AbstractApplicationContext.refresh
(AbstractApplicationContext.java:332)
 at
org.springframework.context.support.ClassPathXmlApplicationContext.init(ClassPathXmlApplicationContext.java:92)
 at org.springframework.context.support.ClassPathXmlApplicationContext
.init(ClassPathXmlApplicationContext.java:77)
 at
org.springframework.test.AbstractSpringContextTests.loadContextLocations(AbstractSpringContextTests.java:130)
 at org.springframework.test.AbstractDependencyInjectionSpringContextTests.loadContextLocations
(AbstractDependencyInjectionSpringContextTests.java:224)
 at
org.springframework.test.AbstractSpringContextTests.getContext(AbstractSpringContextTests.java:110)
 at org.springframework.test.AbstractDependencyInjectionSpringContextTests.setUp
(AbstractDependencyInjectionSpringContextTests.java:192)
 at junit.framework.TestCase.runBare(TestCase.java:125)
 at
org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:69)
 at junit.framework.TestResult$1.protect(TestResult.java:106)
 at
junit.framework.TestResult.runProtected(TestResult.java:124)
 at junit.framework.TestResult.run(TestResult.java:109)
 at junit.framework.TestCase.run