summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java54
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java5
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java55
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java5
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java (renamed from sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLLoaderTie.java)31
5 files changed, 32 insertions, 118 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java
deleted file mode 100644
index b087c45ab4..0000000000
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.implementation.spring.processor;
-
-import java.lang.reflect.Method;
-
-/**
- * This is the Spring runtime side stub for the corresponding Tuscany tie class.
- * It enables the Tuscany code to invoke methods on a Spring context without
- * needing to know about any Spring classes. See the ComponentTie class
- * in the implementation-spring module for what the tie does.
- */
-public class ComponentStub {
-
- private Object tie;
- private Method getService;
-
- public ComponentStub(Object tie) {
- this.tie = tie;
- Class<?> tieClass = tie.getClass();
- try {
- getService = tieClass.getMethod("getService", new Class<?>[] {Class.class, String.class});
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public Object getService(Class<?> type, String name) {
- try {
-
- return getService.invoke(tie, type, name);
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
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 565d0118d9..4763714a38 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
@@ -24,6 +24,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import org.apache.tuscany.sca.implementation.spring.provider.PropertyValueWrapper;
import org.oasisopen.sca.annotation.Property;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
@@ -36,9 +37,9 @@ public class PropertyAnnotationProcessor implements BeanPostProcessor {
private Class<? extends Annotation> propertyAnnotationType = Property.class;
- private PropertyValueStub propertyValue;
+ private PropertyValueWrapper propertyValue;
- public PropertyAnnotationProcessor(PropertyValueStub propertyValue) {
+ public PropertyAnnotationProcessor(PropertyValueWrapper propertyValue) {
this.propertyValue = propertyValue;
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java
deleted file mode 100644
index 9a95f818de..0000000000
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.implementation.spring.processor;
-
-import java.lang.reflect.Method;
-
-/**
- * This is the Spring runtime side stub for the corresponding Tuscany tie class.
- * It enables the Tuscany code to invoke methods on a Spring context without
- * needing to know about any Spring classes. See the PropertyValueTie class
- * in the implementation-spring module for what the tie does.
- */
-public class PropertyValueStub {
-
- private Object tie;
- private Method getPropertyObj;
-
- public PropertyValueStub(Object tie) {
- this.tie = tie;
- Class<?> tieClass = tie.getClass();
- try {
- getPropertyObj = tieClass.getMethod("getPropertyObj", new Class<?>[] {Class.class, String.class});
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public Object getPropertyObj(Class<?> propertyType, String name) {
- try {
-
- return getPropertyObj.invoke(tie, propertyType, name);
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
-}
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 280c723430..ad79db840e 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
@@ -24,6 +24,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import org.apache.tuscany.sca.implementation.spring.provider.ComponentWrapper;
import org.oasisopen.sca.annotation.Reference;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
@@ -35,9 +36,9 @@ import org.springframework.util.ReflectionUtils;
public class ReferenceAnnotationProcessor implements BeanPostProcessor {
private Class<? extends Annotation> referenceAnnotationType = Reference.class;
- private ComponentStub component;
+ private ComponentWrapper component;
- public ReferenceAnnotationProcessor(ComponentStub component) {
+ public ReferenceAnnotationProcessor(ComponentWrapper component) {
this.component = component;
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLLoaderTie.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java
index b3f0a4a883..71feddb9f5 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLLoaderTie.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/SpringXMLBeanDefinitionLoaderImpl.java
@@ -22,7 +22,13 @@ package org.apache.tuscany.sca.implementation.spring.processor;
import java.net.URL;
import java.util.List;
-import org.apache.tuscany.sca.implementation.spring.runtime.context.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
+import org.apache.tuscany.sca.implementation.spring.SpringBeanElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAPropertyElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAReferenceElement;
+import org.apache.tuscany.sca.implementation.spring.SpringSCAServiceElement;
+import org.apache.tuscany.sca.implementation.spring.context.SCAGenericApplicationContext;
+import org.apache.tuscany.sca.implementation.spring.xml.SpringXMLBeanDefinitionLoader;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.UrlResource;
@@ -30,11 +36,11 @@ import org.springframework.core.io.UrlResource;
/**
* A tie that allows Tuscany to call Spring library to load the application context for the purpose of introspection
*/
-public class SpringXMLLoaderTie {
+public class SpringXMLBeanDefinitionLoaderImpl implements SpringXMLBeanDefinitionLoader {
- public static ApplicationContext createApplicationContext(Object scaParentContext,
- ClassLoader classLoader,
- List<URL> resources) {
+ private static SCAGenericApplicationContext createApplicationContext(Object scaParentContext,
+ ClassLoader classLoader,
+ List<URL> resources) {
if (classLoader == null) {
classLoader = Thread.currentThread().getContextClassLoader();
}
@@ -54,4 +60,19 @@ public class SpringXMLLoaderTie {
}
+ @Override
+ public Object load(List<URL> resources,
+ List<SpringSCAServiceElement> serviceElements,
+ List<SpringSCAReferenceElement> referenceElements,
+ List<SpringSCAPropertyElement> propertyElements,
+ List<SpringBeanElement> beanElements,
+ ProcessorContext context) {
+ SCAGenericApplicationContext applicationContext = createApplicationContext(null, null, resources);
+ serviceElements.addAll(applicationContext.getServiceElements());
+ referenceElements.addAll(applicationContext.getReferenceElements());
+ propertyElements.addAll(applicationContext.getPropertyElements());
+ beanElements.addAll(applicationContext.getBeanElements());
+ return applicationContext;
+ }
+
}