summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-spring-runtime
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-07-28 21:01:41 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-07-28 21:01:41 +0000
commit9dafe3e2c4d2476cb3ea7789e3f3063418340059 (patch)
treefa543a6cc40ea6ec3ad43ee7f7bf0478685db344 /sca-java-2.x/trunk/modules/implementation-spring-runtime
parent83d18d1113e87315181b6d9f1daba6146ad12cc9 (diff)
Allow Spring WebApplicationContext to be used by Tuscany
Bring up a sample web application which demonstrates the integration between Spring and Tuscany git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@980218 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-spring-runtime')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java4
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java4
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java10
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java18
4 files changed, 32 insertions, 4 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
index 3e8bca229f..565d0118d9 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java
@@ -93,9 +93,11 @@ public class PropertyAnnotationProcessor implements BeanPostProcessor {
throw new IllegalStateException("Property annotation is not supported on static methods");
}
+ /*
if (Modifier.isPrivate(method.getModifiers())) {
throw new IllegalStateException("Property annotation is not supported on private methods");
}
+ */
if (method.getParameterTypes().length == 0) {
throw new IllegalStateException("Property annotation requires at least one argument: " + method);
@@ -124,9 +126,11 @@ public class PropertyAnnotationProcessor implements BeanPostProcessor {
throw new IllegalStateException("Property annotation is not supported on static fields");
}
+ /*
if (Modifier.isPrivate(field.getModifiers())) {
throw new IllegalStateException("Property annotation is not supported on private fields");
}
+ */
ReflectionUtils.makeAccessible(field);
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
index 6b86f0962e..280c723430 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java
@@ -92,9 +92,11 @@ public class ReferenceAnnotationProcessor implements BeanPostProcessor {
throw new IllegalStateException("Reference annotation is not supported on static methods");
}
+ /*
if (Modifier.isPrivate(method.getModifiers())) {
throw new IllegalStateException("Reference annotation is not supported on private methods");
}
+ */
if (method.getParameterTypes().length == 0) {
throw new IllegalStateException(
@@ -124,9 +126,11 @@ public class ReferenceAnnotationProcessor implements BeanPostProcessor {
throw new IllegalStateException("Reference annotation is not supported on static fields");
}
+ /*
if (Modifier.isPrivate(field.getModifiers())) {
throw new IllegalStateException("Reference annotation is not supported on private fields");
}
+ */
ReflectionUtils.makeAccessible(field);
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java
index 88be5b720f..5b4ef9e130 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java
@@ -110,10 +110,6 @@ class SCAParentApplicationContext implements ApplicationContext {
return EMPTY_ARRAY;
}
- public ApplicationContext getParent() {
- return null;
- }
-
public AutowireCapableBeanFactory getAutowireCapableBeanFactory() throws IllegalStateException {
return null;
}
@@ -199,4 +195,10 @@ class SCAParentApplicationContext implements ApplicationContext {
// resource loading mechanism is exposed right now.
return this.getClass().getClassLoader();
}
+
+ @Override
+ public ApplicationContext getParent() {
+ return implementation.getParentApplicationContext();
+ }
+
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java
index 298d8944fb..bf46765f13 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java
@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.context.ApplicationContext;
/**
* This is the runtime side stub for the corresponding Tuscany-side stub class.
@@ -40,6 +41,7 @@ public class SpringImplementationStub {
Method getComponentTie;
Method getPropertyValueTie;
Method getClassLoader;
+ Method getParentApplicationContext;
public SpringImplementationStub(Object tie) {
this.tie = tie;
@@ -51,6 +53,7 @@ public class SpringImplementationStub {
getComponentTie = tieClass.getMethod("getComponentTie");
getPropertyValueTie = tieClass.getMethod("getPropertyValueTie");
getClassLoader = tieClass.getMethod("getClassLoader");
+ getParentApplicationContext = tieClass.getMethod("getParentApplicationContext");
} catch (Exception e) {
throw new RuntimeException(e);
}
@@ -126,4 +129,19 @@ public class SpringImplementationStub {
throw new RuntimeException(e);
}
}
+
+ /**
+ * Get the parent Spring application context set by the Tuscany runtime
+ * @return
+ */
+ public ApplicationContext getParentApplicationContext() {
+ try {
+
+ return (ApplicationContext)getParentApplicationContext.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
}