tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r826907 [1/2] - in /tuscany/java/sca/modules: assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/ assembly/src/main/java/org/apache/tuscany/sca/assembly/ assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ extensibility...
Date Tue, 20 Oct 2009 00:17:16 GMT
Author: rfeng
Date: Tue Oct 20 00:17:14 2009
New Revision: 826907

URL: http://svn.apache.org/viewvc?rev=826907&view=rev
Log:
Turn JavaClassVisitor to declarative services and remove the module activator
Add a ServiceHelper utility to simplify the instantiation of declared services
Refactor the module activator to receive ExtensionPointRegistry from constructor

Added:
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java   (with props)
    tuscany/java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor
Removed:
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java
    tuscany/java/sca/modules/implementation-java/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
Modified:
    tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
    tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
    tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
    tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java
    tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
    tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java
    tuscany/java/sca/modules/implementation-java/META-INF/MANIFEST.MF
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
    tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ServiceProcessor.java
    tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractProcessorTest.java
    tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessorTestCase.java
    tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicAndPropertyTestCase.java
    tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessorTestCase.java
    tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessorTestCase.java
    tuscany/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/TestAbstractPropertyProcessorTestCase.java
    tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/DefaultOSGiImplementationFactory.java
    tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationFactoryImpl.java
    tuscany/java/sca/modules/implementation-osgi/src/main/java/org/apache/tuscany/sca/implementation/osgi/impl/OSGiImplementationImpl.java
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanIntrospector.java
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringBeanPojoProcessor.java
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/introspect/SpringXMLComponentTypeLoader.java
    tuscany/java/sca/modules/implementation-spring/src/main/java/org/apache/tuscany/sca/implementation/spring/xml/SpringImplementationProcessor.java
    tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/JavaInterfaceFactory.java
    tuscany/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceFactoryImpl.java

Modified: tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java (original)
+++ tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/PolicySubjectProcessor.java Tue Oct 20 00:17:14 2009
@@ -34,6 +34,8 @@
 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 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.

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Implementation.java Tue Oct 20 00:17:14 2009
@@ -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 @@
  */
 public interface Implementation extends ComponentType {
     QName getType();
+    List<Operation> getOperations();
 }

Modified: tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java (original)
+++ tuscany/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ImplementationImpl.java Tue Oct 20 00:17:14 2009
@@ -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 @@
 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 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;
+    }
 }

Modified: tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java (original)
+++ tuscany/java/sca/modules/extensibility-equinox/src/main/java/org/apache/tuscany/sca/extensibility/equinox/OSGiExtensionPointRegistry.java Tue Oct 20 00:17:14 2009
@@ -26,7 +26,7 @@
 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 @@
     @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();
     }

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java (original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java Tue Oct 20 00:17:14 2009
@@ -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 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 @@
         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 @@
         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 @@
             // 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 @@
             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 @@
                 map.put(listener, listener);
             }
         }
-        for (LifeCycleListener listener : map.values()) {
-            listener.stop();
-        }
+        ServiceHelper.stop(map.values());
         extensionPoints.clear();
     }
 

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java (original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultFactoryExtensionPoint.java Tue Oct 20 00:17:14 2009
@@ -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 @@
             // 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

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java (original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultModuleActivatorExtensionPoint.java Tue Oct 20 00:17:14 2009
@@ -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 void removeModuleActivator(ModuleActivator activator) {
         if (activators.remove(activator)) {
-            activator.stop(registry);
+            activator.stop();
         }
     }
 
@@ -89,14 +90,20 @@
             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 @@
         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 @@
         }
         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);

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java (original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java Tue Oct 20 00:17:14 2009
@@ -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 @@
         }
     }
 
-    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 @@
                 }
                 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 @@
                         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);
     }

Modified: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java (original)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/ModuleActivator.java Tue Oct 20 00:17:14 2009
@@ -28,7 +28,18 @@
  * "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 @@
  * 
  * @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();
 }

Added: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java?rev=826907&view=auto
==============================================================================
--- tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java (added)
+++ tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java Tue Oct 20 00:17:14 2009
@@ -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;
+    }
+
+}

Propchange: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/extensibility/ServiceHelper.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java (original)
+++ tuscany/java/sca/modules/host-webapp/src/main/java/org/apache/tuscany/sca/host/webapp/TuscanyContextListener.java Tue Oct 20 00:17:14 2009
@@ -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;
     }
 
 }

Modified: tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java (original)
+++ tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELFactoryImpl.java Tue Oct 20 00:17:14 2009
@@ -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 @@
  */
 public class BPELFactoryImpl implements BPELFactory {
     
-    public BPELFactoryImpl(FactoryExtensionPoint modelFactories) {
+    public BPELFactoryImpl() {
     }
 
     public BPELImplementation createBPELImplementation() {

Modified: tuscany/java/sca/modules/implementation-java/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/META-INF/MANIFEST.MF?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/META-INF/MANIFEST.MF (original)
+++ tuscany/java/sca/modules/implementation-java/META-INF/MANIFEST.MF Tue Oct 20 00:17:14 2009
@@ -30,6 +30,7 @@
  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",

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/DefaultJavaImplementationFactory.java Tue Oct 20 00:17:14 2009
@@ -23,11 +23,18 @@
  *
  * @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());
     }
-
 }

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/impl/JavaImplementationFactoryImpl.java Tue Oct 20 00:17:14 2009
@@ -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 @@
     
     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 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 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;
+    }
 
 }

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/BaseJavaClassVisitor.java Tue Oct 20 00:17:14 2009
@@ -23,9 +23,12 @@
 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 @@
  */
 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 {
     }
 

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AbstractPropertyProcessor.java Tue Oct 20 00:17:14 2009
@@ -27,8 +27,8 @@
 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 @@
 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;
     }
     

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/AllowsPassByReferenceProcessor.java Tue Oct 20 00:17:14 2009
@@ -21,6 +21,7 @@
 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 @@
         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));

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ComponentNameProcessor.java Tue Oct 20 00:17:14 2009
@@ -22,6 +22,7 @@
 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 ComponentNameProcessor(AssemblyFactory factory) {
         super(factory);
     }
+    
+    public ComponentNameProcessor(ExtensionPointRegistry registry) {
+        super(registry);
+    }
 
     @Override
     public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConstructorProcessor.java Tue Oct 20 00:17:14 2009
@@ -21,13 +21,12 @@
 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 ConstructorProcessor(AssemblyFactory factory) {
         super(factory);
     }
+    
+    public ConstructorProcessor(ExtensionPointRegistry registry) {
+        super(registry);
+    }
 
     @Override
     public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ContextProcessor.java Tue Oct 20 00:17:14 2009
@@ -22,6 +22,7 @@
 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 ContextProcessor(AssemblyFactory factory) {
         super(factory);
     }
+    
+    public ContextProcessor(ExtensionPointRegistry registry) {
+        super(registry);
+    }    
 
     @Override
     public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/DestroyProcessor.java Tue Oct 20 00:17:14 2009
@@ -22,6 +22,7 @@
 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 DestroyProcessor(AssemblyFactory factory) {
         super(factory);
     }
+    
+    public DestroyProcessor(ExtensionPointRegistry registry) {
+        super(registry);
+    }    
 
     @Override
     public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/EagerInitProcessor.java Tue Oct 20 00:17:14 2009
@@ -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 @@
         super(factory);
     }
 
+    public EagerInitProcessor(ExtensionPointRegistry registry) {
+        super(registry);
+    }    
+
     @Override
     public <T> void visitClass(Class<T> clazz,
                                JavaImplementation type) throws IntrospectionException {

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/HeuristicPojoProcessor.java Tue Oct 20 00:17:14 2009
@@ -42,6 +42,7 @@
 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 @@
  * @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 @@
         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 @@
         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 @@
             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);

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java Tue Oct 20 00:17:14 2009
@@ -22,6 +22,7 @@
 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 @@
         super(factory);
     }
 
+    public InitProcessor(ExtensionPointRegistry registry) {
+        super(registry);
+    }    
+
     @Override
     public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
         Init annotation = method.getAnnotation(Init.class);

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java Tue Oct 20 00:17:14 2009
@@ -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 @@
     
     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 @@
                                      ((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 @@
         }
         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;
-    }
+   
 }

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java Tue Oct 20 00:17:14 2009
@@ -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 @@
  */
 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();

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java Tue Oct 20 00:17:14 2009
@@ -31,6 +31,7 @@
 
 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 @@
  * @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 @@
     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 @@
             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) {

Modified: tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java?rev=826907&r1=826906&r2=826907&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java Tue Oct 20 00:17:14 2009
@@ -23,6 +23,7 @@
 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 ResourceProcessor(AssemblyFactory factory) {
         super(factory);
     }
+    
+    public ResourceProcessor(ExtensionPointRegistry registry) {
+        super(registry);
+    }    
 
     @Override
     public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {



Mime
View raw message