diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-21 20:28:30 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-21 20:28:30 +0000 |
commit | 9b624f74edcead48b13634323224e2d972f7e6ce (patch) | |
tree | 9fc1a0f9cf0d49a0ca568d7e83dbe35ce9c7ec50 /sca-java-2.x/trunk/modules/implementation-spring-runtime | |
parent | b8a63636ff2dbea555f14b42c5a49e1555e68f85 (diff) |
Bring up the servlet-scoped node start/stop with Spring MVC
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1083940 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-spring-runtime')
3 files changed, 18 insertions, 11 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java index db7831322a..b9b993c609 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java +++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProvider.java @@ -20,6 +20,7 @@ package org.apache.tuscany.sca.implementation.spring.provider; import org.apache.tuscany.sca.context.PropertyValueFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; +import org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor; import org.apache.tuscany.sca.implementation.spring.context.SpringContextWrapper; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Invoker; @@ -34,6 +35,8 @@ import org.springframework.context.ApplicationContext; */ public class SpringImplementationProvider implements ImplementationProvider { private RuntimeComponent component; + private SpringImplementationWrapper implementation; + private SpringApplicationContextAccessor contextAccessor; // A Spring application context object private SpringContextWrapper springContext; @@ -46,13 +49,13 @@ public class SpringImplementationProvider implements ImplementationProvider { */ public SpringImplementationProvider(RuntimeComponent component, SpringImplementationWrapper implementation, - ApplicationContext parentApplicationContext, ProxyFactory proxyService, - PropertyValueFactory propertyValueObjectFactory) { + PropertyValueFactory propertyValueObjectFactory, + SpringApplicationContextAccessor contextAccessor) { super(); this.component = component; - - springContext = new SpringContextWrapper(implementation, implementation.getResource()); + this.implementation = implementation; + this.contextAccessor = contextAccessor; } // end constructor @@ -68,6 +71,10 @@ public class SpringImplementationProvider implements ImplementationProvider { * Start this Spring implementation instance */ public void start() { + ApplicationContext parentApplicationContext = + (contextAccessor == null) ? null : contextAccessor.getParentApplicationContext(component); + implementation.setParentApplicationContext(parentApplicationContext); + springContext = new SpringContextWrapper(implementation, implementation.getResource()); springContext.start(); } diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java index ad395323c5..14105890b9 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java +++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java @@ -28,7 +28,6 @@ import org.apache.tuscany.sca.implementation.spring.context.SpringApplicationCon import org.apache.tuscany.sca.provider.ImplementationProvider; import org.apache.tuscany.sca.provider.ImplementationProviderFactory; import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.springframework.context.ApplicationContext; /** * ImplementationProviderFactory for Spring implementation type @@ -61,11 +60,10 @@ public class SpringImplementationProviderFactory implements ImplementationProvid */ public ImplementationProvider createImplementationProvider(RuntimeComponent component, SpringImplementation implementation) { - ApplicationContext parentApplicationContext = - (contextAccessor != null) ? contextAccessor.getParentApplicationContext(component) : null; + SpringImplementationWrapper tie = - new SpringImplementationWrapper(implementation, parentApplicationContext, component, propertyFactory); - return new SpringImplementationProvider(component, tie, parentApplicationContext, proxyFactory, propertyFactory); + new SpringImplementationWrapper(implementation, component, propertyFactory); + return new SpringImplementationProvider(component, tie, proxyFactory, propertyFactory, contextAccessor); } /** diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java index e5593f5eaa..c3c125ff90 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java +++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationWrapper.java @@ -42,13 +42,11 @@ public class SpringImplementationWrapper { private PropertyValueFactory propertyFactory; public SpringImplementationWrapper(SpringImplementation implementation, - ApplicationContext parentApplicationContext, RuntimeComponent component, PropertyValueFactory propertyFactory) { this.implementation = implementation; this.component = component; this.propertyFactory = propertyFactory; - this.parentApplicationContext = parentApplicationContext; } public String getURI() { @@ -155,4 +153,8 @@ public class SpringImplementationWrapper { return parentApplicationContext; } + public void setParentApplicationContext(ApplicationContext parentApplicationContext) { + this.parentApplicationContext = parentApplicationContext; + } + } |