summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r--sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE14
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/pom.xml4
-rw-r--r--sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java5
-rw-r--r--sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServlet.java3
-rw-r--r--sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java3
-rw-r--r--sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java50
-rw-r--r--sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebContextConfigurator.java22
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/META-INF/MANIFEST.MF22
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/pom.xml6
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java10
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/provider/SpringImplementationProviderFactory.java2
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-tie/META-INF/MANIFEST.MF22
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-tie/pom.xml6
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-webapp/META-INF/MANIFEST.MF25
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-webapp/pom.xml30
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/spring/TuscanyDispatcherServlet.java64
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java49
-rw-r--r--sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java21
-rw-r--r--sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java13
-rw-r--r--sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java2
20 files changed, 245 insertions, 128 deletions
diff --git a/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE b/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
index f38d8ee57d..652293fa92 100644
--- a/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
+++ b/sca-java-2.x/trunk/distribution/all/src/main/release/bin/LICENSE
@@ -297,12 +297,14 @@ The following components come under Apache Software License 2.0
openjpa-1.2.1.jar
org.apache.axis2.osgi-1.5.3.jar
regexp-1.3.jar
- spring-aop-3.0.2.RELEASE.jar
- spring-asm-3.0.2.RELEASE.jar
- spring-beans-3.0.2.RELEASE.jar
- spring-context-3.0.2.RELEASE.jar
- spring-core-3.0.2.RELEASE.jar
- spring-expression-3.0.2.RELEASE.jar
+ spring-aop-3.0.5.RELEASE.jar
+ spring-asm-3.0.5.RELEASE.jar
+ spring-beans-3.0.5.RELEASE.jar
+ spring-context-3.0.5.RELEASE.jar
+ spring-core-3.0.5.RELEASE.jar
+ spring-expression-3.0.5.RELEASE.jar
+ spring-web-3.0.5.RELEASE.jar
+ spring-webmvc-3.0.5.RELEASE.jar
stripes-1.5.2.jar
tranql-connector-1.1.jar
tribes-6.0.26.jar
diff --git a/sca-java-2.x/trunk/modules/core-spi/pom.xml b/sca-java-2.x/trunk/modules/core-spi/pom.xml
index d94b3d7211..a1e48972e2 100644
--- a/sca-java-2.x/trunk/modules/core-spi/pom.xml
+++ b/sca-java-2.x/trunk/modules/core-spi/pom.xml
@@ -86,13 +86,13 @@
<id>process-resources</id>
<phase>process-resources</phase>
<configuration>
- <tasks>
+ <target>
<filter token="version" value="${project.version}"/>
<filter token="svnRevision" value="${sources.version}"/>
<filter token="buildtime" value="${build.timestamp}"/>
<copy toDir="${basedir}/target/classes/org/apache/tuscany/sca/runtime" overwrite="true"
filtering="on" file="${basedir}/src/main/resources/org/apache/tuscany/sca/runtime/revision.properties"/>
- </tasks>
+ </target>
</configuration>
<goals>
<goal>run</goal>
diff --git a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
index d71abdacb2..8959293d71 100644
--- a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
+++ b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
@@ -25,7 +25,6 @@ import java.util.logging.Logger;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
-import org.apache.tuscany.sca.host.webapp.WebAppHelper.Configurator;
/**
* A ServletContextListener to create and close the SCADomain
@@ -38,7 +37,7 @@ public class TuscanyContextListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent event) {
logger.info(event.getServletContext().getServletContextName() + " is starting.");
try {
- Configurator configurator = WebAppHelper.getConfigurator(event.getServletContext());
+ WebContextConfigurator configurator = WebAppHelper.getConfigurator(event.getServletContext());
WebAppHelper.init(configurator);
} catch (Throwable e) {
logger.log(Level.SEVERE, e.getMessage(), e);
@@ -52,7 +51,7 @@ public class TuscanyContextListener implements ServletContextListener {
return;
}
try {
- Configurator configurator = WebAppHelper.getConfigurator(event.getServletContext());
+ WebContextConfigurator configurator = WebAppHelper.getConfigurator(event.getServletContext());
WebAppHelper.stop(configurator);
} catch (Throwable e) {
logger.log(Level.SEVERE, e.getMessage(), e);
diff --git a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServlet.java b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServlet.java
index 6f5c35d3fb..e8c8d941ff 100644
--- a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServlet.java
+++ b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServlet.java
@@ -26,7 +26,6 @@ import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
-import org.apache.tuscany.sca.host.webapp.WebAppHelper.Configurator;
/**
* A Servlet that provides a hook to control the lifecycle of Tuscany node
@@ -37,7 +36,7 @@ public class TuscanyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private Logger logger = Logger.getLogger(TuscanyServlet.class.getName());
- private transient Configurator configurator;
+ private transient WebContextConfigurator configurator;
public TuscanyServlet() {
super();
diff --git a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java
index a3800f221b..f058e03788 100644
--- a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java
+++ b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyServletFilter.java
@@ -32,7 +32,6 @@ import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import org.apache.tuscany.sca.host.http.ServletHost;
-import org.apache.tuscany.sca.host.webapp.WebAppHelper.Configurator;
/**
* A Servlet filter that forwards service requests to the Servlets registered with
@@ -44,7 +43,7 @@ public class TuscanyServletFilter implements Filter {
private static final long serialVersionUID = 1L;
private Logger logger = Logger.getLogger(TuscanyServletFilter.class.getName());
- private transient Configurator configurator;
+ private transient WebContextConfigurator configurator;
private transient ServletHost servletHost;
public TuscanyServletFilter() {
diff --git a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
index 2001067e16..41503f1cac 100644
--- a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
+++ b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebAppHelper.java
@@ -106,7 +106,7 @@ public class WebAppHelper {
return host;
}
- public static Node init(final Configurator configurator) {
+ public static Node init(final WebContextConfigurator configurator) {
synchronized (configurator) {
bootstrapRuntime(configurator);
@@ -127,7 +127,7 @@ public class WebAppHelper {
* Bootstrap the Tuscany runtime for the given scope
* @param configurator
*/
- private synchronized static void bootstrapRuntime(final Configurator configurator) {
+ private synchronized static void bootstrapRuntime(final WebContextConfigurator configurator) {
if (host == null) {
try {
@@ -154,7 +154,7 @@ public class WebAppHelper {
}
}
- private static WebAppServletHost getServletHost(final Configurator configurator) throws ServletException {
+ private static WebAppServletHost getServletHost(final WebContextConfigurator configurator) throws ServletException {
ExtensionPointRegistry registry = factory.getExtensionPointRegistry();
WebAppServletHost host =
(WebAppServletHost)org.apache.tuscany.sca.host.http.ServletHostHelper.getServletHost(registry);
@@ -179,7 +179,7 @@ public class WebAppHelper {
return host;
}
- private static Node createAndStartNode(final Configurator configurator) throws ServletException {
+ private static Node createAndStartNode(final WebContextConfigurator configurator) throws ServletException {
NodeConfiguration configuration = null;
try {
configuration = getNodeConfiguration(configurator);
@@ -195,7 +195,7 @@ public class WebAppHelper {
return node;
}
- public static void stop(Configurator configurator) {
+ public static void stop(WebContextConfigurator configurator) {
Node node = (Node)configurator.getAttribute(SCA_NODE_ATTRIBUTE);
if (node != null) {
node.stop();
@@ -215,7 +215,7 @@ public class WebAppHelper {
return factory;
}
- private static String getDefaultComposite(Configurator configurator) {
+ private static String getDefaultComposite(WebContextConfigurator configurator) {
String name = configurator.getName();
if ("".equals(name)) {
return "/WEB-INF/web.composite";
@@ -224,7 +224,7 @@ public class WebAppHelper {
}
}
- private static NodeConfiguration getNodeConfiguration(Configurator configurator) throws IOException,
+ private static NodeConfiguration getNodeConfiguration(WebContextConfigurator configurator) throws IOException,
URISyntaxException {
NodeConfiguration configuration = null;
String nodeConfigURI = configurator.getInitParameter(NODE_CONFIGURATION);
@@ -234,6 +234,11 @@ public class WebAppHelper {
configuration = factory.loadConfiguration(url.openStream(), url);
} else {
configuration = factory.createNodeConfiguration();
+
+ configuration.setAttribute(ServletContext.class.getName(), servletContext);
+ if(configurator instanceof ServletConfigurator) {
+ configuration.setAttribute(Servlet.class.getName(), ((ServletConfigurator) configurator).servlet);
+ }
boolean explicitContributions = false;
Enumeration<String> names = configurator.getInitParameterNames();
@@ -320,36 +325,19 @@ public class WebAppHelper {
return configuration;
}
- static Configurator getConfigurator(FilterConfig config) {
+ public static WebContextConfigurator getConfigurator(FilterConfig config) {
return new FilterConfigurator(config);
}
- static Configurator getConfigurator(ServletContext context) {
+ public static WebContextConfigurator getConfigurator(ServletContext context) {
return new ServletContextConfigurator(context);
}
- static Configurator getConfigurator(Servlet context) {
+ public static WebContextConfigurator getConfigurator(Servlet context) {
return new ServletConfigurator(context);
}
- /**
- * The interface that represents a given scope (Webapp vs Servlet) that provides the configuration of the Tuscany node
- */
- public static interface Configurator {
- String getInitParameter(String name);
-
- Enumeration<String> getInitParameterNames();
-
- ServletContext getServletContext();
-
- void setAttribute(String name, Object value);
-
- <T> T getAttribute(String name);
-
- String getName();
- }
-
- public static class FilterConfigurator implements Configurator {
+ public static class FilterConfigurator implements WebContextConfigurator {
private FilterConfig config;
public FilterConfigurator(FilterConfig config) {
@@ -395,7 +383,7 @@ public class WebAppHelper {
}
- public static class ServletContextConfigurator implements Configurator {
+ public static class ServletContextConfigurator implements WebContextConfigurator {
private ServletContext context;
public ServletContextConfigurator(ServletContext context) {
@@ -428,11 +416,13 @@ public class WebAppHelper {
}
}
- public static class ServletConfigurator implements Configurator {
+ public static class ServletConfigurator implements WebContextConfigurator {
private ServletConfig config;
+ private Servlet servlet;
public ServletConfigurator(Servlet servlet) {
super();
+ this.servlet = servlet;
this.config = servlet.getServletConfig();
}
diff --git a/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebContextConfigurator.java b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebContextConfigurator.java
new file mode 100644
index 0000000000..66408f26d4
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/WebContextConfigurator.java
@@ -0,0 +1,22 @@
+package org.apache.tuscany.sca.host.webapp;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+
+/**
+ * The interface that represents a given scope (Webapp vs Servlet) that provides the configuration of the Tuscany node
+ */
+public interface WebContextConfigurator {
+ String getInitParameter(String name);
+
+ Enumeration<String> getInitParameterNames();
+
+ ServletContext getServletContext();
+
+ void setAttribute(String name, Object value);
+
+ <T> T getAttribute(String name);
+
+ String getName();
+} \ No newline at end of file
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
index b598607625..ea7eacc49c 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/META-INF/MANIFEST.MF
@@ -40,17 +40,17 @@ Import-Package: org.oasisopen.sca;version="2.0.0",
org.apache.tuscany.sca.policy;version="2.0.0",
org.apache.tuscany.sca.provider;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0",
- org.springframework.beans;version="3.0.2.RELEASE",
- org.springframework.beans.factory;version="3.0.2.RELEASE",
- org.springframework.beans.factory.annotation;version="3.0.2.RELEASE",
- org.springframework.beans.factory.config;version="3.0.2.RELEASE",
- org.springframework.beans.factory.support;version="3.0.2.RELEASE",
- org.springframework.beans.factory.xml;version="3.0.2.RELEASE",
- org.springframework.context;version="3.0.2.RELEASE",
- org.springframework.context.support;version="3.0.2.RELEASE",
- org.springframework.core;version="3.0.2.RELEASE",
- org.springframework.core.io;version="3.0.2.RELEASE",
- org.springframework.util;version="3.0.2.RELEASE"
+ org.springframework.beans,
+ org.springframework.beans.factory,
+ org.springframework.beans.factory.annotation,
+ org.springframework.beans.factory.config,
+ org.springframework.beans.factory.support,
+ org.springframework.beans.factory.xml,
+ org.springframework.context,
+ org.springframework.context.support,
+ org.springframework.core,
+ org.springframework.core.io,
+ org.springframework.util
Export-Package: org.apache.tuscany.sca.implementation.spring.context;version="2.0.0";
uses:="org.springframework.beans.factory.support,
org.springframework.context.support,
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/pom.xml b/sca-java-2.x/trunk/modules/implementation-spring-runtime/pom.xml
index 45e236acd9..a40a0ff393 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/pom.xml
@@ -42,19 +42,19 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
- <version>3.0.2.RELEASE</version>
+ <version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
- <version>3.0.2.RELEASE</version>
+ <version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
- <version>3.0.2.RELEASE</version>
+ <version>3.0.5.RELEASE</version>
</dependency>
</dependencies>
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java
index 2d18b5aa6c..f4820ea9a0 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/context/SpringApplicationContextAccessor.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.implementation.spring.context;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.springframework.context.ApplicationContext;
/**
@@ -28,14 +29,9 @@ public interface SpringApplicationContextAccessor {
/**
* Get the parent Spring application context for the hosting environment. This will be used as the parent
* application context for implementation.spring components
+ * @param component The Spring component instance
* @return The parent application context
*/
- ApplicationContext getParentApplicationContext();
+ ApplicationContext getParentApplicationContext(RuntimeComponent component);
- /**
- * Set the root Spring application context. This is particually useful for Spring web integration where Spring
- * creates WebApplicationContext and keeps it in the ServletContext
- * @param parentApplicationContext The parent application context
- */
- void setParentApplicationContext(ApplicationContext parentApplicationContext);
}
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 be16fb3251..ad395323c5 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
@@ -62,7 +62,7 @@ public class SpringImplementationProviderFactory implements ImplementationProvid
public ImplementationProvider createImplementationProvider(RuntimeComponent component,
SpringImplementation implementation) {
ApplicationContext parentApplicationContext =
- (contextAccessor != null) ? contextAccessor.getParentApplicationContext() : null;
+ (contextAccessor != null) ? contextAccessor.getParentApplicationContext(component) : null;
SpringImplementationWrapper tie =
new SpringImplementationWrapper(implementation, parentApplicationContext, component, propertyFactory);
return new SpringImplementationProvider(component, tie, parentApplicationContext, proxyFactory, propertyFactory);
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-tie/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/implementation-spring-tie/META-INF/MANIFEST.MF
index 5d452244d2..f59fa3c314 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-tie/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/implementation-spring-tie/META-INF/MANIFEST.MF
@@ -11,15 +11,15 @@ Bundle-DocURL: http://www.apache.org/
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
Import-Package: org.oasisopen.sca;version="2.0.0",
org.oasisopen.sca.annotation;version="2.0.0",
- org.springframework.beans;version="3.0.2.RELEASE",
- org.springframework.beans.factory;version="3.0.2.RELEASE",
- org.springframework.beans.factory.annotation;version="3.0.2.RELEASE",
- org.springframework.beans.factory.config;version="3.0.2.RELEASE",
- org.springframework.beans.factory.support;version="3.0.2.RELEASE",
- org.springframework.beans.factory.xml;version="3.0.2.RELEASE",
- org.springframework.context;version="3.0.2.RELEASE",
- org.springframework.context.support;version="3.0.2.RELEASE",
- org.springframework.core;version="3.0.2.RELEASE",
- org.springframework.core.io;version="3.0.2.RELEASE",
- org.springframework.util;version="3.0.2.RELEASE"
+ org.springframework.beans,
+ org.springframework.beans.factory,
+ org.springframework.beans.factory.annotation,
+ org.springframework.beans.factory.config,
+ org.springframework.beans.factory.support,
+ org.springframework.beans.factory.xml,
+ org.springframework.context,
+ org.springframework.context.support,
+ org.springframework.core,
+ org.springframework.core.io,
+ org.springframework.util
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-tie/pom.xml b/sca-java-2.x/trunk/modules/implementation-spring-tie/pom.xml
index a30109d442..e8462997a4 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-tie/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-spring-tie/pom.xml
@@ -51,19 +51,19 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
- <version>3.0.2.RELEASE</version>
+ <version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
- <version>3.0.2.RELEASE</version>
+ <version>3.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
- <version>3.0.2.RELEASE</version>
+ <version>3.0.5.RELEASE</version>
</dependency>
</dependencies>
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/implementation-spring-webapp/META-INF/MANIFEST.MF
index 42c577b6eb..81841b38f7 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-webapp/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/META-INF/MANIFEST.MF
@@ -10,20 +10,25 @@ Bundle-SymbolicName: org.apache.tuscany.sca.implementation.spring.webapp
Bundle-DocURL: http://www.apache.org/
Bundle-RequiredExecutionEnvironment: J2SE-1.5,JavaSE-1.6
Import-Package: javax.servlet,
+ org.apache.tuscany.sca.context;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.extensibility;version="2.0.0",
+ org.apache.tuscany.sca.host.webapp;version="2.0.0",
org.apache.tuscany.sca.implementation.spring;version="2.0.0",
org.apache.tuscany.sca.implementation.spring.context;version="2.0.0",
+ org.apache.tuscany.sca.node;version="2.0.0",
org.apache.tuscany.sca.provider;version="2.0.0",
org.apache.tuscany.sca.runtime;version="2.0.0",
- org.springframework.beans;version="3.0.2.RELEASE",
- org.springframework.beans.factory;version="3.0.2.RELEASE",
- org.springframework.beans.factory.annotation;version="3.0.2.RELEASE",
- org.springframework.beans.factory.config;version="3.0.2.RELEASE",
- org.springframework.beans.factory.support;version="3.0.2.RELEASE",
- org.springframework.beans.factory.xml;version="3.0.2.RELEASE",
- org.springframework.context;version="3.0.2.RELEASE",
- org.springframework.context.support;version="3.0.2.RELEASE",
- org.springframework.core.io;version="3.0.2.RELEASE",
- org.springframework.util;version="3.0.2.RELEASE"
+ org.springframework.beans,
+ org.springframework.beans.factory,
+ org.springframework.beans.factory.annotation,
+ org.springframework.beans.factory.config,
+ org.springframework.beans.factory.support,
+ org.springframework.beans.factory.xml,
+ org.springframework.context,
+ org.springframework.context.support,
+ org.springframework.core.io,
+ org.springframework.util,
+ org.springframework.web.servlet;resolution:=optional
+
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/pom.xml b/sca-java-2.x/trunk/modules/implementation-spring-webapp/pom.xml
index 081af3c80d..0d593caa67 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-webapp/pom.xml
+++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/pom.xml
@@ -35,6 +35,18 @@
<artifactId>tuscany-implementation-spring-runtime</artifactId>
<version>2.0-SNAPSHOT</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-host-webapp</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-core-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
@@ -46,15 +58,21 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
- <version>3.0.2.RELEASE</version>
+ <version>3.0.5.RELEASE</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>3.0.5.RELEASE</version>
</dependency>
<dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <version>2.5</version>
- <type>jar</type>
- <scope>provided</scope>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <type>jar</type>
+ <scope>provided</scope>
</dependency>
</dependencies>
</project>
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/spring/TuscanyDispatcherServlet.java b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/spring/TuscanyDispatcherServlet.java
new file mode 100644
index 0000000000..4a615b9a3a
--- /dev/null
+++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/spring/TuscanyDispatcherServlet.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.host.webapp.spring;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+
+import org.apache.tuscany.sca.host.webapp.WebAppHelper;
+import org.apache.tuscany.sca.host.webapp.WebContextConfigurator;
+import org.springframework.web.servlet.DispatcherServlet;
+
+/**
+ * A Servlet that provides a hook to control the lifecycle of Tuscany node and extend Spring Web MVC's DispatcherServlet
+ *
+ * @version $Rev$ $Date$
+ */
+public class TuscanyDispatcherServlet extends DispatcherServlet {
+ private static final long serialVersionUID = 1L;
+ private Logger logger = Logger.getLogger(TuscanyDispatcherServlet.class.getName());
+
+ private transient WebContextConfigurator configurator;
+
+ public TuscanyDispatcherServlet() {
+ super();
+ }
+
+ @Override
+ public void init(ServletConfig config) throws ServletException {
+ try {
+ super.init(config);
+ WebAppHelper.init(WebAppHelper.getConfigurator(this));
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ configurator.getServletContext().log(e.getMessage(), e);
+ throw new ServletException(e);
+ }
+ }
+
+ public void destroy() {
+ WebAppHelper.stop(configurator);
+ super.destroy();
+ }
+
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java
index f95ba27242..d9596e3ecf 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-webapp/src/main/java/org/apache/tuscany/sca/implementation/spring/webapp/SpringWebApplicationContextAccessor.java
@@ -21,53 +21,42 @@ package org.apache.tuscany.sca.implementation.spring.webapp;
import java.util.logging.Logger;
+import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.host.http.ExtensibleServletHost;
import org.apache.tuscany.sca.implementation.spring.context.SpringApplicationContextAccessor;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
+import org.springframework.web.servlet.FrameworkServlet;
-public class SpringWebApplicationContextAccessor implements SpringApplicationContextAccessor, LifeCycleListener {
+public class SpringWebApplicationContextAccessor implements SpringApplicationContextAccessor {
private static Logger log = Logger.getLogger(SpringWebApplicationContextAccessor.class.getName());
- private ExtensionPointRegistry registry;
- private ApplicationContext parentApplicationContext;
public SpringWebApplicationContextAccessor(ExtensionPointRegistry registry) {
super();
- this.registry = registry;
}
- @Override
- public void start() {
- ExtensibleServletHost servletHost = ExtensibleServletHost.getInstance(registry);
-
- ServletContext servletContext = servletHost.getServletContext();
- if (servletContext != null) {
- parentApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
- if (parentApplicationContext != null) {
- log.info("Spring WebApplicationContext is now injected on Tuscany");
+ public ApplicationContext getParentApplicationContext(RuntimeComponent component) {
+ ApplicationContext context = null;
+ Servlet servlet = component.getComponentContext().getCompositeContext().getAttribute(Servlet.class.getName());
+ if (servlet instanceof FrameworkServlet) {
+ context = ((FrameworkServlet)servlet).getWebApplicationContext();
+ if (context != null) {
+ return context;
}
}
-
- if (parentApplicationContext == null) {
- parentApplicationContext = ApplicationContextAccessorBean.getInstance().getApplicationContext();
+ ServletContext servletContext =
+ component.getComponentContext().getCompositeContext().getAttribute(ServletContext.class.getName());
+ if (servletContext != null) {
+ context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
+ if (context == null) {
+ context = ApplicationContextAccessorBean.getInstance().getApplicationContext();
+ }
}
- }
-
- @Override
- public void stop() {
- parentApplicationContext = null;
- }
-
- public ApplicationContext getParentApplicationContext() {
- return parentApplicationContext;
- }
- public void setParentApplicationContext(ApplicationContext parentApplicationContext) {
- this.parentApplicationContext = parentApplicationContext;
+ return context;
}
}
diff --git a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
index 12c6994dda..ec9148483c 100644
--- a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
+++ b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/NodeConfiguration.java
@@ -24,6 +24,7 @@ import java.io.Reader;
import java.net.URI;
import java.net.URL;
import java.util.List;
+import java.util.Map;
import javax.xml.namespace.QName;
@@ -103,6 +104,24 @@ public interface NodeConfiguration {
NodeConfiguration addBinding(BindingConfiguration binding);
NodeConfiguration addBinding(QName bindingType, String...baseURIs);
NodeConfiguration addBinding(QName bindingType, URI...baseURIs);
-
+
List<Object> getExtensions();
+
+
+ /**
+ * Allow the hosting environment to pass in a map of attributes as context
+ * @param name The name of the attribute
+ * @param value The value of the attribute
+ * @return
+ */
+ Map<String, Object> getAttributes();
+
+ /**
+ * Configure an attribute
+ * @param name
+ * @param value
+ * @return
+ */
+ NodeConfiguration setAttribute(String name, Object value);
+
}
diff --git a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
index b4ec05cae5..f3853fc4bf 100644
--- a/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
+++ b/sca-java-2.x/trunk/modules/node-api/src/main/java/org/apache/tuscany/sca/node/configuration/impl/NodeConfigurationImpl.java
@@ -24,7 +24,9 @@ import java.io.Reader;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.xml.namespace.QName;
@@ -42,6 +44,8 @@ public class NodeConfigurationImpl implements NodeConfiguration {
private List<ContributionConfiguration> contributions = new ArrayList<ContributionConfiguration>();
private List<BindingConfiguration> bindings = new ArrayList<BindingConfiguration>();
private List<Object> extensions = new ArrayList<Object>();
+
+ private transient Map<String, Object> attributes = new HashMap<String, Object>();
public String getURI() {
return uri;
@@ -173,4 +177,13 @@ public class NodeConfigurationImpl implements NodeConfiguration {
return this;
}
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ public NodeConfiguration setAttribute(String name, Object value) {
+ attributes.put(name, value);
+ return this;
+ }
+
}
diff --git a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
index b0342ec37d..c32c1e0271 100644
--- a/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
+++ b/sca-java-2.x/trunk/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java
@@ -136,6 +136,8 @@ public class NodeImpl implements Node {
configuration.getDomainURI(),
configuration.getURI(),
nodeFactory.getDeployer().getSystemDefinitions());
+ // Pass down the context attributes
+ compositeContext.getAttributes().putAll(configuration.getAttributes());
}
} finally {