diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca')
-rw-r--r-- | sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorBean.java (renamed from sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessor.java) | 8 | ||||
-rw-r--r-- | sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java (renamed from sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebModuleActivator.java) | 31 |
2 files changed, 25 insertions, 14 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessor.java b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorBean.java index e2f748aba8..a54ef8df17 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessor.java +++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/ApplicationContextAccessorBean.java @@ -28,15 +28,15 @@ import org.springframework.context.support.ApplicationObjectSupport; * * The Spring bean definition file is: org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml */ -public class ApplicationContextAccessor extends ApplicationObjectSupport implements ApplicationContextAware { +public class ApplicationContextAccessorBean extends ApplicationObjectSupport implements ApplicationContextAware { public final static String BEAN_ID = "tuscanySpringApplicationContextAccessor"; - private final static ApplicationContextAccessor INSTANCE = new ApplicationContextAccessor(); + private final static ApplicationContextAccessorBean INSTANCE = new ApplicationContextAccessorBean(); - private ApplicationContextAccessor() { + private ApplicationContextAccessorBean() { } // Spring static factory method to create the singleton instance - public static ApplicationContextAccessor getInstance() { + public static ApplicationContextAccessorBean getInstance() { return INSTANCE; } diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebModuleActivator.java b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java index 062e6105a2..623a298b74 100644 --- a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebModuleActivator.java +++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java @@ -24,17 +24,18 @@ import java.util.logging.Logger; import javax.servlet.ServletContext; import org.apache.tuscany.sca.core.ExtensionPointRegistry; -import org.apache.tuscany.sca.core.ModuleActivator; +import org.apache.tuscany.sca.core.LifeCycleListener; import org.apache.tuscany.sca.host.http.ExtensibleServletHost; -import org.apache.tuscany.sca.implementation.spring.invocation.SpringApplicationContextHelper; +import org.apache.tuscany.sca.implementation.spring.invocation.SpringApplicationContextAccessor; import org.springframework.context.ApplicationContext; import org.springframework.web.context.support.WebApplicationContextUtils; -public class SpringWebModuleActivator implements ModuleActivator { - private static Logger log = Logger.getLogger(SpringWebModuleActivator.class.getName()); +public class SpringWebApplicationContextAccessor implements SpringApplicationContextAccessor, LifeCycleListener { + private static Logger log = Logger.getLogger(SpringWebApplicationContextAccessor.class.getName()); private ExtensionPointRegistry registry; + private ApplicationContext parentApplicationContext; - public SpringWebModuleActivator(ExtensionPointRegistry registry) { + public SpringWebApplicationContextAccessor(ExtensionPointRegistry registry) { super(); this.registry = registry; } @@ -42,21 +43,31 @@ public class SpringWebModuleActivator implements ModuleActivator { @Override public void start() { ExtensibleServletHost servletHost = ExtensibleServletHost.getInstance(registry); - SpringApplicationContextHelper contextHelper = SpringApplicationContextHelper.getInstance(registry); ServletContext servletContext = servletHost.getServletContext(); if (servletContext != null) { - ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext); - if (context != null) { + parentApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); + if (parentApplicationContext != null) { log.info("Spring WebApplicationContext is now injected on Tuscany"); - contextHelper.setParentApplicationContext(context); } } + + if (parentApplicationContext == null) { + parentApplicationContext = ApplicationContextAccessorBean.getInstance().getApplicationContext(); + } } @Override public void stop() { - // NO-OP + parentApplicationContext = null; + } + + public Object getParentApplicationContext() { + return parentApplicationContext; + } + + public void setParentApplicationContext(Object parentApplicationContext) { + this.parentApplicationContext = (ApplicationContext) parentApplicationContext; } } |