You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/03/28 18:03:04 UTC

svn commit: r523381 [3/4] - in /incubator/tuscany/java/sca/kernel: core/src/main/java/org/apache/tuscany/core/bootstrap/ core/src/main/java/org/apache/tuscany/core/builder/ core/src/main/java/org/apache/tuscany/core/deployer/ core/src/main/java/org/apa...

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/util/JavaIntrospectionHelper.java Wed Mar 28 09:03:01 2007
@@ -18,20 +18,25 @@
  */
 package org.apache.tuscany.core.util;
 
+import java.beans.Introspector;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
+import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
 import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
+import java.lang.reflect.WildcardType;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
 /**
  * Implements various reflection-related operations
- *
+ * 
  * @version $Rev$ $Date$
  */
 public final class JavaIntrospectionHelper {
@@ -44,16 +49,17 @@
     private JavaIntrospectionHelper() {
     }
 
-
     /**
-     * Returns a collection of public, and protected fields declared by a class or one of its supertypes
+     * Returns a collection of public, and protected fields declared by a class
+     * or one of its supertypes
      */
     public static Set<Field> getAllPublicAndProtectedFields(Class clazz) {
         return getAllPublicAndProtectedFields(clazz, new HashSet<Field>());
     }
 
     /**
-     * Recursively evaluates the type hierachy to return all fields that are public or protected
+     * Recursively evaluates the type hierachy to return all fields that are
+     * public or protected
      */
     private static Set<Field> getAllPublicAndProtectedFields(Class clazz, Set<Field> fields) {
         if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
@@ -72,10 +78,12 @@
     }
 
     /**
-     * Returns a collection of public and protected  methods declared by a class or one of its supertypes. Note that
-     * overriden methods will not be returned in the collection (i.e. only the method override will be). <p/> This
-     * method can potentially be expensive as reflection information is not cached. It is assumed that this method will
-     * be used during a configuration phase.
+     * Returns a collection of public and protected methods declared by a class
+     * or one of its supertypes. Note that overriden methods will not be
+     * returned in the collection (i.e. only the method override will be). <p/>
+     * This method can potentially be expensive as reflection information is not
+     * cached. It is assumed that this method will be used during a
+     * configuration phase.
      */
     public static Set<Method> getAllUniquePublicProtectedMethods(Class clazz) {
         return getAllUniqueMethods(clazz, new HashSet<Method>());
@@ -101,7 +109,8 @@
                 List<Method> temp = new ArrayList<Method>();
                 boolean matched = false;
                 for (Method method : methods) {
-                    // only add if not already in the set from a supclass (i.e. the
+                    // only add if not already in the set from a supclass (i.e.
+                    // the
                     // method is not overrided)
                     if (exactMethodMatch(declaredMethod, method)) {
                         matched = true;
@@ -117,17 +126,18 @@
                 temp.clear();
             }
         }
-        // evaluate class hierarchy - this is done last to track inherited methods
+        // evaluate class hierarchy - this is done last to track inherited
+        // methods
         methods = getAllUniqueMethods(pClass.getSuperclass(), methods);
         return methods;
     }
 
     /**
-     * Finds the closest matching field with the given name, that is, a field of the exact specified type or,
-     * alternately, of a supertype.
-     *
-     * @param name   the name of the field
-     * @param type   the field type
+     * Finds the closest matching field with the given name, that is, a field of
+     * the exact specified type or, alternately, of a supertype.
+     * 
+     * @param name the name of the field
+     * @param type the field type
      * @param fields the collection of fields to search
      * @return the matching field or null if not found
      */
@@ -137,12 +147,14 @@
             if (field.getName().equals(name)) {
                 if (field.getType().equals(type)) {
                     return field; // exact match
-                } else if (field.getType().isAssignableFrom(type)
+                } else if (field.getType().isAssignableFrom(type) 
                     || (field.getType().isPrimitive() && primitiveAssignable(field.getType(), type))) {
-                    // We could have the situation where a field parameter is a primitive and the demarshalled value is
+                    // We could have the situation where a field parameter is a
+                    // primitive and the demarshalled value is
                     // an object counterpart (e.g. Integer and int)
                     // @spec issue
-                    // either an interface or super class, so keep a reference until
+                    // either an interface or super class, so keep a reference
+                    // until
                     // we know there are no closer types
                     candidate = field;
                 }
@@ -156,11 +168,11 @@
     }
 
     /**
-     * Finds the closest matching method with the given name, that is, a method taking the exact parameter types or,
-     * alternately, parameter supertypes.
-     *
-     * @param name    the name of the method
-     * @param types   the method parameter types
+     * Finds the closest matching method with the given name, that is, a method
+     * taking the exact parameter types or, alternately, parameter supertypes.
+     * 
+     * @param name the name of the method
+     * @param types the method parameter types
      * @param methods the collection of methods to search
      * @return the matching method or null if not found
      */
@@ -202,74 +214,38 @@
     }
 
     /**
-     * Searches a collection of fields for one that matches by name and has a multiplicity type. i.e. a List or Array of
-     * interfaces
-     *
-     * @return a matching field or null
-     */
-    public static Field findMultiplicityFieldByName(String name, Set<Field> fields) {
-        for (Field candidate : fields) {
-            if (candidate.getName().equals(name)
-                && (List.class.isAssignableFrom(candidate.getType()) || (candidate.getType().isArray()
-                && candidate.getType().getComponentType() != null && candidate.getType().getComponentType()
-                .isInterface()))) {
-                return candidate;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Searches a collection of method for one that matches by name and has single parameter of a multiplicity type.
-     * i.e. a List or Array of interfaces
-     *
-     * @return a matching method or null
-     */
-    public static Method findMultiplicityMethodByName(String name, Set<Method> methods) {
-        for (Method candidate : methods) {
-            if (candidate.getName().equals(name)
-                && candidate.getParameterTypes().length == 1
-                && (List.class.isAssignableFrom(candidate.getParameterTypes()[0])
-                || (candidate.getParameterTypes()[0].isArray()
-                && candidate.getParameterTypes()[0].getComponentType() != null
-                && candidate.getParameterTypes()[0].getComponentType().isInterface()))) {
-                return candidate;
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Determines if two methods "match" - that is, they have the same method names and exact parameter types (one is
-     * not a supertype of the other)
+     * Determines if two methods "match" - that is, they have the same method
+     * names and exact parameter types (one is not a supertype of the other)
      */
     public static boolean exactMethodMatch(Method method1, Method method2) {
         if (!method1.getName().equals(method2.getName())) {
             return false;
         }
-        Class[] types1 = method1.getParameterTypes();
-        Class[] types2 = method2.getParameterTypes();
-        if (types1.length == 0 && types2.length == 0) {
-            return true;
-        } else if (types1.length == types2.length) {
-            for (int n = 0; n < types1.length; n++) {
-                if (!types1[n].equals(types2[n])) {
-                    return false;
-                }
+        Class<?>[] types1 = method1.getParameterTypes();
+        Class<?>[] types2 = method2.getParameterTypes();
+        if (types1.length != types2.length) {
+            return false;
+        }
+        boolean matched = true;
+        for (int i = 0; i < types1.length; i++) {
+            if (types1[i] != types2[i]) {
+                matched = false;
+                break;
             }
-            return true;
         }
-        return false;
+        return matched;
     }
 
     public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws NoSuchMethodException {
-        return clazz.getConstructor((Class[]) null);
+        return clazz.getConstructor((Class[])null);
     }
 
     /**
-     * Loads a class corresponding to the class name using the current context class loader.
-     *
-     * @throws ClassNotFoundException if the class was not found on the classpath
+     * Loads a class corresponding to the class name using the current context
+     * class loader.
+     * 
+     * @throws ClassNotFoundException if the class was not found on the
+     *             classpath
      */
     public static Class loadClass(String pName) throws ClassNotFoundException {
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -277,57 +253,100 @@
     }
 
     /**
-     * Returns the simple name of a class - i.e. the class name devoid of its package qualifier
-     *
+     * Returns the simple name of a class - i.e. the class name devoid of its
+     * package qualifier
+     * 
      * @param implClass the implmentation class
      */
     public static String getBaseName(Class<?> implClass) {
-        String baseName = implClass.getName();
-        int lastDot = baseName.lastIndexOf('.');
-        if (lastDot != -1) {
-            baseName = baseName.substring(lastDot + 1);
-        }
-        return baseName;
+        return implClass.getSimpleName();
     }
 
     public static boolean isImmutable(Class clazz) {
-        return String.class == clazz
-            || clazz.isPrimitive()
-            || Number.class.isAssignableFrom(clazz)
-            || Boolean.class.isAssignableFrom(clazz)
-            || Character.class.isAssignableFrom(clazz)
-            || Byte.class.isAssignableFrom(clazz);
+        return String.class == clazz || clazz.isPrimitive()
+               || Number.class.isAssignableFrom(clazz)
+               || Boolean.class.isAssignableFrom(clazz)
+               || Character.class.isAssignableFrom(clazz)
+               || Byte.class.isAssignableFrom(clazz);
     }
 
     /**
-     * Takes a property name and converts it to a getter method name according to JavaBean conventions. For example,
-     * property <code>foo<code> is returned as <code>getFoo</code>
+     * Takes a property name and converts it to a getter method name according
+     * to JavaBean conventions. For example, property
+     * <code>foo<code> is returned as <code>getFoo</code>
      */
     public static String toGetter(String name) {
         return "get" + name.toUpperCase().substring(0, 1) + name.substring(1);
     }
 
     /**
-     * Takes a setter or getter method name and converts it to a property name according to JavaBean conventions. For
-     * example, <code>setFoo(var)</code> is returned as property <code>foo<code>
+     * Takes a setter or getter method name and converts it to a property name
+     * according to JavaBean conventions. For example, <code>setFoo(var)</code>
+     * is returned as property <code>foo<code>
      */
     public static String toPropertyName(String name) {
         if (!name.startsWith("set")) {
             return name;
         }
-        return Character.toLowerCase(name.charAt(3)) + name.substring(4);
+        return Introspector.decapitalize(name.substring(3));
+    }
+
+    public static Class<?> getErasure(Type type) {
+        if (type instanceof Class) {
+            return (Class)type;
+        } else if (type instanceof GenericArrayType) {
+            // FIXME: How to deal with the []?
+            GenericArrayType arrayType = (GenericArrayType)type;
+            return getErasure(arrayType.getGenericComponentType());
+        } else if (type instanceof ParameterizedType) {
+            ParameterizedType pType = (ParameterizedType)type;
+            return getErasure(pType.getRawType());
+        } else if (type instanceof WildcardType) {
+            WildcardType wType = (WildcardType)type;
+            Type[] types = wType.getUpperBounds();
+            return getErasure(types[0]);
+        } else if (type instanceof TypeVariable) {
+            TypeVariable var = (TypeVariable)type;
+            Type[] types = var.getBounds();
+            return getErasure(types[0]);
+        }
+        return null;
+    }
+
+    public static Class<?> getBaseType(Class<?> cls, Type genericType) {
+        if (cls.isArray()) {
+            return cls.getComponentType();
+        } else if (Collection.class.isAssignableFrom(cls)) {
+            if (genericType instanceof ParameterizedType) {
+                // Collection<BaseType>
+                ParameterizedType parameterizedType = (ParameterizedType)genericType;
+                Type baseType = parameterizedType.getActualTypeArguments()[0];
+                if (baseType instanceof GenericArrayType) {
+                    // Base is array
+                    return cls;
+                } else {
+                    return getErasure(baseType);
+                }
+            } else {
+                return cls;
+            }
+        } else {
+            return cls;
+        }
     }
 
     /**
-     * Takes a property name and converts it to a setter method name according to JavaBean conventions. For example, the
-     * property <code>foo<code> is returned as <code>setFoo(var)</code>
+     * Takes a property name and converts it to a setter method name according
+     * to JavaBean conventions. For example, the property
+     * <code>foo<code> is returned as <code>setFoo(var)</code>
      */
     public static String toSetter(String name) {
         return "set" + name.toUpperCase().substring(0, 1) + name.substring(1);
     }
 
     /**
-     * Compares a two types, assuming one is a primitive, to determine if the other is its object counterpart
+     * Compares a two types, assuming one is a primitive, to determine if the
+     * other is its object counterpart
      */
     private static boolean primitiveAssignable(Class memberType, Class param) {
         if (memberType == Integer.class) {
@@ -364,17 +383,19 @@
     }
 
     /**
-     * Returns the generic types represented in the given type. Usage as follows: <code>
+     * Returns the generic types represented in the given type. Usage as
+     * follows: <code>
      * JavaIntrospectionHelper.getGenerics(field.getGenericType());
      * <p/>
      * JavaIntrospectionHelper.getGenerics(m.getGenericParameterTypes()[0];); </code>
-     *
-     * @return the generic types in order of declaration or an empty array if the type is not genericized
+     * 
+     * @return the generic types in order of declaration or an empty array if
+     *         the type is not genericized
      */
     public static List<? extends Type> getGenerics(Type genericType) {
         List<Type> classes = new ArrayList<Type>();
         if (genericType instanceof ParameterizedType) {
-            ParameterizedType ptype = (ParameterizedType) genericType;
+            ParameterizedType ptype = (ParameterizedType)genericType;
             // get the type arguments
             Type[] targs = ptype.getActualTypeArguments();
             for (Type targ : targs) {
@@ -385,9 +406,8 @@
     }
 
     /**
-     * Returns the generic type specified by the class at the given position as in:
-     * <p/>
-     * <code> public class Foo<Bar,Baz>{ //.. }
+     * Returns the generic type specified by the class at the given position as
+     * in: <p/> <code> public class Foo<Bar,Baz>{ //.. }
      * <p/>
      * JavaIntrospectionHelper.introspectGeneric(Foo.class,1); <code>
      * <p/>
@@ -397,26 +417,27 @@
         assert clazz != null : "No class specified";
         Type type = clazz.getGenericSuperclass();
         if (type instanceof ParameterizedType) {
-            Type[] args = ((ParameterizedType) type).getActualTypeArguments();
+            Type[] args = ((ParameterizedType)type).getActualTypeArguments();
             if (args.length <= pos) {
                 throw new IllegalArgumentException("Invalid index value for generic class " + clazz.getName());
             }
-            return (Class) ((ParameterizedType) type).getActualTypeArguments()[pos];
+            return (Class)((ParameterizedType)type).getActualTypeArguments()[pos];
         } else {
             Type[] interfaces = clazz.getGenericInterfaces();
             for (Type itype : interfaces) {
                 if (!(itype instanceof ParameterizedType)) {
                     continue;
                 }
-                ParameterizedType interfaceType = (ParameterizedType) itype;
-                return (Class) interfaceType.getActualTypeArguments()[0];
+                ParameterizedType interfaceType = (ParameterizedType)itype;
+                return (Class)interfaceType.getActualTypeArguments()[0];
             }
         }
         return null;
     }
 
     /**
-     * Returns the set of interfaces implemented by the given class and its ancestors or a blank set if none
+     * Returns the set of interfaces implemented by the given class and its
+     * ancestors or a blank set if none
      */
     public static Set<Class> getAllInterfaces(Class clazz) {
         Set<Class> implemented = new HashSet<Class>();

Modified: incubator/tuscany/java/sca/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/resources/org/apache/tuscany/core/implementation.scdl Wed Mar 28 09:03:01 2007
@@ -28,11 +28,7 @@
            autowire="true">
 
     <!-- Foundation implementation processors -->
-    <component name="implementation.ImplementationProcessorService">
-        <system:implementation.system
-            class="org.apache.tuscany.core.implementation.processor.ImplementationProcessorServiceImpl"/>
-    </component>
-    <component name="implementation.Constructor">
+    <component name="implementation.Constructor" initLevel="30">
         <system:implementation.system class="org.apache.tuscany.core.implementation.processor.ConstructorProcessor"/>
     </component>
     <component name="implementation.Destroy">

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractConstructorProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractConstructorProcessorTest.java?view=auto&rev=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractConstructorProcessorTest.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractConstructorProcessorTest.java Wed Mar 28 09:03:01 2007
@@ -0,0 +1,75 @@
+/*
+ * 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.core.implementation.processor;
+
+import java.lang.reflect.Constructor;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.monitor.NullMonitorFactory;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.Parameter;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
+
+/**
+ * Base class to simulate the processor sequences
+ * 
+ * @version $Rev$ $Date$
+ */
+public class AbstractConstructorProcessorTest extends TestCase {
+    protected ConstructorProcessor constructorProcessor;
+    private ReferenceProcessor referenceProcessor = new ReferenceProcessor();
+    private PropertyProcessor propertyProcessor = new PropertyProcessor();
+    private ResourceProcessor resourceProcessor = new ResourceProcessor();
+    private MonitorProcessor monitorProcessor = new MonitorProcessor(new NullMonitorFactory());
+
+
+    protected AbstractConstructorProcessorTest() {
+        constructorProcessor = new ConstructorProcessor();
+        referenceProcessor = new ReferenceProcessor();
+        referenceProcessor.setInterfaceProcessorRegistry(new JavaInterfaceProcessorRegistryImpl());
+        propertyProcessor = new PropertyProcessor();
+    }
+
+    protected <T> void visitConstructor(Constructor<T> constructor,
+                                        PojoComponentType<JavaMappedService, 
+                                        JavaMappedReference, JavaMappedProperty<?>> type,
+                                        DeploymentContext context) throws ProcessingException {
+        constructorProcessor.visitConstructor(constructor, type, context);
+        ConstructorDefinition<?> definition = type.getConstructorDefinition();
+        if (definition == null) {
+            definition = new ConstructorDefinition<T>(constructor);
+            type.getConstructors().put(constructor, definition);
+        }
+        Parameter[] parameters = definition.getParameters();
+        for (int i = 0; i < parameters.length; i++) {
+            referenceProcessor.visitConstructorParameter(parameters[i], type, null);
+            propertyProcessor.visitConstructorParameter(parameters[i], type, null);
+            resourceProcessor.visitConstructorParameter(parameters[i], type, null);
+            monitorProcessor.visitConstructorParameter(parameters[i], type, null);
+        }
+    }
+
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractConstructorProcessorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractConstructorProcessorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessorTestCase.java?view=auto&rev=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessorTestCase.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessorTestCase.java Wed Mar 28 09:03:01 2007
@@ -0,0 +1,166 @@
+/*
+ * 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.core.implementation.processor;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException;
+import org.apache.tuscany.spi.implementation.java.IllegalPropertyException;
+import org.apache.tuscany.spi.implementation.java.ImplementationProcessor;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.Parameter;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.easymock.EasyMock;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class AbstractPropertyProcessorTestCase extends TestCase {
+
+    private ImplementationProcessor processor;
+
+    public void testVisitMethod() throws Exception {
+        Method method = Foo.class.getMethod("setBar", String.class);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        processor.visitMethod(method, type, null);
+        JavaMappedProperty<?> prop = type.getProperties().get("test");
+        assertNotNull(prop.getDefaultValueFactory());
+    }
+
+    public void testVisitNoParamsMethod() throws Exception {
+        Method method = Foo.class.getMethod("setNoParamsBar");
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        try {
+            processor.visitMethod(method, type, null);
+            fail();
+        } catch (IllegalPropertyException e) {
+            // expected
+        }
+    }
+
+    public void testVisitNonVoidMethod() throws Exception {
+        Method method = Foo.class.getMethod("setBadBar", String.class);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        try {
+            processor.visitMethod(method, type, null);
+            fail();
+        } catch (IllegalPropertyException e) {
+            // expected
+        }
+    }
+
+    public void testDuplicateMethod() throws Exception {
+        Method method = Foo.class.getMethod("setBar", String.class);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        processor.visitMethod(method, type, null);
+        try {
+            processor.visitMethod(method, type, null);
+            fail();
+        } catch (DuplicatePropertyException e) {
+            // expected
+        }
+    }
+
+    public void testVisitField() throws Exception {
+        Field field = Foo.class.getDeclaredField("d");
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        processor.visitField(field, type, null);
+        JavaMappedProperty<?> prop = type.getProperties().get("test");
+        assertNotNull(prop.getDefaultValueFactory());
+    }
+
+    public void testVisitConstructor() throws Exception {
+        Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        ConstructorDefinition def = new ConstructorDefinition<Foo>(ctor);
+        Parameter parameter = def.getParameters()[0];
+        processor.visitConstructorParameter(parameter, type, null);
+        assertEquals("test", def.getParameters()[0].getName());
+        assertNotNull(type.getProperties().get("test"));
+    }
+
+    @SuppressWarnings("unchecked")
+    protected void setUp() throws Exception {
+        super.setUp();
+        processor = new TestProcessor();
+    }
+
+    @Retention(RUNTIME)
+    private @interface Bar {
+
+    }
+
+    private class TestProcessor extends AbstractPropertyProcessor<Bar> {
+
+        public TestProcessor() {
+            super(Bar.class);
+        }
+
+        @SuppressWarnings("unchecked")
+        protected <T> void initProperty(JavaMappedProperty<T> property, Bar annotation, DeploymentContext context) {
+            property.setDefaultValueFactory(EasyMock.createMock(ObjectFactory.class));
+            property.setName("test");
+        }
+
+        protected String getName(Bar annotation) {
+            return "test";
+        }
+    }
+
+    private static class Foo {
+
+        @Bar
+        protected String d;
+
+        public Foo(String a, @Bar
+        String b) {
+        }
+
+        public Foo(@Bar
+        String d) {
+            this.d = d;
+        }
+
+        @Bar
+        public void setBar(String d) {
+            this.d = d;
+        }
+
+        @Bar
+        public void setNoParamsBar() {
+        }
+
+        @Bar
+        public String setBadBar(String d) {
+            return null;
+        }
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessorTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AbstractPropertyProcessorTestCase.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessorTestCase.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/AllowsPassByReferenceProcessorTestCase.java Wed Mar 28 09:03:01 2007
@@ -18,6 +18,8 @@
  */
 package org.apache.tuscany.core.implementation.processor;
 
+import java.lang.reflect.Method;
+
 import org.osoa.sca.annotations.AllowsPassByReference;
 
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
@@ -36,11 +38,15 @@
     AllowsPassByReferenceProcessor processor;
 
     public void testClassAnnotation() throws Exception {
-//        processor.visitClass(Foo.class, type, null);
-//        assertEquals(true, type.isAllowsPassByReference());
-//
-//        processor.visitClass(Bar.class, type, null);
-//        assertEquals(false, type.isAllowsPassByReference());
+        processor.visitClass(Foo.class, type, null);
+        assertEquals(true, type.isAllowsPassByReference());
+
+        processor.visitClass(Bar.class, type, null);
+        assertEquals(false, type.isAllowsPassByReference());
+
+        Method m1 = Bar.class.getMethod("m1", new Class[] {});
+        processor.visitMethod(m1, type, null);
+        assertTrue(type.isAllowsPassByReference(m1));
     }
 
     protected void setUp() throws Exception {
@@ -53,7 +59,11 @@
     private class Foo {
     }
 
-    //no annotation
+    // no annotation
     private class Bar {
+        @AllowsPassByReference
+        public void m1() {
+
+        }
     }
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorProcessorTestCase.java Wed Mar 28 09:03:01 2007
@@ -23,28 +23,26 @@
 import java.util.List;
 import java.util.Set;
 
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Reference;
+import junit.framework.TestCase;
 
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.Parameter;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
 import org.apache.tuscany.spi.model.Multiplicity;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
 
 /**
  * @version $Rev$ $Date$
  */
 public class ConstructorProcessorTestCase extends TestCase {
-    private ConstructorProcessor processor =
-        new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+    private ConstructorProcessor processor = new ConstructorProcessor();
 
     public void testDuplicateConstructor() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         try {
             processor.visitClass(BadFoo.class, type, null);
             fail();
@@ -54,24 +52,21 @@
     }
 
     public void testConstructorAnnotation() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor1 = Foo.class.getConstructor(String.class);
         processor.visitConstructor(ctor1, type, null);
-        assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0));
+        assertEquals("foo", type.getConstructorDefinition().getParameters()[0].getName());
     }
 
     public void testNoAnnotation() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<NoAnnotation> ctor1 = NoAnnotation.class.getConstructor();
         processor.visitConstructor(ctor1, type, null);
         assertNull(type.getConstructorDefinition());
     }
 
     public void testBadAnnotation() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadAnnotation> ctor1 = BadAnnotation.class.getConstructor(String.class, Foo.class);
         try {
             processor.visitConstructor(ctor1, type, null);
@@ -82,13 +77,22 @@
     }
 
     public void testMixedParameters() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Mixed> ctor1 = Mixed.class.getConstructor(String.class, String.class, String.class);
         processor.visitConstructor(ctor1, type, null);
-        assertEquals("_ref0", type.getConstructorDefinition().getInjectionNames().get(0));
-        assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(1));
-        assertEquals("bar", type.getConstructorDefinition().getInjectionNames().get(2));
+
+        ReferenceProcessor referenceProcessor = new ReferenceProcessor();
+        referenceProcessor.setInterfaceProcessorRegistry(new JavaInterfaceProcessorRegistryImpl());
+        PropertyProcessor propertyProcessor = new PropertyProcessor();
+        Parameter[] parameters = type.getConstructorDefinition().getParameters();
+        for (int i = 0; i < parameters.length; i++) {
+            referenceProcessor.visitConstructorParameter(parameters[i], type, null);
+            propertyProcessor.visitConstructorParameter(parameters[i], type, null);
+        }
+
+        assertEquals("_ref0", parameters[0].getName());
+        assertEquals("foo", parameters[1].getName());
+        assertEquals("bar", parameters[2].getName());
     }
 
     private static class BadFoo {
@@ -122,31 +126,42 @@
         }
     }
 
-
     public static final class Mixed {
         @org.osoa.sca.annotations.Constructor
-        public Mixed(@Reference String param1,
-                     @Property(name = "foo")String param2,
-                     @Reference(name = "bar")String param3) {
+        public Mixed(@Reference String param1, 
+                     @Property(name = "foo") String param2, 
+                     @Reference(name = "bar") String param3) {
         }
     }
 
     public static final class Multiple {
         @org.osoa.sca.annotations.Constructor
-        public Multiple(@Reference Collection<String> param1,
-                        @Property(name = "foo")String[] param2,
-                        @Reference(name = "bar", required = true)List<String> param3,
-                        @Property(name = "abc")Set<String> param4,
-                        @Reference(name = "xyz")String[] param5) {
+        public Multiple(@Reference Collection<String> param1, 
+                        @Property(name = "foo") String[] param2, 
+                        @Reference(name = "bar", required = true) List<String> param3, 
+                        @Property(name = "abc") Set<String> param4, 
+                        @Reference(name = "xyz") String[] param5) {
         }
     }
 
     public void testMultiplicity() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        Constructor<Multiple> ctor1 =
-            Multiple.class.getConstructor(Collection.class, String[].class, List.class, Set.class, String[].class);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type 
+            = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        Constructor<Multiple> ctor1 = Multiple.class.getConstructor(Collection.class,
+                                                                    String[].class,
+                                                                    List.class,
+                                                                    Set.class,
+                                                                    String[].class);
         processor.visitConstructor(ctor1, type, null);
+        ReferenceProcessor referenceProcessor = new ReferenceProcessor();
+        referenceProcessor.setInterfaceProcessorRegistry(new JavaInterfaceProcessorRegistryImpl());
+        PropertyProcessor propertyProcessor = new PropertyProcessor();
+        Parameter[] parameters = type.getConstructorDefinition().getParameters();
+        for (int i = 0; i < parameters.length; i++) {
+            referenceProcessor.visitConstructorParameter(parameters[i], type, null);
+            propertyProcessor.visitConstructorParameter(parameters[i], type, null);
+        }
+
         JavaMappedReference ref0 = type.getReferences().get("_ref0");
         assertNotNull(ref0);
         assertEquals(Multiplicity.ZERO_N, ref0.getMultiplicity());

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorPropertyTestCase.java Wed Mar 28 09:03:01 2007
@@ -21,30 +21,25 @@
 import java.lang.reflect.Constructor;
 import java.util.List;
 
-import org.osoa.sca.annotations.Property;
+import junit.framework.TestCase;
 
 import org.apache.tuscany.spi.implementation.java.DuplicatePropertyException;
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.osoa.sca.annotations.Property;
 
 /**
  * @version $Rev$ $Date$
  */
-public class ConstructorPropertyTestCase extends TestCase {
-
-    ConstructorProcessor processor =
-        new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+public class ConstructorPropertyTestCase extends AbstractConstructorProcessorTest {
 
     public void testProperty() throws Exception {
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         JavaMappedProperty<?> property = type.getProperties().get("myProp");
         assertTrue(property.isRequired());
         assertEquals("myProp", property.getName());
@@ -54,7 +49,7 @@
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         assertNotNull(type.getProperties().get("myProp1"));
         assertNotNull(type.getProperties().get("myProp2"));
     }
@@ -64,7 +59,7 @@
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
         } catch (DuplicatePropertyException e) {
             // expected
@@ -76,7 +71,7 @@
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
         } catch (InvalidPropertyException e) {
             // expected
@@ -87,7 +82,7 @@
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         assertNotNull(type.getProperties().get("myProp"));
     }
 
@@ -96,9 +91,9 @@
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
-        } catch (InvalidPropertyException e) {
+        } catch (InvalidConstructorException e) {
             // expected
         }
     }
@@ -108,7 +103,7 @@
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
         } catch (InvalidConstructorException e) {
             // expected

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorReferenceTestCase.java Wed Mar 28 09:03:01 2007
@@ -21,27 +21,24 @@
 import java.lang.reflect.Constructor;
 import java.util.List;
 
-import org.osoa.sca.annotations.Reference;
+import junit.framework.TestCase;
 
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.osoa.sca.annotations.Reference;
 
 /**
  * @version $Rev$ $Date$
  */
-public class ConstructorReferenceTestCase extends TestCase {
-    private ConstructorProcessor processor;
+public class ConstructorReferenceTestCase extends AbstractConstructorProcessorTest {
 
     public void testReference() throws Exception {
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         JavaMappedReference reference = type.getReferences().get("myRef");
         assertTrue(reference.isRequired());
         assertEquals("#myRef", reference.getUri().toString());
@@ -51,7 +48,7 @@
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         assertNotNull(type.getReferences().get("myRef1"));
         assertNotNull(type.getReferences().get("myRef2"));
     }
@@ -61,7 +58,7 @@
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
         } catch (DuplicateReferenceException e) {
             // expected
@@ -72,7 +69,7 @@
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<NoNameFoo> ctor = NoNameFoo.class.getConstructor(String.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         assertNotNull(type.getReferences().get("_ref0"));
     }
 
@@ -80,7 +77,7 @@
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         assertNotNull(type.getReferences().get("myRef"));
     }
 
@@ -89,9 +86,9 @@
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadFoo> ctor = BadFoo.class.getConstructor(Integer.class, Integer.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
-        } catch (InvalidReferenceException e) {
+        } catch (InvalidConstructorException e) {
             // expected
         }
     }
@@ -101,7 +98,7 @@
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadFoo> ctor = BadFoo.class.getConstructor(List.class, List.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
         } catch (InvalidConstructorException e) {
             // expected
@@ -110,8 +107,6 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        processor =
-            new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
     }
 
 //    public void testMultiplicityRequired() throws Exception {

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorResourceTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorResourceTestCase.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorResourceTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/ConstructorResourceTestCase.java Wed Mar 28 09:03:01 2007
@@ -22,28 +22,21 @@
 import java.util.List;
 
 import org.apache.tuscany.api.annotation.Resource;
-
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
 
-import junit.framework.TestCase;
-import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
-
 /**
  * @version $Rev$ $Date$
  */
-public class ConstructorResourceTestCase extends TestCase {
-
-    ConstructorProcessor processor =
-        new ConstructorProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+public class ConstructorResourceTestCase extends AbstractConstructorProcessorTest {
 
     public void testResource() throws Exception {
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(String.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         org.apache.tuscany.spi.implementation.java.Resource resource = type.getResources().get("myResource");
         assertFalse(resource.isOptional());
     }
@@ -52,7 +45,7 @@
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(String.class, String.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         assertNotNull(type.getResources().get("myResource1"));
         assertNotNull(type.getResources().get("myResource2"));
     }
@@ -62,7 +55,7 @@
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<BadFoo> ctor = BadFoo.class.getConstructor(String.class, String.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
         } catch (DuplicateResourceException e) {
             // expected
@@ -75,7 +68,7 @@
         Constructor<ConstructorResourceTestCase.BadFoo> ctor =
             ConstructorResourceTestCase.BadFoo.class.getConstructor(String.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
         } catch (InvalidResourceException e) {
             // expected
@@ -86,7 +79,7 @@
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor<Foo> ctor = Foo.class.getConstructor(Integer.class);
-        processor.visitConstructor(ctor, type, null);
+        visitConstructor(ctor, type, null);
         assertNotNull(type.getResources().get("myResource"));
     }
 
@@ -96,9 +89,9 @@
         Constructor<ConstructorResourceTestCase.BadFoo> ctor =
             ConstructorResourceTestCase.BadFoo.class.getConstructor(Integer.class, Integer.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
-        } catch (InvalidResourceException e) {
+        } catch (InvalidConstructorException e) {
             // expected
         }
     }
@@ -109,7 +102,7 @@
         Constructor<ConstructorResourceTestCase.BadFoo> ctor =
             ConstructorResourceTestCase.BadFoo.class.getConstructor(List.class, List.class);
         try {
-            processor.visitConstructor(ctor, type, null);
+            visitConstructor(ctor, type, null);
             fail();
         } catch (InvalidConstructorException e) {
             // expected

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicAndPropertyTestCase.java Wed Mar 28 09:03:01 2007
@@ -22,6 +22,7 @@
 
 import org.osoa.sca.annotations.Property;
 
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
 import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
@@ -44,11 +45,10 @@
      */
     @SuppressWarnings("unchecked")
     public void testPropertyProcessorWithHeuristicProcessor() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         Constructor ctor = Foo.class.getConstructor(String.class);
         type.setConstructorDefinition(new ConstructorDefinition(ctor));
-        propertyProcessor.visitConstructor(ctor, type, null);
+        propertyProcessor.visitConstructorParameter(type.getConstructorDefinition().getParameters()[0], type, null);
         heuristicProcessor.visitEnd(Foo.class, type, null);
         assertEquals(1, type.getProperties().size());
         assertNotNull(type.getProperties().get("foo"));
@@ -56,14 +56,16 @@
 
     protected void setUp() throws Exception {
         super.setUp();
-        ImplementationProcessorServiceImpl service =
-            new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl());
-        propertyProcessor = new PropertyProcessor(service);
-        heuristicProcessor = new HeuristicPojoProcessor(service);
+        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+        propertyProcessor = new PropertyProcessor();
+        propertyProcessor.setInterfaceProcessorRegistry(registry);
+        heuristicProcessor = new HeuristicPojoProcessor();
+        heuristicProcessor.setInterfaceProcessorRegistry(registry);
     }
 
     public static class Foo {
-        public Foo(@Property(name = "foo") String prop) {
+        public Foo(@Property(name = "foo")
+        String prop) {
         }
     }
 

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicConstructorTestCase.java Wed Mar 28 09:03:01 2007
@@ -18,67 +18,80 @@
  */
 package org.apache.tuscany.core.implementation.processor;
 
+import java.lang.reflect.Constructor;
 import java.net.URI;
 
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Reference;
-import org.osoa.sca.annotations.Remotable;
-
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
 import org.apache.tuscany.spi.idl.java.JavaServiceContract;
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
+import org.apache.tuscany.spi.implementation.java.ProcessingException;
 import org.apache.tuscany.spi.model.ServiceContract;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Remotable;
 
 /**
  * @version $Rev$ $Date$
  */
-public class HeuristicConstructorTestCase extends TestCase {
+public class HeuristicConstructorTestCase extends AbstractConstructorProcessorTest {
 
-    private HeuristicPojoProcessor processor =
-        new HeuristicPojoProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+    private HeuristicPojoProcessor processor;
+
+    public HeuristicConstructorTestCase() {
+        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+        processor = new HeuristicPojoProcessor();
+        processor.setInterfaceProcessorRegistry(registry);
+    }
+
+    private <T> void visitEnd(Class<T> clazz,
+                              PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+                              DeploymentContext context) throws ProcessingException {
+        for (Constructor<T> constructor : clazz.getConstructors()) {
+            visitConstructor(constructor, type, context);
+        }
+        processor.visitEnd(clazz, type, context);
+    }
 
     /**
      * Verifies a single constructor is chosen with a parameter as the type
      */
     public void testSingleConstructorWithParam() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         JavaMappedProperty<String> prop = new JavaMappedProperty<String>();
         prop.setName("foo");
         prop.setJavaType(String.class);
         type.getProperties().put("foo", prop);
-        processor.visitEnd(Foo1.class, type, null);
+        visitEnd(Foo1.class, type, null);
         assertNotNull(type.getConstructorDefinition().getConstructor());
-        assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0));
+        assertEquals("foo", type.getConstructorDefinition().getParameters()[0].getName());
     }
 
     /**
      * Verifies a single constructor is chosen with a reference as the type
      */
     public void testSingleConstructorWithRef() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         JavaMappedReference ref = new JavaMappedReference();
         ref.setUri(URI.create("#foo"));
         ServiceContract contract = new JavaServiceContract(String.class);
         ref.setServiceContract(contract);
         type.getReferences().put("foo", ref);
-        processor.visitEnd(Foo1.class, type, null);
+        visitEnd(Foo1.class, type, null);
         assertNotNull(type.getConstructorDefinition().getConstructor());
-        assertEquals("foo", type.getConstructorDefinition().getInjectionNames().get(0));
+        assertEquals("foo", type.getConstructorDefinition().getParameters()[0].getName());
     }
 
     /**
-     * Verifies a single constructor is chosen with a property and a reference as the type
+     * Verifies a single constructor is chosen with a property and a reference
+     * as the type
      */
     public void testSingleConstructorWithPropRef() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
 
         JavaMappedProperty<String> prop = new JavaMappedProperty<String>();
         prop.setName("foo");
@@ -90,30 +103,26 @@
         ServiceContract contract = new JavaServiceContract(Foo1.class);
         ref.setServiceContract(contract);
         type.getReferences().put("ref", ref);
-        processor.visitEnd(Foo2.class, type, null);
+        visitEnd(Foo2.class, type, null);
         assertNotNull(type.getConstructorDefinition().getConstructor());
-        assertEquals(2, type.getConstructorDefinition().getInjectionNames().size());
+        assertEquals(2, type.getConstructorDefinition().getParameters().length);
     }
 
-
     public void testSingleConstructorResolvableParam() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        processor.visitEnd(Foo5.class, type, null);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        visitEnd(Foo5.class, type, null);
         assertEquals(String.class, type.getProperties().get("string").getJavaType());
     }
 
     public void testSingleConstructorResolvableRef() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        processor.visitEnd(Foo6.class, type, null);
-        assertEquals(Ref.class,
-            type.getReferences().get("heuristicconstructortestcase$ref").getServiceContract().getInterfaceClass());
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        visitEnd(Foo6.class, type, null);
+        assertEquals(Ref.class, type.getReferences().get("ref").getServiceContract()
+            .getInterfaceClass());
     }
 
     public void testSingleConstructorAmbiguousRef() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         JavaMappedReference ref = new JavaMappedReference();
         ref.setUri(URI.create("#ref"));
         ServiceContract contract = new JavaServiceContract(Foo1.class);
@@ -124,7 +133,7 @@
         ref2.setServiceContract(contract);
         type.getReferences().put("ref2", ref2);
         try {
-            processor.visitEnd(Foo4.class, type, null);
+            visitEnd(Foo4.class, type, null);
             fail();
         } catch (AmbiguousConstructorException e) {
             // expected
@@ -132,31 +141,27 @@
     }
 
     public void testConstructorPropertyAnnotatedParamsOnly() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        processor.visitEnd(Foo7.class, type, null);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        visitEnd(Foo7.class, type, null);
         assertNotNull(type.getProperties().get("myProp"));
     }
 
     public void testConstructorReferenceAnnotatedParamsOnly() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        processor.visitEnd(Foo8.class, type, null);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        visitEnd(Foo8.class, type, null);
         assertNotNull(type.getReferences().get("myRef"));
     }
 
     @SuppressWarnings("unchecked")
     public void testDefaultConstructor() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        processor.visitEnd(Foo3.class, type, null);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        visitEnd(Foo3.class, type, null);
         assertNotNull(type.getConstructorDefinition().getConstructor());
     }
 
     public void testSameTypesButAnnotated() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        processor.visitEnd(Foo12.class, type, null);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        visitEnd(Foo12.class, type, null);
         assertEquals(2, type.getProperties().size());
         assertNotNull(type.getProperties().get("prop1"));
         assertNotNull(type.getProperties().get("prop2"));
@@ -166,30 +171,27 @@
      * Verifies processing executes with additional extension annotations
      */
     public void testRandomAnnotation() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        processor.visitEnd(Foo11.class, type, null);
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        visitEnd(Foo11.class, type, null);
         assertEquals(1, type.getProperties().size());
         assertNotNull(type.getProperties().get("prop1"));
     }
 
     public void testPrivateConstructor() throws Exception {
-        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
-            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
+        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type = new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
         try {
-            processor.visitEnd(Foo14.class, type, null);
+            visitEnd(Foo14.class, type, null);
             fail();
         } catch (NoConstructorException e) {
             // expected
         }
     }
 
-
     public void testMultipleConstructors() throws Exception {
-        //    throw new UnsupportedOperationException("Finish heuristic multiple constructors - Foo10");
+        // throw new UnsupportedOperationException("Finish heuristic multiple
+        // constructors - Foo10");
     }
 
-
     public static class Foo1 {
         public Foo1(String val) {
         }
@@ -228,18 +230,20 @@
     }
 
     public static class Foo7 {
-        public Foo7(@Property(name = "myProp")String prop) {
+        public Foo7(@Property(name = "myProp")
+        String prop) {
         }
     }
 
-
     public static class Foo8 {
-        public Foo8(@Reference(name = "myRef")String ref) {
+        public Foo8(@Reference(name = "myRef")
+        String ref) {
         }
     }
 
     public static class Foo9 {
-        public Foo9(@Reference(name = "myRef")String ref) {
+        public Foo9(@Reference(name = "myRef")
+        String ref) {
         }
     }
 
@@ -251,20 +255,26 @@
         public Foo10(String prop) {
         }
 
-        public Foo10(@Property(name = "prop1")String prop1, @Property(name = "prop2")String prop2) {
+        public Foo10(@Property(name = "prop1")
+        String prop1, @Property(name = "prop2")
+        String prop2) {
 
         }
     }
 
     public static class Foo11 {
 
-        public Foo11(@Property(name = "prop1")String prop, @Baz String baz) {
+        public Foo11(@Property(name = "prop1")
+        String prop, @Baz
+        String baz) {
         }
     }
 
     public static class Foo12 {
 
-        public Foo12(@Property(name = "prop1")String prop, @Property(name = "prop2")String baz) {
+        public Foo12(@Property(name = "prop1")
+        String prop, @Property(name = "prop2")
+        String baz) {
         }
     }
 
@@ -273,7 +283,8 @@
     }
 
     public static class Foo13 {
-        public Foo13(@Reference String foo) {
+        public Foo13(@Reference
+        String foo) {
         }
     }
 
@@ -283,14 +294,17 @@
     }
 
     public static final class Foo15 {
-        public Foo15(@Reference String param1, @Reference String param2) {
+        public Foo15(@Reference
+        String param1, @Reference
+        String param2) {
         }
     }
 
     public static final class Foo16 {
-        public Foo16(@Reference String param1,
-                     @Property(name = "foo")String param2,
-                     @Reference(name = "bar")String param3) {
+        public Foo16(@Reference
+        String param1, @Property(name = "foo")
+        String param2, @Reference(name = "bar")
+        String param3) {
         }
     }
 

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java?view=diff&rev=523381&r1=523380&r2=523381
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/processor/HeuristicPojoProcessorTestCase.java Wed Mar 28 09:03:01 2007
@@ -23,21 +23,22 @@
 import java.util.Collection;
 import java.util.List;
 
-import org.osoa.sca.annotations.Property;
-import org.osoa.sca.annotations.Reference;
-import org.osoa.sca.annotations.Remotable;
-import org.osoa.sca.annotations.Service;
+import junit.framework.TestCase;
 
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
 import org.apache.tuscany.spi.databinding.extension.SimpleTypeMapperExtension;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
 import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
 import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
 import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
 import org.apache.tuscany.spi.implementation.java.JavaMappedService;
 import org.apache.tuscany.spi.implementation.java.PojoComponentType;
 import org.apache.tuscany.spi.implementation.java.ProcessingException;
-
-import junit.framework.TestCase;
-import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Remotable;
+import org.osoa.sca.annotations.Service;
 
 /**
  * Verfies component type information is properly introspected from an unadorned POJO according to the SCA Java Client
@@ -45,10 +46,24 @@
  *
  * @version $Rev$ $Date$
  */
-public class HeuristicPojoProcessorTestCase extends TestCase {
+public class HeuristicPojoProcessorTestCase extends AbstractConstructorProcessorTest {
+
+    private HeuristicPojoProcessor processor;
+
+    public HeuristicPojoProcessorTestCase() {
+        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+        processor = new HeuristicPojoProcessor();
+        processor.setInterfaceProcessorRegistry(registry);
+    }
 
-    private HeuristicPojoProcessor processor =
-        new HeuristicPojoProcessor(new ImplementationProcessorServiceImpl(new JavaInterfaceProcessorRegistryImpl()));
+    private <T> void visitEnd(Class<T> clazz,
+                              PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
+                              DeploymentContext context) throws ProcessingException {
+        for (Constructor<T> constructor : clazz.getConstructors()) {
+            visitConstructor(constructor, type, context);
+        }
+        processor.visitEnd(clazz, type, context);
+    }
 
     /**
      * Verifies a single service interface is computed when only one interface is implemented
@@ -120,8 +135,8 @@
         Constructor<ReferenceCollectionImpl> ctor = ReferenceCollectionImpl.class.getConstructor();
         type.setConstructorDefinition(new ConstructorDefinition<ReferenceCollectionImpl>(ctor));
         processor.visitEnd(ReferenceCollectionImpl.class, type, null);
-        assertEquals(0, type.getProperties().size());
-        assertEquals(4, type.getReferences().size());
+        assertEquals(1, type.getProperties().size());
+        assertEquals(3, type.getReferences().size());
     }
 
     /**
@@ -177,7 +192,7 @@
         JavaMappedProperty<?> prop2 = new JavaMappedProperty();
         prop2.setName("string2");
         type.add(prop2);
-        processor.visitEnd(MockService.class, type, null);
+        visitEnd(MockService.class, type, null);
         assertEquals(1, type.getServices().size());
     }
 
@@ -202,19 +217,18 @@
     public void testSetDataTypes() throws Exception {
         PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
             new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
-        Constructor<PropertyIntTypeOnConstructor> ctor = PropertyIntTypeOnConstructor.class.getConstructor(int.class);
+        Constructor<PropertyIntTypeOnConstructor> ctor = PropertyIntTypeOnConstructor.class.getConstructor();
         type.setConstructorDefinition(new ConstructorDefinition<PropertyIntTypeOnConstructor>(ctor));
-        processor.visitEnd(ProtectedRemotableRefMethodImpl.class, type, null);
+        processor.visitEnd(PropertyIntTypeOnConstructor.class, type, null);
         org.apache.tuscany.spi.model.Property<?> foo = type.getProperties().get("foo");
         assertEquals(int.class, foo.getJavaType());
         assertEquals(SimpleTypeMapperExtension.XSD_INT, foo.getXmlType());
     }
 
     private static class PropertyIntTypeOnConstructor {
-        private int foo;
+        protected int foo;
 
-        public PropertyIntTypeOnConstructor(@Property(name = "foo")int foo) {
-            this.foo = foo;
+        public PropertyIntTypeOnConstructor() {
         }
 
         public int getFoo() {
@@ -330,6 +344,7 @@
         }
 
         public void setNonGenericCollectionReference(Collection ref) {
+            // [rfeng] By the SCA spec, this should be classified as property
         }
 
         public void setListReference(List<Ref> ref) {



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org