summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
Diffstat (limited to 'java')
-rw-r--r--java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java7
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java5
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java19
-rw-r--r--java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java12
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java69
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java30
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java27
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java56
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java23
-rw-r--r--java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java140
-rw-r--r--java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java25
-rw-r--r--java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java3
-rw-r--r--java/sca/modules/implementation-java/META-INF/MANIFEST.MF1
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java9
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java81
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java67
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java11
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java6
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java7
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java22
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java214
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java8
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java14
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java5
-rw-r--r--java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java16
-rw-r--r--java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator18
-rw-r--r--java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor33
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java4
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java4
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java8
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java3
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java4
-rw-r--r--java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java4
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java6
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java9
-rw-r--r--java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java13
-rw-r--r--java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java46
-rw-r--r--java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java22
-rw-r--r--java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java20
-rw-r--r--java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java19
-rw-r--r--java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java8
-rw-r--r--java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java9
49 files changed, 593 insertions, 549 deletions
diff --git a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
index aaf4e97371..b47be74712 100644
--- a/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
+++ b/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
@@ -34,6 +34,8 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicyFactory;
@@ -52,6 +54,11 @@ public class PolicySubjectProcessor extends BaseStAXArtifactProcessor {
public PolicySubjectProcessor(PolicyFactory policyFactory) {
this.policyFactory = policyFactory;
}
+
+ public PolicySubjectProcessor(ExtensionPointRegistry registry) {
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
+ }
/**
* Read policy intents associated with an operation.
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
index d15334000f..2d918a0592 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
@@ -18,8 +18,12 @@
*/
package org.apache.tuscany.sca.assembly;
+import java.util.List;
+
import javax.xml.namespace.QName;
+import org.apache.tuscany.sca.interfacedef.Operation;
+
/**
* Represents a component implementation.
*
@@ -27,4 +31,5 @@ import javax.xml.namespace.QName;
*/
public interface Implementation extends ComponentType {
QName getType();
+ List<Operation> getOperations();
}
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
index baa23450ab..20c7ea3206 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
+++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
@@ -19,9 +19,13 @@
package org.apache.tuscany.sca.assembly.impl;
+import java.util.ArrayList;
+import java.util.List;
+
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.policy.ExtensionType;
import org.apache.tuscany.sca.policy.PolicySubject;
@@ -33,6 +37,7 @@ import org.apache.tuscany.sca.policy.PolicySubject;
public abstract class ImplementationImpl extends ComponentTypeImpl implements Implementation, PolicySubject {
private QName type;
private ExtensionType extensionType;
+ private List<Operation> operations = new ArrayList<Operation>();
protected ImplementationImpl(QName type) {
super();
@@ -54,4 +59,18 @@ public abstract class ImplementationImpl extends ComponentTypeImpl implements Im
public String toString() {
return String.valueOf(getType());
}
+
+ public List<Operation> getOperations() {
+ return operations;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ ImplementationImpl impl = (ImplementationImpl)super.clone();
+ impl.operations = new ArrayList<Operation>();
+ for (Operation operation : operations) {
+ impl.operations.add((Operation)operation.clone());
+ }
+ return impl;
+ }
}
diff --git a/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java b/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
index 3e7eb96798..bfa98ad725 100644
--- a/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
+++ b/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
@@ -26,7 +26,7 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
-import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
@@ -104,20 +104,20 @@ public class OSGiExtensionPointRegistry extends DefaultExtensionPointRegistry {
@Override
public void stop() {
// Get a unique map as an extension point may exist in the map by different keys
- Map<ModuleActivator, ModuleActivator> map = new IdentityHashMap<ModuleActivator, ModuleActivator>();
+ Map<LifeCycleListener, LifeCycleListener> map = new IdentityHashMap<LifeCycleListener, LifeCycleListener>();
for (ServiceRegistration reg : services.values()) {
ServiceReference ref = reg.getReference();
if (ref != null) {
Object service = bundleContext.getService(ref);
- if (service instanceof ModuleActivator) {
- ModuleActivator activator = (ModuleActivator)service;
+ if (service instanceof LifeCycleListener) {
+ LifeCycleListener activator = (LifeCycleListener)service;
map.put(activator, activator);
}
reg.unregister();
}
}
- for (ModuleActivator activator : map.values()) {
- activator.stop(this);
+ for (LifeCycleListener activator : map.values()) {
+ activator.stop();
}
services.clear();
}
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
index f467fcfaba..f6be464cbc 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
@@ -19,9 +19,8 @@
package org.apache.tuscany.sca.core;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
+import static org.apache.tuscany.sca.extensibility.ServiceHelper.newInstance;
+
import java.lang.reflect.Modifier;
import java.util.HashMap;
import java.util.HashSet;
@@ -31,6 +30,7 @@ import java.util.Set;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.extensibility.ServiceHelper;
/**
* Default implementation of a registry to hold all the Tuscany core extension
@@ -65,9 +65,8 @@ public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
if (extensionPoint == null) {
throw new IllegalArgumentException("Cannot register null as an ExtensionPoint");
}
- if (extensionPoint instanceof LifeCycleListener) {
- ((LifeCycleListener)extensionPoint).start();
- }
+ ServiceHelper.start(extensionPoint);
+
Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass());
for (Class<?> i : interfaces) {
registerExtensionPoint(i, extensionPoint, declaration);
@@ -78,25 +77,6 @@ public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
extensionPoints.put(i, extensionPoint);
}
- private Constructor<?> getConstructor(Constructor<?>[] constructors, Class<?>[] paramTypes) {
- for (Constructor<?> c : constructors) {
- Class<?>[] types = c.getParameterTypes();
- if (c.getParameterTypes().length == paramTypes.length) {
- boolean found = true;
- for (int i = 0; i < types.length; i++) {
- if (types[i] != paramTypes[i]) {
- found = false;
- break;
- }
- }
- if (found) {
- return c;
- }
- }
- }
- return null;
- }
-
/**
* Get the extension point by the interface that it implements
*
@@ -116,38 +96,13 @@ public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
// Dynamically load an extension point class declared under META-INF/services
try {
ServiceDeclaration extensionPointDeclaration =
- ServiceDiscovery.getInstance().getServiceDeclaration(extensionPointType.getName());
+ ServiceDiscovery.getInstance().getServiceDeclaration(extensionPointType);
if (extensionPointDeclaration != null) {
- Class<?> extensionPointClass = extensionPointDeclaration.loadClass();
-
- // Construct the extension point
- Constructor<?>[] constructors = extensionPointClass.getConstructors();
- Constructor<?> constructor =
- getConstructor(constructors, new Class<?>[] {ExtensionPointRegistry.class});
- if (constructor != null) {
- extensionPoint = constructor.newInstance(this);
- } else {
- constructor = getConstructor(constructors, new Class<?>[] {});
- if (constructor != null) {
- extensionPoint = constructor.newInstance();
- } else {
- throw new IllegalArgumentException(
- "No valid constructor is found for " + extensionPointClass);
- }
- }
-
+ extensionPoint = newInstance(this, extensionPointDeclaration);
// Cache the loaded extension point
addExtensionPoint(extensionPoint, extensionPointDeclaration);
}
- } catch (InvocationTargetException e) {
- throw new IllegalArgumentException(e);
- } catch (IOException e) {
- throw new IllegalArgumentException(e);
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException(e);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(e);
- } catch (IllegalAccessException e) {
+ } catch (Throwable e) {
throw new IllegalArgumentException(e);
}
}
@@ -170,9 +125,7 @@ public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
throw new IllegalArgumentException("Cannot remove null as an ExtensionPoint");
}
- if (extensionPoint instanceof LifeCycleListener) {
- ((LifeCycleListener)extensionPoint).stop();
- }
+ ServiceHelper.stop(extensionPoint);
Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass());
for (Class<?> i : interfaces) {
@@ -222,9 +175,7 @@ public class DefaultExtensionPointRegistry implements ExtensionPointRegistry {
map.put(listener, listener);
}
}
- for (LifeCycleListener listener : map.values()) {
- listener.stop();
- }
+ ServiceHelper.stop(map.values());
extensionPoints.clear();
}
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
index 54d0d118bb..300acdc259 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
@@ -19,7 +19,8 @@
package org.apache.tuscany.sca.core;
-import java.lang.reflect.Constructor;
+import static org.apache.tuscany.sca.extensibility.ServiceHelper.newInstance;
+
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.security.AccessController;
@@ -109,33 +110,20 @@ public class DefaultFactoryExtensionPoint implements FactoryExtensionPoint {
// Dynamically load a factory class declared under META-INF/services
try {
ServiceDeclaration factoryDeclaration =
- ServiceDiscovery.getInstance().getServiceDeclaration(factoryInterface.getName());
+ ServiceDiscovery.getInstance().getServiceDeclaration(factoryInterface);
if (factoryDeclaration != null) {
- Class<?> factoryClass = factoryDeclaration.loadClass();
try {
-
- // Default empty constructor
- Constructor<?> constructor = factoryClass.getConstructor();
- factory = constructor.newInstance();
+ // Constructor taking the extension point registry
+ factory = newInstance(extensionPointRegistry, factoryDeclaration);
} catch (NoSuchMethodException e) {
- try {
-
- // Constructor taking the model factory extension point
- Constructor<?> constructor = factoryClass.getConstructor(FactoryExtensionPoint.class);
- factory = constructor.newInstance(this);
- } catch (NoSuchMethodException e1) {
-
- // Constructor taking the extension point registry
- Constructor<?> constructor = factoryClass.getConstructor(ExtensionPointRegistry.class);
- factory = constructor.newInstance(extensionPointRegistry);
- }
+ factory = newInstance(factoryDeclaration.loadClass(), FactoryExtensionPoint.class, this);
}
// Cache the loaded factory
factories.put(factoryInterface, factory);
-
- return factoryInterface.cast(factory);
-
+
+ return factoryInterface.cast(factory);
+
} else {
// If the input interface is an abstract class
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
index 60d933a443..83bc4a836e 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
@@ -19,8 +19,9 @@
package org.apache.tuscany.sca.core;
+import static org.apache.tuscany.sca.extensibility.ServiceHelper.newInstance;
+
import java.io.IOException;
-import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -61,7 +62,7 @@ public class DefaultModuleActivatorExtensionPoint implements ModuleActivatorExte
public void removeModuleActivator(ModuleActivator activator) {
if (activators.remove(activator)) {
- activator.stop(registry);
+ activator.stop();
}
}
@@ -89,14 +90,20 @@ public class DefaultModuleActivatorExtensionPoint implements ModuleActivatorExte
ModuleActivator activator = null;
try {
Class<ModuleActivator> activatorClass = (Class<ModuleActivator>)activatorDeclaration.loadClass();
- Constructor<ModuleActivator> constructor = null;
try {
- constructor = activatorClass.getConstructor();
- activator = constructor.newInstance();
+ activator = newInstance(activatorClass, ExtensionPointRegistry.class, registry);
} catch (NoSuchMethodException e) {
- // Try the one that takes a Map<String, String>
- constructor = activatorClass.getConstructor(Map.class);
- activator = constructor.newInstance(activatorDeclaration.getAttributes());
+ try {
+ activator =
+ newInstance(activatorClass,
+ new Class<?>[] {ExtensionPointRegistry.class, Map.class},
+ registry,
+ activatorDeclaration.getAttributes());
+
+ } catch (NoSuchMethodException e1) {
+ activator = newInstance(activatorClass);
+
+ }
}
} catch (Throwable e) {
String optional = activatorDeclaration.getAttributes().get("optional");
@@ -121,7 +128,7 @@ public class DefaultModuleActivatorExtensionPoint implements ModuleActivatorExte
getModuleActivators();
for (ModuleActivator activator : activators) {
try {
- activator.start(registry);
+ activator.start();
} catch (Throwable e) {
// Ignore the failing module for now
logger.log(Level.SEVERE, e.getMessage(), e);
@@ -136,7 +143,7 @@ public class DefaultModuleActivatorExtensionPoint implements ModuleActivatorExte
}
for (int i = activators.size() - 1; i >= 0; i--) {
try {
- activators.get(i).stop(registry);
+ activators.get(i).stop();
} catch (Throwable e) {
// Ignore the failing module for now
logger.log(Level.SEVERE, e.getMessage(), e);
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
index 5ff32e04df..eca59d689d 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
@@ -19,9 +19,8 @@
package org.apache.tuscany.sca.core;
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
+import static org.apache.tuscany.sca.extensibility.ServiceHelper.newInstance;
+
import java.lang.reflect.Modifier;
import java.util.HashSet;
import java.util.IdentityHashMap;
@@ -84,25 +83,6 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
}
}
- private Constructor<?> getConstructor(Constructor<?>[] constructors, Class<?>... paramTypes) {
- for (Constructor<?> c : constructors) {
- Class<?>[] types = c.getParameterTypes();
- if (c.getParameterTypes().length == paramTypes.length) {
- boolean found = true;
- for (int i = 0; i < types.length; i++) {
- if (types[i] != paramTypes[i]) {
- found = false;
- break;
- }
- }
- if (found) {
- return c;
- }
- }
- }
- return null;
- }
-
/**
* Get the utility by the interface that it implements
*
@@ -190,21 +170,13 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
}
if (utilityClass != null) {
// Construct the utility
- Constructor<?>[] constructors = utilityClass.getConstructors();
- Constructor<?> constructor = getConstructor(constructors, ExtensionPointRegistry.class, Map.class);
- if (constructor != null) {
- utility = constructor.newInstance(extensionPoints, utilityDeclaration.getAttributes());
+ if (utilityDeclaration != null) {
+ utility = newInstance(extensionPoints, utilityDeclaration);
} else {
- constructor = getConstructor(constructors, ExtensionPointRegistry.class);
- if (constructor != null) {
- utility = constructor.newInstance(extensionPoints);
- } else {
- constructor = getConstructor(constructors);
- if (constructor != null) {
- utility = constructor.newInstance();
- } else {
- throw new IllegalArgumentException("No valid constructor is found for " + utilityClass);
- }
+ try {
+ utility = newInstance(utilityClass, ExtensionPointRegistry.class, extensionPoints);
+ } catch (NoSuchMethodException e) {
+ utility = newInstance(utilityClass);
}
}
// Cache the loaded utility
@@ -214,17 +186,9 @@ public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
addUtility(key, utility);
}
}
- } catch (InvocationTargetException e) {
- throw new IllegalArgumentException(e);
- } catch (IOException e) {
- throw new IllegalArgumentException(e);
- } catch (ClassNotFoundException e) {
+ } catch (Throwable e) {
throw new IllegalArgumentException(e);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(e);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException(e);
- }
+ }
}
return utilityType.cast(utility);
}
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java
index dbfd0dcd90..f05c11f9b6 100644
--- a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java
@@ -28,7 +28,18 @@ package org.apache.tuscany.sca.core;
* "META-INF/services/org.apache.tuscany.core.ModuleActivator"
*
* The content of the file is the class name of the ModuleActivator implementation.
- * The implementation class must have a no-arg constructor. The same instance
+ * The implementation class can have different flavors of constructors. The following
+ * order will be searched:
+ * <ul>
+ * <li>(ExtensionRegistry.class)
+ * <li>(ExtensionRegistry.class, Map.class)
+ * <li>()
+ * </ul>
+ *
+ *
+ *
+ *
+ * The same instance
* will be used to invoke all the methods during different phases of the module
* activation. Note that the start and stop methods defined by this interface
* take a reference to the Tuscany SCA runtime ExtensionPointRegistry. This
@@ -38,23 +49,23 @@ package org.apache.tuscany.sca.core;
*
* @version $Rev$ $Date$
*/
-public interface ModuleActivator {
+public interface ModuleActivator extends LifeCycleListener {
/**
- * This method is invoked when the module is started by the Tuscany system.
+ * This method is invoked when the module is started by the Tuscany runtime.
* It can be used by this module to register extensions against extension
* points.
*
* @param registry The extension point registry
*/
- void start(ExtensionPointRegistry registry);
+ void start();
/**
- * This method is invoked when the module is stopped by the Tuscany system.
+ * This method is invoked when the module is stopped by the Tuscany runtime.
* It can be used by this module to unregister extensions against the
* extension points.
*
* @param registry The extension point registry
*/
- void stop(ExtensionPointRegistry registry);
+ void stop();
}
diff --git a/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java
new file mode 100644
index 0000000000..c642667f77
--- /dev/null
+++ b/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.extensibility;
+
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.LifeCycleListener;
+
+/**
+ * A helper for handling service lifecycle and instantiations
+ */
+public class ServiceHelper {
+ private ServiceHelper() {
+ }
+
+ /**
+ * Start the service instance
+ * @param instance
+ */
+ public static boolean start(Object instance) {
+ if (instance instanceof LifeCycleListener) {
+ ((LifeCycleListener)instance).start();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Stop the service instance
+ * @param instance
+ */
+ public static boolean stop(Object instance) {
+ if (instance instanceof LifeCycleListener) {
+ ((LifeCycleListener)instance).stop();
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Stop a collection of service instances
+ * @param instances
+ */
+ public static void stop(Collection<? extends Object> instances) {
+ if (instances == null) {
+ return;
+ }
+ for (Object instance : instances) {
+ if (instance instanceof LifeCycleListener) {
+ ((LifeCycleListener)instance).stop();
+ }
+ }
+ }
+
+ /**
+ * Create a service instance with one parameter
+ * @param cls The service type
+ * @param parameterType The parameter type
+ * @param parameter The parameter value
+ * @return The newly created service instance
+ * @throws Exception
+ */
+ public static <T> T newInstance(Class<T> cls, Class<?> parameterType, Object parameter) throws Exception {
+ Constructor<T> constructor = cls.getConstructor(parameterType);
+ return constructor.newInstance(parameter);
+ }
+
+ /**
+ * Create a service instance with an array of parameters
+ * @param cls The service type
+ * @param parameterTypes An array of parameter types
+ * @param parameters An array of parameter values
+ * @return The newly created service instance
+ * @throws Exception
+ */
+ public static <T> T newInstance(Class<T> cls, Class<?> parameterTypes[], Object... parameters) throws Exception {
+ Constructor<T> constructor = cls.getConstructor(parameterTypes);
+ return constructor.newInstance(parameters);
+ }
+
+ /**
+ * Create a service instance with the default no-arg constructor
+ * @param cls The service type
+ * @return The newly created service instance
+ * @throws Exception
+ */
+ public static <T> T newInstance(Class<T> cls) throws Exception {
+ Constructor<T> constructor = cls.getConstructor();
+ return constructor.newInstance();
+ }
+
+ private final static Class<?>[] ARG_TYPES = new Class<?>[] {ExtensionPointRegistry.class, Map.class};
+
+ /**
+ * Create a service instance from the service declaration
+ * @param <T>
+ * @param registry The extension point registry
+ * @param sd The service declaration
+ * @return The newly created service instance
+ * @throws Exception
+ */
+ public static <T> T newInstance(ExtensionPointRegistry registry, ServiceDeclaration sd) throws Exception {
+ Class<T> cls = (Class<T>)sd.loadClass();
+ T instance = null;
+ try {
+ // Try constructor(ExtensionPointRegistry.class)
+ instance = newInstance(cls, ExtensionPointRegistry.class, registry);
+ } catch (NoSuchMethodException e) {
+ try {
+ // Try Try constructor(ExtensionPointRegistry.class, Map.class)
+ instance = newInstance(cls, ARG_TYPES, registry, sd.getAttributes());
+ } catch (NoSuchMethodException e1) {
+ // Try constructor()
+ instance = newInstance(cls);
+ }
+ }
+ return instance;
+ }
+
+}
diff --git a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
index 0f36094311..62c238e135 100644
--- a/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
+++ b/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
@@ -19,22 +19,41 @@
package org.apache.tuscany.sca.host.webapp;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
-
/**
* A ServletContextListener to create and close the SCADomain
* when the webapp is initialized or destroyed.
*/
public class TuscanyContextListener implements ServletContextListener {
+ private final Logger logger = Logger.getLogger(TuscanyContextListener.class.getName());
+ private boolean inited;
public void contextInitialized(ServletContextEvent event) {
- ServletHostHelper.init(event.getServletContext());
+ logger.info(event.getServletContext().getServletContextName() + " is starting.");
+ try {
+ ServletHostHelper.init(event.getServletContext());
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ inited = true;
}
public void contextDestroyed(ServletContextEvent event) {
- ServletHostHelper.stop(event.getServletContext());
+ logger.info(event.getServletContext().getServletContextName() + " is stopping.");
+ if (!inited) {
+ return;
+ }
+ try {
+ ServletHostHelper.stop(event.getServletContext());
+ } catch (Throwable e) {
+ logger.log(Level.SEVERE, e.getMessage(), e);
+ }
+ inited = false;
}
}
diff --git a/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java b/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java
index f9b95c7da8..bd98a4af95 100644
--- a/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java
+++ b/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.implementation.bpel.impl;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.bpel.BPELFactory;
import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
@@ -31,7 +30,7 @@ import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition;
*/
public class BPELFactoryImpl implements BPELFactory {
- public BPELFactoryImpl(FactoryExtensionPoint modelFactories) {
+ public BPELFactoryImpl() {
}
public BPELImplementation createBPELImplementation() {
diff --git a/java/sca/modules/implementation-java/META-INF/MANIFEST.MF b/java/sca/modules/implementation-java/META-INF/MANIFEST.MF
index c7694912c8..517aaac39f 100644
--- a/java/sca/modules/implementation-java/META-INF/MANIFEST.MF
+++ b/java/sca/modules/implementation-java/META-INF/MANIFEST.MF
@@ -30,6 +30,7 @@ Import-Package: javax.jws,
org.apache.tuscany.sca.contribution.resolver;version="2.0.0",
org.apache.tuscany.sca.core;version="2.0.0",
org.apache.tuscany.sca.definitions;version="2.0.0";resolution:=optional,
+ org.apache.tuscany.sca.extensibility;version="2.0.0",
org.apache.tuscany.sca.implementation.java;version="2.0.0",
org.apache.tuscany.sca.implementation.java.introspect;version="2.0.0",
org.apache.tuscany.sca.interfacedef;version="2.0.0",
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java
index e44ebd7c91..f98a617925 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java
@@ -23,11 +23,18 @@ package org.apache.tuscany.sca.implementation.java;
*
* @version $Rev$ $Date$
*/
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.impl.JavaImplementationFactoryImpl;
public class DefaultJavaImplementationFactory extends JavaImplementationFactoryImpl implements JavaImplementationFactory {
+ public DefaultJavaImplementationFactory(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
+ // For UNIT test only
public DefaultJavaImplementationFactory() {
+ super(new DefaultExtensionPointRegistry());
}
-
}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java
deleted file mode 100644
index f72b40d794..0000000000
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.implementation.java;
-
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.core.ModuleActivator;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByReferenceProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ScopeProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.policy.PolicyFactory;
-
-/**
- * A module activator for the Java implementation model.
- *
- * @version $Rev$ $Date$
- */
-public class JavaImplementationActivator implements ModuleActivator {
-
- public void start(ExtensionPointRegistry registry) {
- FactoryExtensionPoint modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
- AssemblyFactory assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
- JavaInterfaceFactory javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
- PolicyFactory policyFactory = modelFactories.getFactory(PolicyFactory.class);
-
- BaseJavaClassVisitor[] extensions =
- new BaseJavaClassVisitor[] {new ConstructorProcessor(assemblyFactory),
- new AllowsPassByReferenceProcessor(assemblyFactory),
- new ComponentNameProcessor(assemblyFactory),
- new ContextProcessor(assemblyFactory),
- new DestroyProcessor(assemblyFactory), new EagerInitProcessor(assemblyFactory),
- new InitProcessor(assemblyFactory), new PropertyProcessor(assemblyFactory),
- new ReferenceProcessor(assemblyFactory, javaFactory),
- new ResourceProcessor(assemblyFactory), new ScopeProcessor(assemblyFactory),
- new ServiceProcessor(assemblyFactory, javaFactory),
- new HeuristicPojoProcessor(assemblyFactory, javaFactory),
- new PolicyProcessor(assemblyFactory, policyFactory)};
-
- JavaImplementationFactory javaImplementationFactory = modelFactories.getFactory(JavaImplementationFactory.class);
- for (JavaClassVisitor extension : extensions) {
- javaImplementationFactory.addClassVisitor(extension);
- }
-
- }
-
- public void stop(ExtensionPointRegistry registry) {
- }
-
-}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
index d6361a5655..a1f65ecc00 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
@@ -18,14 +18,21 @@
*/
package org.apache.tuscany.sca.implementation.java.impl;
+import java.io.IOException;
+import java.lang.reflect.Constructor;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+
/**
* A factory for the Java model.
*
@@ -35,9 +42,11 @@ public abstract class JavaImplementationFactoryImpl implements JavaImplementatio
private List<JavaClassVisitor> visitors = new ArrayList<JavaClassVisitor>();
private JavaClassIntrospectorImpl introspector;
+ private boolean loaded;
+ protected ExtensionPointRegistry registry;
- public JavaImplementationFactoryImpl() {
- introspector = new JavaClassIntrospectorImpl(visitors);
+ public JavaImplementationFactoryImpl(ExtensionPointRegistry registry) {
+ this.registry = registry;
}
public JavaImplementation createJavaImplementation() {
@@ -47,12 +56,12 @@ public abstract class JavaImplementationFactoryImpl implements JavaImplementatio
public JavaImplementation createJavaImplementation(Class<?> implementationClass) throws IntrospectionException {
JavaImplementation javaImplementation = createJavaImplementation();
- introspector.introspectClass(javaImplementation, implementationClass);
+ getIntrospector().introspectClass(javaImplementation, implementationClass);
return javaImplementation;
}
public void createJavaImplementation(JavaImplementation javaImplementation, Class<?> implementationClass) throws IntrospectionException {
- introspector.introspectClass(javaImplementation, implementationClass);
+ getIntrospector().introspectClass(javaImplementation, implementationClass);
}
public void addClassVisitor(JavaClassVisitor visitor) {
@@ -71,7 +80,57 @@ public abstract class JavaImplementationFactoryImpl implements JavaImplementatio
}
public List<JavaClassVisitor> getClassVisitors() {
+ loadVisitors();
return visitors;
}
+
+ /**
+ * Load visitors declared under META-INF/services
+ */
+ @SuppressWarnings("unchecked")
+ private synchronized void loadVisitors() {
+ if (loaded)
+ return;
+
+ // Get the databinding service declarations
+ Collection<ServiceDeclaration> visitorDeclarations;
+ try {
+ visitorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(JavaClassVisitor.class, true);
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+
+ // Load data bindings
+ for (ServiceDeclaration visitorDeclaration: visitorDeclarations) {
+ JavaClassVisitor visitor = null;
+ try {
+ Class<JavaClassVisitor> visitorClass = (Class<JavaClassVisitor>)visitorDeclaration.loadClass();
+
+ try {
+ Constructor<JavaClassVisitor> constructor = visitorClass.getConstructor(ExtensionPointRegistry.class);
+ visitor = constructor.newInstance(registry);
+ } catch (NoSuchMethodException e) {
+ visitor = visitorClass.newInstance();
+ }
+
+
+ } catch (Exception e) {
+ IllegalStateException ie = new IllegalStateException(e);
+ throw ie;
+ }
+
+ addClassVisitor(visitor);
+ }
+
+ loaded = true;
+ }
+
+ private synchronized JavaClassIntrospectorImpl getIntrospector() {
+ if (introspector != null) {
+ return introspector;
+ }
+ introspector = new JavaClassIntrospectorImpl(getClassVisitors());
+ return introspector;
+ }
}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java
index 39b20d41eb..26ca54df88 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java
@@ -23,9 +23,12 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
/**
* A convenience class for annotation processors which alleviates the need to
@@ -35,11 +38,19 @@ import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
*/
public abstract class BaseJavaClassVisitor implements JavaClassVisitor {
protected AssemblyFactory assemblyFactory;
+ protected JavaInterfaceFactory javaInterfaceFactory;
protected BaseJavaClassVisitor(AssemblyFactory factory) {
this.assemblyFactory = factory;
}
+ protected BaseJavaClassVisitor(ExtensionPointRegistry registry) {
+ super();
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
+ }
+
public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
index d70cdc114c..b951e17fd2 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
@@ -27,8 +27,8 @@ import java.util.Collection;
import java.util.List;
import java.util.Map;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -46,8 +46,8 @@ import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper;
public abstract class AbstractPropertyProcessor<A extends Annotation> extends BaseJavaClassVisitor {
private final Class<A> annotationClass;
- protected AbstractPropertyProcessor(AssemblyFactory assemblyFactory, Class<A> annotationClass) {
- super(assemblyFactory);
+ protected AbstractPropertyProcessor(ExtensionPointRegistry registry, Class<A> annotationClass) {
+ super(registry);
this.annotationClass = annotationClass;
}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
index b08a1f6182..4aa29d3b91 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
@@ -21,6 +21,7 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl;
import java.lang.reflect.Method;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
@@ -37,6 +38,10 @@ public class AllowsPassByReferenceProcessor extends BaseJavaClassVisitor {
super(factory);
}
+ public AllowsPassByReferenceProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
@Override
public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
type.setAllowsPassByReference(clazz.isAnnotationPresent(AllowsPassByReference.class));
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
index fd6dbcc1ed..1813a177b4 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -42,6 +43,10 @@ public class ComponentNameProcessor extends BaseJavaClassVisitor {
public ComponentNameProcessor(AssemblyFactory factory) {
super(factory);
}
+
+ public ComponentNameProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
index 2d5470c08c..68f0b46f2e 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
@@ -21,13 +21,12 @@ package org.apache.tuscany.sca.implementation.java.introspect.impl;
import java.lang.reflect.Constructor;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.JavaParameterImpl;
import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.oasisopen.sca.annotation.Property;
-import org.oasisopen.sca.annotation.Reference;
/**
* Handles processing of a constructor decorated with
@@ -41,6 +40,10 @@ public class ConstructorProcessor extends BaseJavaClassVisitor {
public ConstructorProcessor(AssemblyFactory factory) {
super(factory);
}
+
+ public ConstructorProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java
index 0694def99a..651ecdbd7e 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -44,6 +45,10 @@ public class ContextProcessor extends BaseJavaClassVisitor {
public ContextProcessor(AssemblyFactory factory) {
super(factory);
}
+
+ public ContextProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
index 68cfc4c189..25f31c5f12 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
@@ -38,6 +39,10 @@ public class DestroyProcessor extends BaseJavaClassVisitor {
public DestroyProcessor(AssemblyFactory factory) {
super(factory);
}
+
+ public DestroyProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
index ca02c96834..9ad7e8f7a9 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.implementation.java.introspect.impl;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
@@ -35,6 +36,10 @@ public class EagerInitProcessor extends BaseJavaClassVisitor {
super(factory);
}
+ public EagerInitProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
@Override
public <T> void visitClass(Class<T> clazz,
JavaImplementation type) throws IntrospectionException {
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
index 551909e9bc..87a8031ea7 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
@@ -42,6 +42,7 @@ import javax.jws.WebService;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
@@ -74,12 +75,15 @@ import org.oasisopen.sca.annotation.Remotable;
* @version $Rev$ $Date$
*/
public class HeuristicPojoProcessor extends BaseJavaClassVisitor {
- private JavaInterfaceFactory javaFactory;
public HeuristicPojoProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
super(assemblyFactory);
- this.javaFactory = javaFactory;
+ this.javaInterfaceFactory = javaFactory;
}
+
+ public HeuristicPojoProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
@@ -442,13 +446,13 @@ public class HeuristicPojoProcessor extends BaseJavaClassVisitor {
throws IntrospectionException {
org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
reference.setName(name);
- JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
reference.setInterfaceContract(interfaceContract);
try {
- JavaInterface callInterface = javaFactory.createJavaInterface(paramType);
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(paramType);
reference.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
reference.getInterfaceContract().setCallbackInterface(callbackInterface);
}
reference.setMultiplicity(Multiplicity.ZERO_ONE);
@@ -469,13 +473,13 @@ public class HeuristicPojoProcessor extends BaseJavaClassVisitor {
org.apache.tuscany.sca.assembly.Service service = assemblyFactory.createService();
service.setName(interfaze.getSimpleName());
- JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
service.setInterfaceContract(interfaceContract);
- JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
service.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
service.getInterfaceContract().setCallbackInterface(callbackInterface);
}
@@ -491,7 +495,7 @@ public class HeuristicPojoProcessor extends BaseJavaClassVisitor {
Class<?> callbackClass = callback.value();
JavaInterface javaInterface;
try {
- javaInterface = javaFactory.createJavaInterface(callbackClass);
+ javaInterface = javaInterfaceFactory.createJavaInterface(callbackClass);
contract.getInterfaceContract().setCallbackInterface(javaInterface);
} catch (InvalidInterfaceException e) {
throw new InvalidServiceTypeException("Invalid callback interface "+callbackClass, interfaze);
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
index 8d12f14729..8d67236fe2 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
@@ -22,6 +22,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
@@ -39,6 +40,10 @@ public class InitProcessor extends BaseJavaClassVisitor {
super(factory);
}
+ public InitProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
+
@Override
public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
Init annotation = method.getAnnotation(Init.class);
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
index ac7187b1c7..1b75ff938c 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
@@ -19,26 +19,29 @@
package org.apache.tuscany.sca.implementation.java.introspect.impl;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import javax.xml.namespace.QName;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.Callback;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicyFactory;
import org.apache.tuscany.sca.policy.PolicySet;
@@ -56,57 +59,16 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
private PolicyFactory policyFactory;
- public PolicyProcessor(AssemblyFactory assemblyFactory, PolicyFactory policyFactory) {
+ public PolicyProcessor(AssemblyFactory assemblyFactory, PolicyFactory policyFactory, JavaInterfaceFactory javaInterfaceFactory) {
super(assemblyFactory);
this.policyFactory = policyFactory;
+ this.javaInterfaceFactory = javaInterfaceFactory;
}
-
-
- @Override
- public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
- org.oasisopen.sca.annotation.Reference annotation =
- field.getAnnotation( org.oasisopen.sca.annotation.Reference.class);
- if (annotation == null) {
- return;
- }
- String name = annotation.name();
- if ("".equals(name)) {
- name = field.getName();
- }
-
- Reference reference = null;
- if ( (reference = getReferenceByName(name, type)) != null ) {
- readIntents(field.getAnnotation(Requires.class), reference.getRequiredIntents());
- readSpecificIntents(field.getAnnotations(), reference.getRequiredIntents());
- readPolicySets(field.getAnnotation(PolicySets.class), reference.getPolicySets());
- }
- }
-
- @Override
- public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
- Reference reference = null;
- if ( (reference = getReference(method, type)) != null ) {
- readIntents(method.getAnnotation(Requires.class), reference.getRequiredIntents());
- readSpecificIntents(method.getAnnotations(), reference.getRequiredIntents());
- readPolicySets(method.getAnnotation(PolicySets.class), reference.getPolicySets());
- } else {
- /*
- if ( type instanceof OperationsConfigurator ) {
- //Read the intents specified on the given implementation method
- if ( (method.getAnnotation(Requires.class) != null ||
- method.getAnnotation(PolicySets.class) != null ) &&
- (type instanceof PolicySubject )) {
- ConfiguredOperation confOp = assemblyFactory.createConfiguredOperation();
- confOp.setName(method.getName());
- ((OperationsConfigurator)type).getConfiguredOperations().add(confOp);
-
-
- readIntents(method.getAnnotation(Requires.class), confOp.getRequiredIntents());
- readPolicySets(method.getAnnotation(PolicySets.class), confOp.getPolicySets());
- }
- }
- */
- }
+
+ public PolicyProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
}
@Override
@@ -118,72 +80,53 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
((PolicySubject)type).getRequiredIntents(),
((PolicySubject)type).getPolicySets());
}
-
- // Process annotations on the service interfaces
- //TODO This will have to move to a JavaInterface introspector later
- for (Service service: type.getServices()) {
- InterfaceContract interfaceContract = service.getInterfaceContract();
- if (interfaceContract instanceof JavaInterfaceContract) {
- JavaInterfaceContract javaInterfaceContract = (JavaInterfaceContract)interfaceContract;
-
- // Read intents on the service interface
- if (javaInterfaceContract.getInterface() != null) {
- JavaInterface javaInterface = (JavaInterface)javaInterfaceContract.getInterface();
- if (javaInterface.getJavaClass() != null) {
- readIntentsAndPolicySets(javaInterface.getJavaClass(),
- service.getRequiredIntents(),
- service.getPolicySets());
- /*
- // Read intents on the service interface methods
- Method[] methods = javaInterface.getJavaClass().getMethods();
- ConfiguredOperation confOp = null;
- for (Method method: methods) {
- if ( method.getAnnotation(Requires.class) != null ||
- method.getAnnotation(PolicySets.class) != null ) {
- confOp = assemblyFactory.createConfiguredOperation();
- confOp.setName(method.getName());
- confOp.setContractName(service.getName());
-
- service.getConfiguredOperations().add(confOp);
- readIntents(method.getAnnotation(Requires.class), confOp.getRequiredIntents());
- readPolicySets(method.getAnnotation(PolicySets.class), confOp.getPolicySets());
- }
- }
- */
- }
-
+ // FIXME: [rfeng] We might want to refactor this out
+ // Find the business methods in the implementation class for all services
+ Set<Method> methods = new HashSet<Method>();
+ for (Service service : type.getServices()) {
+ for (Operation op : service.getInterfaceContract().getInterface().getOperations()) {
+ Method method;
+ try {
+ method = JavaInterfaceUtil.findMethod(clazz, op);
+ } catch (NoSuchMethodException e1) {
+ throw new IntrospectionException(e1);
}
-
- // Read intents on the callback interface
- if (javaInterfaceContract.getCallbackInterface() != null) {
- JavaInterface javaCallbackInterface = (JavaInterface)javaInterfaceContract.getCallbackInterface();
- if (javaCallbackInterface.getJavaClass() != null) {
- Callback callback = service.getCallback();
- if (callback == null) {
- callback = assemblyFactory.createCallback();
- service.setCallback(callback);
- }
- readIntentsAndPolicySets(javaCallbackInterface.getJavaClass(),
- callback.getRequiredIntents(),
- callback.getPolicySets());
-
- /*
- // Read intents on the callback interface methods
- Method[] methods = javaCallbackInterface.getJavaClass().getMethods();
- ConfiguredOperation confOp = null;
- for (Method method: methods) {
- confOp = assemblyFactory.createConfiguredOperation();
- confOp.setName(method.getName());
- callback.getConfiguredOperations().add(confOp);
- readIntents(method.getAnnotation(Requires.class), confOp.getRequiredIntents());
- readPolicySets(method.getAnnotation(PolicySets.class), confOp.getPolicySets());
- }
- */
- }
+ if (method != null) {
+ methods.add(method);
}
}
}
+ for (Method method : methods) {
+ JavaOperation op = javaInterfaceFactory.createJavaOperation(method);
+ type.getOperations().add(op);
+ }
+
+ // Read the operation-level policy settings for the implementation
+ for (Operation op : type.getOperations()) {
+ JavaOperation operation = (JavaOperation)op;
+ PolicySubject subject = op;
+ Method method = operation.getJavaMethod();
+ if (subject != null) {
+ readIntents(method.getAnnotation(Requires.class), subject.getRequiredIntents());
+ readSpecificIntents(method.getAnnotations(), subject.getRequiredIntents());
+ readPolicySets(method.getAnnotation(PolicySets.class), subject.getPolicySets());
+ }
+ }
+
+ // Start to process annotations on the reference members
+ Map<String, Reference> referenceMap = new HashMap<String, Reference>();
+ for(Reference ref: type.getReferences()) {
+ referenceMap.put(ref.getName(), ref);
+ }
+ Map<String, JavaElementImpl> members = type.getReferenceMembers();
+ for(Map.Entry<String, JavaElementImpl> e: members.entrySet()) {
+ Reference reference = referenceMap.get(e.getKey());
+ readIntents(e.getValue().getAnnotation(Requires.class), reference.getRequiredIntents());
+ readSpecificIntents(e.getValue().getAnnotations(), reference.getRequiredIntents());
+ readPolicySets(e.getValue().getAnnotation(PolicySets.class), reference.getPolicySets());
+ }
+
}
private void readSpecificIntents(Annotation[] annotations, List<Intent> requiredIntents) {
@@ -342,44 +285,5 @@ public class PolicyProcessor extends BaseJavaClassVisitor {
}
return qname;
}
-
-
- /**
- *
- * @param name
- * @param type
- * @return
- */
- private static Reference getReferenceByName(String name, JavaImplementation type) {
- for ( Reference reference : type.getReferences() ) {
- if ( reference.getName().equals(name) ) {
- return reference;
- }
- }
- return null;
- }
-
-
- /**
- *
- * @param method
- * @param type
- * @return
- */
- private static Reference getReference(Method method, JavaImplementation type) {
- //since the ReferenceProcessor is called ahead of the PolicyProcessor the type should have
- //picked up the reference setter method
- org.oasisopen.sca.annotation.Reference annotation =
- method.getAnnotation(org.oasisopen.sca.annotation.Reference.class);
- if (annotation != null) {
- if (JavaIntrospectionHelper.isSetter(method)) {
- String name = annotation.name();
- if ("".equals(name)) {
- name = JavaIntrospectionHelper.toPropertyName(method.getName());
- }
- return getReferenceByName(name, type);
- }
- }
- return null;
- }
+
}
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
index 4cbd5c013c..ed68be20b4 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
@@ -18,7 +18,7 @@
*/
package org.apache.tuscany.sca.implementation.java.introspect.impl;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.oasisopen.sca.annotation.Property;
/**
@@ -29,10 +29,10 @@ import org.oasisopen.sca.annotation.Property;
*/
public class PropertyProcessor extends AbstractPropertyProcessor<Property> {
- public PropertyProcessor(AssemblyFactory assemblyFactory) {
- super(assemblyFactory, Property.class);
+ public PropertyProcessor(ExtensionPointRegistry registry) {
+ super(registry, Property.class);
}
-
+
@Override
protected String getName(Property annotation) {
return annotation.name();
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
index 0733f0084c..d30ac074af 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
@@ -31,6 +31,7 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -52,12 +53,15 @@ import org.oasisopen.sca.annotation.Reference;
* @version $Rev$ $Date$
*/
public class ReferenceProcessor extends BaseJavaClassVisitor {
- private JavaInterfaceFactory javaFactory;
public ReferenceProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
super(assemblyFactory);
- this.javaFactory = javaFactory;
+ this.javaInterfaceFactory = javaFactory;
}
+
+ public ReferenceProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
@@ -173,7 +177,7 @@ public class ReferenceProcessor extends BaseJavaClassVisitor {
private org.apache.tuscany.sca.assembly.Reference createReference(JavaElementImpl element, String name)
throws IntrospectionException {
org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
- JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
reference.setInterfaceContract(interfaceContract);
// reference.setMember((Member)element.getAnchor());
@@ -207,10 +211,10 @@ public class ReferenceProcessor extends BaseJavaClassVisitor {
baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, genericType);
}
try {
- JavaInterface callInterface = javaFactory.createJavaInterface(baseType);
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(baseType);
reference.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
reference.getInterfaceContract().setCallbackInterface(callbackInterface);
}
} catch (InvalidInterfaceException e) {
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
index 49320579d0..3abe832cb9 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
@@ -23,6 +23,7 @@ import java.lang.reflect.Member;
import java.lang.reflect.Method;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -42,6 +43,10 @@ public class ResourceProcessor extends BaseJavaClassVisitor {
public ResourceProcessor(AssemblyFactory factory) {
super(factory);
}
+
+ public ResourceProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
index 66be4f1f1e..dfc122c715 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
@@ -19,6 +19,7 @@
package org.apache.tuscany.sca.implementation.java.introspect.impl;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.JavaScopeImpl;
@@ -34,6 +35,10 @@ public class ScopeProcessor extends BaseJavaClassVisitor {
public ScopeProcessor(AssemblyFactory factory) {
super(factory);
}
+
+ public ScopeProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public <T> void visitClass(Class<T> clazz,
diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
index 9753e4eff0..30ed5dda44 100644
--- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
+++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
@@ -28,12 +28,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import java.util.logging.Logger;
import javax.jws.WebService;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -55,12 +55,14 @@ import org.oasisopen.sca.annotation.Remotable;
* @version $Rev$ $Date$
*/
public class ServiceProcessor extends BaseJavaClassVisitor {
- private static final Logger logger = Logger.getLogger(ServiceProcessor.class.getName());
- private JavaInterfaceFactory javaFactory;
public ServiceProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
super(assemblyFactory);
- this.javaFactory = javaFactory;
+ this.javaInterfaceFactory = javaFactory;
+ }
+
+ public ServiceProcessor(ExtensionPointRegistry registry) {
+ super(registry);
}
@Override
@@ -180,7 +182,7 @@ public class ServiceProcessor extends BaseJavaClassVisitor {
public Service createService(Class<?> interfaze, String name) throws InvalidInterfaceException {
Service service = assemblyFactory.createService();
- JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
service.setInterfaceContract(interfaceContract);
if (name == null) {
@@ -189,10 +191,10 @@ public class ServiceProcessor extends BaseJavaClassVisitor {
service.setName(name);
}
- JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
service.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
service.getInterfaceContract().setCallbackInterface(callbackInterface);
}
return service;
diff --git a/java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator b/java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
deleted file mode 100644
index 856d4e55b2..0000000000
--- a/java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-org.apache.tuscany.sca.implementation.java.JavaImplementationActivator
diff --git a/java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor b/java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
new file mode 100644
index 0000000000..7bddb31227
--- /dev/null
+++ b/java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
@@ -0,0 +1,33 @@
+# Licensed to the Apache Software Foundation
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# NOTE: The ranking attribute is important for the JavaClassVistors
+# Some visitors need to be called after the others
+org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor;ranking=200
+org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByReferenceProcessor;ranking=190
+org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor;ranking=180
+org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor;ranking=170
+org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor;ranking=160
+org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor;ranking=150
+org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor;ranking=140
+org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor;ranking=130
+org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor;ranking=120
+org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor;ranking=110
+org.apache.tuscany.sca.implementation.java.introspect.impl.ScopeProcessor;ranking=100
+org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor;ranking=90
+org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor;ranking=80
+org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor;ranking=70 \ No newline at end of file
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
index a4d5c6fb95..b77aea4c78 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
@@ -51,11 +51,11 @@ public abstract class AbstractProcessorTest {
factory = new DefaultAssemblyFactory(registry);
javaFactory = new DefaultJavaInterfaceFactory(registry);
referenceProcessor = new ReferenceProcessor(factory, javaFactory);
- propertyProcessor = new PropertyProcessor(factory);
+ propertyProcessor = new PropertyProcessor(registry);
resourceProcessor = new ResourceProcessor(factory);
constructorProcessor = new ConstructorProcessor(factory);
referenceProcessor = new ReferenceProcessor(factory, javaFactory);
- propertyProcessor = new PropertyProcessor(factory);
+ propertyProcessor = new PropertyProcessor(registry);
}
protected <T> void visitConstructor(Constructor<T> constructor,
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
index e049ad0321..512e34a0fa 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
@@ -103,7 +103,7 @@ public class ConstructorProcessorTestCase {
AssemblyFactory assemblyFactory = new DefaultAssemblyFactory(registry);
JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory(registry);
ReferenceProcessor referenceProcessor = new ReferenceProcessor(assemblyFactory, javaFactory);
- PropertyProcessor propertyProcessor = new PropertyProcessor(assemblyFactory);
+ PropertyProcessor propertyProcessor = new PropertyProcessor(registry);
JavaParameterImpl[] parameters = type.getConstructor().getParameters();
for (int i = 0; i < parameters.length; i++) {
referenceProcessor.visitConstructorParameter(parameters[i], type);
@@ -179,7 +179,7 @@ public class ConstructorProcessorTestCase {
AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
JavaInterfaceFactory javaFactory = new DefaultJavaInterfaceFactory(registry);
ReferenceProcessor referenceProcessor = new ReferenceProcessor(assemblyFactory, javaFactory);
- PropertyProcessor propertyProcessor = new PropertyProcessor(assemblyFactory);
+ PropertyProcessor propertyProcessor = new PropertyProcessor(registry);
JavaParameterImpl[] parameters = type.getConstructor().getParameters();
for (int i = 0; i < parameters.length; i++) {
referenceProcessor.visitConstructorParameter(parameters[i], type);
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java
index 6c8c84a200..39a2980b2b 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java
@@ -22,15 +22,12 @@ import static org.junit.Assert.assertEquals;
import java.lang.reflect.Constructor;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
-import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
-import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
import org.junit.Before;
import org.junit.Test;
import org.oasisopen.sca.annotation.Property;
@@ -42,7 +39,6 @@ public class HeuristicAndPropertyTestCase {
private PropertyProcessor propertyProcessor;
private HeuristicPojoProcessor heuristicProcessor;
- private AssemblyFactory assemblyFactory = new DefaultAssemblyFactory();
private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
/**
@@ -63,8 +59,8 @@ public class HeuristicAndPropertyTestCase {
@Before
public void setUp() throws Exception {
ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
- propertyProcessor = new PropertyProcessor(assemblyFactory);
- heuristicProcessor = new HeuristicPojoProcessor(assemblyFactory, new DefaultJavaInterfaceFactory(registry));
+ propertyProcessor = new PropertyProcessor(registry);
+ heuristicProcessor = new HeuristicPojoProcessor(registry);
}
public static class Foo {
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
index c43db2df09..e1fe484a2e 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
@@ -35,7 +35,6 @@ import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.impl.PolicyJavaInterfaceVisitor;
-import org.apache.tuscany.sca.policy.DefaultPolicyFactory;
import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySubject;
import org.junit.Before;
@@ -246,7 +245,7 @@ public class PolicyProcessorTestCase {
public void setUp() throws Exception {
ExtensionPointRegistry registry = new DefaultExtensionPointRegistry();
serviceProcessor = new ServiceProcessor(new DefaultAssemblyFactory(), new DefaultJavaInterfaceFactory(registry));
- policyProcessor = new PolicyProcessor(new DefaultAssemblyFactory(), new DefaultPolicyFactory());
+ policyProcessor = new PolicyProcessor(registry);
visitor = new PolicyJavaInterfaceVisitor(registry);
JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
type = javaImplementationFactory.createJavaImplementation();
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
index b89efd8b9f..559659cdeb 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
@@ -28,7 +28,7 @@ import java.lang.reflect.Method;
import java.util.Collection;
import java.util.List;
-import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -50,7 +50,7 @@ public class PropertyProcessorTestCase {
public void setUp() throws Exception {
JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory();
type = javaImplementationFactory.createJavaImplementation();
- processor = new PropertyProcessor(new DefaultAssemblyFactory());
+ processor = new PropertyProcessor(new DefaultExtensionPointRegistry());
}
@Test
diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
index 6cdc9224bf..a90a6d18c7 100644
--- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
+++ b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
@@ -29,8 +29,8 @@ import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory;
import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
@@ -129,7 +129,7 @@ public class TestAbstractPropertyProcessorTestCase {
private class TestProcessor extends AbstractPropertyProcessor<Bar> {
public TestProcessor() {
- super(new DefaultAssemblyFactory(), Bar.class);
+ super(new DefaultExtensionPointRegistry(), Bar.class);
}
@Override
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
index 545898fe5f..20c7e8d60a 100644
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
@@ -19,7 +19,7 @@
package org.apache.tuscany.sca.implementation.osgi;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationFactoryImpl;
/**
@@ -27,8 +27,8 @@ import org.apache.tuscany.sca.implementation.osgi.impl.OSGiImplementationFactory
*/
public class DefaultOSGiImplementationFactory extends OSGiImplementationFactoryImpl {
- public DefaultOSGiImplementationFactory(FactoryExtensionPoint factoryExtensionPoint) {
- super(factoryExtensionPoint);
+ public DefaultOSGiImplementationFactory(ExtensionPointRegistry registry) {
+ super(registry);
}
}
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
index 80b68d1728..9fab65272f 100644
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
@@ -19,7 +19,7 @@
package org.apache.tuscany.sca.implementation.osgi.impl;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementationFactory;
import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
@@ -28,15 +28,12 @@ import org.apache.tuscany.sca.implementation.osgi.OSGiProperty;
*
*/
public class OSGiImplementationFactoryImpl implements OSGiImplementationFactory {
- private final FactoryExtensionPoint factoryExtensionPoint;
-
- public OSGiImplementationFactoryImpl(FactoryExtensionPoint factoryExtensionPoint) {
+ public OSGiImplementationFactoryImpl(ExtensionPointRegistry registry) {
super();
- this.factoryExtensionPoint = factoryExtensionPoint;
}
public OSGiImplementation createOSGiImplementation() {
- return new OSGiImplementationImpl(factoryExtensionPoint);
+ return new OSGiImplementationImpl();
}
public OSGiProperty createOSGiProperty() {
diff --git a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
index f3397619f5..51e1e69b5d 100644
--- a/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
+++ b/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.implementation.osgi.impl;
import org.apache.tuscany.sca.assembly.impl.ImplementationImpl;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.osgi.OSGiImplementation;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
@@ -37,18 +36,14 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm
private String bundleVersion;
private Bundle osgiBundle;
- private FactoryExtensionPoint modelFactories;
-
- protected OSGiImplementationImpl(FactoryExtensionPoint modelFactories) {
+ protected OSGiImplementationImpl() {
super(TYPE);
- this.modelFactories = modelFactories;
}
- public OSGiImplementationImpl(FactoryExtensionPoint modelFactories, String bundleSymbolicName, String bundleVersion) {
+ public OSGiImplementationImpl(String bundleSymbolicName, String bundleVersion) {
super(TYPE);
this.bundleSymbolicName = bundleSymbolicName;
this.bundleVersion = bundleVersion;
- this.modelFactories = modelFactories;
}
public String getBundleSymbolicName() {
@@ -59,10 +54,6 @@ public class OSGiImplementationImpl extends ImplementationImpl implements OSGiIm
return bundleVersion;
}
- public FactoryExtensionPoint getModelFactories() {
- return modelFactories;
- }
-
/**
* Since OSGi implementation annotations may not be processed until much later, leave it to
* the OSGi invoker to decide whether pass-by-reference is allowed.
diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
index 720db77e35..3aa257686d 100644
--- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
+++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
@@ -20,29 +20,14 @@ package org.apache.tuscany.sca.implementation.spring.introspect;
import java.util.List;
-import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.ComponentType;
import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaImplementation;
import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
-import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.PolicyProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor;
-import org.apache.tuscany.sca.implementation.java.introspect.impl.ServiceProcessor;
import org.apache.tuscany.sca.implementation.spring.SpringConstructorArgElement;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.policy.PolicyFactory;
/**
* Provides introspection functions for Spring beans
@@ -62,32 +47,11 @@ public class SpringBeanIntrospector {
* @param javaFactory The Java Interface Factory to use
* @param policyFactory The Policy Factory to use.
*/
- public SpringBeanIntrospector(AssemblyFactory assemblyFactory,
- JavaInterfaceFactory javaFactory,
- PolicyFactory policyFactory,
+ public SpringBeanIntrospector(ExtensionPointRegistry registry,
List<SpringConstructorArgElement> conArgs) {
- javaImplementationFactory = new DefaultJavaImplementationFactory();
-
- // Create the list of class visitors
- BaseJavaClassVisitor[] extensions =
- new BaseJavaClassVisitor[] {
- new ConstructorProcessor(assemblyFactory),
- new ComponentNameProcessor(assemblyFactory),
- new ContextProcessor(assemblyFactory),
- new DestroyProcessor(assemblyFactory),
- new EagerInitProcessor(assemblyFactory),
- new InitProcessor(assemblyFactory),
- new PropertyProcessor(assemblyFactory),
- new ReferenceProcessor(assemblyFactory, javaFactory),
- new ResourceProcessor(assemblyFactory),
- new ServiceProcessor(assemblyFactory, javaFactory),
- new SpringBeanPojoProcessor(assemblyFactory, javaFactory, conArgs),
- new PolicyProcessor(assemblyFactory, policyFactory)};
- for (JavaClassVisitor extension : extensions) {
- javaImplementationFactory.addClassVisitor(extension);
- }
-
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ javaImplementationFactory = factories.getFactory(JavaImplementationFactory.class);
} // end constructor
/**
diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
index bef2d3665d..3a8eec99fa 100644
--- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
+++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
@@ -43,6 +43,7 @@ import javax.jws.WebService;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.implementation.java.IntrospectionException;
import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
@@ -80,14 +81,17 @@ import org.oasisopen.sca.annotation.Remotable;
* @version $Rev$ $Date$
*/
public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
- private JavaInterfaceFactory javaFactory;
private List<SpringConstructorArgElement> conArgs;
public SpringBeanPojoProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory, List<SpringConstructorArgElement> conArgs) {
super(assemblyFactory);
- this.javaFactory = javaFactory;
+ this.javaInterfaceFactory = javaFactory;
this.conArgs = conArgs;
}
+
+ public SpringBeanPojoProcessor(ExtensionPointRegistry registry) {
+ super(registry);
+ }
@Override
public <T> void visitEnd(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
@@ -582,13 +586,13 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
throws IntrospectionException {
org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
reference.setName(name);
- JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
reference.setInterfaceContract(interfaceContract);
try {
- JavaInterface callInterface = javaFactory.createJavaInterface(paramType);
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(paramType);
reference.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
reference.getInterfaceContract().setCallbackInterface(callbackInterface);
}
reference.setMultiplicity(Multiplicity.ZERO_ONE);
@@ -609,13 +613,13 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
org.apache.tuscany.sca.assembly.Service service = assemblyFactory.createService();
service.setName(interfaze.getSimpleName());
- JavaInterfaceContract interfaceContract = javaFactory.createJavaInterfaceContract();
+ JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
service.setInterfaceContract(interfaceContract);
- JavaInterface callInterface = javaFactory.createJavaInterface(interfaze);
+ JavaInterface callInterface = javaInterfaceFactory.createJavaInterface(interfaze);
service.getInterfaceContract().setInterface(callInterface);
if (callInterface.getCallbackClass() != null) {
- JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+ JavaInterface callbackInterface = javaInterfaceFactory.createJavaInterface(callInterface.getCallbackClass());
service.getInterfaceContract().setCallbackInterface(callbackInterface);
}
@@ -631,7 +635,7 @@ public class SpringBeanPojoProcessor extends BaseJavaClassVisitor {
Class<?> callbackClass = callback.value();
JavaInterface javaInterface;
try {
- javaInterface = javaFactory.createJavaInterface(callbackClass);
+ javaInterface = javaInterfaceFactory.createJavaInterface(callbackClass);
contract.getInterfaceContract().setCallbackInterface(javaInterface);
} catch (InvalidInterfaceException e) {
throw new InvalidServiceTypeException("Invalid callback interface "+callbackClass, interfaze);
diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
index 9195b6c9cc..bd3134c5f2 100644
--- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
+++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
@@ -59,6 +59,7 @@ import org.apache.tuscany.sca.contribution.processor.ContributionResolveExceptio
import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.contribution.resolver.ClassReference;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl;
import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
@@ -89,7 +90,7 @@ import org.apache.tuscany.sca.policy.PolicyFactory;
* @version $Rev$ $Date$
*/
public class SpringXMLComponentTypeLoader {
-
+ private ExtensionPointRegistry registry;
private XMLInputFactory xmlInputFactory;
private ContributionFactory contributionFactory;
private AssemblyFactory assemblyFactory;
@@ -99,15 +100,14 @@ public class SpringXMLComponentTypeLoader {
private Monitor monitor;
private SpringBeanIntrospector beanIntrospector;
- public SpringXMLComponentTypeLoader(FactoryExtensionPoint factories,
- AssemblyFactory assemblyFactory,
- JavaInterfaceFactory javaFactory,
- PolicyFactory policyFactory,
+ public SpringXMLComponentTypeLoader(ExtensionPointRegistry registry,
Monitor monitor) {
super();
- this.assemblyFactory = assemblyFactory;
- this.javaFactory = javaFactory;
- this.policyFactory = policyFactory;
+ this.registry = registry;
+ FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.javaFactory = factories.getFactory(JavaInterfaceFactory.class);
+ this.policyFactory = factories.getFactory(PolicyFactory.class);
this.policyProcessor = new PolicySubjectProcessor(policyFactory);
this.contributionFactory = factories.getFactory(ContributionFactory.class);
this.xmlInputFactory = factories.getFactory(XMLInputFactory.class);
@@ -653,7 +653,7 @@ public class SpringXMLComponentTypeLoader {
Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
// Introspect the bean
beanIntrospector =
- new SpringBeanIntrospector(assemblyFactory, javaFactory, policyFactory, beanElement.getCustructorArgs());
+ new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
ComponentType beanComponentType = assemblyFactory.createComponentType();
javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
// Set the service name as bean name
@@ -680,7 +680,7 @@ public class SpringXMLComponentTypeLoader {
Class<?> beanClass = resolveClass(resolver, beanElement.getClassName(), context);
// Introspect the bean
beanIntrospector =
- new SpringBeanIntrospector(assemblyFactory, javaFactory, policyFactory, beanElement.getCustructorArgs());
+ new SpringBeanIntrospector(registry, beanElement.getCustructorArgs());
ComponentType beanComponentType = assemblyFactory.createComponentType();
javaImplementation = beanIntrospector.introspectBean(beanClass, beanComponentType);
Map<String, JavaElementImpl> propertyMap = javaImplementation.getPropertyMembers();
diff --git a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
index 5d896ca726..0cd85d1e33 100644
--- a/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
+++ b/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
@@ -36,14 +36,13 @@ import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.implementation.spring.SpringImplementation;
import org.apache.tuscany.sca.implementation.spring.introspect.SpringXMLComponentTypeLoader;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
-import org.apache.tuscany.sca.policy.PolicyFactory;
/**
* SpringArtifactProcessor is responsible for processing the XML of an <implementation.spring.../>
@@ -58,20 +57,18 @@ public class SpringImplementationProcessor implements StAXArtifactProcessor<Spri
private static final QName IMPLEMENTATION_SPRING_QNAME = new QName(Constants.SCA11_NS, IMPLEMENTATION_SPRING);
private static final String MSG_LOCATION_MISSING = "Reading implementation.spring - location attribute missing";
+ private ExtensionPointRegistry registry;
private AssemblyFactory assemblyFactory;
- private JavaInterfaceFactory javaFactory;
- private PolicyFactory policyFactory;
private PolicySubjectProcessor policyProcessor;
private FactoryExtensionPoint factories;
- public SpringImplementationProcessor(FactoryExtensionPoint modelFactories) {
- this.factories = modelFactories;
- this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class);
- this.javaFactory = modelFactories.getFactory(JavaInterfaceFactory.class);
- this.policyFactory = modelFactories.getFactory(PolicyFactory.class);
- this.policyProcessor = new PolicySubjectProcessor(policyFactory);
+ public SpringImplementationProcessor(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ this.factories = registry.getExtensionPoint(FactoryExtensionPoint.class);
+ this.assemblyFactory = factories.getFactory(AssemblyFactory.class);
+ this.policyProcessor = new PolicySubjectProcessor(registry);
}
/**
@@ -196,7 +193,7 @@ public class SpringImplementationProcessor implements StAXArtifactProcessor<Spri
Monitor monitor = context.getMonitor();
/* Load the Spring component type by reading the Spring application context */
SpringXMLComponentTypeLoader springLoader =
- new SpringXMLComponentTypeLoader(factories, assemblyFactory, javaFactory, policyFactory, monitor);
+ new SpringXMLComponentTypeLoader(registry, monitor);
try {
// Load the Spring Implementation information from its application context file...
springLoader.load(springImplementation, resolver, context);
diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java
index 9225926269..c849a1acfa 100644
--- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java
+++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.sca.interfacedef.java;
+import java.lang.reflect.Method;
import java.util.List;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
@@ -53,6 +54,13 @@ public interface JavaInterfaceFactory {
void createJavaInterface(JavaInterface javaInterface, Class<?> interfaceClass) throws InvalidInterfaceException;
/**
+ * Create a JavaOperation
+ * @param method
+ * @return
+ */
+ JavaOperation createJavaOperation(Method method);
+
+ /**
* Creates a new Java interface contract.
*
* @return
diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
index 1454851fb1..b443cb988e 100644
--- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
+++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java
@@ -18,6 +18,7 @@
*/
package org.apache.tuscany.sca.interfacedef.java.impl;
+import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -28,6 +29,7 @@ import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor;
/**
@@ -81,4 +83,11 @@ public abstract class JavaInterfaceFactoryImpl implements JavaInterfaceFactory {
public List<JavaInterfaceVisitor> getInterfaceVisitors() {
return visitors;
}
+
+ public JavaOperation createJavaOperation(Method method) {
+ JavaOperation op = new JavaOperationImpl();
+ op.setJavaMethod(method);
+ op.setName(method.getName());
+ return op;
+ }
}