summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-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
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.invocation.SpringApplicationContextAccessor (renamed from sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator)2
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml2
4 files changed, 27 insertions, 16 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;
}
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.invocation.SpringApplicationContextAccessor
index 984e81bf87..506b02c782 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
+++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.spring.invocation.SpringApplicationContextAccessor
@@ -14,4 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-org.apache.tuscany.sca.implementation.spring.webapp.SpringWebModuleActivator \ No newline at end of file
+org.apache.tuscany.sca.implementation.spring.webapp.SpringWebApplicationContextAccessor \ No newline at end of file
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml
index 3e9d7deb91..b98374a88b 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml
+++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/resources/org/apache/tuscany/sca/implementation/spring/webapp/spring-webapp-context.xml
@@ -22,7 +22,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="tuscanySpringApplicationContextAccessor"
- class="org.apache.tuscany.sca.implementation.spring.webapp.ApplicationContextAccessor"
+ class="org.apache.tuscany.sca.implementation.spring.webapp.ApplicationContextAccessorBean"
scope="singleton" factory-method="getInstance">
</bean>