Hi,

I checked in a new module "implementation-spring-webapp" to integrate Tuscany's 
"implementation.spring" with Spring's WebApplicationContext [1]. This new 
feature is demonstrated with samples/webapps/helloworld-spring.

Typically for a web application, Spring provides a ServletContextListener so 
that a WebApplicationContext will be created/destroyed around the start/stop of 
a web application. Now we have two code path to create the ApplicationContext 
with both Tuscany and Spring enabled for the same web application. Having the 
two runtime collaborate is interesting from the following perspectives:   

a. Allow Tuscany to access the WebApplicationContext as the parent of Spring 
context hierarchy (potentially, we can an implementation.spring component 
representing the WebApplicationContext too). Otherwise, Tuscany and Spring will 
load two isolated copies of the application context and have duplicate bean 
instances.

b. Avoid parsing the spring xml definitions twice. (TBD)

I tried two ways:
1) org.apache.tuscany.sca.implementation.spring.webapp.SpringWebModuleActivator 
that finds the Spring WebApplicationContext from the ServletContext and inject 
it into a utility in the UtilityExtensionPoint 
org.apache.tuscany.sca.implementation.spring.invocation.SpringApplicationContextHelper
 so that implementation Spring providers can access it.

2) Define a Spring singleton bean that implements ApplicationContextAware to be 
injected by Spring. We'll need to configure the related application context xml 
file to the web.xml.

[1] 
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#context-create

Thanks,
Raymond
________________________________________________________________ 
Raymond Feng
[email protected]
Apache Tuscany PMC member and committer: tuscany.apache.org
Co-author of Tuscany SCA In Action book: www.tuscanyinaction.com
Personal Web Site: www.enjoyjava.com
________________________________________________________________

On Jul 28, 2010, at 2:57 PM, [email protected] wrote:

> Author: rfeng
> Date: Wed Jul 28 21:57:29 2010
> New Revision: 980244
> 
> URL: http://svn.apache.org/viewvc?rev=980244&view=rev
> Log:
> Add implementation-spring-webapp into the build
> 
> Modified:
>    tuscany/sca-java-2.x/trunk/modules/pom.xml
> 
> Modified: tuscany/sca-java-2.x/trunk/modules/pom.xml
> URL: 
> http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/pom.xml?rev=980244&r1=980243&r2=980244&view=diff
> ==============================================================================
> --- tuscany/sca-java-2.x/trunk/modules/pom.xml (original)
> +++ tuscany/sca-java-2.x/trunk/modules/pom.xml Wed Jul 28 21:57:29 2010
> @@ -93,6 +93,7 @@
>         <module>implementation-java-runtime</module>
>         <module>implementation-spring</module>
>         <module>implementation-spring-runtime</module>
> +        <module>implementation-spring-webapp</module>
>         <module>implementation-web</module>
>         <module>implementation-web-client</module>
>         <module>implementation-web-runtime</module>
> 
> 

Reply via email to