You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ad...@apache.org on 2008/05/03 22:52:58 UTC

svn commit: r653133 [29/33] - in /incubator/tuscany/sandbox/mobile-android: android-jdk-classes/ android-jdk-classes/src/ android-jdk-classes/src/javax/ android-jdk-classes/src/javax/xml/ android-jdk-classes/src/javax/xml/namespace/ android-jdk-classes...

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/IllegalServiceDefinitionException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an illegal use of the {@link @org.osoa.sca.annotations.Service} annotation
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class IllegalServiceDefinitionException extends IntrospectionException {
+    private static final long serialVersionUID = -7151534258405092548L;
+
+    public IllegalServiceDefinitionException(String message) {
+        super(message);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InitProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.osoa.sca.annotations.Init;
+
+/**
+ * Processes the {@link @Init} annotation on a component implementation and
+ * updates the component type with the decorated initializer method
+ * 
+ * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $
+ */
+public class InitProcessor extends BaseJavaClassVisitor {
+    
+    public InitProcessor(AssemblyFactory factory) {
+        super(factory);
+    }
+
+    @Override
+    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+        Init annotation = method.getAnnotation(Init.class);
+        if (annotation == null) {
+            return;
+        }
+        if (method.getParameterTypes().length != 0) {
+            throw new IllegalInitException("Initializer must not have argments", method);
+        }
+        if (type.getInitMethod() != null) {
+            throw new DuplicateInitException("More than one initializer found on implementaton");
+        }
+        if (Modifier.isProtected(method.getModifiers())) {
+            method.setAccessible(true);
+        }
+        type.setInitMethod(method);
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConstructorException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an invalid constructor definition, e.g. when the number of injection names specified in {@link
+ * org.osoa.sca.annotations.Constructor} do not match the number of actual constructor parameters
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class InvalidConstructorException extends IntrospectionException {
+    private static final long serialVersionUID = 1411492435210741512L;
+
+    public InvalidConstructorException(String message) {
+        super(message);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementation.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementation.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidConversationalImplementation.java Sat May  3 13:52:41 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Raised when an implementation specifies improper conversational metadata
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class InvalidConversationalImplementation extends IntrospectionException {
+    private static final long serialVersionUID = -5487291552769408149L;
+
+    public InvalidConversationalImplementation(String message) {
+        super(message);
+    }
+
+    public InvalidConversationalImplementation(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidPropertyException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an invalid usage of {@link org.osoa.sca.annotations.Property}
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class InvalidPropertyException extends IntrospectionException {
+    private static final long serialVersionUID = -2682862652069727948L;
+
+    public InvalidPropertyException(String message) {
+        super(message);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidReferenceException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an invalid usage of {@link org.osoa.sca.annotations.Reference}
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class InvalidReferenceException extends IntrospectionException {
+    private static final long serialVersionUID = -3285246635989254165L;
+
+    public InvalidReferenceException(String message) {
+        super(message);
+    }
+
+    public InvalidReferenceException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public InvalidReferenceException(Throwable cause) {
+        super(cause);
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidResourceException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Member;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Denotes an invalid usage of {@link @org.apache.tuscany.api.annotation.Resource}
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class InvalidResourceException extends IntrospectionException {
+    private static final long serialVersionUID = 511728001735534934L;
+
+    public InvalidResourceException(String message) {
+        super(message);
+    }
+    
+    public InvalidResourceException(String message, Member member) {
+        super(message, member);
+    }    
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceType.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceType.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceType.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/InvalidServiceType.java Sat May  3 13:52:41 2008
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when a service type specified by an {@link org.osoa.sca.annotations.Service} annotation is invalid, e.g. it is
+ * not an interface
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class InvalidServiceType extends IntrospectionException {
+    private static final long serialVersionUID = -1076466639416644386L;
+    private Class<?> serviceType;
+
+    public InvalidServiceType(String message) {
+        super(message);
+    }
+    
+    public InvalidServiceType(String message, Class<?> clazz) {
+        super(message);
+        this.serviceType = clazz;
+    }
+
+    /**
+     * @return the serviceType
+     */
+    public Class<?> getServiceType() {
+        return serviceType;
+    }    
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/JavaIntrospectionHelper.java Sat May  3 13:52:41 2008
@@ -0,0 +1,544 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.beans.Introspector;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+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.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+
+import org.osoa.sca.CallableReference;
+
+/**
+ * Implements various reflection-related operations
+ * 
+ * @version $Rev: 641645 $ $Date: 2008-03-26 15:37:28 -0800 (Wed, 26 Mar 2008) $
+ */
+public final class JavaIntrospectionHelper {
+    private static final Logger logger = Logger.getLogger(JavaIntrospectionHelper.class.getName());
+    private static final Class[] EMPTY_CLASS_ARRY = new Class[0];
+
+    /**
+     * Hide the constructor
+     */
+    private JavaIntrospectionHelper() {
+    }
+
+    /**
+     * Returns a collection of public, and protected fields declared by a class
+     * or one of its supertypes
+     */
+    public static Set<Field> getAllPublicAndProtectedFields(Class clazz, boolean validating) {
+        return getAllPublicAndProtectedFields(clazz, new HashSet<Field>(), validating);
+    }
+
+    private static void checkInvalidAnnotations(AnnotatedElement element) {
+        for (Annotation a : element.getAnnotations()) {
+            if ("org.osoa.sca.annotations".equals(a.annotationType().getPackage().getName())) {
+                logger.warning("Invalid annotation " + a + " is found on " + element);
+            }
+        }
+    }
+
+    /**
+     * Recursively evaluates the type hierarchy to return all fields that are
+     * public or protected
+     */
+    private static Set<Field> getAllPublicAndProtectedFields(Class clazz, Set<Field> fields, boolean validating) {
+        if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
+            return fields;
+        }
+        fields = getAllPublicAndProtectedFields(clazz.getSuperclass(), fields, validating);
+        Field[] declaredFields = clazz.getDeclaredFields();
+        for (Field field : declaredFields) {
+            int modifiers = field.getModifiers();
+            if ((Modifier.isPublic(modifiers) || Modifier.isProtected(modifiers)) && !Modifier.isStatic(modifiers)) {
+                field.setAccessible(true); // ignore Java accessibility
+                fields.add(field);
+            } else {
+                if (validating) {
+                    checkInvalidAnnotations(field);
+                }
+            }
+        }
+        return fields;
+    }
+
+    /**
+     * Returns a collection of public and protected methods declared by a class
+     * or one of its supertypes. Note that overridden 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, boolean validating) {
+        return getAllUniqueMethods(clazz, new HashSet<Method>(), validating);
+    }
+
+    /**
+     * Recursively evaluates the type hierarchy to return all unique methods
+     */
+    private static Set<Method> getAllUniqueMethods(Class pClass, Set<Method> methods, boolean validating) {
+        if (pClass == null || pClass.isArray() || Object.class.equals(pClass)) {
+            return methods;
+        }
+        // we first evaluate methods of the subclass and then move to the parent
+        Method[] declaredMethods = pClass.getDeclaredMethods();
+        for (final Method declaredMethod : declaredMethods) {
+            int modifiers = declaredMethod.getModifiers();
+            if ((!Modifier.isPublic(modifiers) && !Modifier.isProtected(modifiers)) || Modifier.isStatic(modifiers)) {
+                if (validating) {
+                    checkInvalidAnnotations(declaredMethod);
+                }
+                continue;
+            }
+            if (methods.size() == 0) {
+                methods.add(declaredMethod);
+            } else {
+                List<Method> temp = new ArrayList<Method>();
+                boolean matched = false;
+                for (Method method : methods) {
+                    // only add if not already in the set from a superclass (i.e.
+                    // the method is not overridden)
+                    if (exactMethodMatch(declaredMethod, method)) {
+                        matched = true;
+                        break;
+                    }
+                }
+                if (!matched) {
+                    // Allow privileged access to set accessibility. Requires ReflectPermission
+                    // in security policy.
+                    AccessController.doPrivileged(new PrivilegedAction<Object>() {
+                        public Object run() {
+                            declaredMethod.setAccessible(true);
+                            return null;
+                        }
+                    });
+                    temp.add(declaredMethod);
+                }
+                methods.addAll(temp);
+                temp.clear();
+            }
+        }
+        // evaluate class hierarchy - this is done last to track inherited
+        // methods
+        methods = getAllUniqueMethods(pClass.getSuperclass(), methods, validating);
+        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
+     * @param fields the collection of fields to search
+     * @return the matching field or null if not found
+     */
+    public static Field findClosestMatchingField(String name, Class type, Set<Field> fields) {
+        Field candidate = null;
+        for (Field field : fields) {
+            if (field.getName().equals(name)) {
+                if (field.getType().equals(type)) {
+                    return field; // exact match
+                } 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
+                    // an object counterpart (e.g. Integer and int)
+                    // @spec issue
+                    // either an interface or super class, so keep a reference
+                    // until
+                    // we know there are no closer types
+                    candidate = field;
+                }
+            }
+        }
+        if (candidate != null) {
+            return candidate;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * 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
+     */
+    public static Method findClosestMatchingMethod(String name, Class[] types, Set<Method> methods) {
+        if (types == null) {
+            types = EMPTY_CLASS_ARRY;
+        }
+        Method candidate = null;
+        for (Method method : methods) {
+            if (method.getName().equals(name) && method.getParameterTypes().length == types.length) {
+                Class<?>[] params = method.getParameterTypes();
+                boolean disqualify = false;
+                boolean exactMatch = true;
+                for (int i = 0; i < params.length; i++) {
+                    if (!params[i].equals(types[i]) && !params[i].isAssignableFrom(types[i])) {
+                        // no match
+                        disqualify = true;
+                        exactMatch = false;
+                        break;
+                    } else if (!params[i].equals(types[i]) && params[i].isAssignableFrom(types[i])) {
+                        // not exact match
+                        exactMatch = false;
+                    }
+                }
+                if (disqualify) {
+                    continue;
+                } else if (exactMatch) {
+                    return method;
+                } else {
+                    candidate = method;
+                }
+            }
+        }
+        if (candidate != null) {
+            return candidate;
+        } else {
+            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)
+     */
+    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 != types2.length) {
+            return false;
+        }
+        boolean matched = true;
+        for (int i = 0; i < types1.length; i++) {
+            if (types1[i] != types2[i]) {
+                matched = false;
+                break;
+            }
+        }
+        return matched;
+    }
+
+    public static <T> Constructor<T> getDefaultConstructor(Class<T> clazz) throws NoSuchMethodException {
+        return clazz.getConstructor((Class[])null);
+    }
+
+    /**
+     * Returns the simple name of a class - i.e. the class name devoid of its
+     * package qualifier
+     * 
+     * @param implClass the implementation class
+     */
+    public static String getBaseName(Class<?> implClass) {
+        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);
+    }
+
+    /**
+     * 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>
+     */
+    public static String toPropertyName(String name) {
+        if (!name.startsWith("set")) {
+            return name;
+        }
+        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;
+        }
+    }
+
+    public static Type getParameterType(Type type) {
+        if (type instanceof ParameterizedType) {
+            // Collection<BaseType>
+            ParameterizedType parameterizedType = (ParameterizedType)type;
+            Type baseType = parameterizedType.getActualTypeArguments()[0];
+            return baseType;
+        } else {
+            return Object.class;
+        }
+    }
+
+    public static Class<?> getBusinessInterface(Class<?> cls, Type callableReferenceType) {
+        if (CallableReference.class.isAssignableFrom(cls) && callableReferenceType instanceof ParameterizedType) {
+            // Collection<BaseType>
+            ParameterizedType parameterizedType = (ParameterizedType)callableReferenceType;
+            Type baseType = parameterizedType.getActualTypeArguments()[0];
+            if (baseType instanceof GenericArrayType) {
+                // Base is array
+                return cls;
+            } else {
+                return getErasure(baseType);
+            }
+        }
+        return Object.class;
+    }
+
+    /**
+     * 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
+     */
+    private static boolean primitiveAssignable(Class memberType, Class param) {
+        if (memberType == Integer.class) {
+            return param == Integer.TYPE;
+        } else if (memberType == Double.class) {
+            return param == Double.TYPE;
+        } else if (memberType == Float.class) {
+            return param == Float.TYPE;
+        } else if (memberType == Short.class) {
+            return param == Short.TYPE;
+        } else if (memberType == Character.class) {
+            return param == Character.TYPE;
+        } else if (memberType == Boolean.class) {
+            return param == Boolean.TYPE;
+        } else if (memberType == Byte.class) {
+            return param == Byte.TYPE;
+        } else if (param == Integer.class) {
+            return memberType == Integer.TYPE;
+        } else if (param == Double.class) {
+            return memberType == Double.TYPE;
+        } else if (param == Float.class) {
+            return memberType == Float.TYPE;
+        } else if (param == Short.class) {
+            return memberType == Short.TYPE;
+        } else if (param == Character.class) {
+            return memberType == Character.TYPE;
+        } else if (param == Boolean.class) {
+            return memberType == Boolean.TYPE;
+        } else if (param == Byte.class) {
+            return memberType == Byte.TYPE;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 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
+     */
+    public static List<? extends Type> getGenerics(Type genericType) {
+        List<Type> classes = new ArrayList<Type>();
+        if (genericType instanceof ParameterizedType) {
+            ParameterizedType ptype = (ParameterizedType)genericType;
+            // get the type arguments
+            Type[] targs = ptype.getActualTypeArguments();
+            for (Type targ : targs) {
+                classes.add(targ);
+            }
+        }
+        return classes;
+    }
+
+    /**
+     * 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/>
+     * will return Baz.
+     */
+    public static Class introspectGeneric(Class<?> clazz, int pos) {
+        assert clazz != null : "No class specified";
+        Type type = clazz.getGenericSuperclass();
+        if (type instanceof ParameterizedType) {
+            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];
+        } else {
+            Type[] interfaces = clazz.getGenericInterfaces();
+            for (Type itype : interfaces) {
+                if (!(itype instanceof ParameterizedType)) {
+                    continue;
+                }
+                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
+     */
+    public static Set<Class> getAllInterfaces(Class clazz) {
+        Set<Class> implemented = new HashSet<Class>();
+        getAllInterfaces(clazz, implemented);
+        return implemented;
+    }
+
+    private static void getAllInterfaces(Class clazz, Set<Class> implemented) {
+        Class[] interfaces = clazz.getInterfaces();
+        for (Class interfaze : interfaces) {
+            implemented.add(interfaze);
+        }
+        Class<?> superClass = clazz.getSuperclass();
+        // Object has no superclass so check for null
+        if (superClass != null && !superClass.equals(Object.class)) {
+            getAllInterfaces(superClass, implemented);
+        }
+    }
+
+    public static boolean isSetter(Method method) {
+        return (void.class == method.getReturnType() && method.getParameterTypes().length == 1 && method.getName()
+            .startsWith("set"));
+    }
+
+    public static boolean isGetter(Method method) {
+        return (void.class != method.getReturnType() && method.getParameterTypes().length == 0 && method.getName()
+            .startsWith("get"));
+    }
+
+    private final static Map<Class, String> signatures = new HashMap<Class, String>();
+    static {
+        signatures.put(boolean.class, "Z");
+        signatures.put(byte.class, "B");
+        signatures.put(char.class, "C");
+        signatures.put(short.class, "S");
+        signatures.put(int.class, "I");
+        signatures.put(long.class, "J");
+        signatures.put(float.class, "F");
+        signatures.put(double.class, "D");
+    };
+
+    public static String getSignature(Class<?> cls) {
+        if (cls.isPrimitive()) {
+            return signatures.get(cls);
+        }
+        if (cls.isArray()) {
+            return "[" + getSignature(cls.getComponentType());
+        }
+        return "L" + cls.getName().replace('.', '/') + ";";
+    }
+
+    public static Class<?> getArrayType(Class<?> componentType, int dims) throws ClassNotFoundException {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < dims; i++) {
+            buf.append('[');
+        }
+        buf.append(getSignature(componentType));
+        return Class.forName(buf.toString(), false, componentType.getClassLoader());
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/NoConstructorException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+
+/**
+ * Thrown when a suitable constructor for a component implementation cannot be found
+ *
+ * @version $Rev: 563061 $ $Date: 2007-08-06 01:19:58 -0700 (Mon, 06 Aug 2007) $
+ */
+public class NoConstructorException extends IntrospectionException {
+    private static final long serialVersionUID = 3086706387280694424L;
+    
+    public NoConstructorException() {
+    }
+    
+    public NoConstructorException(String message) {
+       super(message);
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PolicyProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,292 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.List;
+
+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.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+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.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.osoa.sca.annotations.PolicySets;
+import org.osoa.sca.annotations.Requires;
+
+/**
+ * Processes an {@link org.osoa.sca.annotations.Requires} annotation
+ * 
+ * @version $Rev:
+ */
+public class PolicyProcessor extends BaseJavaClassVisitor {
+    
+    private PolicyFactory policyFactory;
+
+    public PolicyProcessor(AssemblyFactory assemblyFactory, PolicyFactory policyFactory) {
+        super(assemblyFactory);
+        this.policyFactory = policyFactory;
+    }
+
+    private QName getQName(String intentName) {
+        QName qname;
+        if (intentName.startsWith("{")) {
+            int i = intentName.indexOf('}');
+            if (i != -1) {
+                qname = new QName(intentName.substring(1, i), intentName.substring(i + 1));
+            } else {
+                qname = new QName("", intentName);
+            }
+        } else {
+            qname = new QName("", intentName);
+        }
+        return qname;
+    }
+
+    /**
+     * Read policy intents on the given interface or class 
+     * @param clazz
+     * @param requiredIntents
+     */
+    private void readIntentsAndPolicySets(Class<?> clazz, 
+                                          List<Intent> requiredIntents, 
+                                          List<PolicySet> policySets) {
+        Requires intentAnnotation = clazz.getAnnotation(Requires.class);
+        if (intentAnnotation != null) {
+            String[] intentNames = intentAnnotation.value();
+            if (intentNames.length != 0) {
+                for (String intentName : intentNames) {
+
+                    // Add each intent to the list
+                    Intent intent = policyFactory.createIntent();
+                    intent.setName(getQName(intentName));
+                    requiredIntents.add(intent);
+                }
+            }
+        }
+        
+        PolicySets policySetAnnotation = clazz.getAnnotation(PolicySets.class);
+        if (policySetAnnotation != null) {
+            String[] policySetNames = policySetAnnotation.value();
+            if (policySetNames.length != 0) {
+                for (String policySetName : policySetNames) {
+
+                    // Add each intent to the list
+                    PolicySet policySet = policyFactory.createPolicySet();
+                    policySet.setName(getQName(policySetName));
+                    policySets.add(policySet);
+                }
+            }
+        }
+    }
+    
+    private void readIntents(Requires intentAnnotation, List<Intent> requiredIntents) {
+        //Requires intentAnnotation = method.getAnnotation(Requires.class);
+        if (intentAnnotation != null) {
+            String[] intentNames = intentAnnotation.value();
+            if (intentNames.length != 0) {
+                //Operation operation = assemblyFactory.createOperation();
+                //operation.setName(method.getName());
+                //operation.setUnresolved(true);
+                for (String intentName : intentNames) {
+
+                    // Add each intent to the list, associated with the
+                    // operation corresponding to the annotated method
+                    Intent intent = policyFactory.createIntent();
+                    intent.setName(getQName(intentName));
+                    //intent.getOperations().add(operation);
+                    requiredIntents.add(intent);
+                }
+            }
+        }
+    }
+    
+    private void readPolicySets(PolicySets policySetAnnotation, List<PolicySet> policySets) {
+        if (policySetAnnotation != null) {
+            String[] policySetNames = policySetAnnotation.value();
+            if (policySetNames.length != 0) {
+                //Operation operation = assemblyFactory.createOperation();
+                //operation.setName(method.getName());
+                //operation.setUnresolved(true);
+                for (String policySetName : policySetNames) {
+                    // Add each intent to the list, associated with the
+                    // operation corresponding to the annotated method
+                    PolicySet policySet = policyFactory.createPolicySet();
+                    policySet.setName(getQName(policySetName));
+                    //intent.getOperations().add(operation);
+                    policySets.add(policySet);
+                }
+            }
+        }
+    }
+
+    @Override
+    public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException {
+        
+        // Read intents on the Java implementation class
+        if ( type instanceof PolicySetAttachPoint ) {
+            readIntentsAndPolicySets(clazz, 
+                                     ((PolicySetAttachPoint)type).getRequiredIntents(),
+                                     ((PolicySetAttachPoint)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());
+                            }
+                        }
+                    }
+                    
+                }
+                
+                // 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());
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private 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.osoa.sca.annotations.Reference annotation = 
+                                        method.getAnnotation(org.osoa.sca.annotations.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;
+    }
+    
+    private Reference getReferenceByName(String name, JavaImplementation type) {
+        for ( Reference reference : type.getReferences() ) {
+            if ( reference.getName().equals(name) ) {
+                return reference;
+            }
+        }
+        return null;
+    }
+    
+    @Override
+    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+        org.osoa.sca.annotations.Reference annotation = 
+            field.getAnnotation( org.osoa.sca.annotations.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());
+            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());
+            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 PolicySetAttachPoint )) {
+                    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());
+                }
+            }
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/PropertyProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.osoa.sca.annotations.Property;
+
+/**
+ * Processes an {@link @Property} annotation, updating the component type with
+ * corresponding {@link JavaMappedProperty}
+ * 
+ * @version $Rev: 584985 $ $Date: 2007-10-15 17:47:36 -0700 (Mon, 15 Oct 2007) $
+ */
+public class PropertyProcessor extends AbstractPropertyProcessor<Property> {
+
+    public PropertyProcessor(AssemblyFactory assemblyFactory) {
+        super(assemblyFactory, Property.class);
+    }
+
+    @Override
+    protected String getName(Property annotation) {
+        return annotation.name();
+    }
+
+    @Override
+    protected void initProperty(org.apache.tuscany.sca.assembly.Property property, Property annotation) {
+        property.setMustSupply(annotation.required());
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import static org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper.getBaseType;
+
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaParameterImpl;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.annotations.Reference;
+
+/**
+ * Processes an {@link @Reference} annotation, updating the component type with
+ * corresponding {@link
+ * org.apache.tuscany.spi.implementation.java.JavaMappedReference}
+ * 
+ * @version $Rev: 584985 $ $Date: 2007-10-15 17:47:36 -0700 (Mon, 15 Oct 2007) $
+ */
+public class ReferenceProcessor extends BaseJavaClassVisitor {
+    private JavaInterfaceFactory javaFactory;
+
+    public ReferenceProcessor(AssemblyFactory assemblyFactory, JavaInterfaceFactory javaFactory) {
+        super(assemblyFactory);
+        this.javaFactory = javaFactory;
+    }
+
+    @Override
+    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+        Reference annotation = method.getAnnotation(Reference.class);
+        if (annotation == null) {
+            return; // Not a reference annotation.
+        }
+        if (!JavaIntrospectionHelper.isSetter(method)) {
+            throw new IllegalReferenceException("Annotated method is not a setter: " + method, method);
+        }
+        String name = annotation.name();
+        if ("".equals(name)) {
+            name = JavaIntrospectionHelper.toPropertyName(method.getName());
+        }
+        JavaElementImpl ref = type.getReferenceMembers().get(name);
+        // Setter override field
+        if (ref != null && ref.getElementType() != ElementType.FIELD) {
+            throw new DuplicateReferenceException(name);
+        }
+        removeReference(ref, type);
+
+        JavaElementImpl element = new JavaElementImpl(method, 0);
+        org.apache.tuscany.sca.assembly.Reference reference = createReference(element, name);
+        type.getReferences().add(reference);
+        type.getReferenceMembers().put(name, element);
+    }
+
+    private boolean removeReference(JavaElementImpl ref, JavaImplementation type) {
+        if (ref == null) {
+            return false;
+        }
+        List<org.apache.tuscany.sca.assembly.Reference> refs = type.getReferences();
+        for (int i = 0; i < refs.size(); i++) {
+            if (refs.get(i).getName().equals(ref.getName())) {
+                refs.remove(i);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+        Reference annotation = field.getAnnotation(Reference.class);
+        if (annotation == null) {
+            return;
+        }
+        String name = annotation.name();
+        if ("".equals(name)) {
+            name = field.getName();
+        }
+        JavaElementImpl ref = type.getReferenceMembers().get(name);
+        if (ref != null && ref.getElementType() == ElementType.FIELD) {
+            throw new DuplicateReferenceException(name);
+        }
+
+        // Setter method override field
+        if (ref == null) {
+            JavaElementImpl element = new JavaElementImpl(field);
+            org.apache.tuscany.sca.assembly.Reference reference = createReference(element, name);
+            type.getReferences().add(reference);
+            type.getReferenceMembers().put(name, element);
+        }
+    }
+
+    @Override
+    public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
+        throws IntrospectionException {
+        Reference refAnnotation = parameter.getAnnotation(Reference.class);
+        if (refAnnotation == null) {
+            return;
+        }
+        String paramName = parameter.getName();
+        String name = getReferenceName(paramName, parameter.getIndex(), refAnnotation.name());
+        JavaElementImpl ref = type.getReferenceMembers().get(name);
+
+        // Setter override field
+        if (ref != null && ref.getElementType() != ElementType.FIELD) {
+            throw new DuplicateReferenceException(name);
+        }
+
+        removeReference(ref, type);
+        org.apache.tuscany.sca.assembly.Reference reference = createReference(parameter, name);
+        type.getReferences().add(reference);
+        type.getReferenceMembers().put(name, parameter);
+        parameter.setClassifer(Reference.class);
+        parameter.setName(name);
+    }
+
+    private String getReferenceName(String paramName, int pos, String name) throws InvalidConstructorException {
+        if ("".equals(name)) {
+            name = paramName;
+        }
+        if ("".equals(name)) {
+            return "_ref" + pos;
+        }
+        if (!"".equals(paramName) && !name.equals(paramName)) {
+            throw new InvalidConstructorException("Mismatching names specified for reference parameter " + pos);
+        } else {
+            return name;
+        }
+    }
+
+    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();
+        reference.setInterfaceContract(interfaceContract);
+
+        // reference.setMember((Member)element.getAnchor());
+        boolean required = true;
+        Reference ref = element.getAnnotation(Reference.class);
+        if (ref != null) {
+            required = ref.required();
+        }
+        // reference.setRequired(required);
+        reference.setName(name);
+        Class<?> rawType = element.getType();
+        if (rawType.isArray() || Collection.class.isAssignableFrom(rawType)) {
+            if (required) {
+                reference.setMultiplicity(Multiplicity.ONE_N);
+            } else {
+                reference.setMultiplicity(Multiplicity.ZERO_N);
+            }
+        } else {
+            if (required) {
+                reference.setMultiplicity(Multiplicity.ONE_ONE);
+            } else {
+                reference.setMultiplicity(Multiplicity.ZERO_ONE);
+            }
+        }
+        Type genericType = element.getGenericType();
+        Class<?> baseType = getBaseType(rawType, genericType);
+        if (CallableReference.class.isAssignableFrom(baseType)) {
+            if (Collection.class.isAssignableFrom(rawType)) {
+                genericType = JavaIntrospectionHelper.getParameterType(genericType);
+            }
+            baseType = JavaIntrospectionHelper.getBusinessInterface(baseType, genericType);
+        }
+        try {
+            JavaInterface callInterface = javaFactory.createJavaInterface(baseType);
+            reference.getInterfaceContract().setInterface(callInterface);
+            if (callInterface.getCallbackClass() != null) {
+                JavaInterface callbackInterface = javaFactory.createJavaInterface(callInterface.getCallbackClass());
+                reference.getInterfaceContract().setCallbackInterface(callbackInterface);
+            }
+        } catch (InvalidInterfaceException e) {
+            throw new IntrospectionException(e);
+        }
+        return reference;
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/Resource.java Sat May  3 13:52:41 2008
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Annotation used to indicate a resource should be provided to an implementation by the runtime.
+ *
+ * @version $Rev: 563019 $ $Date: 2007-08-05 20:43:59 -0700 (Sun, 05 Aug 2007) $
+ */
+@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Resource {
+
+    /**
+     * Denotes the name of the resource declared by the implementation.
+     */
+    String name() default "";
+
+    /**
+     * Denotes if the resource is optional
+     */
+    boolean optional() default false;
+
+    /**
+     * Denotes the default name of the resource provided by the runtime environment.
+     */
+    String mappedName() default "";
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ResourceProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaParameterImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
+
+/**
+ * Processes an {@link @Resource} annotation, updating the component type with
+ * corresponding {@link org.apache.tuscany.spi.implementation.java.JavaResourceImpl}
+ * 
+ * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $
+ */
+public class ResourceProcessor extends BaseJavaClassVisitor {
+    
+    public ResourceProcessor(AssemblyFactory factory) {
+        super(factory);
+    }
+
+    @Override
+    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
+        org.apache.tuscany.sca.implementation.java.introspect.impl.Resource annotation = method
+            .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+        if (annotation == null) {
+            return;
+        }
+        if (method.getParameterTypes().length != 1) {
+            throw new IllegalResourceException("Resource setter must have one parameter", method);
+        }
+        String name = annotation.name();
+        if (name.length() < 1) {
+            name = JavaIntrospectionHelper.toPropertyName(method.getName());
+        }
+        if (type.getResources().get(name) != null) {
+            throw new DuplicateResourceException(name);
+        }
+
+        String mappedName = annotation.mappedName();
+        JavaResourceImpl resource = createResource(name, new JavaElementImpl(method, 0));
+        resource.setOptional(annotation.optional());
+        if (mappedName.length() > 0) {
+            resource.setMappedName(mappedName);
+        }
+        type.getResources().put(resource.getName(), resource);
+    }
+
+    @Override
+    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
+
+        org.apache.tuscany.sca.implementation.java.introspect.impl.Resource annotation = field
+            .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+        if (annotation == null) {
+            return;
+        }
+        String name = annotation.name();
+        if (name.length() < 1) {
+            name = field.getName();
+        }
+        if (type.getResources().get(name) != null) {
+            throw new DuplicateResourceException(name);
+        }
+
+        String mappedName = annotation.mappedName();
+
+        JavaResourceImpl resource = createResource(name, new JavaElementImpl(field));
+        resource.setOptional(annotation.optional());
+        if (mappedName.length() > 0) {
+            resource.setMappedName(mappedName);
+        }
+        type.getResources().put(resource.getName(), resource);
+    }
+
+    @SuppressWarnings("unchecked")
+    public JavaResourceImpl createResource(String name, JavaElementImpl element) {
+        element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+        element.setName(name);
+        return new JavaResourceImpl(element);
+    }
+
+    @Override
+    public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
+        throws IntrospectionException {
+        org.apache.tuscany.sca.implementation.java.introspect.impl.Resource resourceAnnotation = parameter
+            .getAnnotation(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class);
+        if (resourceAnnotation != null) {
+            String name = resourceAnnotation.name();
+            if ("".equals(name)) {
+                name = parameter.getName();
+            }
+            if ("".equals(name)) {
+                throw new InvalidResourceException("Missing resource name", (Member)parameter.getAnchor());
+            }
+
+            if (!"".equals(parameter.getName()) && !name.equals(parameter.getName())) {
+                throw new InvalidConstructorException("Mismatched resource name: " + parameter);
+            }
+
+            if (type.getResources().get(name) != null) {
+                throw new DuplicateResourceException(name);
+            }
+
+            String mappedName = resourceAnnotation.mappedName();
+
+            JavaResourceImpl resource = createResource(name, parameter);
+            resource.setOptional(resourceAnnotation.optional());
+            if (mappedName.length() > 0) {
+                resource.setMappedName(mappedName);
+            }
+            type.getResources().put(resource.getName(), resource);
+        }
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ScopeProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.introspect.impl;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.implementation.java.IntrospectionException;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.impl.JavaScopeImpl;
+
+/**
+ * Processes the {@link JavaScopeImpl} annotation and updates the component type with the corresponding implmentation scope
+ *
+ * @version $Rev: 567542 $ $Date: 2007-08-19 22:13:29 -0700 (Sun, 19 Aug 2007) $
+ */
+public class ScopeProcessor extends BaseJavaClassVisitor {
+    
+    public ScopeProcessor(AssemblyFactory factory) {
+        super(factory);
+    }
+
+    @Override
+    public <T> void visitClass(Class<T> clazz,
+                               JavaImplementation type)
+        throws IntrospectionException {
+        org.osoa.sca.annotations.Scope annotation = clazz.getAnnotation(org.osoa.sca.annotations.Scope.class);
+        if (annotation == null) {
+            type.setJavaScope(JavaScopeImpl.STATELESS);
+            return;
+        }
+        String name = annotation.value();
+        JavaScopeImpl scope;
+        if ("COMPOSITE".equals(name)) {
+            scope = JavaScopeImpl.COMPOSITE;
+        } else if ("SESSION".equals(name)) {
+            scope = JavaScopeImpl.SESSION;
+        } else if ("CONVERSATION".equals(name)) {
+            scope = JavaScopeImpl.CONVERSATION;
+        } else if ("REQUEST".equals(name)) {
+            scope = JavaScopeImpl.REQUEST;
+        } else {
+            scope = new JavaScopeImpl(name);
+        }
+        type.setJavaScope(scope);
+    }
+}