summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules')
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java47
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentStub.java4
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java21
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyAnnotationProcessor.java48
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/PropertyValueStub.java4
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ReferenceAnnotationProcessor.java49
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java35
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAParentApplicationContext.java6
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java64
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringImplementationStub.java26
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java26
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java20
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java29
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java30
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java6
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java4
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java15
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java15
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java11
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java48
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java871
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java2
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java6
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java39
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java14
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java9
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java19
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java8
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java11
-rw-r--r--sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java63
30 files changed, 808 insertions, 742 deletions
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
index 7613f8166d..68d49bbc24 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ComponentNameAnnotationProcessor.java
@@ -36,13 +36,13 @@ import org.springframework.util.ReflectionUtils;
public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
private Class<? extends Annotation> componentNameAnnotationType = ComponentName.class;
-
+
private String componentName;
-
- public ComponentNameAnnotationProcessor (String componentName) {
+
+ public ComponentNameAnnotationProcessor(String componentName) {
this.componentName = componentName;
}
-
+
/**
* Gets componentName annotation type.
*/
@@ -63,8 +63,7 @@ public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
*/
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
processAnnotation(bean);
return bean;
}
@@ -74,8 +73,7 @@ public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@@ -83,7 +81,7 @@ public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
* <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
*/
protected void processAnnotation(final Object bean) {
-
+
final Class<?> clazz = bean.getClass();
ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
@@ -94,19 +92,20 @@ public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
if (Modifier.isStatic(field.getModifiers())) {
throw new IllegalStateException("ComponentName annotation is not supported on static fields");
}
-
+
if (Modifier.isPrivate(field.getModifiers())) {
throw new IllegalStateException("ComponentName annotation is not supported on private fields");
}
ReflectionUtils.makeAccessible(field);
-
+
if (field.getType().getName().equals("java.lang.String")) {
- Object nameObj = componentName;
+ Object nameObj = componentName;
if (nameObj != null)
ReflectionUtils.setField(field, bean, nameObj);
} else {
- throw new IllegalStateException("ComponentName annotation is supported only on java.lang.String field type.");
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
}
}
}
@@ -115,33 +114,35 @@ public class ComponentNameAnnotationProcessor implements BeanPostProcessor {
ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
public void doWith(Method method) {
Annotation annotation = method.getAnnotation(getComponentNameAnnotationType());
-
+
if (annotation != null) {
if (Modifier.isStatic(method.getModifiers())) {
throw new IllegalStateException("ComponentName annotation is not supported on static methods");
}
-
+
if (Modifier.isPrivate(method.getModifiers())) {
throw new IllegalStateException("ComponentName annotation is not supported on private methods");
}
if (method.getParameterTypes().length == 0) {
- throw new IllegalStateException("ComponentName annotation requires at least one argument: " + method);
+ throw new IllegalStateException(
+ "ComponentName annotation requires at least one argument: " + method);
}
-
- PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
-
+
+ PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
+
if (pd.getPropertyType().getName().equals("java.lang.String")) {
- Object nameObj = componentName;
+ Object nameObj = componentName;
if (nameObj != null) {
- try {
- pd.getWriteMethod().invoke(bean, new Object[] { nameObj });
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {nameObj});
} catch (Throwable e) {
throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
}
}
} else {
- throw new IllegalStateException("ComponentName annotation is supported only on java.lang.String field type.");
+ throw new IllegalStateException(
+ "ComponentName annotation is supported only on java.lang.String field type.");
}
}
}
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
index c72ccd6636..b087c45ab4 100644
--- 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
@@ -31,12 +31,12 @@ 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});
+ getService = tieClass.getMethod("getService", new Class<?>[] {Class.class, String.class});
} 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/ConstructorAnnotationProcessor.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
index 7eb63678f6..a52a85ff3a 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/processor/ConstructorAnnotationProcessor.java
@@ -28,15 +28,14 @@ import org.springframework.util.Assert;
public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostProcessorAdapter {
- private Class<? extends Annotation> constructorAnnotationType
- = org.oasisopen.sca.annotation.Constructor.class;
-
+ private Class<? extends Annotation> constructorAnnotationType = org.oasisopen.sca.annotation.Constructor.class;
+
private Class<? extends Annotation> autowiredAnnotationType = Autowired.class;
-
- public ConstructorAnnotationProcessor () {
+
+ public ConstructorAnnotationProcessor() {
// Default constructor.
}
-
+
/**
* Set the 'autowired' annotation type, to be used on constructors, fields,
* setter methods and arbitrary config methods.
@@ -52,7 +51,7 @@ public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostPr
protected Class<? extends Annotation> getAutowiredAnnotationType() {
return this.autowiredAnnotationType;
}
-
+
/**
* Return the 'constructor' annotation type.
*/
@@ -73,8 +72,7 @@ public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostPr
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
*/
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@@ -83,11 +81,10 @@ public class ConstructorAnnotationProcessor extends InstantiationAwareBeanPostPr
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
-
+
public Constructor[] determineCandidateConstructors(Class beanClass, String beanName) throws BeansException {
/*Constructor[] declaredConstructors = beanClass.getDeclaredConstructors();
Method[] declaredMethods = beanClass.getDeclaredMethods();
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 f800654c34..3e8bca229f 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
@@ -35,10 +35,10 @@ import org.springframework.util.ReflectionUtils;
public class PropertyAnnotationProcessor implements BeanPostProcessor {
private Class<? extends Annotation> propertyAnnotationType = Property.class;
-
+
private PropertyValueStub propertyValue;
-
- public PropertyAnnotationProcessor (PropertyValueStub propertyValue) {
+
+ public PropertyAnnotationProcessor(PropertyValueStub propertyValue) {
this.propertyValue = propertyValue;
}
@@ -62,8 +62,7 @@ public class PropertyAnnotationProcessor implements BeanPostProcessor {
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
*/
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
processAnnotation(bean);
return bean;
}
@@ -73,8 +72,7 @@ public class PropertyAnnotationProcessor implements BeanPostProcessor {
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@@ -82,19 +80,19 @@ public class PropertyAnnotationProcessor implements BeanPostProcessor {
* <p>Processes a beans fields for injection if it has a {@link Property} annotation.</p>
*/
protected void processAnnotation(final Object bean) {
-
- final Class<?> clazz = bean.getClass();
+
+ final Class<?> clazz = bean.getClass();
ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
public void doWith(Method method) {
- Property annotation = (Property) method.getAnnotation(getPropertyAnnotationType());
-
+ Property annotation = (Property)method.getAnnotation(getPropertyAnnotationType());
+
if (annotation != null) {
if (Modifier.isStatic(method.getModifiers())) {
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");
}
@@ -102,7 +100,7 @@ public class PropertyAnnotationProcessor implements BeanPostProcessor {
if (method.getParameterTypes().length == 0) {
throw new IllegalStateException("Property annotation requires at least one argument: " + method);
}
-
+
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
if (pd != null) {
String propName = annotation.name();
@@ -115,47 +113,47 @@ public class PropertyAnnotationProcessor implements BeanPostProcessor {
}
}
});
-
+
ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
public void doWith(Field field) {
- Property annotation = (Property) field.getAnnotation(getPropertyAnnotationType());
-
+ Property annotation = (Property)field.getAnnotation(getPropertyAnnotationType());
+
if (annotation != null) {
if (Modifier.isStatic(field.getModifiers())) {
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);
-
+
Object propertyObj = null;
String propName = annotation.name();
if ("".equals(propName)) {
- propertyObj = propertyValue.getPropertyObj(field.getType(), field.getName());
+ propertyObj = propertyValue.getPropertyObj(field.getType(), field.getName());
} else {
propertyObj = propertyValue.getPropertyObj(field.getType(), propName);
}
-
+
if (propertyObj != null)
ReflectionUtils.setField(field, bean, propertyObj);
}
}
});
}
-
+
public void injectProperty(Object bean, PropertyDescriptor pd, Object propertyObj) {
-
+
if (propertyObj != null) {
- try {
- pd.getWriteMethod().invoke(bean, new Object[] { propertyObj });
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {propertyObj});
} catch (Throwable e) {
throw new FatalBeanException("Problem injecting property: " + e.getMessage(), e);
}
}
}
-
+
}
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
index ea8f560ae1..9a95f818de 100644
--- 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
@@ -31,12 +31,12 @@ 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});
+ getPropertyObj = tieClass.getMethod("getPropertyObj", new Class<?>[] {Class.class, String.class});
} 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 dd43d63d97..6b86f0962e 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
@@ -36,11 +36,11 @@ public class ReferenceAnnotationProcessor implements BeanPostProcessor {
private Class<? extends Annotation> referenceAnnotationType = Reference.class;
private ComponentStub component;
-
- public ReferenceAnnotationProcessor (ComponentStub component) {
+
+ public ReferenceAnnotationProcessor(ComponentStub component) {
this.component = component;
}
-
+
/**
* Gets referece annotation type.
*/
@@ -61,8 +61,7 @@ public class ReferenceAnnotationProcessor implements BeanPostProcessor {
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object, java.lang.String)
*/
- public Object postProcessBeforeInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
processAnnotation(bean);
return bean;
}
@@ -72,8 +71,7 @@ public class ReferenceAnnotationProcessor implements BeanPostProcessor {
*
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
- public Object postProcessAfterInitialization(Object bean, String beanName)
- throws BeansException {
+ public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@@ -81,27 +79,28 @@ public class ReferenceAnnotationProcessor implements BeanPostProcessor {
* <p>Processes a beans fields for injection if it has a {@link Reference} annotation.</p>
*/
protected void processAnnotation(final Object bean) {
-
- final Class<?> clazz = bean.getClass();
+
+ final Class<?> clazz = bean.getClass();
ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
public void doWith(Method method) {
- Reference annotation = (Reference) method.getAnnotation(getReferenceAnnotationType());
-
+ Reference annotation = (Reference)method.getAnnotation(getReferenceAnnotationType());
+
if (annotation != null) {
if (Modifier.isStatic(method.getModifiers())) {
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("Reference annotation requires at least one argument: " + method);
+ throw new IllegalStateException(
+ "Reference annotation requires at least one argument: " + method);
}
-
+
PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
if (pd != null) {
String refName = annotation.name();
@@ -114,31 +113,31 @@ public class ReferenceAnnotationProcessor implements BeanPostProcessor {
}
}
});
-
+
ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
public void doWith(Field field) {
- Reference annotation = (Reference) field.getAnnotation(getReferenceAnnotationType());
-
+ Reference annotation = (Reference)field.getAnnotation(getReferenceAnnotationType());
+
if (annotation != null) {
if (Modifier.isStatic(field.getModifiers())) {
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);
-
+
Object referenceObj = null;
String refName = annotation.name();
if ("".equals(refName)) {
referenceObj = component.getService(field.getType(), field.getName());
} else {
referenceObj = component.getService(field.getType(), refName);
- }
-
+ }
+
if (referenceObj != null)
ReflectionUtils.setField(field, bean, referenceObj);
}
@@ -150,12 +149,12 @@ public class ReferenceAnnotationProcessor implements BeanPostProcessor {
* Processes a property descriptor to inject a service.
*/
public void injectReference(Object bean, PropertyDescriptor pd, String name) {
-
+
Object referenceObj = component.getService(pd.getPropertyType(), name);
-
+
if (referenceObj != null) {
- try {
- pd.getWriteMethod().invoke(bean, new Object[] { referenceObj });
+ try {
+ pd.getWriteMethod().invoke(bean, new Object[] {referenceObj});
} catch (Throwable e) {
throw new FatalBeanException("Problem injecting reference: " + e.getMessage(), e);
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java
index 6426306f26..3e0aacdb40 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SCAGenericApplicationContext.java
@@ -25,23 +25,22 @@ import org.springframework.context.support.GenericApplicationContext;
public class SCAGenericApplicationContext extends GenericApplicationContext {
- ClassLoader classloader = null;
-
- public SCAGenericApplicationContext(DefaultListableBeanFactory beanFactory,
- ApplicationContext parent,
- ClassLoader classloader) {
- super(beanFactory, parent);
- this.classloader = classloader;
- }
-
- public SCAGenericApplicationContext(ApplicationContext parent,
- ClassLoader classloader) {
- super(parent);
- this.classloader = classloader;
- }
+ ClassLoader classloader = null;
- @Override
- protected void postProcessBeanFactory (ConfigurableListableBeanFactory beanFactory) {
- beanFactory.setBeanClassLoader(classloader);
- }
+ public SCAGenericApplicationContext(DefaultListableBeanFactory beanFactory,
+ ApplicationContext parent,
+ ClassLoader classloader) {
+ super(beanFactory, parent);
+ this.classloader = classloader;
+ }
+
+ public SCAGenericApplicationContext(ApplicationContext parent, ClassLoader classloader) {
+ super(parent);
+ this.classloader = classloader;
+ }
+
+ @Override
+ protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
+ beanFactory.setBeanClassLoader(classloader);
+ }
}
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 36f1f6d761..88be5b720f 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
@@ -58,7 +58,7 @@ class SCAParentApplicationContext implements ApplicationContext {
} // end constructor
public Object getBean(String name) throws BeansException {
- return getBean(name, (Class) null);
+ return getBean(name, (Class)null);
}
/**
@@ -73,7 +73,7 @@ class SCAParentApplicationContext implements ApplicationContext {
} // end method getBean( String, Class )
public Object getBean(String name, Object[] args) throws BeansException {
- return getBean(name, ((Class)null));
+ return getBean(name, ((Class)null));
}
public <T> T getBean(Class<T> clazz) throws BeansException {
@@ -119,7 +119,7 @@ class SCAParentApplicationContext implements ApplicationContext {
}
public String getId() {
- return this.toString();
+ return this.toString();
}
public String getDisplayName() {
diff --git a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
index 77681b600f..d5a330c916 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring-runtime/src/main/java/org/apache/tuscany/sca/implementation/spring/runtime/context/SpringContextTie.java
@@ -32,8 +32,8 @@ import org.apache.tuscany.sca.implementation.spring.processor.ReferenceAnnotatio
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
-import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.io.UrlResource;
@@ -48,11 +48,11 @@ public class SpringContextTie {
private AbstractApplicationContext springContext;
private SpringImplementationStub implementation;
-
+
public SpringContextTie(SpringImplementationStub implementation, List<URL> resource) {
this.implementation = implementation;
SCAParentApplicationContext scaParentContext = new SCAParentApplicationContext(implementation);
- springContext = createApplicationContext(scaParentContext, resource);
+ springContext = createApplicationContext(scaParentContext, resource);
}
public void start() {
@@ -71,30 +71,29 @@ public class SpringContextTie {
/**
* Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
*/
- private AbstractApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext, List<URL> resources) {
-
- XmlBeanFactory beanFactory = null;
- AbstractApplicationContext appContext = null;
-
- if (resources.size() > 1) {
- GenericApplicationContext appCtx =
- new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader());
- XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
- for (URL resource : resources) {
- xmlReader.loadBeanDefinitions(new UrlResource(resource));
- }
- xmlReader.setBeanClassLoader(implementation.getClassLoader());
- includeAnnotationProcessors(appCtx.getBeanFactory());
- return appCtx;
- }
-
- // use the generic application context as default
- beanFactory = new XmlBeanFactory(new UrlResource(resources.get(0)));
+ private AbstractApplicationContext createApplicationContext(SCAParentApplicationContext scaParentContext,
+ List<URL> resources) {
+
+ XmlBeanFactory beanFactory = null;
+ AbstractApplicationContext appContext = null;
+
+ if (resources.size() > 1) {
+ GenericApplicationContext appCtx =
+ new SCAGenericApplicationContext(scaParentContext, implementation.getClassLoader());
+ XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(appCtx);
+ for (URL resource : resources) {
+ xmlReader.loadBeanDefinitions(new UrlResource(resource));
+ }
+ xmlReader.setBeanClassLoader(implementation.getClassLoader());
+ includeAnnotationProcessors(appCtx.getBeanFactory());
+ return appCtx;
+ }
+
+ // use the generic application context as default
+ beanFactory = new XmlBeanFactory(new UrlResource(resources.get(0)));
beanFactory.setBeanClassLoader(implementation.getClassLoader());
includeAnnotationProcessors(beanFactory);
- appContext = new SCAGenericApplicationContext(beanFactory,
- scaParentContext,
- implementation.getClassLoader());
+ appContext = new SCAGenericApplicationContext(beanFactory, scaParentContext, implementation.getClassLoader());
return appContext;
}
@@ -106,7 +105,7 @@ public class SpringContextTie {
* Include BeanPostProcessor to deal with SCA Annotations in Spring Bean
*/
private void includeAnnotationProcessors(ConfigurableListableBeanFactory beanFactory) {
-
+
// Processor to deal with @Init and @Destroy SCA Annotations
BeanPostProcessor initDestroyProcessor = new InitDestroyAnnotationProcessor();
beanFactory.addBeanPostProcessor(initDestroyProcessor);
@@ -115,19 +114,20 @@ public class SpringContextTie {
ComponentStub component = new ComponentStub(implementation.getComponentTie());
BeanPostProcessor referenceProcessor = new ReferenceAnnotationProcessor(component);
beanFactory.addBeanPostProcessor(referenceProcessor);
-
+
// Processor to deal with @Property SCA Annotations
PropertyValueStub pvs = new PropertyValueStub(implementation.getPropertyValueTie());
BeanPostProcessor propertyProcessor = new PropertyAnnotationProcessor(pvs);
beanFactory.addBeanPostProcessor(propertyProcessor);
-
+
// Processor to deal with @ComponentName SCA Annotations
- BeanPostProcessor componentNameProcessor = new ComponentNameAnnotationProcessor(implementation.getComponentName());
+ BeanPostProcessor componentNameProcessor =
+ new ComponentNameAnnotationProcessor(implementation.getComponentName());
beanFactory.addBeanPostProcessor(componentNameProcessor);
-
+
// Processor to deal with @Constructor SCA Annotations
BeanPostProcessor constructorProcessor = new ConstructorAnnotationProcessor();
- beanFactory.addBeanPostProcessor(constructorProcessor);
+ beanFactory.addBeanPostProcessor(constructorProcessor);
}
-} \ No newline at end of file
+}
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 af39869522..298d8944fb 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
@@ -40,13 +40,13 @@ public class SpringImplementationStub {
Method getComponentTie;
Method getPropertyValueTie;
Method getClassLoader;
-
+
public SpringImplementationStub(Object tie) {
this.tie = tie;
Class<?> tieClass = tie.getClass();
try {
- getURI = tieClass.getMethod("getURI", new Class<?>[]{});
- getBean = tieClass.getMethod("getBean", new Class<?>[]{String.class, Class.class});
+ getURI = tieClass.getMethod("getURI", new Class<?>[] {});
+ getBean = tieClass.getMethod("getBean", new Class<?>[] {String.class, Class.class});
getComponentName = tieClass.getMethod("getComponentName");
getComponentTie = tieClass.getMethod("getComponentTie");
getPropertyValueTie = tieClass.getMethod("getPropertyValueTie");
@@ -55,7 +55,7 @@ public class SpringImplementationStub {
throw new RuntimeException(e);
}
}
-
+
public String getURI() {
try {
@@ -116,14 +116,14 @@ public class SpringImplementationStub {
throw new RuntimeException(e);
}
}
-
+
public ClassLoader getClassLoader() {
- try {
-
- return (ClassLoader) getClassLoader.invoke(tie);
-
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
+ try {
+
+ return (ClassLoader)getClassLoader.invoke(tie);
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
}
-} \ No newline at end of file
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java
index f64c5f9476..fd6aed893c 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringBeanElement.java
@@ -37,7 +37,7 @@ public class SpringBeanElement {
private boolean parentAttribute = false;
private boolean factoryBeanAttribute = false;
private boolean factoryMethodAttribute = false;
-
+
private List<SpringPropertyElement> properties = new ArrayList<SpringPropertyElement>();
private List<SpringConstructorArgElement> constructorargs = new ArrayList<SpringConstructorArgElement>();
@@ -53,7 +53,7 @@ public class SpringBeanElement {
public String getId() {
return id;
}
-
+
public void setId(String id) {
this.id = id;
}
@@ -65,7 +65,7 @@ public class SpringBeanElement {
public void addProperty(SpringPropertyElement property) {
properties.add(property);
}
-
+
public List<SpringConstructorArgElement> getCustructorArgs() {
return constructorargs;
}
@@ -73,43 +73,43 @@ public class SpringBeanElement {
public void addCustructorArgs(SpringConstructorArgElement args) {
constructorargs.add(args);
}
-
+
public boolean isInnerBean() {
return innerBean;
}
-
+
public void setInnerBean(boolean innerBean) {
this.innerBean = innerBean;
}
-
+
public boolean isAbstractBean() {
return abstractBean;
}
-
+
public void setAbstractBean(boolean abstractBean) {
this.abstractBean = abstractBean;
}
-
+
public boolean hasParentAttribute() {
return parentAttribute;
}
-
+
public void setParentAttribute(boolean parentAttribute) {
this.parentAttribute = parentAttribute;
}
-
+
public boolean hasFactoryBeanAttribute() {
return factoryBeanAttribute;
}
-
+
public void setFactoryBeanAttribute(boolean factoryBeanAttribute) {
this.factoryBeanAttribute = factoryBeanAttribute;
}
-
+
public boolean hasFactoryMethodAttribute() {
return factoryMethodAttribute;
}
-
+
public void setFactoryMethodAttribute(boolean factoryMethodAttribute) {
this.factoryMethodAttribute = factoryMethodAttribute;
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java
index 9ae1273592..5674c26ba3 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringConstructorArgElement.java
@@ -28,8 +28,8 @@ import java.util.List;
* @version $Rev$ $Date$
*/
public class SpringConstructorArgElement {
-
- private String type;
+
+ private String type;
private int autoIndex = -1;
private int index = -1;
private List<String> refs = new ArrayList<String>();
@@ -38,35 +38,35 @@ public class SpringConstructorArgElement {
public SpringConstructorArgElement(String type) {
this.type = type;
}
-
+
public String getType() {
return this.type;
}
-
+
public List<String> getRefs() {
return this.refs;
}
-
+
public void addRef(String ref) {
this.refs.add(ref);
}
-
+
public int getIndex() {
return this.index;
}
-
+
public void setIndex(int index) {
this.index = index;
}
-
+
public int getAutoIndex() {
return this.autoIndex;
}
-
+
public void setAutoIndex(int index) {
this.autoIndex = index;
}
-
+
public List<String> getValues() {
return this.values;
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
index 7a73f79a45..6cefaae73f 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementation.java
@@ -35,7 +35,6 @@ import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
/**
* Represents a Spring implementation.
*
@@ -168,7 +167,6 @@ public class SpringImplementation extends ImplementationImpl implements Implemen
return unresolvedBeanRef.get(refName);
} // end method getUnresolvedBeanRef
-
/**
* Use preProcess to validate and map the references and properties dynamically
*/
@@ -176,22 +174,21 @@ public class SpringImplementation extends ImplementationImpl implements Implemen
if (!(component instanceof RuntimeComponent))
return;
- RuntimeComponent rtc = (RuntimeComponent) component;
+ RuntimeComponent rtc = (RuntimeComponent)component;
for (Reference reference : rtc.getReferences()) {
if (unresolvedBeanRef.containsKey(reference.getName())) {
- Reference ref = unresolvedBeanRef.get(reference.getName());
- componentType.getReferences().add(
- createReference(reference, ref.getInterfaceContract()));
- unresolvedBeanRef.remove(reference.getName());
+ Reference ref = unresolvedBeanRef.get(reference.getName());
+ componentType.getReferences().add(createReference(reference, ref.getInterfaceContract()));
+ unresolvedBeanRef.remove(reference.getName());
}
}
for (Property property : rtc.getProperties()) {
- if (unresolvedBeanRef.containsKey(property.getName())) {
- componentType.getProperties().add(createProperty(property));
- this.setPropertyClass(property.getName(), property.getClass());
- unresolvedBeanRef.remove(property.getName());
+ if (unresolvedBeanRef.containsKey(property.getName())) {
+ componentType.getProperties().add(createProperty(property));
+ this.setPropertyClass(property.getName(), property.getClass());
+ unresolvedBeanRef.remove(property.getName());
}
}
}
@@ -201,7 +198,7 @@ public class SpringImplementation extends ImplementationImpl implements Implemen
try {
newReference = (Reference)reference.clone();
if (newReference.getInterfaceContract() == null)
- newReference.setInterfaceContract(interfaze);
+ newReference.setInterfaceContract(interfaze);
} catch (CloneNotSupportedException e) {
throw new AssertionError(e); // should not ever happen
}
@@ -217,13 +214,13 @@ public class SpringImplementation extends ImplementationImpl implements Implemen
}
return newProperty;
}
-
+
public ClassLoader getClassLoader() {
- return classLoader;
+ return classLoader;
}
public void setClassLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
+ this.classLoader = classLoader;
}
@Override
@@ -255,4 +252,4 @@ public class SpringImplementation extends ImplementationImpl implements Implemen
}
return true;
}
-} \ No newline at end of file
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java
index caae72fa90..27c09c1f18 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringImplementationConstants.java
@@ -25,47 +25,47 @@ import javax.xml.namespace.QName;
* Constants used in Spring Application Context XML files.
*/
public interface SpringImplementationConstants {
-
+
String SCA_NS = "http://www.springframework.org/schema/sca";
String SPRING_NS = "http://www.springframework.org/schema/beans";
-
+
String PROPERTY = "property";
QName SCA_PROPERTY_ELEMENT = new QName(SCA_NS, PROPERTY);
QName PROPERTY_ELEMENT = new QName(SPRING_NS, PROPERTY);
-
+
String SCASERVICE = "service";
QName SCA_SERVICE_ELEMENT = new QName(SCA_NS, SCASERVICE);
-
+
String SCAREFERENCE = "reference";
QName SCA_REFERENCE_ELEMENT = new QName(SCA_NS, SCAREFERENCE);
-
+
String BEANS = "beans";
QName BEANS_ELEMENT = new QName(SPRING_NS, BEANS);
-
+
String IMPORT = "import";
QName IMPORT_ELEMENT = new QName(SPRING_NS, IMPORT);
-
+
String BEAN = "bean";
QName BEAN_ELEMENT = new QName(SPRING_NS, BEAN);
-
+
String CONSTRUCTORARG = "constructor-arg";
QName CONSTRUCTORARG_ELEMENT = new QName(SPRING_NS, CONSTRUCTORARG);
-
+
String LIST = "list";
- QName LIST_ELEMENT = new QName(SPRING_NS, LIST);
-
+ QName LIST_ELEMENT = new QName(SPRING_NS, LIST);
+
String SET = "set";
QName SET_ELEMENT = new QName(SPRING_NS, SET);
-
+
String MAP = "map";
QName MAP_ELEMENT = new QName(SPRING_NS, MAP);
-
+
String VALUE = "value";
QName VALUE_ELEMENT = new QName(SPRING_NS, VALUE);
-
+
String REF = "ref";
QName REF_ELEMENT = new QName(SPRING_NS, REF);
-
+
String ENTRY = "entry";
QName ENTRY_ELEMENT = new QName(SPRING_NS, ENTRY);
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java
index 37b8ef37a6..030364d9a0 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringPropertyElement.java
@@ -44,11 +44,11 @@ public class SpringPropertyElement {
public List<String> getRefs() {
return this.refs;
}
-
+
public void addRef(String ref) {
this.refs.add(ref);
}
-
+
public List<String> getValues() {
return this.values;
}
@@ -56,5 +56,5 @@ public class SpringPropertyElement {
public void addValue(String value) {
this.values.add(value);
}
-
+
} // end class SpringPropertyElement
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java
index b192580a78..5b17d2f7d0 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAPropertyElement.java
@@ -32,7 +32,7 @@ public class SpringSCAPropertyElement {
this.name = name;
this.type = type;
}
-
+
public void setName(String name) {
this.name = name;
}
@@ -40,7 +40,7 @@ public class SpringSCAPropertyElement {
public String getName() {
return name;
}
-
+
public void setType(String type) {
this.type = type;
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
index bc010229ad..a18758a1fa 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAReferenceElement.java
@@ -20,6 +20,7 @@ package org.apache.tuscany.sca.implementation.spring;
import java.util.ArrayList;
import java.util.List;
+
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -42,7 +43,7 @@ public class SpringSCAReferenceElement {
this.name = name;
this.type = type;
}
-
+
public void setName(String name) {
this.name = name;
}
@@ -50,7 +51,7 @@ public class SpringSCAReferenceElement {
public String getName() {
return name;
}
-
+
public void setType(String type) {
this.type = type;
}
@@ -58,7 +59,7 @@ public class SpringSCAReferenceElement {
public String getType() {
return type;
}
-
+
public void setDefaultBean(String defaultBean) {
this.defaultBean = defaultBean;
}
@@ -66,13 +67,13 @@ public class SpringSCAReferenceElement {
public String getDefaultBean() {
return defaultBean;
}
-
+
public List<Intent> getRequiredIntents() {
return intents;
}
-
- public List<PolicySet> getPolicySets() {
- return policySets;
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
}
} // end class SpringSCAReferenceElement
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
index dbddc00b33..ef4bd3bfdf 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/SpringSCAServiceElement.java
@@ -20,6 +20,7 @@ package org.apache.tuscany.sca.implementation.spring;
import java.util.ArrayList;
import java.util.List;
+
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -42,7 +43,7 @@ public class SpringSCAServiceElement {
this.name = name;
this.target = target;
}
-
+
public void setName(String name) {
this.name = name;
}
@@ -50,7 +51,7 @@ public class SpringSCAServiceElement {
public String getName() {
return name;
}
-
+
public void setType(String type) {
this.type = type;
}
@@ -58,7 +59,7 @@ public class SpringSCAServiceElement {
public String getType() {
return type;
}
-
+
public void setTarget(String target) {
this.target = target;
}
@@ -66,13 +67,13 @@ public class SpringSCAServiceElement {
public String getTarget() {
return target;
}
-
+
public List<Intent> getRequiredIntents() {
return intents;
}
-
- public List<PolicySet> getPolicySets() {
- return policySets;
+
+ public List<PolicySet> getPolicySets() {
+ return policySets;
}
} // end class SpringSCAServiceElement
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
index 3aa257686d..0d446a9fa7 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
@@ -47,8 +47,7 @@ public class SpringBeanIntrospector {
* @param javaFactory The Java Interface Factory to use
* @param policyFactory The Policy Factory to use.
*/
- public SpringBeanIntrospector(ExtensionPointRegistry registry,
- List<SpringConstructorArgElement> conArgs) {
+ public SpringBeanIntrospector(ExtensionPointRegistry registry, List<SpringConstructorArgElement> conArgs) {
FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
javaImplementationFactory = factories.getFactory(JavaImplementationFactory.class);
@@ -64,8 +63,8 @@ public class SpringBeanIntrospector {
* Spring Bean or its componentType
*
*/
- public JavaImplementation introspectBean(Class<?> beanClass, ComponentType componentType) throws ContributionResolveException
- {
+ public JavaImplementation introspectBean(Class<?> beanClass, ComponentType componentType)
+ throws ContributionResolveException {
if (componentType == null)
throw new ContributionResolveException("Introspect Spring bean: supplied componentType is null");
@@ -81,7 +80,7 @@ public class SpringBeanIntrospector {
componentType.getServices().addAll(javaImplementation.getServices());
componentType.getReferences().addAll(javaImplementation.getReferences());
componentType.getProperties().addAll(javaImplementation.getProperties());
-
+
} catch (IntrospectionException e) {
throw new ContributionResolveException(e);
} // end try
@@ -91,7 +90,7 @@ public class SpringBeanIntrospector {
String name = service.getName();
System.out.println("Spring Bean: found service with name: " + name);
} // end for */
-
+
return javaImplementation;
} // end method introspectBean
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
index 3a8eec99fa..985b127adf 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
@@ -83,12 +83,14 @@ import org.oasisopen.sca.annotation.Remotable;
public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
private List<SpringConstructorArgElement> conArgs;
- public SpringBeanPojoProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory, List<SpringConstructorArgElement> conArgs) {
+ public SpringBeanPojoProcessor(AssemblyFactory assemblyFactory,
+ JavaInterfaceFactory javaFactory,
+ List<SpringConstructorArgElement> conArgs) {
super(assemblyFactory);
this.javaInterfaceFactory = javaFactory;
this.conArgs = conArgs;
}
-
+
public SpringBeanPojoProcessor(ExtensionPointRegistry registry) {
super(registry);
}
@@ -245,7 +247,7 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
}
}
}
-
+
// Private fields unless there is a public or protected
// setter method for the same name
Set<Field> privateFields = getPrivateFields(clazz);
@@ -287,7 +289,7 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
// determine constructor if one is not annotated
JavaConstructorImpl<?> definition = type.getConstructor();
Map<String, JavaElementImpl> props = type.getPropertyMembers();
- Map<String, JavaElementImpl> refs = type.getReferenceMembers();
+ Map<String, JavaElementImpl> refs = type.getReferenceMembers();
Constructor constructor;
boolean explict = false;
if (definition != null && definition.getConstructor()
@@ -307,24 +309,24 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
constructor = constructors[0];
} else {
// multiple constructors scenario
- Constructor<T> selected = null;
+ Constructor<T> selected = null;
for (Constructor<T> ctor : constructors) {
if (ctor.getParameterTypes().length == 0) {
selected = ctor;
} else if (ctor.getParameterTypes().length == conArgs.size()) {
// we will find a constructor which has atleast one
- // reference or property as its parameter types.
- Class<?>[] parametersTypes = ctor.getParameterTypes();
- for (Class<?> pType: parametersTypes) {
- for (JavaElementImpl property : props.values()) {
- if (pType.equals(property.getType()))
- selected = ctor;
- }
- for (JavaElementImpl reference : refs.values()) {
- if (pType.equals(reference.getType()))
- selected = ctor;
- }
- }
+ // reference or property as its parameter types.
+ Class<?>[] parametersTypes = ctor.getParameterTypes();
+ for (Class<?> pType : parametersTypes) {
+ for (JavaElementImpl property : props.values()) {
+ if (pType.equals(property.getType()))
+ selected = ctor;
+ }
+ for (JavaElementImpl reference : refs.values()) {
+ if (pType.equals(reference.getType()))
+ selected = ctor;
+ }
+ }
}
}
if (selected == null) {
@@ -335,12 +337,12 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
definition = type.getConstructors().get(constructor);
type.setConstructor(definition);
}
-
+
JavaParameterImpl[] parameters = definition.getParameters();
if (parameters.length == 0) {
return;
}
-
+
Annotation[][] annotations = constructor.getParameterAnnotations();
if (!explict) {
// the constructor wasn't defined by an annotation, so check to see
@@ -592,7 +594,8 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(paramType);
reference.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ JavaInterface callbackInterface =
+ javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
reference.getInterfaceContract().setCallbackInterface(callbackInterface);
}
reference.setMultiplicity(Multiplicity.ZERO_ONE);
@@ -619,7 +622,8 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
service.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
+ JavaInterface callbackInterface =
+ javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
service.getInterfaceContract().setCallbackInterface(callbackInterface);
}
@@ -638,7 +642,7 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
javaInterface = javaInterfaceFactory.createJavaInterface(callbackClass);
contract.getInterfaceContract().setCallbackInterface(javaInterface);
} catch (InvalidInterfaceException e) {
- throw new InvalidServiceTypeException("Invalid callback interface "+callbackClass, interfaze);
+ throw new InvalidServiceTypeException("Invalid callback interface " + callbackClass, interfaze);
}
} else if (callback != null && Void.class.equals(callback.value())) {
throw new InvalidServiceTypeException("No callback interface specified on annotation", interfaze);
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
index bd3134c5f2..28506a7141 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
@@ -100,8 +100,7 @@ public class SpringXMLComponentTypeLoader {
private Monitor monitor;
private SpringBeanIntrospector beanIntrospector;
- public SpringXMLComponentTypeLoader(ExtensionPointRegistry registry,
- Monitor monitor) {
+ public SpringXMLComponentTypeLoader(ExtensionPointRegistry registry, Monitor monitor) {
super();
this.registry = registry;
FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
@@ -113,7 +112,7 @@ public class SpringXMLComponentTypeLoader {
this.xmlInputFactory = factories.getFactory(XMLInputFactory.class);
this.monitor = monitor;
}
-
+
/**
* Report a exception.
*
@@ -122,10 +121,16 @@ public class SpringXMLComponentTypeLoader {
* @param model
*/
private void error(String message, Object model, Exception ex) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "impl-spring-validation-messages", Severity.ERROR, model, message, ex);
- monitor.problem(problem);
- }
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
}
/**
@@ -136,10 +141,16 @@ public class SpringXMLComponentTypeLoader {
* @param model
*/
private void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "impl-spring-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
}
protected Class<SpringImplementation> getImplementationClass() {
@@ -151,9 +162,10 @@ public class SpringXMLComponentTypeLoader {
* Spring implementation
*
*/
- public void load(SpringImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionReadException {
+ public void load(SpringImplementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionReadException {
//System.out.println("Spring TypeLoader - load method start");
- ComponentType componentType = implementation.getComponentType();
+ ComponentType componentType = implementation.getComponentType();
/* Check that there is a component type object already set */
if (componentType == null) {
throw new ContributionReadException("SpringXMLLoader load: implementation has no ComponentType object");
@@ -164,10 +176,11 @@ public class SpringXMLComponentTypeLoader {
if (!componentType.isUnresolved())
implementation.setUnresolved(false);
} // end if
- //System.out.println("Spring TypeLoader - load method complete");
+ //System.out.println("Spring TypeLoader - load method complete");
} // end method load
- private Class<?> resolveClass(ModelResolver resolver, String className, ProcessorContext context) throws ClassNotFoundException {
+ private Class<?> resolveClass(ModelResolver resolver, String className, ProcessorContext context)
+ throws ClassNotFoundException {
ClassReference classReference = new ClassReference(className);
classReference = resolver.resolveModel(ClassReference.class, classReference, context);
if (classReference.isUnresolved()) {
@@ -184,7 +197,8 @@ public class SpringXMLComponentTypeLoader {
* @param implementation SpringImplementation into which to load the component type information
* @throws ContributionReadException Failed to read the contribution
*/
- private void loadFromXML(SpringImplementation implementation, ModelResolver resolver, ProcessorContext context) throws ContributionReadException {
+ private void loadFromXML(SpringImplementation implementation, ModelResolver resolver, ProcessorContext context)
+ throws ContributionReadException {
XMLStreamReader reader;
List<SpringBeanElement> beans = new ArrayList<SpringBeanElement>();
List<SpringSCAServiceElement> services = new ArrayList<SpringSCAServiceElement>();
@@ -195,31 +209,38 @@ public class SpringXMLComponentTypeLoader {
List<URL> contextResources = new ArrayList<URL>();
String contextPath = implementation.getLocation();
- try {
+ try {
resource = resolveLocation(resolver, contextPath, context);
contextResources = getApplicationContextResource(resource);
-
+
implementation.setClassLoader(new ContextClassLoader(resolver, context));
implementation.setResource(contextResources);
// The URI is used to uniquely identify the Implementation
implementation.setURI(resource.toString());
-
- for (URL contextResource : contextResources) {
- List<SpringBeanElement> appCxtBeans = new ArrayList<SpringBeanElement>();
+
+ for (URL contextResource : contextResources) {
+ List<SpringBeanElement> appCxtBeans = new ArrayList<SpringBeanElement>();
List<SpringSCAServiceElement> appCxtServices = new ArrayList<SpringSCAServiceElement>();
List<SpringSCAReferenceElement> appCxtReferences = new ArrayList<SpringSCAReferenceElement>();
List<SpringSCAPropertyElement> appCxtProperties = new ArrayList<SpringSCAPropertyElement>();
- reader = xmlInputFactory.createXMLStreamReader(contextResource.openStream());
- // Read the beans, services, references and properties for individual application context
- readContextDefinition(resolver, reader, contextPath, appCxtBeans, appCxtServices, appCxtReferences, appCxtProperties, context);
- // Validate the beans from individual application context for uniqueness
- validateBeans(appCxtBeans, appCxtServices, appCxtReferences, appCxtProperties);
- // Add all the validated beans to the generic list
- beans.addAll(appCxtBeans);
- services.addAll(appCxtServices);
- references.addAll(appCxtReferences);
- scaproperties.addAll(appCxtProperties);
- reader.close();
+ reader = xmlInputFactory.createXMLStreamReader(contextResource.openStream());
+ // Read the beans, services, references and properties for individual application context
+ readContextDefinition(resolver,
+ reader,
+ contextPath,
+ appCxtBeans,
+ appCxtServices,
+ appCxtReferences,
+ appCxtProperties,
+ context);
+ // Validate the beans from individual application context for uniqueness
+ validateBeans(appCxtBeans, appCxtServices, appCxtReferences, appCxtProperties);
+ // Add all the validated beans to the generic list
+ beans.addAll(appCxtBeans);
+ services.addAll(appCxtServices);
+ references.addAll(appCxtReferences);
+ scaproperties.addAll(appCxtProperties);
+ reader.close();
}
} catch (IOException e) {
throw new ContributionReadException(e);
@@ -235,8 +256,8 @@ public class SpringXMLComponentTypeLoader {
return;
} // end method loadFromXML
- private URL resolveLocation(ModelResolver resolver, String contextPath, ProcessorContext context) throws MalformedURLException,
- ContributionReadException {
+ private URL resolveLocation(ModelResolver resolver, String contextPath, ProcessorContext context)
+ throws MalformedURLException, ContributionReadException {
URL resource = null;
URI uri = URI.create(contextPath);
if (!uri.isAbsolute()) {
@@ -259,12 +280,13 @@ public class SpringXMLComponentTypeLoader {
* Method which returns the XMLStreamReader for the Spring application-context.xml file
* specified in the location attribute
*/
- private XMLStreamReader getApplicationContextReader(ModelResolver resolver, String location, ProcessorContext context) throws ContributionReadException {
+ private XMLStreamReader getApplicationContextReader(ModelResolver resolver,
+ String location,
+ ProcessorContext context) throws ContributionReadException {
try {
URL resource = getApplicationContextResource(resolveLocation(resolver, location, context)).get(0);
- XMLStreamReader reader =
- xmlInputFactory.createXMLStreamReader(resource.openStream());
+ XMLStreamReader reader = xmlInputFactory.createXMLStreamReader(resource.openStream());
return reader;
} catch (IOException e) {
throw new ContributionReadException(e);
@@ -284,7 +306,8 @@ public class SpringXMLComponentTypeLoader {
List<SpringBeanElement> beans,
List<SpringSCAServiceElement> services,
List<SpringSCAReferenceElement> references,
- List<SpringSCAPropertyElement> scaproperties, ProcessorContext context) throws ContributionReadException {
+ List<SpringSCAPropertyElement> scaproperties,
+ ProcessorContext context) throws ContributionReadException {
SpringBeanElement bean = null;
@@ -296,74 +319,84 @@ public class SpringXMLComponentTypeLoader {
QName qname = reader.getName();
//System.out.println("Spring TypeLoader - found element with name: " + qname.toString());
if (SpringImplementationConstants.IMPORT_ELEMENT.equals(qname)) {
- //FIXME - put the sequence of code below which gets the ireader into a subsidiary method
+ //FIXME - put the sequence of code below which gets the ireader into a subsidiary method
String location = reader.getAttributeValue(null, "resource");
if (location != null) {
- // FIXME - need to find a right way of generating this path
- String resourcePath = contextPath.substring(0, contextPath.lastIndexOf("/")+1) + location;
+ // FIXME - need to find a right way of generating this path
+ String resourcePath =
+ contextPath.substring(0, contextPath.lastIndexOf("/") + 1) + location;
XMLStreamReader ireader = getApplicationContextReader(resolver, resourcePath, context);
// Read the context definition for the identified imported resource
- readContextDefinition(resolver, ireader, contextPath, beans, services, references, scaproperties, context);
+ readContextDefinition(resolver,
+ ireader,
+ contextPath,
+ beans,
+ services,
+ references,
+ scaproperties,
+ context);
}
} else if (SpringImplementationConstants.SCA_SERVICE_ELEMENT.equals(qname)) {
- // The value of the @name attribute of an <sca:service/> subelement of a <beans/>
- // element MUST be unique amongst the <sca:service/> subelements of the <beans/> element.
- if (!services.isEmpty() && (services.contains(reader.getAttributeValue(null, "name"))))
- error("ScaServiceNameNotUnique", resolver);
-
- SpringSCAServiceElement service =
- new SpringSCAServiceElement(reader.getAttributeValue(null, "name"),
- reader.getAttributeValue(null, "target"));
+ // The value of the @name attribute of an <sca:service/> subelement of a <beans/>
+ // element MUST be unique amongst the <sca:service/> subelements of the <beans/> element.
+ if (!services.isEmpty() && (services.contains(reader.getAttributeValue(null, "name"))))
+ error("ScaServiceNameNotUnique", resolver);
+
+ SpringSCAServiceElement service =
+ new SpringSCAServiceElement(reader.getAttributeValue(null, "name"),
+ reader.getAttributeValue(null, "target"));
if (reader.getAttributeValue(null, "type") != null)
- service.setType(reader.getAttributeValue(null, "type"));
+ service.setType(reader.getAttributeValue(null, "type"));
policyProcessor.readPolicies(service, reader);
services.add(service);
} else if (SpringImplementationConstants.SCA_REFERENCE_ELEMENT.equals(qname)) {
- // The value of the @name attribute of an <sca:reference/> subelement of a <beans/>
- // element MUST be unique amongst the @name attributes of the <sca:reference/> subelements,
- // of the <beans/> element.
- if (!references.isEmpty() && (references.contains(reader.getAttributeValue(null, "name"))))
- error("ScaReferenceNameNotUnique", resolver);
-
- SpringSCAReferenceElement reference =
- new SpringSCAReferenceElement(reader.getAttributeValue(null, "name"),
- reader.getAttributeValue(null, "type"));
+ // The value of the @name attribute of an <sca:reference/> subelement of a <beans/>
+ // element MUST be unique amongst the @name attributes of the <sca:reference/> subelements,
+ // of the <beans/> element.
+ if (!references.isEmpty() && (references.contains(reader.getAttributeValue(null, "name"))))
+ error("ScaReferenceNameNotUnique", resolver);
+
+ SpringSCAReferenceElement reference =
+ new SpringSCAReferenceElement(reader.getAttributeValue(null, "name"),
+ reader.getAttributeValue(null, "type"));
if (reader.getAttributeValue(null, "default") != null)
- reference.setDefaultBean(reader.getAttributeValue(null, "default"));
+ reference.setDefaultBean(reader.getAttributeValue(null, "default"));
policyProcessor.readPolicies(reference, reader);
- references.add(reference);
+ references.add(reference);
} else if (SpringImplementationConstants.SCA_PROPERTY_ELEMENT.equals(qname)) {
- // The value of the @name attribute of an <sca:property/> subelement of a <beans/>
- // element MUST be unique amongst the @name attributes of the <sca:property/> subelements,
- // of the <beans/> element.
- if (!scaproperties.isEmpty() && (scaproperties.contains(reader.getAttributeValue(null, "name"))))
- error("ScaPropertyNameNotUnique", resolver);
-
- SpringSCAPropertyElement scaproperty =
- new SpringSCAPropertyElement(reader.getAttributeValue(null, "name"), reader
- .getAttributeValue(null, "type"));
+ // The value of the @name attribute of an <sca:property/> subelement of a <beans/>
+ // element MUST be unique amongst the @name attributes of the <sca:property/> subelements,
+ // of the <beans/> element.
+ if (!scaproperties.isEmpty() && (scaproperties.contains(reader.getAttributeValue(null,
+ "name"))))
+ error("ScaPropertyNameNotUnique", resolver);
+
+ SpringSCAPropertyElement scaproperty =
+ new SpringSCAPropertyElement(reader.getAttributeValue(null, "name"),
+ reader.getAttributeValue(null, "type"));
scaproperties.add(scaproperty);
} else if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
- bean = new SpringBeanElement(reader.getAttributeValue(null, "id"),
- reader.getAttributeValue(null, "class"));
+ bean =
+ new SpringBeanElement(reader.getAttributeValue(null, "id"),
+ reader.getAttributeValue(null, "class"));
if (reader.getAttributeValue(null, "abstract") != null)
- if (reader.getAttributeValue(null, "abstract").equals("true"))
- bean.setAbstractBean(true);
+ if (reader.getAttributeValue(null, "abstract").equals("true"))
+ bean.setAbstractBean(true);
if (reader.getAttributeValue(null, "parent") != null)
- if (!reader.getAttributeValue(null, "parent").equals(""))
- bean.setParentAttribute(true);
+ if (!reader.getAttributeValue(null, "parent").equals(""))
+ bean.setParentAttribute(true);
if (reader.getAttributeValue(null, "factory-bean") != null)
- if (!reader.getAttributeValue(null, "factory-bean").equals(""))
- bean.setFactoryBeanAttribute(true);
+ if (!reader.getAttributeValue(null, "factory-bean").equals(""))
+ bean.setFactoryBeanAttribute(true);
if (reader.getAttributeValue(null, "factory-method") != null)
- if (!reader.getAttributeValue(null, "factory-method").equals(""))
- bean.setFactoryMethodAttribute(true);
+ if (!reader.getAttributeValue(null, "factory-method").equals(""))
+ bean.setFactoryMethodAttribute(true);
// Set the first name as bean name, when the @id attribute is absent.
if (reader.getAttributeValue(null, "id") == null) {
- if (reader.getAttributeValue(null, "name") != null) {
- String[] names = (reader.getAttributeValue(null, "name")).split(",");
- bean.setId(names[0]);
- }
+ if (reader.getAttributeValue(null, "name") != null) {
+ String[] names = (reader.getAttributeValue(null, "name")).split(",");
+ bean.setId(names[0]);
+ }
}
beans.add(bean);
// Read the <bean> element and its child elements
@@ -383,34 +416,33 @@ public class SpringXMLComponentTypeLoader {
}
}
-
/**
* Method which reads the bean definitions from Spring application-context.xml file and identifies
* the defined beans, properties, services and references
*/
- private void readBeanDefinition(XMLStreamReader reader,
- SpringBeanElement bean,
- List<SpringBeanElement> beans) throws ContributionReadException {
+ private void readBeanDefinition(XMLStreamReader reader, SpringBeanElement bean, List<SpringBeanElement> beans)
+ throws ContributionReadException {
- SpringBeanElement innerbean = null;
+ SpringBeanElement innerbean = null;
SpringPropertyElement property = null;
SpringConstructorArgElement constructorArg = null;
-
+
try {
- boolean completed = false;
+ boolean completed = false;
while (!completed) {
switch (reader.next()) {
case START_ELEMENT:
QName qname = reader.getName();
if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
- innerbean = new SpringBeanElement(reader.getAttributeValue(null, "id"), reader
- .getAttributeValue(null, "class"));
- // Set the first name as bean name, when the @id attribute is absent.
+ innerbean =
+ new SpringBeanElement(reader.getAttributeValue(null, "id"),
+ reader.getAttributeValue(null, "class"));
+ // Set the first name as bean name, when the @id attribute is absent.
if (reader.getAttributeValue(null, "id") == null) {
- if (reader.getAttributeValue(null, "name") != null) {
- String[] names = (reader.getAttributeValue(null, "name")).split(",");
- innerbean.setId(names[0]);
- }
+ if (reader.getAttributeValue(null, "name") != null) {
+ String[] names = (reader.getAttributeValue(null, "name")).split(",");
+ innerbean.setId(names[0]);
+ }
}
innerbean.setInnerBean(true);
beans.add(innerbean);
@@ -418,34 +450,37 @@ public class SpringXMLComponentTypeLoader {
} else if (SpringImplementationConstants.PROPERTY_ELEMENT.equals(qname)) {
property = new SpringPropertyElement(reader.getAttributeValue(null, "name"));
if (reader.getAttributeValue(null, "ref") != null)
- property.addRef(reader.getAttributeValue(null, "ref"));
+ property.addRef(reader.getAttributeValue(null, "ref"));
bean.addProperty(property);
} else if (SpringImplementationConstants.CONSTRUCTORARG_ELEMENT.equals(qname)) {
constructorArg = new SpringConstructorArgElement(reader.getAttributeValue(null, "type"));
if (reader.getAttributeValue(null, "ref") != null)
- constructorArg.addRef(reader.getAttributeValue(null, "ref"));
+ constructorArg.addRef(reader.getAttributeValue(null, "ref"));
if (reader.getAttributeValue(null, "index") != null)
- constructorArg.setIndex((new Integer(reader.getAttributeValue(null, "index"))).intValue());
+ constructorArg.setIndex((new Integer(reader.getAttributeValue(null, "index")))
+ .intValue());
if (reader.getAttributeValue(null, "value") != null)
- constructorArg.addValue(reader.getAttributeValue(null, "value"));
+ constructorArg.addValue(reader.getAttributeValue(null, "value"));
bean.addCustructorArgs(constructorArg);
} else if (SpringImplementationConstants.REF_ELEMENT.equals(qname)) {
- String ref = reader.getAttributeValue(null, "bean");
+ String ref = reader.getAttributeValue(null, "bean");
// Check if the parent element is a property
- if (property != null) property.addRef(ref);
+ if (property != null)
+ property.addRef(ref);
// Check if the parent element is a constructor-arg
- if (constructorArg != null) constructorArg.addRef(ref);
+ if (constructorArg != null)
+ constructorArg.addRef(ref);
} else if (SpringImplementationConstants.VALUE_ELEMENT.equals(qname)) {
String value = reader.getElementText();
// Check if the parent element is a constructor-arg
- if (constructorArg != null) constructorArg.addValue(value);
- } else if (SpringImplementationConstants.LIST_ELEMENT.equals(qname) ||
- SpringImplementationConstants.SET_ELEMENT.equals(qname) ||
- SpringImplementationConstants.MAP_ELEMENT.equals(qname)) {
- if (property != null)
- readCollections(reader, bean, beans, property, null);
if (constructorArg != null)
- readCollections(reader, bean, beans, null, constructorArg);
+ constructorArg.addValue(value);
+ } else if (SpringImplementationConstants.LIST_ELEMENT.equals(qname) || SpringImplementationConstants.SET_ELEMENT
+ .equals(qname) || SpringImplementationConstants.MAP_ELEMENT.equals(qname)) {
+ if (property != null)
+ readCollections(reader, bean, beans, property, null);
+ if (constructorArg != null)
+ readCollections(reader, bean, beans, null, constructorArg);
} // end if
break;
case END_ELEMENT:
@@ -463,8 +498,7 @@ public class SpringXMLComponentTypeLoader {
throw new ContributionReadException(e);
}
}
-
-
+
/**
* Method which reads the collection elements from Spring application-context.xml file and identifies
* the defined beans, list, maps and sets
@@ -474,54 +508,62 @@ public class SpringXMLComponentTypeLoader {
List<SpringBeanElement> beans,
SpringPropertyElement property,
SpringConstructorArgElement constructorArg) throws ContributionReadException {
-
- SpringBeanElement innerbean = null;
-
+
+ SpringBeanElement innerbean = null;
+
try {
- boolean completed = false;
+ boolean completed = false;
while (!completed) {
switch (reader.next()) {
case START_ELEMENT:
QName qname = reader.getName();
if (SpringImplementationConstants.BEAN_ELEMENT.equals(qname)) {
- innerbean = new SpringBeanElement(reader.getAttributeValue(null, "id"), reader
- .getAttributeValue(null, "class"));
- // Set the first name as bean name, when the @id attribute is absent.
+ innerbean =
+ new SpringBeanElement(reader.getAttributeValue(null, "id"),
+ reader.getAttributeValue(null, "class"));
+ // Set the first name as bean name, when the @id attribute is absent.
if (reader.getAttributeValue(null, "id") == null)
- if (reader.getAttributeValue(null, "name") != null) {
- String[] names = (reader.getAttributeValue(null, "name")).split(",");
- innerbean.setId(names[0]);
- }
+ if (reader.getAttributeValue(null, "name") != null) {
+ String[] names = (reader.getAttributeValue(null, "name")).split(",");
+ innerbean.setId(names[0]);
+ }
innerbean.setInnerBean(true);
beans.add(innerbean);
readBeanDefinition(reader, innerbean, beans);
} else if (SpringImplementationConstants.REF_ELEMENT.equals(qname)) {
- String ref = reader.getAttributeValue(null, "bean");
- if (property != null) property.addRef(ref);
- if (constructorArg != null) constructorArg.addRef(ref);
- } else if (SpringImplementationConstants.LIST_ELEMENT.equals(qname) ||
- SpringImplementationConstants.SET_ELEMENT.equals(qname) ||
- SpringImplementationConstants.MAP_ELEMENT.equals(qname)) {
- if (property != null)
- readCollections(reader, innerbean, beans, property, null);
- if (constructorArg != null)
- readCollections(reader, innerbean, beans, null, constructorArg);
+ String ref = reader.getAttributeValue(null, "bean");
+ if (property != null)
+ property.addRef(ref);
+ if (constructorArg != null)
+ constructorArg.addRef(ref);
+ } else if (SpringImplementationConstants.LIST_ELEMENT.equals(qname) || SpringImplementationConstants.SET_ELEMENT
+ .equals(qname) || SpringImplementationConstants.MAP_ELEMENT.equals(qname)) {
+ if (property != null)
+ readCollections(reader, innerbean, beans, property, null);
+ if (constructorArg != null)
+ readCollections(reader, innerbean, beans, null, constructorArg);
} else if (SpringImplementationConstants.ENTRY_ELEMENT.equals(qname)) {
String keyRef = reader.getAttributeValue(null, "key-ref");
String valueRef = reader.getAttributeValue(null, "value-ref");
- if (property != null) {property.addRef(keyRef); property.addRef(valueRef);}
- if (constructorArg != null) {constructorArg.addRef(keyRef); constructorArg.addRef(valueRef);}
+ if (property != null) {
+ property.addRef(keyRef);
+ property.addRef(valueRef);
+ }
+ if (constructorArg != null) {
+ constructorArg.addRef(keyRef);
+ constructorArg.addRef(valueRef);
+ }
} // end if
break;
case END_ELEMENT:
if (SpringImplementationConstants.LIST_ELEMENT.equals(reader.getName())) {
- completed = true;
+ completed = true;
break;
} else if (SpringImplementationConstants.SET_ELEMENT.equals(reader.getName())) {
- completed = true;
+ completed = true;
break;
} else if (SpringImplementationConstants.MAP_ELEMENT.equals(reader.getName())) {
- completed = true;
+ completed = true;
break;
} // end if
} // end switch
@@ -553,14 +595,14 @@ public class SpringXMLComponentTypeLoader {
* at another bean in the application context becomes a property in the component type
*/
- JavaImplementation javaImplementation = null;
+ JavaImplementation javaImplementation = null;
ComponentType componentType = implementation.getComponentType();
try {
// Deal with the services first....
Iterator<SpringSCAServiceElement> its = services.iterator();
while (its.hasNext()) {
- SpringSCAServiceElement serviceElement = its.next();
+ SpringSCAServiceElement serviceElement = its.next();
Class<?> interfaze = resolveClass(resolver, serviceElement.getType(), context);
Service theService = createService(interfaze, serviceElement.getName());
// Spring allows duplication of bean definitions in multiple context scenario,
@@ -568,23 +610,23 @@ public class SpringXMLComponentTypeLoader {
// we will remove any older definition and use the latest.
Service duplicate = null;
for (Service service : componentType.getServices()) {
- if (service.getName().equals(theService.getName()))
- duplicate = service;
+ if (service.getName().equals(theService.getName()))
+ duplicate = service;
}
if (duplicate != null)
- componentType.getServices().remove(duplicate);
-
+ componentType.getServices().remove(duplicate);
+
componentType.getServices().add(theService);
// Add this service to the Service / Bean map
String beanName = serviceElement.getTarget();
for (SpringBeanElement beanElement : beans) {
if (beanName.equals(beanElement.getId())) {
- if (isvalidBeanForService(beanElement)) {
- // add the required intents and policySets for the service
+ if (isvalidBeanForService(beanElement)) {
+ // add the required intents and policySets for the service
theService.getRequiredIntents().addAll(serviceElement.getRequiredIntents());
theService.getPolicySets().addAll(serviceElement.getPolicySets());
implementation.setBeanForService(theService, beanElement);
- }
+ }
}
} // end for
} // end while
@@ -599,12 +641,12 @@ public class SpringXMLComponentTypeLoader {
// for the duplicate definitions found.
Reference duplicate = null;
for (Reference reference : componentType.getReferences()) {
- if (reference.getName().equals(theReference.getName()))
- duplicate = reference;
+ if (reference.getName().equals(theReference.getName()))
+ duplicate = reference;
}
if (duplicate != null)
- componentType.getReferences().remove(duplicate);
-
+ componentType.getReferences().remove(duplicate);
+
// add the required intents and policySets for this reference
theReference.getRequiredIntents().addAll(referenceElement.getRequiredIntents());
theReference.getPolicySets().addAll(referenceElement.getPolicySets());
@@ -627,12 +669,12 @@ public class SpringXMLComponentTypeLoader {
// for the duplicate definitions found.
Property duplicate = null;
for (Property property : componentType.getProperties()) {
- if (property.getName().equals(theProperty.getName()))
- duplicate = property;
+ if (property.getName().equals(theProperty.getName()))
+ duplicate = property;
}
if (duplicate != null)
- componentType.getProperties().remove(duplicate);
-
+ componentType.getProperties().remove(duplicate);
+
componentType.getProperties().add(theProperty);
// Remember the Java Class (ie the type) for this property
implementation.setPropertyClass(theProperty.getName(), propType);
@@ -648,17 +690,17 @@ public class SpringXMLComponentTypeLoader {
while (itb.hasNext()) {
SpringBeanElement beanElement = itb.next();
// If its not a valid bean for service, ignore it
- if (!isvalidBeanForService(beanElement)) continue;
+ if (!isvalidBeanForService(beanElement))
+ continue;
// Load the Spring bean class
Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
// Introspect the bean
- beanIntrospector =
- new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
+ beanIntrospector = new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
ComponentType beanComponentType = assemblyFactory.createComponentType();
javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
// Set the service name as bean name
- for (Service componentService : beanComponentType.getServices())
- componentService.setName(beanElement.getId());
+ for (Service componentService : beanComponentType.getServices())
+ componentService.setName(beanElement.getId());
// Get the service interface defined by this Spring Bean and add to
// the component type of the Spring Assembly
List<Service> beanServices = beanComponentType.getServices();
@@ -675,12 +717,11 @@ public class SpringXMLComponentTypeLoader {
SpringBeanElement beanElement = itb.next();
// Ignore if the bean has no properties and constructor arguments
if (beanElement.getProperties().isEmpty() && beanElement.getCustructorArgs().isEmpty())
- continue;
+ continue;
Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
// Introspect the bean
- beanIntrospector =
- new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
+ beanIntrospector = new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
ComponentType beanComponentType = assemblyFactory.createComponentType();
javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
Map<String, JavaElementImpl> propertyMap = javaImplementation.getPropertyMembers();
@@ -694,60 +735,62 @@ public class SpringXMLComponentTypeLoader {
while (itp.hasNext()) {
SpringPropertyElement propertyElement = itp.next();
for (String propertyRef : propertyElement.getRefs()) {
- if (propertyRefUnresolved(propertyRef, beans, references, scaproperties)) {
- // This means an unresolved reference from the spring bean...
- for (Reference reference : beanReferences) {
- if (propertyElement.getName().equals(reference.getName())) {
- // The name of the reference in this case is the string in
- // the @ref attribute of the Spring property element, NOT the
- // name of the field in the Spring bean....
- reference.setName(propertyRef);
- componentType.getReferences().add(reference);
- } // end if
- } // end for
-
- // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
- for (Property scaproperty : beanProperties) {
- if (propertyElement.getName().equals(scaproperty.getName())) {
- // The name of the reference in this case is the string in
- // the @ref attribute of the Spring property element, NOT the
- // name of the field in the Spring bean....
- Class<?> interfaze = resolveClass(resolver, (propertyMap.get(propertyElement.getName()).getType()).getName(), context);
- Reference theReference = createReference(interfaze, propertyRef);
- implementation.setUnresolvedBeanRef(propertyRef, theReference);
- } // end if
- } // end for
- } // end if
+ if (propertyRefUnresolved(propertyRef, beans, references, scaproperties)) {
+ // This means an unresolved reference from the spring bean...
+ for (Reference reference : beanReferences) {
+ if (propertyElement.getName().equals(reference.getName())) {
+ // The name of the reference in this case is the string in
+ // the @ref attribute of the Spring property element, NOT the
+ // name of the field in the Spring bean....
+ reference.setName(propertyRef);
+ componentType.getReferences().add(reference);
+ } // end if
+ } // end for
+
+ // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
+ for (Property scaproperty : beanProperties) {
+ if (propertyElement.getName().equals(scaproperty.getName())) {
+ // The name of the reference in this case is the string in
+ // the @ref attribute of the Spring property element, NOT the
+ // name of the field in the Spring bean....
+ Class<?> interfaze =
+ resolveClass(resolver,
+ (propertyMap.get(propertyElement.getName()).getType()).getName(),
+ context);
+ Reference theReference = createReference(interfaze, propertyRef);
+ implementation.setUnresolvedBeanRef(propertyRef, theReference);
+ } // end if
+ } // end for
+ } // end if
} // end for
} // end while
Iterator<SpringConstructorArgElement> itcr = beanElement.getCustructorArgs().iterator();
while (itcr.hasNext()) {
- SpringConstructorArgElement conArgElement = itcr.next();
- for (String constructorArgRef : conArgElement.getRefs()) {
- if (propertyRefUnresolved(constructorArgRef, beans, references, scaproperties)) {
- for (JavaParameterImpl parameter : constructor.getParameters()) {
- String paramType = parameter.getType().getName();
- Class<?> interfaze = resolveClass(resolver, paramType, context);
- // Create a component type reference/property if the constructor-arg element has a
- // type attribute OR index attribute declared...
- if ((conArgElement.getType() != null && paramType.equals(conArgElement.getType())) ||
- (conArgElement.getIndex() != -1 && (conArgElement.getIndex() == parameter.getIndex())))
- {
- if (parameter.getClassifer().getName().equals("org.osoa.sca.annotations.Reference")) {
- Reference theReference = createReference(interfaze, constructorArgRef);
- componentType.getReferences().add(theReference);
- }
- if (parameter.getClassifer().getName().equals("org.osoa.sca.annotations.Property")) {
- // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
- // we might need to verify with the component definition later.
- Reference theReference = createReference(interfaze, constructorArgRef);
- implementation.setUnresolvedBeanRef(constructorArgRef, theReference);
- }
- }
- } // end for
- } // end if
- } // end for
+ SpringConstructorArgElement conArgElement = itcr.next();
+ for (String constructorArgRef : conArgElement.getRefs()) {
+ if (propertyRefUnresolved(constructorArgRef, beans, references, scaproperties)) {
+ for (JavaParameterImpl parameter : constructor.getParameters()) {
+ String paramType = parameter.getType().getName();
+ Class<?> interfaze = resolveClass(resolver, paramType, context);
+ // Create a component type reference/property if the constructor-arg element has a
+ // type attribute OR index attribute declared...
+ if ((conArgElement.getType() != null && paramType.equals(conArgElement.getType())) || (conArgElement
+ .getIndex() != -1 && (conArgElement.getIndex() == parameter.getIndex()))) {
+ if (parameter.getClassifer().getName().equals("org.osoa.sca.annotations.Reference")) {
+ Reference theReference = createReference(interfaze, constructorArgRef);
+ componentType.getReferences().add(theReference);
+ }
+ if (parameter.getClassifer().getName().equals("org.osoa.sca.annotations.Property")) {
+ // Store the unresolved references as unresolvedBeanRef in the Spring Implementation type
+ // we might need to verify with the component definition later.
+ Reference theReference = createReference(interfaze, constructorArgRef);
+ implementation.setUnresolvedBeanRef(constructorArgRef, theReference);
+ }
+ }
+ } // end for
+ } // end if
+ } // end for
} // end while
} // end while
@@ -793,7 +836,7 @@ public class SpringXMLComponentTypeLoader {
break;
} // end if
} // end while
- // Scan over the SCA reference elements looking for a match
+ // Scan over the SCA reference elements looking for a match
if (unresolved) {
Iterator<SpringSCAReferenceElement> itr = references.iterator();
while (itr.hasNext()) {
@@ -804,7 +847,7 @@ public class SpringXMLComponentTypeLoader {
} // end if
} // end while
} // end if
- // Scan over the SCA property elements looking for a match
+ // Scan over the SCA property elements looking for a match
if (unresolved) {
Iterator<SpringSCAPropertyElement> itsp = scaproperties.iterator();
while (itsp.hasNext()) {
@@ -824,35 +867,35 @@ public class SpringXMLComponentTypeLoader {
return unresolved;
} // end method propertyRefUnresolved
-
+
/**
* Validates whether the <sca:service>, <sca:reference> and <sca:property> elements
* has unique names within the application context.
*/
private void validateBeans(List<SpringBeanElement> beans,
- List<SpringSCAServiceElement> services,
- List<SpringSCAReferenceElement> references,
- List<SpringSCAPropertyElement> scaproperties) throws ContributionReadException {
-
- // The @target attribute of a <service/> subelement of a <beans/> element
- // MUST have the value of the @name attribute of one of the <bean/>
- // subelements of the <beans/> element.
- Iterator<SpringSCAServiceElement> its = services.iterator();
+ List<SpringSCAServiceElement> services,
+ List<SpringSCAReferenceElement> references,
+ List<SpringSCAPropertyElement> scaproperties) throws ContributionReadException {
+
+ // The @target attribute of a <service/> subelement of a <beans/> element
+ // MUST have the value of the @name attribute of one of the <bean/>
+ // subelements of the <beans/> element.
+ Iterator<SpringSCAServiceElement> its = services.iterator();
while (its.hasNext()) {
- SpringSCAServiceElement serviceElement = its.next();
- boolean targetBeanExists = false;
- Iterator<SpringBeanElement> itb = beans.iterator();
- while (itb.hasNext()) {
- SpringBeanElement beanElement = itb.next();
- if (serviceElement.getTarget().equals(beanElement.getId()))
- targetBeanExists = true;
- }
- if (!targetBeanExists)
- error("TargetBeanDoesNotExist", beans);
+ SpringSCAServiceElement serviceElement = its.next();
+ boolean targetBeanExists = false;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (serviceElement.getTarget().equals(beanElement.getId()))
+ targetBeanExists = true;
+ }
+ if (!targetBeanExists)
+ error("TargetBeanDoesNotExist", beans);
} // end while
-
- // The value of the @name attribute of an <sca:reference/> subelement of a <beans/>
- // element MUST be unique amongst the @name attributes of the <sca:property/>
+
+ // The value of the @name attribute of an <sca:reference/> subelement of a <beans/>
+ // element MUST be unique amongst the @name attributes of the <sca:property/>
// subelements and the <bean/> subelements of the <beans/> element.
// AND
// The @default attribute of a <sca:reference/> subelement of a <beans/>
@@ -860,213 +903,219 @@ public class SpringXMLComponentTypeLoader {
// subelements of the <beans/> element.
Iterator<SpringSCAReferenceElement> itr = references.iterator();
while (itr.hasNext()) {
- SpringSCAReferenceElement referenceElement = itr.next();
- boolean defaultBeanExists = true;
- boolean isUniqueReferenceName = true;
- Iterator<SpringBeanElement> itb = beans.iterator();
- while (itb.hasNext()) {
- SpringBeanElement beanElement = itb.next();
- if (referenceElement.getDefaultBean() != null)
- if (referenceElement.getDefaultBean().equals(beanElement.getId()))
- defaultBeanExists = false;
- if (referenceElement.getName().equals(beanElement.getId()))
- isUniqueReferenceName = false;
- }
- Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
- while (itp.hasNext()) {
- SpringSCAPropertyElement propertyElement = itp.next();
- if (referenceElement.getName().equals(propertyElement.getName()))
- isUniqueReferenceName = false;
- }
- if (!defaultBeanExists)
- error("DefaultBeanDoesNotExist", beans);
- if (!isUniqueReferenceName)
- error("ScaReferenceNameNotUnique", beans);
+ SpringSCAReferenceElement referenceElement = itr.next();
+ boolean defaultBeanExists = true;
+ boolean isUniqueReferenceName = true;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (referenceElement.getDefaultBean() != null)
+ if (referenceElement.getDefaultBean().equals(beanElement.getId()))
+ defaultBeanExists = false;
+ if (referenceElement.getName().equals(beanElement.getId()))
+ isUniqueReferenceName = false;
+ }
+ Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
+ while (itp.hasNext()) {
+ SpringSCAPropertyElement propertyElement = itp.next();
+ if (referenceElement.getName().equals(propertyElement.getName()))
+ isUniqueReferenceName = false;
+ }
+ if (!defaultBeanExists)
+ error("DefaultBeanDoesNotExist", beans);
+ if (!isUniqueReferenceName)
+ error("ScaReferenceNameNotUnique", beans);
} // end while
-
- // The value of the @name attribute of an <sca:property/> subelement of a <beans/>
- // element MUST be unique amongst the @name attributes of the <sca:reference/>
+
+ // The value of the @name attribute of an <sca:property/> subelement of a <beans/>
+ // element MUST be unique amongst the @name attributes of the <sca:reference/>
// subelements and the <bean/> subelements of the <beans/> element.
Iterator<SpringSCAPropertyElement> itp = scaproperties.iterator();
while (itp.hasNext()) {
- SpringSCAPropertyElement propertyElement = itp.next();
- boolean isUniquePropertyName = true;
- Iterator<SpringBeanElement> itb = beans.iterator();
- while (itb.hasNext()) {
- SpringBeanElement beanElement = itb.next();
- if (propertyElement.getName().equals(beanElement.getId()))
- isUniquePropertyName = false;
- }
- Iterator<SpringSCAReferenceElement> itrp = references.iterator();
+ SpringSCAPropertyElement propertyElement = itp.next();
+ boolean isUniquePropertyName = true;
+ Iterator<SpringBeanElement> itb = beans.iterator();
+ while (itb.hasNext()) {
+ SpringBeanElement beanElement = itb.next();
+ if (propertyElement.getName().equals(beanElement.getId()))
+ isUniquePropertyName = false;
+ }
+ Iterator<SpringSCAReferenceElement> itrp = references.iterator();
while (itrp.hasNext()) {
- SpringSCAReferenceElement referenceElement = itrp.next();
- if (propertyElement.getName().equals(referenceElement.getName()))
- isUniquePropertyName = false;
+ SpringSCAReferenceElement referenceElement = itrp.next();
+ if (propertyElement.getName().equals(referenceElement.getName()))
+ isUniquePropertyName = false;
}
- if (!isUniquePropertyName)
- error("ScaPropertyNameNotUnique", beans);
+ if (!isUniquePropertyName)
+ error("ScaPropertyNameNotUnique", beans);
} // end while
}
-
+
/**
* Validates whether a bean definition is valid for exposing as service.
*/
private boolean isvalidBeanForService(SpringBeanElement beanElement) {
-
- if (beanElement.isInnerBean())
- return false;
- if (beanElement.hasParentAttribute())
- return false;
- if (beanElement.hasFactoryMethodAttribute())
- return false;
- if (beanElement.hasFactoryBeanAttribute())
- return false;
- if (beanElement.getClassName() == null)
- return false;
- if (beanElement.getClassName().startsWith("org.springframework"))
- return false;
+
+ if (beanElement.isInnerBean())
+ return false;
+ if (beanElement.hasParentAttribute())
+ return false;
+ if (beanElement.hasFactoryMethodAttribute())
+ return false;
+ if (beanElement.hasFactoryBeanAttribute())
+ return false;
+ if (beanElement.getClassName() == null)
+ return false;
+ if (beanElement.getClassName().startsWith("org.springframework"))
+ return false;
// return true otherwise
- return true;
+ return true;
}
-
-
+
/**
* Gets hold of the application-context.xml file as a Spring resource
* @param locationAttr - the location attribute from the <implementation.spring../> element
* @param cl - the ClassLoader for the Spring implementation
*/
- protected List<URL> getApplicationContextResource(URL url)
- throws ContributionReadException {
+ protected List<URL> getApplicationContextResource(URL url) throws ContributionReadException {
File manifestFile = null;
File appXmlFile;
File appXmlFolder;
File locationFile = null;
List<URL> appCtxResources = new ArrayList<URL>();
-
+
if (url != null) {
String path = url.getPath();
locationFile = new File(path);
} else {
- throw new ContributionReadException("SpringXMLComponentTypeLoader getApplicationContextResource: "
- + "unable to find resource file " + url);
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + "unable to find resource file "
+ + url);
}
if (locationFile.isDirectory()) {
try {
- manifestFile = new File(locationFile, "META-INF"+ File.separator +"MANIFEST.MF");
+ manifestFile = new File(locationFile, "META-INF" + File.separator + "MANIFEST.MF");
if (manifestFile.exists()) {
Manifest mf = new Manifest(new FileInputStream(manifestFile));
Attributes mainAttrs = mf.getMainAttributes();
String appCtxPath = mainAttrs.getValue("Spring-Context");
if (appCtxPath != null) {
- String[] cxtPaths = appCtxPath.split(";");
- for (String path : cxtPaths) {
- appXmlFile = new File(locationFile, path.trim());
- if (appXmlFile.exists()) {
- appCtxResources.add(appXmlFile.toURI().toURL());
- }
- }
- return appCtxResources;
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ appXmlFile = new File(locationFile, path.trim());
+ if (appXmlFile.exists()) {
+ appCtxResources.add(appXmlFile.toURI().toURL());
+ }
+ }
+ return appCtxResources;
}
- }
+ }
// No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
// xml files available in the META-INF/spring folder.
appXmlFolder = new File(locationFile, "META-INF" + File.separator + "spring");
if (appXmlFolder.exists()) {
- File[] files = appXmlFolder.listFiles();
- for (File appFile: files) {
- if (appFile.getName().endsWith(".xml")) {
- appCtxResources.add(appFile.toURI().toURL());
- }
- }
- return appCtxResources;
+ File[] files = appXmlFolder.listFiles();
+ for (File appFile : files) {
+ if (appFile.getName().endsWith(".xml")) {
+ appCtxResources.add(appFile.toURI().toURL());
+ }
+ }
+ return appCtxResources;
}
} catch (IOException e) {
throw new ContributionReadException("Error reading manifest " + manifestFile);
}
} else {
- if (locationFile.isFile() && locationFile.getName().endsWith(".jar")) {
+ if (locationFile.isFile() && locationFile.getName().endsWith(".jar")) {
try {
- JarFile jf = new JarFile(locationFile);
+ JarFile jf = new JarFile(locationFile);
JarEntry je;
Manifest mf = jf.getManifest();
if (mf != null) {
Attributes mainAttrs = mf.getMainAttributes();
String appCtxPath = mainAttrs.getValue("Spring-Context");
if (appCtxPath != null) {
- String[] cxtPaths = appCtxPath.split(";");
- for (String path : cxtPaths) {
- je = jf.getJarEntry(path.trim());
- if (je != null)
- appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL() + "!/" + appCtxPath));
- }
- return appCtxResources;
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ je = jf.getJarEntry(path.trim());
+ if (je != null)
+ appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL()
+ + "!/"
+ + appCtxPath));
+ }
+ return appCtxResources;
}
}
// No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
// .xml files available in the META-INF/spring folder.
Enumeration<JarEntry> entries = jf.entries();
while (entries.hasMoreElements()) {
- je = entries.nextElement();
- if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
- appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL() + "!/" + je.getName()));
- }
+ je = entries.nextElement();
+ if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
+ appCtxResources.add(new URL("jar:" + locationFile.toURI().toURL() + "!/" + je.getName()));
+ }
}
return appCtxResources;
} catch (IOException e) {
// TODO: create a more appropriate exception type
- throw new ContributionReadException("SpringXMLComponentTypeLoader getApplicationContextResource: "
- + " IO exception reading context file.", e);
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + " IO exception reading context file.",
+ e);
}
- }
- else {
- if (locationFile.getName().endsWith(".xml")) {
- appCtxResources.add(url);
- return appCtxResources;
- }
- else {
- // Deal with the directory inside a jar file, in case the contribution itself is a JAR file.
- try {
- if (locationFile.getPath().indexOf(".jar") > 0) {
- String jarPath = url.getPath().substring(5, url.getPath().indexOf("!"));
- JarFile jf = new JarFile(jarPath);
- JarEntry je = jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/")+2)
- + "/" + "META-INF" + "/" + "MANIFEST.MF");
- if (je != null) {
- Manifest mf = new Manifest(jf.getInputStream(je));
- Attributes mainAttrs = mf.getMainAttributes();
- String appCtxPath = mainAttrs.getValue("Spring-Context");
- if (appCtxPath != null) {
- String[] cxtPaths = appCtxPath.split(";");
- for (String path : cxtPaths) {
- je = jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/")+2) + "/" + path.trim());
- if (je != null) {
- appCtxResources.add(new URL("jar:" + url.getPath() + "/" + path.trim()));
- }
- }
- return appCtxResources;
- }
- }
- // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
- // .xml files available in the META-INF/spring folder.
- Enumeration<JarEntry> entries = jf.entries();
- while (entries.hasMoreElements()) {
- je = entries.nextElement();
- if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
- appCtxResources.add(new URL("jar:" + url.getPath() + "/" + je.getName()));
- }
- }
+ } else {
+ if (locationFile.getName().endsWith(".xml")) {
+ appCtxResources.add(url);
+ return appCtxResources;
+ } else {
+ // Deal with the directory inside a jar file, in case the contribution itself is a JAR file.
+ try {
+ if (locationFile.getPath().indexOf(".jar") > 0) {
+ String jarPath = url.getPath().substring(5, url.getPath().indexOf("!"));
+ JarFile jf = new JarFile(jarPath);
+ JarEntry je =
+ jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/") + 2) + "/"
+ + "META-INF"
+ + "/"
+ + "MANIFEST.MF");
+ if (je != null) {
+ Manifest mf = new Manifest(jf.getInputStream(je));
+ Attributes mainAttrs = mf.getMainAttributes();
+ String appCtxPath = mainAttrs.getValue("Spring-Context");
+ if (appCtxPath != null) {
+ String[] cxtPaths = appCtxPath.split(";");
+ for (String path : cxtPaths) {
+ je =
+ jf.getJarEntry(url.getPath().substring(url.getPath().indexOf("!/") + 2) + "/"
+ + path.trim());
+ if (je != null) {
+ appCtxResources.add(new URL("jar:" + url.getPath() + "/" + path.trim()));
+ }
+ }
+ return appCtxResources;
+ }
+ }
+ // No MANIFEST.MF file OR no manifest-specified Spring context , then read all the
+ // .xml files available in the META-INF/spring folder.
+ Enumeration<JarEntry> entries = jf.entries();
+ while (entries.hasMoreElements()) {
+ je = entries.nextElement();
+ if (je.getName().startsWith("META-INF/spring/") && je.getName().endsWith(".xml")) {
+ appCtxResources.add(new URL("jar:" + url.getPath() + "/" + je.getName()));
+ }
+ }
return appCtxResources;
- }
- } catch (IOException e) {
+ }
+ } catch (IOException e) {
throw new ContributionReadException("Error reading manifest " + manifestFile);
}
- }
- }
+ }
+ }
}
- throw new ContributionReadException("SpringXMLComponentTypeLoader getApplicationContextResource: "
- + "unable to read resource file " + url);
+ throw new ContributionReadException(
+ "SpringXMLComponentTypeLoader getApplicationContextResource: " + "unable to read resource file "
+ + url);
} // end method getApplicationContextResource
/**
@@ -1114,40 +1163,40 @@ public class SpringXMLComponentTypeLoader {
return reference;
}
-
+
private class ContextClassLoader extends ClassLoader {
- public ContextClassLoader(ModelResolver resolver, ProcessorContext context) {
- super();
- this.resolver = resolver;
- this.context = context;
- }
-
- private ModelResolver resolver;
- private ProcessorContext context;
-
- @Override
- protected Class<?> findClass(String name) throws ClassNotFoundException {
- return SpringXMLComponentTypeLoader.this.resolveClass(resolver, name, context);
- }
-
- @Override
- protected URL findResource(String name) {
- try {
- return resolveLocation(resolver, name, context);
- } catch (Exception e) {
- return null;
- }
- }
-
- @Override
- protected Enumeration<URL> findResources(String name) throws IOException {
- URL url = findResource(name);
- if (url != null) {
- return Collections.enumeration(Arrays.asList(url));
- } else {
- Collection<URL> urls = Collections.emptyList();
- return Collections.enumeration(urls);
- }
- }
+ public ContextClassLoader(ModelResolver resolver, ProcessorContext context) {
+ super();
+ this.resolver = resolver;
+ this.context = context;
+ }
+
+ private ModelResolver resolver;
+ private ProcessorContext context;
+
+ @Override
+ protected Class<?> findClass(String name) throws ClassNotFoundException {
+ return SpringXMLComponentTypeLoader.this.resolveClass(resolver, name, context);
+ }
+
+ @Override
+ protected URL findResource(String name) {
+ try {
+ return resolveLocation(resolver, name, context);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @Override
+ protected Enumeration<URL> findResources(String name) throws IOException {
+ URL url = findResource(name);
+ if (url != null) {
+ return Collections.enumeration(Arrays.asList(url));
+ } else {
+ Collection<URL> urls = Collections.emptyList();
+ return Collections.enumeration(urls);
+ }
+ }
}
-} // end class SpringXMLComponentTypeLoader \ No newline at end of file
+} // end class SpringXMLComponentTypeLoader
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java
index b97c02d216..63e88f15a5 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/ComponentTie.java
@@ -30,7 +30,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponent;
public class ComponentTie {
private RuntimeComponent component;
-
+
public ComponentTie(RuntimeComponent component) {
this.component = component;
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java
index 89d14961ac..6289ec8626 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/PropertyValueTie.java
@@ -35,7 +35,7 @@ public class PropertyValueTie {
private RuntimeComponent component;
private JavaPropertyValueObjectFactory propertyFactory;
-
+
public PropertyValueTie(RuntimeComponent component, JavaPropertyValueObjectFactory propertyFactory) {
this.component = component;
this.propertyFactory = propertyFactory;
@@ -46,8 +46,8 @@ public class PropertyValueTie {
for (ComponentProperty prop : props) {
if (prop.getName().equals(name)) {
return propertyFactory.createValueFactory(prop, prop.getValue(), type).getInstance();
- }
- }
+ }
+ }
return null; // property name not found
}
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
index dcb9a53a33..6980b81e5d 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringContextStub.java
@@ -43,11 +43,11 @@ public class SpringContextStub {
private Method getBeanMethod;
public SpringContextStub(RuntimeComponent component,
- SpringImplementation implementation,
- ProxyFactory proxyService,
- JavaPropertyValueObjectFactory propertyValueObjectFactory) {
+ SpringImplementation implementation,
+ ProxyFactory proxyService,
+ JavaPropertyValueObjectFactory propertyValueObjectFactory) {
- initTie(component, implementation, propertyValueObjectFactory);
+ initTie(component, implementation, propertyValueObjectFactory);
}
@@ -60,14 +60,21 @@ public class SpringContextStub {
try {
- Class<?> stubClass = Class.forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringImplementationStub", true, cl);
- Constructor<?> stubConstructor = stubClass.getConstructor(new Class<?>[]{Object.class});
- Object stub = stubConstructor.newInstance(new SpringImplementationTie(implementation, component, propertyValueObjectFactory));
-
- Class<?> tieClass = Class.forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringContextTie", true, cl);
- Constructor<?> tieConstructor = tieClass.getConstructor(new Class<?>[]{stubClass, List.class});
+ Class<?> stubClass =
+ Class.forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringImplementationStub",
+ true,
+ cl);
+ Constructor<?> stubConstructor = stubClass.getConstructor(new Class<?>[] {Object.class});
+ Object stub =
+ stubConstructor.newInstance(new SpringImplementationTie(implementation, component,
+ propertyValueObjectFactory));
+
+ Class<?> tieClass =
+ Class
+ .forName("org.apache.tuscany.sca.implementation.spring.runtime.context.SpringContextTie", true, cl);
+ Constructor<?> tieConstructor = tieClass.getConstructor(new Class<?>[] {stubClass, List.class});
this.tie = tieConstructor.newInstance(stub, implementation.getResource());
-
+
this.startMethod = tieClass.getMethod("start");
this.closeMethod = tieClass.getMethod("close");
this.getBeanMethod = tieClass.getMethod("getBean", String.class);
@@ -85,7 +92,7 @@ public class SpringContextStub {
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
- e.printStackTrace();
+ e.printStackTrace();
throw new RuntimeException(e);
}
}
@@ -98,7 +105,7 @@ public class SpringContextStub {
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
- e.printStackTrace();
+ e.printStackTrace();
throw new RuntimeException(e);
}
}
@@ -111,7 +118,7 @@ public class SpringContextStub {
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
- e.printStackTrace();
+ e.printStackTrace();
throw new RuntimeException(e);
}
}
@@ -126,9 +133,9 @@ public class SpringContextStub {
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
- e.printStackTrace();
+ e.printStackTrace();
throw new RuntimeException(e);
}
}
-} \ No newline at end of file
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
index 0ecd00d5a8..304f3e2c1a 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProvider.java
@@ -33,12 +33,12 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentService;
*/
public class SpringImplementationProvider implements ImplementationProvider {
private RuntimeComponent component;
-
+
// A Spring application context object
private SpringContextStub springContext;
-
+
private SpringImplementation implementation;
-
+
private JavaPropertyValueObjectFactory propertyValueObjectFactory;
/**
@@ -56,14 +56,14 @@ public class SpringImplementationProvider implements ImplementationProvider {
this.component = component;
this.propertyValueObjectFactory = propertyValueObjectFactory;
- springContext = new SpringContextStub(component, implementation, proxyService, propertyValueObjectFactory);
-
+ springContext = new SpringContextStub(component, implementation, proxyService, propertyValueObjectFactory);
+
} // end constructor
public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
return new SpringInvoker(component, springContext, service, operation);
}
-
+
public boolean supportsOneWayInvocation() {
return false;
}
@@ -79,7 +79,7 @@ public class SpringImplementationProvider implements ImplementationProvider {
* Stop this implementation instance
*/
public void stop() {
- springContext.close();
+ springContext.close();
}
} // end class SpringImplementationProvider
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
index 01b458d1f5..5d9d6b31c4 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationProviderFactory.java
@@ -44,8 +44,8 @@ public class SpringImplementationProviderFactory implements ImplementationProvid
*/
public SpringImplementationProviderFactory(ExtensionPointRegistry extensionPoints) {
super();
-
- proxyFactory = ExtensibleProxyFactory.getInstance(extensionPoints);
+
+ proxyFactory = ExtensibleProxyFactory.getInstance(extensionPoints);
// TODO: could the runtime have a default PropertyValueObjectFactory?
propertyFactory = new JavaPropertyValueObjectFactory(new MediatorImpl(extensionPoints));
@@ -60,10 +60,7 @@ public class SpringImplementationProviderFactory implements ImplementationProvid
*/
public ImplementationProvider createImplementationProvider(RuntimeComponent component,
SpringImplementation implementation) {
- return new SpringImplementationProvider(component,
- implementation,
- proxyFactory,
- propertyFactory);
+ return new SpringImplementationProvider(component, implementation, proxyFactory, propertyFactory);
}
/**
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java
index a65db51449..749081e95b 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringImplementationTie.java
@@ -42,13 +42,15 @@ public class SpringImplementationTie {
private SpringImplementation implementation;
private RuntimeComponent component;
private JavaPropertyValueObjectFactory propertyFactory;
-
- public SpringImplementationTie(SpringImplementation implementation, RuntimeComponent component, JavaPropertyValueObjectFactory propertyFactory) {
+
+ public SpringImplementationTie(SpringImplementation implementation,
+ RuntimeComponent component,
+ JavaPropertyValueObjectFactory propertyFactory) {
this.implementation = implementation;
this.component = component;
this.propertyFactory = propertyFactory;
}
-
+
public String getURI() {
return implementation.getURI();
}
@@ -56,6 +58,7 @@ public class SpringImplementationTie {
public String getComponentName() {
return component.getName();
}
+
/**
* Method to create a Java Bean for a Property value
* @param <B> the class type of the Bean
@@ -127,11 +130,11 @@ public class SpringImplementationTie {
return getPropertyBean(requiredType, property.getName());
} // end if
} // end for
- // TODO: NoSuchBeanException
+ // TODO: NoSuchBeanException
throw new RuntimeException("Unable to find Bean with name " + name);
} // end method getBean( String, Class )
-
+
public Object getComponentTie() {
return new ComponentTie(component);
}
@@ -139,9 +142,9 @@ public class SpringImplementationTie {
public Object getPropertyValueTie() {
return new PropertyValueTie(component, propertyFactory);
}
-
+
public ClassLoader getClassLoader() {
- return implementation.getClassLoader();
+ return implementation.getClassLoader();
}
-} \ No newline at end of file
+}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java
index 6a23830aa9..dbc6f6f687 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvocationException.java
@@ -28,13 +28,13 @@ public class SpringInvocationException extends Exception {
public SpringInvocationException(String msg) {
super(msg);
}
-
+
public SpringInvocationException(Throwable e) {
super(e);
}
-
- public SpringInvocationException(String msg,Throwable e) {
- super(msg,e);
+
+ public SpringInvocationException(String msg, Throwable e) {
+ super(msg, e);
}
}
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java
index 1f9796ccc4..fc0642cdb1 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/invocation/SpringInvoker.java
@@ -70,14 +70,14 @@ public class SpringInvoker implements Invoker {
} // end constructor SpringInvoker
// Lazy-load the method to avoid timing problems with the Spring Context
- private void setupMethod() throws SpringInvocationException{
+ private void setupMethod() throws SpringInvocationException {
try {
bean = springContext.getBean(beanElement.getId());
Class<?> beanClass = bean.getClass();
theMethod = JavaInterfaceUtil.findMethod(beanClass, operation);
//System.out.println("SpringInvoker - found method " + theMethod.getName() );
} catch (NoSuchMethodException e) {
- throw new SpringInvocationException(e);
+ throw new SpringInvocationException(e);
}
}
@@ -98,9 +98,10 @@ public class SpringInvoker implements Invoker {
}
return ret;
} catch (InvocationTargetException e) {
- throw new SpringInvocationException("Spring invoker invoke method '"+ theMethod.getName()+"' error.",e.getCause());
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.",
+ e.getCause());
} catch (Exception e) {
- throw new SpringInvocationException("Spring invoker invoke method '"+ theMethod.getName()+"' error.",e);
+ throw new SpringInvocationException("Spring invoker invoke method '" + theMethod.getName() + "' error.", e);
}
} // end method doInvoke
@@ -114,7 +115,7 @@ public class SpringInvoker implements Invoker {
msg.setBody(resp);
} catch (SpringInvocationException e) {
msg.setFaultBody(e.getCause());
- }catch (Throwable e) {
+ } catch (Throwable e) {
msg.setFaultBody(e);
}
//System.out.println("Spring Invoker - invoke called");
diff --git a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
index d553011098..086dd3b5cf 100644
--- a/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
@@ -51,7 +51,8 @@ import org.apache.tuscany.sca.monitor.Problem.Severity;
*
* @version $Rev$ $Date$
*/
-public class SpringImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<SpringImplementation> {
+public class SpringImplementationProcessor extends BaseStAXArtifactProcessor implements
+ StAXArtifactProcessor<SpringImplementation> {
private static final String LOCATION = "location";
private static final String IMPLEMENTATION_SPRING = "implementation.spring";
@@ -61,7 +62,6 @@ public class SpringImplementationProcessor extends BaseStAXArtifactProcessor imp
private ExtensionPointRegistry registry;
private AssemblyFactory assemblyFactory;
private PolicySubjectProcessor policyProcessor;
-
private FactoryExtensionPoint factories;
@@ -80,10 +80,16 @@ public class SpringImplementationProcessor extends BaseStAXArtifactProcessor imp
* @param model
*/
private void error(Monitor monitor, String message, Object model, Exception ex) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "impl-spring-validation-messages", Severity.ERROR, model, message, ex);
- monitor.problem(problem);
- }
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ ex);
+ monitor.problem(problem);
+ }
}
/**
@@ -94,10 +100,16 @@ public class SpringImplementationProcessor extends BaseStAXArtifactProcessor imp
* @param model
*/
private void error(Monitor monitor, String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "impl-spring-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
+ if (monitor != null) {
+ Problem problem =
+ monitor.createProblem(this.getClass().getName(),
+ "impl-spring-validation-messages",
+ Severity.ERROR,
+ model,
+ message,
+ (Object[])messageParameters);
+ monitor.problem(problem);
+ }
}
/*
@@ -119,7 +131,8 @@ public class SpringImplementationProcessor extends BaseStAXArtifactProcessor imp
* then the default behaviour is to build an application context using all the *.xml files
* in the METAINF/spring directory.
*/
- public SpringImplementation read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException, XMLStreamException {
+ public SpringImplementation read(XMLStreamReader reader, ProcessorContext context)
+ throws ContributionReadException, XMLStreamException {
// Create the Spring implementation
SpringImplementation springImplementation = null;
@@ -127,12 +140,12 @@ public class SpringImplementationProcessor extends BaseStAXArtifactProcessor imp
// Read the location attribute for the spring implementation
String springLocation = getURIString(reader, LOCATION);
if (springLocation != null) {
- springImplementation = new SpringImplementation();
- springImplementation.setLocation(springLocation);
- springImplementation.setUnresolved(true);
+ springImplementation = new SpringImplementation();
+ springImplementation.setLocation(springLocation);
+ springImplementation.setUnresolved(true);
processComponentType(springImplementation);
} else {
- error(context.getMonitor(), "LocationAttributeMissing", reader);
+ error(context.getMonitor(), "LocationAttributeMissing", reader);
//throw new ContributionReadException(MSG_LOCATION_MISSING);
}
@@ -167,7 +180,8 @@ public class SpringImplementationProcessor extends BaseStAXArtifactProcessor imp
* Write out the XML representation of the Spring implementation
* <implementation.spring location="..." />
*/
- public void write(SpringImplementation springImplementation, XMLStreamWriter writer, ProcessorContext context) throws ContributionWriteException, XMLStreamException {
+ public void write(SpringImplementation springImplementation, XMLStreamWriter writer, ProcessorContext context)
+ throws ContributionWriteException, XMLStreamException {
// Write <implementation.spring>
writer.writeStartElement(Constants.SCA11_NS, IMPLEMENTATION_SPRING);
@@ -188,19 +202,18 @@ public class SpringImplementationProcessor extends BaseStAXArtifactProcessor imp
public void resolve(SpringImplementation springImplementation, ModelResolver resolver, ProcessorContext context)
throws ContributionResolveException {
- if (springImplementation == null)
- return;
+ if (springImplementation == null)
+ return;
- Monitor monitor = context.getMonitor();
+ Monitor monitor = context.getMonitor();
/* Load the Spring component type by reading the Spring application context */
- SpringXMLComponentTypeLoader springLoader =
- new SpringXMLComponentTypeLoader(registry, monitor);
+ SpringXMLComponentTypeLoader springLoader = new SpringXMLComponentTypeLoader(registry, monitor);
try {
// Load the Spring Implementation information from its application context file...
springLoader.load(springImplementation, resolver, context);
} catch (ContributionReadException e) {
- ContributionResolveException ce = new ContributionResolveException(e);
- error(monitor, "ContributionResolveException", resolver, ce);
+ ContributionResolveException ce = new ContributionResolveException(e);
+ error(monitor, "ContributionResolveException", resolver, ce);
throw ce;
}
@@ -209,12 +222,12 @@ public class SpringImplementationProcessor extends BaseStAXArtifactProcessor imp
// If the introspection fails to resolve, try to find a side file...
ComponentType componentType = resolver.resolveModel(ComponentType.class, ct, context);
if (componentType.isUnresolved()) {
- error(monitor, "UnableToResolveComponentType", resolver);
+ error(monitor, "UnableToResolveComponentType", resolver);
//throw new ContributionResolveException("SpringArtifactProcessor: unable to resolve componentType for Spring component");
} else {
springImplementation.setComponentType(componentType);
springImplementation.setUnresolved(false);
- }
+ }
} // end if