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 [17/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-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PolicyComputer.java Sat May  3 13:52:41 2008
@@ -0,0 +1,372 @@
+/*
+ * 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.assembly.builder.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPoint;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.ProfileIntent;
+import org.apache.tuscany.sca.policy.QualifiedIntent;
+import org.apache.tuscany.sca.policy.util.PolicyValidationException;
+import org.apache.tuscany.sca.policy.util.PolicyValidationUtils;
+
+/**
+ * This class contains policy computation methods common to computing implementation and binding policies
+ */
+public abstract class PolicyComputer {
+    
+    protected PolicyComputer() {
+        
+    }
+    
+    protected List<Intent> computeInheritableIntents(IntentAttachPointType attachPointType, 
+                                                   List<Intent> inheritableIntents) throws PolicyValidationException {
+        List<Intent> validInheritableIntents = new ArrayList<Intent>();
+        
+        //expand profile intents in inherited intents
+        expandProfileIntents(inheritableIntents);
+
+        //validate if inherited intent applies to the attachpoint (binding / implementation) and 
+        //only add such intents to the attachpoint (binding / implementation)
+        for (Intent intent : inheritableIntents) {
+            if ( !intent.isUnresolved() ) { 
+                for (QName constrained : intent.getConstrains()) {
+                    if ( PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
+                        validInheritableIntents.add(intent);
+                        break;
+                    }
+                }
+            } else {
+                throw new PolicyValidationException("Policy Intent '" + intent.getName() + "' is not defined in this domain");
+            }
+        }
+        
+        return validInheritableIntents;
+    }
+    
+    protected void expandProfileIntents(List<Intent> intents) {
+        List<Intent> expandedIntents = null;
+        if ( intents.size() > 0 ) {
+            expandedIntents = findAndExpandProfileIntents(intents);
+            intents.clear();
+            intents.addAll(expandedIntents);
+        }
+    }
+    
+    protected void normalizeIntents(IntentAttachPoint intentAttachPoint) {
+        //expand profile intents specified in the attachpoint (binding / implementation)
+        expandProfileIntents(intentAttachPoint.getRequiredIntents());
+
+        //remove duplicates and ...
+        //where qualified form of intent exists retain it and remove the qualifiable intent
+        filterDuplicatesAndQualifiableIntents(intentAttachPoint);
+    }
+    
+    protected void trimInherentlyProvidedIntents(IntentAttachPointType attachPointType, List<Intent>intents) {
+        //exclude intents that are inherently supported by the 
+        //attachpoint-type (binding-type  / implementation-type)
+        List<Intent> requiredIntents = new ArrayList<Intent>(intents);
+        for ( Intent intent : requiredIntents ) {
+            if ( isProvidedInherently(attachPointType, intent) ) {
+                intents.remove(intent);
+            }
+        }
+    }
+    
+    
+    protected void computeIntentsForOperations(IntentAttachPoint intentAttachPoint) throws PolicyValidationException {
+        if ( intentAttachPoint instanceof OperationsConfigurator ) {
+            computeIntentsForOperations((OperationsConfigurator)intentAttachPoint, 
+                                        intentAttachPoint, 
+                                        intentAttachPoint.getRequiredIntents());
+        }
+    }
+    
+    protected void computeIntentsForOperations(OperationsConfigurator opConfigurator, 
+                                               IntentAttachPoint intentAttachPoint, 
+                                               List<Intent> parentIntents) throws PolicyValidationException {
+        IntentAttachPointType attachPointType = intentAttachPoint.getType();
+        
+        boolean found = false;
+        for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
+            //expand profile intents specified on operations
+            expandProfileIntents(confOp.getRequiredIntents());
+            
+            //validateIntents(confOp, attachPointType);
+            
+            //add intents specified for parent intent attach point (binding / implementation)
+            //wherever its not overridden in the operation
+            Intent tempIntent = null;
+            List<Intent> attachPointOpIntents = new ArrayList<Intent>();
+            for (Intent anIntent : parentIntents) {
+                found = false;
+            
+                tempIntent = anIntent;
+                while ( tempIntent instanceof QualifiedIntent ) {
+                    tempIntent = ((QualifiedIntent)tempIntent).getQualifiableIntent();
+                }
+                
+                for ( Intent opIntent : confOp.getRequiredIntents() ) {
+                    if ( opIntent.getName().getLocalPart().startsWith(tempIntent.getName().getLocalPart())) {
+                        found = true;
+                        break;
+                    }
+                }
+                
+                if ( !found ) {
+                    attachPointOpIntents.add(anIntent);
+                }
+            }
+            
+            confOp.getRequiredIntents().addAll(attachPointOpIntents);
+            
+            //remove duplicates and ...
+            //where qualified form of intent exists retain it and remove the qualifiable intent
+            filterDuplicatesAndQualifiableIntents(confOp);
+            
+            //exclude intents that are inherently supported by the parent
+            //attachpoint-type (binding-type  / implementation-type)
+            if ( attachPointType != null ) {
+                List<Intent> requiredIntents = new ArrayList<Intent>(confOp.getRequiredIntents());
+                for ( Intent intent : requiredIntents ) {
+                    if ( isProvidedInherently(attachPointType, intent) ) {
+                        confOp.getRequiredIntents().remove(intent);
+                    }
+                }
+            }
+        }
+    }
+    
+    protected List<PolicySet> computeInheritablePolicySets(List<PolicySet> inheritablePolicySets,
+                                                           List<PolicySet> applicablePolicySets) 
+                                                               throws PolicyValidationException {
+        List<PolicySet> validInheritablePolicySets = new ArrayList<PolicySet>();
+        for (PolicySet policySet : inheritablePolicySets) {
+            if ( !policySet.isUnresolved() ) { 
+                if ( applicablePolicySets.contains(policySet) ) {
+                    validInheritablePolicySets.add(policySet);
+                }
+            } else {
+                throw new PolicyValidationException("Policy Set '" + policySet.getName()
+                        + "' is not defined in this domain  ");
+            }
+        }
+        
+        return validInheritablePolicySets;
+    }
+    
+    protected void normalizePolicySets(PolicySetAttachPoint policySetAttachPoint ) {
+        //get rid of duplicate entries
+        HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
+        for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
+            policySetTable.put(policySet.getName(), policySet);
+        }
+        
+        policySetAttachPoint.getPolicySets().clear();
+        policySetAttachPoint.getPolicySets().addAll(policySetTable.values());
+            
+        //expand profile intents
+        for ( PolicySet policySet : policySetAttachPoint.getPolicySets() ) {
+            expandProfileIntents(policySet.getProvidedIntents());
+        }
+    }
+    
+    protected void computePolicySetsForOperations(List<PolicySet> applicablePolicySets,
+                                                  PolicySetAttachPoint policySetAttachPoint) 
+                                                                        throws PolicyValidationException {
+        if ( policySetAttachPoint instanceof OperationsConfigurator ) {
+            computePolicySetsForOperations(applicablePolicySets, 
+                                           (OperationsConfigurator)policySetAttachPoint, 
+                                           policySetAttachPoint);
+        }
+        
+    }
+    
+    protected void computePolicySetsForOperations(List<PolicySet> applicablePolicySets, 
+                                                  OperationsConfigurator opConfigurator,
+                                                  PolicySetAttachPoint policySetAttachPoint) 
+                                                                        throws PolicyValidationException {
+        //String appliesTo = null;
+        //String scdlFragment = "";
+        HashMap<QName, PolicySet> policySetTable = new HashMap<QName, PolicySet>();
+        IntentAttachPointType attachPointType = policySetAttachPoint.getType();
+        
+        for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
+            //validate policysets specified for the attachPoint
+            for (PolicySet policySet : confOp.getPolicySets()) {
+                if ( !policySet.isUnresolved() ) {
+                    //appliesTo = policySet.getAppliesTo();
+        
+                    //if (!PolicyValidationUtils.isPolicySetApplicable(scdlFragment, appliesTo, attachPointType)) {
+                    if (!applicablePolicySets.contains(policySet)) {
+                        throw new PolicyValidationException("Policy Set '" + policySet.getName() 
+                                + " specified for operation " + confOp.getName()  
+                            + "' does not constrain extension type  "
+                            + attachPointType.getName());
+        
+                    }
+                } else {
+                    throw new PolicyValidationException("Policy Set '" + policySet.getName() 
+                            + " specified for operation " + confOp.getName()  
+                        + "' is not defined in this domain  ");
+                }
+            }
+            
+            //get rid of duplicate entries
+            for ( PolicySet policySet : confOp.getPolicySets() ) {
+                policySetTable.put(policySet.getName(), policySet);
+            }
+        
+            confOp.getPolicySets().clear();
+            confOp.getPolicySets().addAll(policySetTable.values());
+            policySetTable.clear();
+            
+            //expand profile intents
+            for ( PolicySet policySet : confOp.getPolicySets() ) {
+                expandProfileIntents(policySet.getProvidedIntents());
+            }
+        }
+    }
+    
+        
+    protected void trimProvidedIntents(List<Intent> requiredIntents, List<PolicySet> policySets) {
+        for ( PolicySet policySet : policySets ) {
+            trimProvidedIntents(requiredIntents, policySet);
+        }
+    }
+    
+    protected void determineApplicableDomainPolicySets(List<PolicySet> applicablePolicySets,
+                                                     PolicySetAttachPoint policySetAttachPoint,
+                                                     IntentAttachPointType intentAttachPointType) {
+
+        if (policySetAttachPoint.getRequiredIntents().size() > 0) {
+            //since the set of applicable policysets for this attachpoint is known 
+            //we only need to check in that list if there is a policyset that matches
+            for (PolicySet policySet : applicablePolicySets) {
+                int prevSize = policySetAttachPoint.getRequiredIntents().size();
+                trimProvidedIntents(policySetAttachPoint.getRequiredIntents(), policySet);
+                // if any intent was trimmed off, then this policyset must
+                // be attached to the intent attachpoint's policyset
+                if (prevSize != policySetAttachPoint.getRequiredIntents().size()) {
+                    policySetAttachPoint.getPolicySets().add(policySet);
+                }
+            } 
+        }
+    }
+    
+    private List<Intent> findAndExpandProfileIntents(List<Intent> intents) {
+        List<Intent> expandedIntents = new ArrayList<Intent>();
+        for ( Intent intent : intents ) {
+            if ( intent instanceof ProfileIntent ) {
+                ProfileIntent profileIntent = (ProfileIntent)intent;
+                List<Intent> requiredIntents = profileIntent.getRequiredIntents();
+                expandedIntents.addAll(findAndExpandProfileIntents(requiredIntents));
+            } else {
+                expandedIntents.add(intent);
+            }
+        }
+        return expandedIntents;
+    }
+    
+    private boolean isProvidedInherently(IntentAttachPointType attachPointType, Intent intent) {
+        return ( attachPointType != null && 
+                 (( attachPointType.getAlwaysProvidedIntents() != null &&
+                     attachPointType.getAlwaysProvidedIntents().contains(intent) ) || 
+                  ( attachPointType.getMayProvideIntents() != null &&
+                     attachPointType.getMayProvideIntents().contains(intent) )
+                 ) );
+     }
+    
+    private void trimProvidedIntents(List<Intent> requiredIntents, PolicySet policySet) {
+        for ( Intent providedIntent : policySet.getProvidedIntents() ) {
+            if ( requiredIntents.contains(providedIntent) ) {
+                requiredIntents.remove(providedIntent);
+            } 
+        }
+        
+        for ( Intent mappedIntent : policySet.getMappedPolicies().keySet() ) {
+            if ( requiredIntents.contains(mappedIntent) ) {
+                requiredIntents.remove(mappedIntent);
+            } 
+        }
+    }
+    
+    private void filterDuplicatesAndQualifiableIntents(IntentAttachPoint intentAttachPoint) {
+        //remove duplicates
+        Map<QName, Intent> intentsTable = new HashMap<QName, Intent>();
+        for ( Intent intent : intentAttachPoint.getRequiredIntents() ) {
+            intentsTable.put(intent.getName(), intent);
+        }
+        
+        //where qualified form of intent exists retain it and remove the qualifiable intent
+        Map<QName, Intent> intentsTableCopy = new HashMap<QName, Intent>(intentsTable);
+        //if qualified form of intent exists remove the unqualified form
+        for ( Intent intent : intentsTableCopy.values() ) {
+            if ( intent instanceof QualifiedIntent ) {
+                QualifiedIntent qualifiedIntent = (QualifiedIntent)intent;
+                if ( intentsTable.get(qualifiedIntent.getQualifiableIntent().getName()) != null ) {
+                    intentsTable.remove(qualifiedIntent.getQualifiableIntent().getName());
+                }
+            }
+        }
+        intentAttachPoint.getRequiredIntents().clear();
+        intentAttachPoint.getRequiredIntents().addAll(intentsTable.values());
+    }
+    
+    private void validateIntents(ConfiguredOperation confOp, IntentAttachPointType attachPointType) throws PolicyValidationException {
+        boolean found = false;
+        if ( attachPointType != null ) {
+            //validate intents specified against the parent (binding / implementation)
+            found = false;
+            for (Intent intent : confOp.getRequiredIntents()) {
+                if ( !intent.isUnresolved() ) {
+                    for (QName constrained : intent.getConstrains()) {
+                        if (PolicyValidationUtils.isConstrained(constrained, attachPointType)) {
+                            found = true;
+                            break;
+                        }
+                    }
+        
+                    if (!found) {
+                        throw new PolicyValidationException("Policy Intent '" + intent.getName() 
+                                + " specified for operation " + confOp.getName()  
+                            + "' does not constrain extension type  "
+                            + attachPointType.getName());
+                    }
+                } else {
+                    throw new PolicyValidationException("Policy Intent '" + intent.getName() 
+                            + " specified for operation " + confOp.getName()  
+                        + "' is not defined in this domain  ");
+                }
+            }
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PrintUtil.java Sat May  3 13:52:41 2008
@@ -0,0 +1,273 @@
+/*
+ * 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.assembly.builder.impl;
+
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.w3c.dom.Node;
+
+/**
+ * A simple print utility class to help print model instances.
+ * 
+ * @version $Rev: 639224 $ $Date: 2008-03-20 02:37:04 -0700 (Thu, 20 Mar 2008) $
+ */
+class PrintUtil {
+    private boolean useGetters = false;
+    private PrintWriter out;
+    private int indent;
+
+    public PrintUtil(PrintWriter out, boolean useGetters) {
+        this.out = out;
+        this.useGetters = useGetters;
+    }
+
+    public PrintUtil(OutputStream out) {
+        this.out = new PrintWriter(new OutputStreamWriter(out), true);
+    }
+
+    void indent() {
+        for (int i = 0; i < indent; i++) {
+            out.print("  ");
+        }
+    }
+
+    /**
+     * Print an object.
+     * 
+     * @param object
+     */
+    public void print(Object object) {
+        Set<Integer> objects = new HashSet<Integer>();
+        print(object, objects);
+    }
+
+    /**
+     * Print an object.
+     * 
+     * @param object
+     */
+    private void print(Object object, Set<Integer> printed) {
+        if (object == null) {
+            return;
+        }
+        int id = System.identityHashCode(object);
+        if (printed.contains(id)) {
+
+            // If we've already printed an object, print just it's HashCode
+            indent();
+            out.println(object.getClass().getName() + "@" + id);
+        } else {
+            printed.add(id);
+            try {
+
+                // Print the object class name
+                indent();
+                out.println(object.getClass().getSimpleName() + " {");
+
+                // Get the object's properties
+                ValueAccessor accessor = useGetters ? new PropertyAccessor(object) : new FieldAccessor(object);
+                for (int i = 0; i < accessor.size(); i++) {
+                    try {
+
+                        // Get the value of each property
+                        Object value = accessor.getValue(i);
+                        if (value != null) {
+
+                            // Convert array value into a list
+                            if (value.getClass().isArray()) {
+                                value = Arrays.asList((Object[])value);
+                            }
+
+                            // Print elements in a list
+                            if (value instanceof List) {
+                                if (!((List)value).isEmpty()) {
+                                    indent++;
+                                    indent();
+                                    out.println(accessor.getName(i) + "= [");
+
+                                    // Print each element, recursively
+                                    for (Object element : (List)value) {
+                                        indent++;
+                                        print(element, printed);
+                                        indent--;
+                                    }
+                                    indent();
+                                    out.println(" ]");
+                                    indent--;
+                                }
+                            } else {
+                                Class<?> valueClass = value.getClass();
+
+                                // Print a primitive, java built in type or
+                                // enum, using toString()
+                                if (valueClass.isPrimitive() || valueClass.getName().startsWith("java.")
+                                    || valueClass.getName().startsWith("javax.")
+                                    || valueClass.isEnum()) {
+                                    if (!accessor.getName(i).equals("class")) {
+                                        if (!(Boolean.FALSE.equals(value))) {
+                                            indent++;
+                                            indent();
+                                            out.println(accessor.getName(i) + "=" + value.toString());
+                                            indent--;
+                                        }
+                                    }
+                                } else if (value instanceof Node) {
+                                    indent++;
+                                    indent();
+                                    out.println(accessor.getName(i) + "=" + value.toString());
+                                    indent--;
+                                } else {
+
+                                    // Print an object, recursively
+                                    indent++;
+                                    indent();
+                                    out.println(accessor.getName(i) + "= {");
+                                    indent++;
+                                    print(value, printed);
+                                    indent--;
+                                    indent();
+                                    out.println("}");
+                                    indent--;
+                                }
+                            }
+                        }
+                    } catch (Exception e) {
+                    }
+                }
+                indent();
+                out.println("}");
+            } catch (Exception e) {
+                indent();
+                out.println(e);
+            }
+        }
+    }
+
+    public static interface ValueAccessor {
+        int size();
+
+        String getName(int i);
+
+        Object getValue(int i) throws Exception;
+    }
+
+    /**
+     * Java field reflection based value accessor
+     */
+    private static class FieldAccessor implements ValueAccessor {
+
+        private Object object;
+        private List<Field> fields;
+
+        public FieldAccessor(Object object) {
+            this.fields = getAllFields(object.getClass());
+            this.object = object;
+        }
+
+        public String getName(int i) {
+            return fields.get(i).getName();
+        }
+
+        public Object getValue(int i) throws Exception {
+            return fields.get(i).get(object);
+        }
+
+        public int size() {
+            return fields.size();
+        }
+
+    }
+
+    /**
+     * JavaBean-based value accessor
+     */
+    private static class PropertyAccessor implements ValueAccessor {
+
+        private Object object;
+        private PropertyDescriptor[] fields;
+
+        public PropertyAccessor(Object object) throws IntrospectionException {
+            BeanInfo beanInfo = Introspector.getBeanInfo(object.getClass());
+            this.fields = beanInfo.getPropertyDescriptors();
+            this.object = object;
+        }
+
+        public String getName(int i) {
+            return fields[i].getName();
+        }
+
+        public Object getValue(int i) throws Exception {
+            Method getter = fields[i].getReadMethod();
+            if (getter != null) {
+                return getter.invoke(object);
+            }
+            return null;
+        }
+
+        public int size() {
+            return fields.length;
+        }
+
+    }
+
+    /**
+     * Returns a collection of fields declared by a class
+     * or one of its supertypes
+     */
+    private static List<Field> getAllFields(Class<?> clazz) {
+        return getAllFields(clazz, new ArrayList<Field>());
+    }
+
+    /**
+     * Recursively evaluates the type hierarchy to return all fields 
+     */
+    private static List<Field> getAllFields(Class<?> clazz, List<Field> fields) {
+        if (clazz == null || clazz.isArray() || Object.class.equals(clazz)) {
+            return fields;
+        }
+        fields = getAllFields(clazz.getSuperclass(), fields);
+        Field[] declaredFields = clazz.getDeclaredFields();
+        for (final Field field : declaredFields) {
+            AccessController.doPrivileged(new PrivilegedAction<Object>() {
+                public Object run() {
+                    field.setAccessible(true); // ignore Java accessibility
+                    return null;
+                }
+            });
+            fields.add(field);
+        }
+        return fields;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ProblemImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ProblemImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ProblemImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ProblemImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,112 @@
+/*
+ * 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.assembly.builder.impl;
+
+import org.apache.tuscany.sca.assembly.builder.Problem;
+
+/**
+ * Reports a composite assembly problem. 
+ *
+ * @version $Rev: 589508 $ $Date: 2007-10-28 23:23:26 -0700 (Sun, 28 Oct 2007) $
+ */
+public class ProblemImpl implements Problem {
+
+    private String message;
+    private Severity severity;
+    private Object model;
+    private Object resource;
+    private Exception cause;
+
+    /**
+     * Constructs a new problem.
+     * 
+     * @param severity
+     * @param message
+     * @param model
+     */
+    public ProblemImpl(Severity severity, String message, Object model) {
+        this.severity = severity;
+        this.message = message;
+        this.model = model;
+    }
+
+    /**
+     * Constructs a new problem.
+     * 
+     * @param severity
+     * @param message
+     * @param model
+     * @param resource
+     */
+    public ProblemImpl(Severity severity, String message, Object model, Object resource) {
+        this.severity = severity;
+        this.message = message;
+        this.model = model;
+        this.resource = resource;
+    }
+
+    /**
+     * Constructs a new problem.
+     * 
+     * @param severity
+     * @param message
+     * @param cause
+     */
+    public ProblemImpl(Severity severity, String message, Exception cause) {
+        this.severity = severity;
+        this.message = message;
+        this.cause = cause;
+    }
+
+    public Severity getSeverity() {
+        return severity;
+    }
+
+    public String getMessage() {
+        return message;
+    }
+
+    public Object getModel() {
+        return model;
+    }
+
+    public Object getResource() {
+        return resource;
+    }
+
+    public Exception getCause() {
+        return cause;
+    }
+
+    @Override
+    public String toString() {
+        StringBuffer sb = new StringBuffer();
+        if (message !=  null) {
+            sb.append(message);
+        }
+        if (resource != null) {
+            if (sb.length() != 0) {
+                sb.append(" - ");
+            }
+            sb.append(resource.toString());
+        }
+        return sb.toString();
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyUtil.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyUtil.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/PropertyUtil.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.assembly.builder.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.xml.sax.InputSource;
+
+import sun.reflect.generics.reflectiveObjects.NotImplementedException;
+
+/**
+ * Utility class to deal with processing of component properties that are taking values from the parent 
+ * composite's properties or an external file.
+ */
+public class PropertyUtil {
+    //private static final XPathFactory XPATH_FACTORY = XPathFactory.newInstance();
+    private static final DocumentBuilderFactory DOC_BUILDER_FACTORY = DocumentBuilderFactory.newInstance();
+    //private static final TransformerFactory TRANSFORMER_FACTORY = TransformerFactory.newInstance();
+    
+    static private Document evaluate(Document node, XPathExpression expression)
+        throws XPathExpressionException, ParserConfigurationException {
+
+        Node value = node.getDocumentElement();
+        Node result = (Node)expression.evaluate(value, XPathConstants.NODE);
+        if (result == null) {
+            return null;
+        }
+
+        // TODO: How to wrap the result into a Document?
+        Document document = DOC_BUILDER_FACTORY.newDocumentBuilder().newDocument();
+        if (result instanceof Document) {
+            return (Document)result;
+        } else {
+            //Element root = document.createElementNS(null, "value");
+            //document.appendChild(root);
+            document.appendChild(document.importNode(result, true));
+            return document;
+        }
+    }
+    
+    static private Document loadFromFile(String file) throws MalformedURLException, IOException,
+        TransformerException, ParserConfigurationException {
+        URI uri = URI.create(file);
+        // URI resolution for relative URIs is done when the composite is resolved.
+        URL url = uri.toURL();
+        URLConnection connection = url.openConnection();
+        connection.setUseCaches(false);
+        InputStream is = null;
+        try {
+            is = connection.getInputStream();
+    
+            Source streamSource = new SAXSource(new InputSource(is));
+            DOMResult result = new DOMResult();
+            //javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
+            //transformer.transform(streamSource, result);
+            throw new NotImplementedException();
+            
+            //return (Document)result.getNode();
+        } finally {
+            if (is != null) {
+                is.close();
+            }
+        }
+    }
+    
+    static void sourceComponentProperties(Map<String, Property> compositeProperties,
+                                                 Component componentDefinition) throws CompositeBuilderException,
+                                                                               ParserConfigurationException,
+                                                                               XPathExpressionException,
+                                                                               TransformerException,
+                                                                               IOException {
+
+        List<ComponentProperty> componentProperties = componentDefinition.getProperties();
+        for (ComponentProperty aProperty : componentProperties) {
+            String source = aProperty.getSource();
+            String file = aProperty.getFile();
+            if (source != null) {
+                // $<name>/...
+                int index = source.indexOf('/');
+                if (index == -1) {
+                    // Tolerating $prop
+                    source = source + "/";
+                    index = source.length() - 1;
+                }
+                if (source.charAt(0) == '$') {
+                    String name = source.substring(1, index);
+                    Property compositeProp = compositeProperties.get(name);
+                    if (compositeProp == null) {
+                        throw new CompositeBuilderException("The 'source' cannot be resolved to a composite property: " + source);
+                    }
+
+                    Document compositePropDefValues = (Document)compositeProp.getValue();
+
+                    // FIXME: How to deal with namespaces?
+                    Document node = evaluate(compositePropDefValues, aProperty.getSourceXPathExpression());
+
+                    if (node != null) {
+                        aProperty.setValue(node);
+                    }
+                } else {
+                    throw new CompositeBuilderException("The 'source' has an invalid value: " + source);
+                }
+            } else if (file != null) {
+                aProperty.setValue(loadFromFile(aProperty.getFile()));
+
+            }
+        }
+    }
+    
+    private static class DOMNamespaceContext implements NamespaceContext {
+        private Node node;
+
+        /**
+         * @param node
+         */
+        public DOMNamespaceContext(Node node) {
+            super();
+            this.node = node;
+        }
+
+        public String getNamespaceURI(String prefix) {
+            if (prefix == null) {
+                throw new IllegalArgumentException("Prefix is null");
+            } else if (XMLConstants.XML_NS_PREFIX.equals(prefix)) {
+                return XMLConstants.XML_NS_URI;
+            } else if (XMLConstants.XMLNS_ATTRIBUTE.equals(prefix)) {
+                return XMLConstants.XMLNS_ATTRIBUTE_NS_URI;
+            }
+            String ns = node.lookupNamespaceURI(prefix);
+            return ns == null ? XMLConstants.NULL_NS_URI : ns;
+        }
+
+        public String getPrefix(String namespaceURI) {
+            if (namespaceURI == null) {
+                throw new IllegalArgumentException("Namespace URI is null");
+            } else if (XMLConstants.XML_NS_URI.equals(namespaceURI)) {
+                return XMLConstants.XML_NS_PREFIX;
+            } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+                return XMLConstants.XMLNS_ATTRIBUTE;
+            }
+            return node.lookupPrefix(namespaceURI);
+        }
+
+        public Iterator<?> getPrefixes(String namespaceURI) {
+            // Not implemented
+            if (namespaceURI == null) {
+                throw new IllegalArgumentException("Namespace URI is null");
+            } else if (XMLConstants.XML_NS_URI.equals(namespaceURI)) {
+                return Arrays.asList(XMLConstants.XML_NS_PREFIX).iterator();
+            } else if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespaceURI)) {
+                return Arrays.asList(XMLConstants.XMLNS_ATTRIBUTE).iterator();
+            }
+            String prefix = getPrefix(namespaceURI);
+            if (prefix == null) {
+                return Collections.emptyList().iterator();
+            }
+            return Arrays.asList(prefix).iterator();
+        }
+
+    }
+    
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceUtil.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceUtil.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceUtil.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceUtil.java Sat May  3 13:52:41 2008
@@ -0,0 +1,94 @@
+/*
+ * 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.assembly.builder.impl;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+import org.apache.tuscany.sca.assembly.OptimizableBinding;
+
+/**
+ * This class encapsulates utility methods to deal with reference definitions
+ *
+ */
+class ReferenceUtil {
+    static boolean isValidMultiplicityOverride(Multiplicity definedMul, Multiplicity overridenMul) {
+        if (definedMul != overridenMul) {
+            switch (definedMul) {
+                case ZERO_N:
+                    return overridenMul == Multiplicity.ZERO_ONE;
+                case ONE_N:
+                    return overridenMul == Multiplicity.ONE_ONE;
+                default:
+                    return false;
+            }
+        } else {
+            return true;
+        }
+    }
+    
+    static boolean validateMultiplicityAndTargets(Multiplicity multiplicity,
+                                                         List<?> targets, List<Binding> bindings) {
+        
+        // Count targets
+        int count = targets.size();
+        
+        //FIXME workaround, this validation is sometimes invoked too early
+        // before we get a chance to init the multiplicity attribute
+        if (multiplicity == null) {
+            return true;
+        }
+        
+        switch (multiplicity) {
+            case ZERO_N:
+                break;
+            case ZERO_ONE:
+                if (count > 1) {
+                    return false;
+                }
+                break;
+            case ONE_ONE:
+                if (count != 1) {
+                    if (count == 0) {
+                        for (Binding binding: bindings) {
+                            if (!(binding instanceof OptimizableBinding) || binding.getURI()!=null) {
+                                return true;
+                            }
+                        }
+                    }
+                    return false;
+                }
+                break;
+            case ONE_N:
+                if (count < 1) {
+                    if (count == 0) {
+                        for (Binding binding: bindings) {
+                            if (!(binding instanceof OptimizableBinding) || binding.getURI()!=null) {
+                                return true;
+                            }
+                        }
+                    }
+                    return false;
+                }
+                break;
+        }
+        return true;
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractPropertyImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,114 @@
+/*
+ * 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+
+/**
+ * Represents an abstract property.
+ * 
+ * @version $Rev: 592745 $ $Date: 2007-11-07 05:36:22 -0800 (Wed, 07 Nov 2007) $
+ */
+public class AbstractPropertyImpl extends ExtensibleImpl implements AbstractProperty {
+    private Object value;
+    private String name;
+    private QName xsdType;
+    private QName xsdElement;
+    private boolean many;
+    private boolean mustSupply;
+    private List<Intent> requiredIntents = new ArrayList<Intent>();
+    
+
+    public List<Intent> getRequiredIntents() {
+        return requiredIntents;
+    }
+
+    /**
+     * Constructs a new abstract property.
+     */
+    protected AbstractPropertyImpl() {
+    }
+    
+    public Object getValue() {
+        return value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public QName getXSDElement() {
+        return xsdElement;
+    }
+
+    public QName getXSDType() {
+        return xsdType;
+    }
+
+    public boolean isMany() {
+        return many;
+    }
+
+    public boolean isMustSupply() {
+        return mustSupply;
+    }
+
+    public void setValue(Object defaultValue) {
+        this.value = defaultValue;
+    }
+
+    public void setMany(boolean many) {
+        this.many = many;
+    }
+
+    public void setMustSupply(boolean mustSupply) {
+        this.mustSupply = mustSupply;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public void setXSDElement(QName element) {
+        this.xsdElement = element;
+    }
+
+    public void setXSDType(QName type) {
+        this.xsdType = type;
+    }
+
+    public IntentAttachPointType getType() {
+        return null;
+    }
+
+    public void setType(IntentAttachPointType type) {
+    }
+    
+    public void setRequiredIntents(List<Intent> intents) {
+        this.requiredIntents = intents;
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractReferenceImpl.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.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.Multiplicity;
+
+/**
+ * Represents an abstract reference
+ * 
+ * @version $Rev: 537384 $ $Date: 2007-05-12 04:02:56 -0700 (Sat, 12 May 2007) $
+ */
+public class AbstractReferenceImpl extends ContractImpl implements AbstractReference {
+    private Multiplicity multiplicity = Multiplicity.ONE_ONE;
+
+    /**
+     * Constructs a new abstract reference.
+     */
+    protected AbstractReferenceImpl() {
+    }
+    
+    public Multiplicity getMultiplicity() {
+        return multiplicity;
+    }
+
+    public void setMultiplicity(Multiplicity multiplicity) {
+        this.multiplicity = multiplicity;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AbstractServiceImpl.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.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractService;
+
+/**
+ * Represents an abstract service
+ * 
+ * @version $Rev: 537384 $ $Date: 2007-05-12 04:02:56 -0700 (Sat, 12 May 2007) $
+ */
+public class AbstractServiceImpl extends ContractImpl implements AbstractService {
+    
+    /**
+     * Constructs a new abstract service.
+     */
+    protected AbstractServiceImpl() {
+    }
+    
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/AssemblyFactoryImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,121 @@
+/*
+ * 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.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.AbstractProperty;
+import org.apache.tuscany.sca.assembly.AbstractReference;
+import org.apache.tuscany.sca.assembly.AbstractService;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.Composite;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.assembly.Wire;
+
+/**
+ * A factory for the assembly model.
+ * 
+ * @version $Rev: 637192 $ $Date: 2008-03-14 11:13:01 -0700 (Fri, 14 Mar 2008) $
+ */
+public abstract class AssemblyFactoryImpl implements AssemblyFactory {
+
+    public AbstractProperty createAbstractProperty() {
+        return new AbstractPropertyImpl();
+    }
+
+    public AbstractReference createAbstractReference() {
+        return new AbstractReferenceImpl();
+    }
+
+    public AbstractService createAbstractService() {
+        return new AbstractServiceImpl();
+    }
+
+    public Callback createCallback() {
+        return new CallbackImpl();
+    }
+
+    public Component createComponent() {
+        return new ComponentImpl();
+    }
+
+    public ComponentProperty createComponentProperty() {
+        return new ComponentPropertyImpl();
+    }
+
+    public ComponentReference createComponentReference() {
+        return new ComponentReferenceImpl();
+    }
+
+    public ComponentService createComponentService() {
+        return new ComponentServiceImpl();
+    }
+
+    public ComponentType createComponentType() {
+        return new ComponentTypeImpl();
+    }
+
+    public Composite createComposite() {
+        return new CompositeImpl();
+    }
+
+    public CompositeReference createCompositeReference() {
+        return new CompositeReferenceImpl();
+    }
+
+    public CompositeService createCompositeService() {
+        return new CompositeServiceImpl();
+    }
+
+    public ConstrainingType createConstrainingType() {
+        return new ConstrainingTypeImpl();
+    }
+
+    public Property createProperty() {
+        return new PropertyImpl();
+    }
+
+    public Reference createReference() {
+        return new ReferenceImpl();
+    }
+
+    public Service createService() {
+        return new ServiceImpl();
+    }
+
+    public Wire createWire() {
+        return new WireImpl();
+    }
+
+    public ConfiguredOperation createConfiguredOperation() {
+        return new ConfiguredOperationImpl();
+    }
+    
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/BaseImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,45 @@
+/*
+ * 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.assembly.impl;
+
+import org.apache.tuscany.sca.assembly.Base;
+
+/**
+ * Convenience base class for assembly model objects.
+ * 
+ * @version $Rev: 568902 $ $Date: 2007-08-23 02:32:29 -0700 (Thu, 23 Aug 2007) $
+ */
+public abstract class BaseImpl implements Base {
+    private boolean unresolved;
+
+    /**
+     * Constructs a new base model object.
+     */
+    protected BaseImpl() {
+    }
+    
+    public boolean isUnresolved() {
+        return unresolved;
+    }
+
+    public void setUnresolved(boolean undefined) {
+        this.unresolved = undefined;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/CallbackImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,82 @@
+/*
+ * 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Callback;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a reference.
+ * 
+ * @version $Rev: 620307 $ $Date: 2008-02-10 10:56:51 -0800 (Sun, 10 Feb 2008) $
+ */
+public class CallbackImpl extends ExtensibleImpl implements Callback {
+    private List<Binding> bindings = new ArrayList<Binding>();
+    private List<Intent> requiredIntents = new ArrayList<Intent>();
+    private List<PolicySet> policySets = new ArrayList<PolicySet>();
+    private List<ConfiguredOperation>  configuredOperations = new ArrayList<ConfiguredOperation>();
+    private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>(); 
+
+    public List<PolicySet> getPolicySets() {
+        return policySets;
+    }
+
+    public List<Intent> getRequiredIntents() {
+        return requiredIntents;
+    }
+
+    protected CallbackImpl() {
+    }
+
+    public List<Binding> getBindings() {
+        return bindings;
+    }
+    
+    public IntentAttachPointType getType() {
+        return null;
+    }
+
+    public void setType(IntentAttachPointType type) {
+    }
+    
+    public void setPolicySets(List<PolicySet> policySets) {
+        this.policySets = policySets; 
+    }
+
+    public void setRequiredIntents(List<Intent> intents) {
+        this.requiredIntents = intents;
+    }
+    
+    public List<ConfiguredOperation> getConfiguredOperations() {
+        return configuredOperations;
+    }
+
+    public List<PolicySet> getApplicablePolicySets() {
+        return applicablePolicySets;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,174 @@
+/*
+ * 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.IntentAttachPointType;
+import org.apache.tuscany.sca.policy.PolicySet;
+
+/**
+ * Represents a component.
+ * 
+ * @version $Rev: 637192 $ $Date: 2008-03-14 11:13:01 -0700 (Fri, 14 Mar 2008) $
+ */
+public class ComponentImpl extends ExtensibleImpl implements Component, Cloneable, OperationsConfigurator {
+    private ConstrainingType constrainingType;
+    private Implementation implementation;
+    private String name;
+    private String uri;
+    private List<ComponentProperty> properties = new ArrayList<ComponentProperty>();
+    private List<ComponentReference> references = new ArrayList<ComponentReference>();
+    private List<ComponentService> services = new ArrayList<ComponentService>();
+    private List<Intent> requiredIntents = new ArrayList<Intent>();
+    private List<PolicySet> policySets = new ArrayList<PolicySet>();
+    private Boolean autowire;
+    private IntentAttachPointType type;
+    private List<ConfiguredOperation>  configuredImplOperations = new ArrayList<ConfiguredOperation>();
+    private List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+    /**
+     * Constructs a new component.
+     */
+    protected ComponentImpl() {
+    }
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        ComponentImpl clone = (ComponentImpl)super.clone();
+
+        clone.properties = new ArrayList<ComponentProperty>();
+        for (ComponentProperty property : getProperties()) {
+            clone.properties.add((ComponentProperty)property.clone());
+        }
+        clone.references = new ArrayList<ComponentReference>();
+        for (ComponentReference reference : getReferences()) {
+            clone.references.add((ComponentReference)reference.clone());
+        }
+        clone.services = new ArrayList<ComponentService>();
+        for (ComponentService service : getServices()) {
+            clone.services.add((ComponentService)service.clone());
+        }
+        return clone;
+    }
+
+    public String getURI() {
+        return uri;
+    }
+
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    public ConstrainingType getConstrainingType() {
+        return constrainingType;
+    }
+
+    public Implementation getImplementation() {
+        return implementation;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public List<ComponentProperty> getProperties() {
+        return properties;
+    }
+
+    public List<ComponentReference> getReferences() {
+        return references;
+    }
+
+    public List<ComponentService> getServices() {
+        return services;
+    }
+
+    public void setConstrainingType(ConstrainingType constrainingType) {
+        this.constrainingType = constrainingType;
+    }
+
+    public void setImplementation(Implementation implementation) {
+        this.implementation = implementation;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<Intent> getRequiredIntents() {
+        return requiredIntents;
+    }
+
+    public List<PolicySet> getPolicySets() {
+        return policySets;
+    }
+
+    public boolean isAutowire() {
+        return (autowire == null) ? false : autowire.booleanValue();
+    }
+
+    public void setAutowire(Boolean autowire) {
+        this.autowire = autowire;
+    }
+    
+    public Boolean getAutowire() {
+        return autowire;
+    }
+
+    public IntentAttachPointType getType() {
+        return type;
+    }
+
+    public void setType(IntentAttachPointType type) {
+        this.type = type;
+    }
+
+    public void setPolicySets(List<PolicySet> policySets) {
+        this.policySets = policySets;
+        
+    }
+
+    public void setRequiredIntents(List<Intent> intents) {
+        this.requiredIntents = intents;
+        
+    }
+    
+    public List<ConfiguredOperation> getConfiguredOperations() {
+        return configuredImplOperations;
+    }
+
+    public void setConfiguredOperations(List<ConfiguredOperation> configuredOperations) {
+        this.configuredImplOperations = configuredOperations;
+    }
+    
+    public List<PolicySet> getApplicablePolicySets() {
+        return applicablePolicySets;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentPropertyImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,93 @@
+/*
+ * 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.assembly.impl;
+
+import javax.xml.xpath.XPathExpression;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+
+/**
+ * Represents a component property.
+ * 
+ * @version $Rev: 636985 $ $Date: 2008-03-13 20:48:47 -0700 (Thu, 13 Mar 2008) $
+ */
+public class ComponentPropertyImpl extends PropertyImpl implements ComponentProperty, Cloneable {
+    private String file;
+    private Property property;
+    private String source;
+    private XPathExpression sourceXPathExpression;
+    
+    /**
+     * Constructs a new component property.
+     */
+    protected ComponentPropertyImpl() {
+    }
+    
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+    
+    // FIXME getValue should not delegate to property.getValue()
+    // Doing this violates the setValue/getValue semantics, as you
+    // can call setValue() then get a different value from getValue()
+    @Override
+    public Object getValue() {
+        if (super.getValue() == null && property != null) {
+            return property.getValue();
+        } else {
+            return super.getValue();
+        }
+    }
+ 
+    public String getFile() {
+        return file;
+    }
+
+    public Property getProperty() {
+        return property;
+    }
+
+    public String getSource() {
+        return source;
+    }
+
+    public void setFile(String file) {
+        this.file = file;
+    }
+
+    public void setProperty(Property property) {
+        this.property = property;
+    }
+
+    public void setSource(String source) {
+        this.source = source;
+    }
+
+    public XPathExpression getSourceXPathExpression() {
+        return sourceXPathExpression;
+    }
+
+    public void setSourceXPathExpression(XPathExpression sourceXPathExpression) {
+        this.sourceXPathExpression = sourceXPathExpression;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,86 @@
+/*
+ * 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeReference;
+import org.apache.tuscany.sca.assembly.Reference;
+
+/**
+ * Represents a component reference
+ * 
+ * @version $Rev: 571694 $ $Date: 2007-08-31 22:24:11 -0700 (Fri, 31 Aug 2007) $
+ */
+public class ComponentReferenceImpl extends ReferenceImpl implements ComponentReference, Cloneable {
+    private Reference reference;
+    private Boolean autowire;
+    private List<CompositeReference> promotedAs = new ArrayList<CompositeReference>();
+    private ComponentService callbackService;
+
+    /**
+     * Constructs a new component reference.
+     */
+    protected ComponentReferenceImpl() {
+        // Set multiplicity to null so that by default it'll inherit from the Reference
+        setMultiplicity(null);
+    }
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+    
+    public Reference getReference() {
+        return reference;
+    }
+
+    public void setReference(Reference reference) {
+        this.reference = reference;
+    }
+
+    public boolean isAutowire() {
+        return (autowire == null) ? false : autowire.booleanValue();
+    }
+
+    public void setAutowire(Boolean autowire) {
+        this.autowire = autowire;
+    }
+    
+    public Boolean getAutowire() {
+        return autowire;
+    }
+
+    public List<CompositeReference> promotedAs() {
+        return promotedAs;
+    }
+
+    public ComponentService getCallbackService() {
+        return callbackService;
+    }
+
+    public void setCallbackService(ComponentService callbackService) {
+        this.callbackService = callbackService;
+    }
+    
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentServiceImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,71 @@
+/*
+ * 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.CompositeService;
+import org.apache.tuscany.sca.assembly.Service;
+
+/**
+ * Represents a component service
+ * 
+ * @version $Rev: 564107 $ $Date: 2007-08-08 23:05:29 -0700 (Wed, 08 Aug 2007) $
+ */
+public class ComponentServiceImpl extends ServiceImpl implements ComponentService, Cloneable {
+    private Service service;
+    private List<CompositeService> promotedAs = new ArrayList<CompositeService>();
+    private ComponentReference callbackReference;
+    
+    /**
+     * Constructs a new component service.
+     */
+    protected ComponentServiceImpl() {
+    }
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        return super.clone();
+    }
+    
+    public Service getService() {
+        return service;
+    }
+
+    public void setService(Service service) {
+        this.service = service;
+    }
+
+    public List<CompositeService> promotedAs() {
+        return promotedAs;
+    }
+
+    public ComponentReference getCallbackReference() {
+        return callbackReference;
+    }
+
+    public void setCallbackReference(ComponentReference callbackReference) {
+        this.callbackReference = callbackReference;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentTypeImpl.java Sat May  3 13:52:41 2008
@@ -0,0 +1,115 @@
+/*
+ * 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.assembly.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.ComponentType;
+import org.apache.tuscany.sca.assembly.ConstrainingType;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.assembly.Service;
+
+/** 
+ * Represents a component type.
+ * 
+ * @version $Rev: 637192 $ $Date: 2008-03-14 11:13:01 -0700 (Fri, 14 Mar 2008) $
+ */
+public class ComponentTypeImpl extends ExtensibleImpl implements ComponentType, Cloneable {
+    private String uri;
+    private ConstrainingType constrainingType;
+    private List<Property> properties = new ArrayList<Property>();
+    private List<Reference> references = new ArrayList<Reference>();
+    private List<Service> services = new ArrayList<Service>();
+    /**
+     * Constructs a new component type.
+     */
+    protected ComponentTypeImpl() {
+    }
+
+    @Override
+    public Object clone() throws CloneNotSupportedException {
+        ComponentTypeImpl clone = (ComponentTypeImpl)super.clone();
+
+        clone.services = new ArrayList<Service>();
+        for (Service service : getServices()) {
+            clone.services.add((Service)service.clone());
+        }
+        clone.references = new ArrayList<Reference>();
+        for (Reference reference : getReferences()) {
+            clone.references.add((Reference)reference.clone());
+        }
+        clone.properties = new ArrayList<Property>();
+        for (Property property : getProperties()) {
+            clone.properties.add((Property)property.clone());
+        }
+        return clone;
+    }
+
+    public String getURI() {
+        return uri;
+    }
+
+    public void setURI(String uri) {
+        this.uri = uri;
+    }
+
+    public ConstrainingType getConstrainingType() {
+        return constrainingType;
+    }
+
+    public List<Property> getProperties() {
+        return properties;
+    }
+
+    public List<Reference> getReferences() {
+        return references;
+    }
+
+    public List<Service> getServices() {
+        return services;
+    }
+
+    public void setConstrainingType(ConstrainingType constrainingType) {
+        this.constrainingType = constrainingType;
+    }
+
+    @Override
+    public int hashCode() {
+        return String.valueOf(getURI()).hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == this) {
+            return true;
+        } else {
+            if (obj instanceof ComponentType) {
+                if (getURI() != null) {
+                    return getURI().equals(((ComponentType)obj).getURI());
+                } else {
+                    return ((ComponentType)obj).getURI() == null;
+                }
+            } else {
+                return false;
+            }
+        }
+    }
+}