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 [24/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-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java Sat May  3 13:52:41 2008
@@ -0,0 +1,379 @@
+/*
+ * 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.invocation;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.Multiplicity;
+import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.context.ComponentContextImpl;
+import org.apache.tuscany.sca.core.context.InstanceWrapper;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.CallableReferenceObjectFactory;
+import org.apache.tuscany.sca.core.invocation.CallbackReferenceObjectFactory;
+import org.apache.tuscany.sca.core.invocation.CallbackWireObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.invocation.WireObjectFactory;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.TargetResolutionException;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.impl.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.injection.ConversationIDObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.InvalidAccessorException;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.osoa.sca.CallableReference;
+import org.osoa.sca.annotations.ConversationID;
+
+/**
+ * The runtime instantiation of Java component implementations
+ * 
+ * @version $Rev: 638895 $ $Date: 2008-03-19 08:56:51 -0700 (Wed, 19 Mar 2008) $
+ */
+public class JavaComponentContextProvider {
+    private JavaPropertyValueObjectFactory propertyValueFactory;
+    private DataBindingExtensionPoint dataBindingRegistry;
+    private RuntimeComponent component;
+    private JavaInstanceFactoryProvider<?> instanceFactoryProvider;
+    private ProxyFactory proxyFactory;
+
+    public JavaComponentContextProvider(RuntimeComponent component,
+                                        JavaInstanceFactoryProvider configuration,
+                                        DataBindingExtensionPoint dataBindingExtensionPoint,
+                                        JavaPropertyValueObjectFactory propertyValueObjectFactory,
+                                        ComponentContextFactory componentContextFactory,
+                                        RequestContextFactory requestContextFactory) {
+        super();
+        this.instanceFactoryProvider = configuration;
+        this.proxyFactory = configuration.getProxyFactory();
+        //        if (componentContextFactory != null) {
+        //            this.componentContext = componentContextFactory.createComponentContext(component, requestContextFactory);
+        //        } else {
+        //            this.componentContext = new ComponentContextImpl(this, requestContextFactory, this.proxyService);
+        //        }
+        this.component = component;
+        this.dataBindingRegistry = dataBindingExtensionPoint;
+        this.propertyValueFactory = propertyValueObjectFactory;
+    }
+
+    InstanceWrapper<?> createInstanceWrapper() throws ObjectCreationException {
+        return instanceFactoryProvider.createFactory().newInstance();
+    }
+
+    void configureProperties(List<ComponentProperty> definedProperties) {
+        for (ComponentProperty p : definedProperties) {
+            configureProperty(p);
+        }
+    }
+
+    private void configureProperty(ComponentProperty configuredProperty) {
+        JavaElementImpl element =
+            instanceFactoryProvider.getImplementation().getPropertyMembers().get(configuredProperty.getName());
+
+        if (element != null && configuredProperty.getValue() != null) {
+            if (!(element.getAnchor() instanceof Constructor)) {
+                instanceFactoryProvider.getInjectionSites().add(element);
+            }
+
+            //Class propertyJavaType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+            ObjectFactory<?> propertyObjectFactory =
+                createPropertyValueFactory(configuredProperty, configuredProperty.getValue(), element);
+            instanceFactoryProvider.setObjectFactory(element, propertyObjectFactory);
+            
+            JavaConstructorImpl constructor = instanceFactoryProvider.getImplementation().getConstructor();
+            for(JavaElementImpl p: constructor.getParameters()){
+                if(element.getName().equals(p.getName())) {
+                    instanceFactoryProvider.setObjectFactory(p, propertyObjectFactory);
+                }
+            }
+        }
+    }
+
+    void start() {
+        if (!instanceFactoryProvider.getImplementation().getCallbackMembers().isEmpty()) {
+            Map<String, List<RuntimeWire>> callbackWires = new HashMap<String, List<RuntimeWire>>();
+            for (ComponentService service : component.getServices()) {
+
+                RuntimeComponentReference callbackReference = (RuntimeComponentReference)service.getCallbackReference();
+                if (callbackReference != null) {
+                    List<RuntimeWire> wires = callbackReference.getRuntimeWires();
+                    if (!wires.isEmpty()) {
+                        callbackWires.put(wires.get(0).getSource().getInterfaceContract().getInterface().toString(),
+                                          wires);
+                    }
+                }
+            }
+
+            for (Map.Entry<String, JavaElementImpl> entry : instanceFactoryProvider.getImplementation()
+                .getCallbackMembers().entrySet()) {
+                List<RuntimeWire> wires = callbackWires.get(entry.getKey());
+                if (wires == null) {
+                    // this can happen when there are no client wires to a
+                    // component that has a callback
+                    continue;
+                }
+                JavaElementImpl element = entry.getValue();
+                Class<?> businessInterface = element.getType();
+                ObjectFactory<?> factory = null;
+                if (CallableReference.class.isAssignableFrom(element.getType())) {
+                    businessInterface =
+                        JavaIntrospectionHelper.getBusinessInterface(element.getType(), element.getGenericType());
+                    factory =
+                        new CallbackReferenceObjectFactory(businessInterface, proxyFactory, wires);
+                } else {
+                    factory = new CallbackWireObjectFactory(businessInterface, proxyFactory, wires);
+                }
+                if (!(element.getAnchor() instanceof Constructor)) {
+                    instanceFactoryProvider.getInjectionSites().add(element);
+                }
+                instanceFactoryProvider.setObjectFactory(element, factory);
+            }
+        }
+        for (Reference ref : instanceFactoryProvider.getImplementation().getReferences()) {
+            JavaElementImpl element =
+                instanceFactoryProvider.getImplementation().getReferenceMembers().get(ref.getName());
+            if (element != null) {
+                if (!(element.getAnchor() instanceof Constructor)) {
+                    instanceFactoryProvider.getInjectionSites().add(element);
+                }
+                ComponentReference componentReference = null;
+                List<RuntimeWire> wireList = null;
+                for (ComponentReference reference : component.getReferences()) {
+                    if (reference.getName().equals(ref.getName())) {
+                        wireList = ((RuntimeComponentReference)reference).getRuntimeWires();
+                        componentReference = reference;
+                        break;
+                    }
+                }
+                if (ref.getMultiplicity() == Multiplicity.ONE_N || ref.getMultiplicity() == Multiplicity.ZERO_N) {
+                    List<ObjectFactory<?>> factories = new ArrayList<ObjectFactory<?>>();
+                    Class<?> baseType =
+                        JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+                    for (int i = 0; i < wireList.size(); i++) {
+                        ObjectFactory<?> factory = null;
+                        if (CallableReference.class.isAssignableFrom(baseType)) {
+                            Type callableRefType = JavaIntrospectionHelper.getParameterType(element.getGenericType());
+                            // Type businessType = JavaIntrospectionHelper.getParameterType(callableRefType);
+                            Class<?> businessInterface =
+                                JavaIntrospectionHelper.getBusinessInterface(baseType, callableRefType);
+                            factory =
+                                new CallableReferenceObjectFactory(businessInterface, component,
+                                                                   (RuntimeComponentReference)wireList.get(i)
+                                                                       .getSource().getContract(), wireList.get(i)
+                                                                       .getSource().getBinding());
+                        } else {
+                            factory = createObjectFactory(baseType, wireList.get(i));
+                        }
+                        factories.add(factory);
+                    }
+                    instanceFactoryProvider.setObjectFactories(element, factories);
+                    JavaConstructorImpl constructor = instanceFactoryProvider.getImplementation().getConstructor();
+                    for(JavaElementImpl p: constructor.getParameters()){
+                        if(element.getName().equals(p.getName())) {
+                            instanceFactoryProvider.setObjectFactories(p, factories);
+                        }
+                    }
+                } else {
+                    if (wireList == null && ref.getMultiplicity() == Multiplicity.ONE_ONE) {
+                        throw new IllegalStateException("Required reference is missing: " + ref.getName());
+                    }
+                    if (wireList != null && !wireList.isEmpty()) {
+                        ObjectFactory<?> factory = null;
+                        if (CallableReference.class.isAssignableFrom(element.getType())) {
+                            Class<?> businessInterface =
+                                JavaIntrospectionHelper.getBusinessInterface(element.getType(), element
+                                    .getGenericType());
+                            factory =
+                                new CallableReferenceObjectFactory(businessInterface, component,
+                                                                   (RuntimeComponentReference)componentReference, null);
+                        } else {
+                            factory = createObjectFactory(element.getType(), wireList.get(0));
+                        }
+                        instanceFactoryProvider.setObjectFactory(element, factory);
+                        JavaConstructorImpl constructor = instanceFactoryProvider.getImplementation().getConstructor();
+                        for(JavaElementImpl p: constructor.getParameters()){
+                            if(element.getName().equals(p.getName())) {
+                                instanceFactoryProvider.setObjectFactory(p, factory);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+
+        // We need to set the PropertyValueFactory on the ComponentContextImpl
+        // so the ComponentContext can "de-marshal" the property type to a value 
+        // when the getProperty() method is called
+        ComponentContextImpl ccImpl = (ComponentContextImpl)component.getComponentContext();
+        ccImpl.setPropertyValueFactory(propertyValueFactory);
+
+        //setUpPolicyHandlers();
+    }
+
+    void addResourceFactory(String name, ObjectFactory<?> factory) {
+        JavaResourceImpl resource = instanceFactoryProvider.getImplementation().getResources().get(name);
+
+        if (resource != null && !(resource.getElement().getAnchor() instanceof Constructor)) {
+            instanceFactoryProvider.getInjectionSites().add(resource.getElement());
+        }
+
+        instanceFactoryProvider.setObjectFactory(resource.getElement(), factory);
+    }
+
+    void addConversationIDFactories(List<Member> names) {
+        ObjectFactory<String> factory = new ConversationIDObjectFactory();
+        for (Member name : names) {
+            if (name instanceof Field) {
+                JavaElementImpl element = new JavaElementImpl((Field)name);
+                element.setClassifer(ConversationID.class);
+                instanceFactoryProvider.setObjectFactory(element, factory);
+            } else if (name instanceof Method) {
+                JavaElementImpl element = new JavaElementImpl((Method)name, 0);
+                element.setName(JavaIntrospectionHelper.toPropertyName(name.getName()));
+                element.setClassifer(ConversationID.class);
+                instanceFactoryProvider.setObjectFactory(element, factory);
+            } else {
+                throw new InvalidAccessorException("Member must be a field or method: " + name.getName());
+            }
+        }
+    }
+
+    Object createInstance() throws ObjectCreationException {
+        return createInstanceWrapper().getInstance();
+    }
+
+    JavaInstanceFactoryProvider<?> getInstanceFactoryProvider() {
+        return instanceFactoryProvider;
+    }
+
+    void stop() {
+        //cleanUpPolicyHandlers();
+    }
+
+    Invoker createInvoker(Operation operation) throws NoSuchMethodException {
+        Class<?> implClass = instanceFactoryProvider.getImplementationClass();
+
+        Method method = JavaInterfaceUtil.findMethod(implClass, operation);
+        return new JavaImplementationInvoker(operation, method, component);
+    }
+
+    private static class OptimizedObjectFactory<T> implements ObjectFactory<T> {
+        private ScopeContainer scopeContainer;
+
+        public OptimizedObjectFactory(ScopeContainer scopeContainer) {
+            super();
+            this.scopeContainer = scopeContainer;
+        }
+
+        public T getInstance() throws ObjectCreationException {
+            try {
+                return (T)scopeContainer.getWrapper(null).getInstance();
+            } catch (TargetResolutionException e) {
+                throw new ObjectCreationException(e);
+            }
+        }
+
+    }
+
+    private <B> ObjectFactory<B> createObjectFactory(Class<B> interfaze, RuntimeWire wire) {
+        // FIXME: [rfeng] Disable the optimization for new as it needs more discussions
+        /*
+        boolean conversational = wire.getSource().getInterfaceContract().getInterface().isConversational();
+        Binding binding = wire.getSource().getBinding();
+        // Check if it's wireable binding for optimization
+        if (!conversational && binding instanceof OptimizableBinding) {
+            OptimizableBinding optimizableBinding = (OptimizableBinding)binding;
+            Component component = optimizableBinding.getTargetComponent();
+            if (component != null) {
+                Implementation implementation = component.getImplementation();
+                // Check if the target component is java component
+                if (implementation instanceof JavaImplementation) {
+                    JavaImplementation javaImplementation = (JavaImplementation)implementation;
+                    if (interfaze.isAssignableFrom(javaImplementation.getJavaClass())) {
+                        ScopedRuntimeComponent scopedComponent = (ScopedRuntimeComponent)component;
+                        ScopeContainer scopeContainer = scopedComponent.getScopeContainer();
+                        Scope scope = scopeContainer.getScope();
+                        if (scope == Scope.COMPOSITE || scope == Scope.STATELESS || scope == Scope.SYSTEM) {
+                            boolean optimizable = true;
+                            for (InvocationChain chain : wire.getInvocationChains()) {
+                                if (chain.getHeadInvoker() != chain.getTailInvoker()) {
+                                    optimizable = false;
+                                    break;
+                                }
+                            }
+                            if (optimizable) {
+                                return new OptimizedObjectFactory<B>(scopeContainer);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        */
+        return new WireObjectFactory<B>(interfaze, wire, proxyFactory);
+    }
+
+    private ObjectFactory<?> createPropertyValueFactory(ComponentProperty property,
+                                                        Object propertyValue,
+                                                        JavaElementImpl javaElement) {
+        return propertyValueFactory.createValueFactory(property, propertyValue, javaElement);
+    }
+
+    /**
+     * @return the component
+     */
+    RuntimeComponent getComponent() {
+        return component;
+    }
+
+    /*private void setUpPolicyHandlers() {
+        for (PolicyHandler policyHandler : policyHandlers.values()) {
+            policyHandler.setUp(component.getImplementation());
+        }
+    }
+
+    private void cleanUpPolicyHandlers() {
+        for (PolicyHandler policyHandler : policyHandlers.values() ) {
+            policyHandler.cleanUp(this);
+        }
+    }*/
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentNameFactory.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.invocation;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public class JavaComponentNameFactory implements ObjectFactory<String> {
+    private final JavaComponentContextProvider componentContextProvider;
+
+
+    public JavaComponentNameFactory(JavaComponentContextProvider component) {
+        this.componentContextProvider = component;
+    }
+
+
+    public String getInstance() throws ObjectCreationException {
+        String uri = componentContextProvider.getComponent().getURI();
+        return uri.substring(uri.lastIndexOf('/')+1);
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java Sat May  3 13:52:41 2008
@@ -0,0 +1,133 @@
+/*
+ * 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.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.tuscany.sca.core.context.InstanceWrapper;
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.ScopeContainer;
+import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.interfacedef.ConversationSequence;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
+import org.apache.tuscany.sca.runtime.EndpointReference;
+import org.apache.tuscany.sca.runtime.ReferenceParameters;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * Responsible for synchronously dispatching an invocation to a Java component
+ * implementation instance
+ * 
+ * @version $Rev: 634778 $ $Date: 2008-03-07 10:58:16 -0800 (Fri, 07 Mar 2008) $
+ */
+public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics {
+    protected Operation operation;
+    protected Method method;
+    protected boolean allowsPBR;
+
+    @SuppressWarnings("unchecked")
+    protected final ScopeContainer scopeContainer;
+
+    public JavaImplementationInvoker(Operation operation, Method method, RuntimeComponent component) {
+        assert method != null : "Operation method cannot be null";
+        this.method = method;
+        this.operation = operation;
+        this.scopeContainer = ((ScopedRuntimeComponent)component).getScopeContainer();
+        this.allowsPBR = ((JavaImplementation)component.getImplementation()).isAllowsPassByReference(method);
+    }
+
+    @SuppressWarnings("unchecked")
+    public Message invoke(Message msg) {
+        Operation op = msg.getOperation();
+        if (op == null) {
+            op = this.operation;
+        }
+        ConversationSequence sequence = op.getConversationSequence();
+        Object payload = msg.getBody();
+
+        Object contextId = null;
+
+        EndpointReference from = msg.getFrom();
+        ReferenceParameters parameters = null;
+        if (from != null) {
+            parameters = from.getReferenceParameters();
+        }
+        // check what sort of context is required
+        if (scopeContainer != null) {
+            Scope scope = scopeContainer.getScope();
+            if (scope == Scope.REQUEST) {
+                contextId = Thread.currentThread();
+            } else if (scope == Scope.CONVERSATION && parameters != null) {
+                contextId = parameters.getConversationID();
+            }
+        }
+
+        try {
+            // The following call might create a new conversation, as a result, the msg.getConversationID() might 
+            // return a new value
+            InstanceWrapper wrapper = scopeContainer.getWrapper(contextId);
+
+            // detects whether the scope container has created a conversation Id. This will
+            // happen in the case that the component has conversational scope but only the
+            // callback interface is conversational. Or in the callback case if the service interface
+            // is conversational and the callback interface isn't. If we are in this situation we need
+            // to get the contextId of this component and remove it after we have invoked the method on 
+            // it. It is possible that the component instance will not go away when it is removed below 
+            // because a callback conversation will still be holding a reference to it
+            boolean removeTemporaryConversationalComponentAfterCall = false;
+            if (parameters != null && (contextId == null) && (parameters.getConversationID() != null)) {
+                contextId = parameters.getConversationID();
+                removeTemporaryConversationalComponentAfterCall = true;
+            }
+
+            Object instance = wrapper.getInstance();
+            Object ret;
+            if (payload != null && !payload.getClass().isArray()) {
+                ret = method.invoke(instance, payload);
+            } else {
+                ret = method.invoke(instance, (Object[])payload);
+            }
+
+            scopeContainer.returnWrapper(wrapper, contextId);
+
+            if ((sequence == ConversationSequence.CONVERSATION_END) || (removeTemporaryConversationalComponentAfterCall)) {
+                // if end conversation, or we have the special case where a conversational
+                // object was created to service the stateless half of a stateful component
+                scopeContainer.remove(contextId);
+                parameters.setConversationID(null);
+            }
+            msg.setBody(ret);
+        } catch (InvocationTargetException e) {
+            msg.setFaultBody(e.getCause());
+        } catch (Exception e) {
+            msg.setFaultBody(e);
+        }
+        return msg;
+    }
+
+    public boolean allowsPassByReference() {
+        return allowsPBR;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java Sat May  3 13:52:41 2008
@@ -0,0 +1,183 @@
+/*
+ * 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.invocation;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.context.InstanceWrapper;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.core.scope.Scope;
+import org.apache.tuscany.sca.core.scope.ScopedImplementationProvider;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.impl.JavaResourceImpl;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.RequestContextObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.ResourceHost;
+import org.apache.tuscany.sca.implementation.java.injection.ResourceObjectFactory;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.osoa.sca.ComponentContext;
+import org.osoa.sca.RequestContext;
+
+/**
+ * @version $Rev: 638895 $ $Date: 2008-03-19 08:56:51 -0700 (Wed, 19 Mar 2008) $
+ */
+public class JavaImplementationProvider implements ScopedImplementationProvider {
+    private JavaImplementation implementation;
+    private JavaComponentContextProvider componentContextProvider;
+    private RequestContextFactory requestContextFactory;
+    
+    public JavaImplementationProvider(RuntimeComponent component,
+                                      JavaImplementation implementation,
+                                      ProxyFactory proxyService,
+                                      DataBindingExtensionPoint dataBindingRegistry,
+                                      JavaPropertyValueObjectFactory propertyValueObjectFactory,
+                                      ComponentContextFactory componentContextFactory,
+                                      RequestContextFactory requestContextFactory,
+                                      Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames) {
+        super();
+        this.implementation = implementation;
+        this.requestContextFactory = requestContextFactory;
+        this.implementation.setPolicyHandlerClassNames(policyHandlerClassNames);
+        
+        try {
+            JavaInstanceFactoryProvider configuration = new JavaInstanceFactoryProvider(implementation);
+            configuration.setProxyFactory(proxyService);
+            componentContextProvider =
+                new JavaComponentContextProvider(component, 
+                                                 configuration, 
+                                                 dataBindingRegistry,
+                                                 propertyValueObjectFactory,
+                                                 componentContextFactory, 
+                                                 requestContextFactory);
+
+            Scope scope = getScope();
+
+            if (scope == Scope.SYSTEM || scope == Scope.COMPOSITE) {
+                // Nothing
+            } else {
+                // Check for conversational contract if conversational scope
+                if (scope == Scope.CONVERSATION) {
+                    boolean hasConversationalContract = false;
+                    for (Service serviceDef : implementation.getServices()) {
+                        if (serviceDef.getInterfaceContract().getInterface().isConversational()) {
+                            hasConversationalContract = true;
+                            break;
+                        }
+                    }
+                    if (!hasConversationalContract) {
+                        String name = implementation.getJavaClass().getName();
+                        throw new NoConversationalContractException(name);
+                    }
+                }
+            }
+
+            if (implementation.getConversationIDMembers().size() > 0) {
+                componentContextProvider.addConversationIDFactories(implementation.getConversationIDMembers());
+            }
+
+            componentContextProvider.configureProperties(component.getProperties());
+            handleResources(implementation, proxyService);
+        } catch (Exception e) {
+            throw new IllegalStateException(e);
+        }
+        
+    }
+    
+    private void handleResources(JavaImplementation componentType, ProxyFactory proxyService) {
+        for (JavaResourceImpl resource : componentType.getResources().values()) {
+            String name = resource.getName();
+
+            ObjectFactory<?> objectFactory =
+                (ObjectFactory<?>)componentContextProvider.getInstanceFactoryProvider().getFactories().get(resource.getElement());
+            if (objectFactory == null) {
+                Class<?> type = resource.getElement().getType();
+                if (ComponentContext.class.equals(type)) {
+                    objectFactory = new JavaComponentContextFactory(componentContextProvider);
+                } else if (RequestContext.class.equals(type)) {
+                    objectFactory = new RequestContextObjectFactory(requestContextFactory, proxyService);
+                } else if (String.class.equals(type)) {
+                    objectFactory = new JavaComponentNameFactory(componentContextProvider);
+                } else {
+                    boolean optional = resource.isOptional();
+                    String mappedName = resource.getMappedName();
+                    objectFactory = createResourceObjectFactory(type, mappedName, optional, null);
+                }
+            }
+            componentContextProvider.addResourceFactory(name, objectFactory);
+        }
+    }
+
+    private <T> ResourceObjectFactory<T> createResourceObjectFactory(Class<T> type,
+                                                                     String mappedName,
+                                                                     boolean optional,
+                                                                     ResourceHost host) {
+        return new ResourceObjectFactory<T>(type, mappedName, optional, host);
+    }
+
+    public Invoker createInvoker(RuntimeComponentService service, Operation operation) {
+        try {
+            return componentContextProvider.createInvoker(operation);
+        } catch (NoSuchMethodException e) {
+            throw new IllegalArgumentException(e);
+        }
+    }
+    
+    public boolean supportsOneWayInvocation() {
+        return false;
+    }
+
+    public Scope getScope() {
+        return new Scope(implementation.getJavaScope().getScope());
+    }
+
+    public void start() {
+        componentContextProvider.start();
+    }
+
+    public void stop() {
+        componentContextProvider.stop();
+    }
+
+    public InstanceWrapper createInstanceWrapper() {
+        return componentContextProvider.createInstanceWrapper();
+    }
+
+    public boolean isEagerInit() {
+        return implementation.isEagerInit();
+    }
+
+    public long getMaxAge() {
+        return implementation.getMaxAge();
+    }
+
+    public long getMaxIdleTime() {
+        return implementation.getMaxIdleTime();
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProviderFactory.java Sat May  3 13:52:41 2008
@@ -0,0 +1,77 @@
+/*
+ * 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.invocation;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
+import org.apache.tuscany.sca.provider.ImplementationProvider;
+import org.apache.tuscany.sca.provider.ImplementationProviderFactory;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev: 604245 $ $Date: 2007-12-14 10:07:40 -0800 (Fri, 14 Dec 2007) $
+ */
+public class JavaImplementationProviderFactory implements ImplementationProviderFactory<JavaImplementation> {
+    private JavaPropertyValueObjectFactory propertyValueObjectFactory;
+    private DataBindingExtensionPoint dataBindingRegistry;
+    private ProxyFactory proxyService;
+    private ComponentContextFactory componentContextFactory;
+    private RequestContextFactory requestContextFactory;
+    private Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames = null;
+
+    public JavaImplementationProviderFactory(ProxyFactory proxyService,
+                                             DataBindingExtensionPoint dataBindingRegistry,
+                                             JavaPropertyValueObjectFactory propertyValueObjectFactory,
+                                             ComponentContextFactory componentContextFactory,
+                                             RequestContextFactory requestContextFactory,
+                                             Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames) {
+        super();
+        this.proxyService = proxyService;
+        this.dataBindingRegistry = dataBindingRegistry;
+        this.propertyValueObjectFactory = propertyValueObjectFactory;
+        this.componentContextFactory = componentContextFactory;
+        this.requestContextFactory = requestContextFactory;
+        this.policyHandlerClassNames = policyHandlerClassNames;
+    }
+
+    public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+                                                               JavaImplementation implementation) {
+        return new JavaImplementationProvider(component, 
+                                              implementation, 
+                                              proxyService, 
+                                              dataBindingRegistry,
+                                              propertyValueObjectFactory, 
+                                              componentContextFactory, 
+                                              requestContextFactory,
+                                              policyHandlerClassNames);
+    }
+
+    public Class<JavaImplementation> getModelType() {
+        return JavaImplementation.class;
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaInstanceFactoryProvider.java Sat May  3 13:52:41 2008
@@ -0,0 +1,183 @@
+/*
+ * 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.invocation;
+
+import java.lang.annotation.ElementType;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.implementation.java.context.InstanceFactory;
+import org.apache.tuscany.sca.implementation.java.context.InstanceFactoryProvider;
+import org.apache.tuscany.sca.implementation.java.context.ReflectiveInstanceFactory;
+import org.apache.tuscany.sca.implementation.java.impl.JavaConstructorImpl;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.injection.ArrayMultiplicityObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.FieldInjector;
+import org.apache.tuscany.sca.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.implementation.java.injection.InvalidAccessorException;
+import org.apache.tuscany.sca.implementation.java.injection.ListMultiplicityObjectFactory;
+import org.apache.tuscany.sca.implementation.java.injection.MethodInjector;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper;
+
+/**
+ * Encapsulates configuration for a Java-based atomic component
+ * 
+ * @version $Rev: 639649 $ $Date: 2008-03-21 06:04:01 -0800 (Fri, 21 Mar 2008) $
+ */
+public class JavaInstanceFactoryProvider<T> implements InstanceFactoryProvider<T> {
+    private JavaImplementation definition;
+    private ProxyFactory proxyService;
+
+    private final List<JavaElementImpl> injectionSites;
+    private final EventInvoker<T> initInvoker;
+    private final EventInvoker<T> destroyInvoker;
+    private final Map<JavaElementImpl, Object> factories = new HashMap<JavaElementImpl, Object>();
+
+    public JavaInstanceFactoryProvider(JavaImplementation definition) {
+        this.definition = definition;
+        this.initInvoker = definition.getInitMethod() == null ? null : new MethodEventInvoker<T>(definition
+            .getInitMethod());
+        this.destroyInvoker = definition.getDestroyMethod() == null ? null : new MethodEventInvoker<T>(definition
+            .getDestroyMethod());
+        injectionSites = new ArrayList<JavaElementImpl>();
+    }
+
+    ProxyFactory getProxyFactory() {
+        return proxyService;
+    }
+
+    void setProxyFactory(ProxyFactory proxyService) {
+        this.proxyService = proxyService;
+    }
+
+    /**
+     * @return the definition
+     */
+    JavaImplementation getImplementation() {
+        return definition;
+    }
+
+    @SuppressWarnings("unchecked")
+    public InstanceFactory<T> createFactory() {
+        ObjectFactory<?>[] initArgs = getConstructorArgs();
+        Injector<T>[] injectors = getInjectors();
+        return new ReflectiveInstanceFactory<T>((Constructor<T>)definition.getConstructor().getConstructor(),
+                                                initArgs, injectors, initInvoker, destroyInvoker);
+    }
+
+    private ObjectFactory<?>[] getConstructorArgs() {
+        JavaConstructorImpl<?> constructor = definition.getConstructor();
+        ObjectFactory<?>[] initArgs = new ObjectFactory<?>[constructor.getParameters().length];
+        for (int i = 0; i < initArgs.length; i++) {
+            ObjectFactory<?> factory = (ObjectFactory<?>)factories.get(constructor.getParameters()[i]);
+            assert factory != null;
+            initArgs[i] = factory;
+        }
+        return initArgs;
+    }
+
+    @SuppressWarnings("unchecked")
+    private Injector<T>[] getInjectors() {
+        // work around JDK1.5 issue with allocating generic arrays
+        @SuppressWarnings("unchecked")
+        Injector<T>[] injectors = new Injector[injectionSites.size()];
+
+        int i = 0;
+        for (JavaElementImpl element : injectionSites) {
+            Object obj = factories.get(element);
+            if (obj != null) {
+                if (obj instanceof ObjectFactory) {
+                    ObjectFactory<?> factory = (ObjectFactory<?>)obj;
+                    Member member = (Member)element.getAnchor();
+                    if (element.getElementType() == ElementType.FIELD) {
+                        injectors[i++] = new FieldInjector<T>((Field)member, factory);
+                    } else if (element.getElementType() == ElementType.PARAMETER && member instanceof Method) {
+                        injectors[i++] = new MethodInjector<T>((Method)member, factory);
+                    } else if (member instanceof Constructor) {
+                        // Ignore
+                    } else {
+                        throw new AssertionError(String.valueOf(element));
+                    }
+                } else {
+                    injectors[i++] = createMultiplicityInjector(element, (List<ObjectFactory<?>>)obj);
+                }
+            }
+        }
+        return injectors;
+    }
+
+    private Injector<T> createMultiplicityInjector(JavaElementImpl element, List<ObjectFactory<?>> factories) {
+        Class<?> interfaceType = JavaIntrospectionHelper.getBaseType(element.getType(), element.getGenericType());
+
+        if (element.getAnchor() instanceof Field) {
+            Field field = (Field)element.getAnchor();
+            if (field.getType().isArray()) {
+                return new FieldInjector<T>(field, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+            } else {
+                return new FieldInjector<T>(field, new ListMultiplicityObjectFactory(factories));
+            }
+        } else if (element.getAnchor() instanceof Method) {
+            Method method = (Method)element.getAnchor();
+            if (method.getParameterTypes()[0].isArray()) {
+                return new MethodInjector<T>(method, new ArrayMultiplicityObjectFactory(interfaceType, factories));
+            } else {
+                return new MethodInjector<T>(method, new ListMultiplicityObjectFactory(factories));
+            }
+        } else {
+            throw new InvalidAccessorException("Member must be a field or method: " + element.getName());
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    public Class<T> getImplementationClass() {
+        return (Class<T>)definition.getJavaClass();
+    }
+
+    public void setObjectFactory(JavaElementImpl element, ObjectFactory<?> objectFactory) {
+        factories.put(element, objectFactory);
+    }
+
+    public void setObjectFactories(JavaElementImpl element, List<ObjectFactory<?>> objectFactory) {
+        factories.put(element, objectFactory);
+    }
+
+    /**
+     * @return the injectionSites
+     */
+    List<JavaElementImpl> getInjectionSites() {
+        return injectionSites;
+    }
+
+    /**
+     * @return the factories
+     */
+    Map<JavaElementImpl, Object> getFactories() {
+        return factories;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaPolicyHandlingRuntimeWireProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,124 @@
+/*
+ * 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.invocation;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import org.apache.tuscany.sca.assembly.ConfiguredOperation;
+import org.apache.tuscany.sca.assembly.OperationsConfigurator;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.util.PolicyHandler;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerUtils;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+
+/**
+ * Processor to inject policy handling interceptor whenever PolicySets are specified in a Java Implementation 
+ */
+public class JavaPolicyHandlingRuntimeWireProcessor implements RuntimeWireProcessor {
+    private final static Logger logger = Logger.getLogger(JavaPolicyHandlingRuntimeWireProcessor.class.getName());
+
+    public JavaPolicyHandlingRuntimeWireProcessor() {
+        super();
+    }
+
+    public void process(RuntimeWire wire) {
+        /*Contract contract = wire.getSource().getContract();
+        if (!(contract instanceof RuntimeComponentReference)) {
+            return;
+        }*/
+
+        RuntimeComponent component = wire.getTarget().getComponent();
+        if (component != null && component.getImplementation() instanceof JavaImplementation) {
+            JavaImplementation javaImpl = (JavaImplementation)component.getImplementation();
+            if (javaImpl instanceof PolicySetAttachPoint) {
+                PolicyHandler policyHandler = null;
+                List<PolicyHandler> implPolicyHandlers = new ArrayList<PolicyHandler>();
+                PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)javaImpl;
+
+                try {
+                    //for ( PolicySet policySet : policiedImpl.getPolicySets() ) {
+                    for (PolicySet policySet : component.getPolicySets()) {
+                        policyHandler =
+                            PolicyHandlerUtils.findPolicyHandler(policySet, javaImpl.getPolicyHandlerClassNames());
+                        if (policyHandler != null) {
+                            policyHandler.setUp(javaImpl);
+                            implPolicyHandlers.add(policyHandler);
+                        } else {
+                            //FIXME: to be removed after the PolicyHandler story has crystalized..
+                            //maybe replace with exception then...
+                            logger.warning("No PolicyHandler registered for PolicySet - " + policySet.getName());
+                        }
+                    }
+
+                    List<PolicyHandler> applicablePolicyHandlers = null;
+                    for (InvocationChain chain : wire.getInvocationChains()) {
+                        applicablePolicyHandlers = new ArrayList<PolicyHandler>();
+                        if (javaImpl instanceof OperationsConfigurator) {
+                            String operationName = chain.getTargetOperation().getName();
+                            OperationsConfigurator opConfigurator = (OperationsConfigurator)component;
+                            for (ConfiguredOperation confOp : opConfigurator.getConfiguredOperations()) {
+                                if (confOp.getName().equals(operationName)) {
+                                    for (PolicySet policySet : confOp.getPolicySets()) {
+                                        policyHandler =
+                                            PolicyHandlerUtils.findPolicyHandler(policySet, javaImpl
+                                                .getPolicyHandlerClassNames());
+                                        if (policyHandler != null) {
+                                            policyHandler.setUp(javaImpl);
+                                            applicablePolicyHandlers.add(policyHandler);
+                                        } else {
+                                            logger.warning("No PolicyHandler registered for " + policySet);
+                                        }
+                                    }
+                                    break;
+                                }
+                            }
+
+                            //if no policies have been specified at the operation level then simply
+                            //apply whatever is specified for the implementation level
+                            if (applicablePolicyHandlers.isEmpty()) {
+                                applicablePolicyHandlers = implPolicyHandlers;
+                            }
+                        }
+
+                        if (!applicablePolicyHandlers.isEmpty()) {
+                            String phase =
+                                (wire.getSource().getContract() instanceof ComponentReference) ? Phase.REFERENCE_POLICY
+                                    : Phase.SERVICE_POLICY;
+
+                            chain.addInterceptor(Phase.IMPLEMENTATION_POLICY, new PolicyHandlingInterceptor(chain.getTargetOperation(),
+                                                                                      applicablePolicyHandlers));
+                        }
+                    }
+                } catch (Exception e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/MethodEventInvoker.java Sat May  3 13:52:41 2008
@@ -0,0 +1,56 @@
+/*
+ * 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.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+
+/**
+ * Performs an wire on a method of a given instance
+ *
+ * @version $Rev: 639649 $ $Date: 2008-03-21 06:04:01 -0800 (Fri, 21 Mar 2008) $
+ */
+public class MethodEventInvoker<T> implements EventInvoker<T> {
+    private final Method method;
+
+    /**
+     * Instantiates an  invoker for the given method
+     */
+    public MethodEventInvoker(Method method) {
+        assert method != null;
+        this.method = method;
+    }
+
+    public void invokeEvent(T instance) throws EventInvocationException {
+        try {
+            method.invoke(instance, (Object[]) null);
+        } catch (IllegalArgumentException e) {
+            String name = method.getName();
+            throw new EventInvocationException("Exception thrown by event method [" + name + "]", e.getCause());
+        } catch (IllegalAccessException e) {
+            String name = method.getName();
+            throw new EventInvocationException("Method is not accessible [" + name + "]");
+        } catch (InvocationTargetException e) {
+            String name = method.getName();
+            throw new EventInvocationException("Exception thrown by event method [" + name + "]", e.getCause());
+        }
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/NoConversationalContractException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,34 @@
+/*
+ * 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.invocation;
+
+
+/**
+ * Raised when a component has conversational scope but no conversational contract
+ *
+ * @version $Rev: 487877 $ $Date: 2006-12-16 15:32:16 -0500 (Sat, 16 Dec 2006) $
+ */
+public class NoConversationalContractException extends Exception {
+
+    private static final long serialVersionUID = -1157790036638157539L;
+
+    public NoConversationalContractException(String message) {
+        super(message);
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PolicyHandlingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PolicyHandlingInterceptor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PolicyHandlingInterceptor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/PolicyHandlingInterceptor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.invocation;
+
+import java.util.List;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.policy.util.PolicyHandler;
+
+/**
+ * An interceptor to invoke policy handlers before and after the invocation of operations on 
+ * an implementation.
+ */
+public class PolicyHandlingInterceptor implements Interceptor {
+    private Invoker next;
+    private List<PolicyHandler> policyHandlers = null;
+    private Operation targetOperation = null;
+
+    public PolicyHandlingInterceptor(Operation targetOperation, List<PolicyHandler> policyHandlers) {
+        this.policyHandlers = policyHandlers;
+        this.targetOperation = targetOperation;
+    }
+
+    public Message invoke(Message msg) {
+        try {
+            applyPreInvocationPolicies(targetOperation, msg);
+            msg = next.invoke(msg);
+        } finally {
+            applyPostInvocationPolices(targetOperation, msg);
+        }
+        return msg;
+    }
+
+    public void setNext(Invoker next) {
+        this.next = next;
+    }
+
+    public Invoker getNext() {
+        return next;
+    }
+
+    private void applyPreInvocationPolicies(Object... context) {
+        for (PolicyHandler policyHandler : policyHandlers) {
+            policyHandler.beforeInvoke(context);
+        }
+    }
+
+    private void applyPostInvocationPolices(Object... context) {
+        for ( int count = policyHandlers.size() - 1 ; count >= 0 ; --count) {
+            policyHandlers.get(count).afterInvoke(context);
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/module/JavaRuntimeModuleActivator.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.module;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
+import org.apache.tuscany.sca.context.ComponentContextFactory;
+import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint;
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ModuleActivator;
+import org.apache.tuscany.sca.core.invocation.CglibProxyFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
+import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.DefaultDataBindingExtensionPoint;
+import org.apache.tuscany.sca.databinding.DefaultTransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.TransformerExtensionPoint;
+import org.apache.tuscany.sca.databinding.impl.MediatorImpl;
+import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory;
+import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory;
+import org.apache.tuscany.sca.implementation.java.introspect.JavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.BaseJavaClassVisitor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationIDProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.InitProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.PropertyProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ReferenceProcessor;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.ResourceProcessor;
+import org.apache.tuscany.sca.implementation.java.invocation.JavaCallbackRuntimeWireProcessor;
+import org.apache.tuscany.sca.implementation.java.invocation.JavaImplementationProviderFactory;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.policy.PolicyFactory;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerDefinitionsLoader;
+import org.apache.tuscany.sca.policy.util.PolicyHandlerTuple;
+import org.apache.tuscany.sca.provider.DefaultProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.DefaultWireProcessorExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
+
+/**
+ * @version $Rev: 641726 $ $Date: 2008-03-26 23:24:37 -0800 (Wed, 26 Mar 2008) $
+ */
+public class JavaRuntimeModuleActivator implements ModuleActivator {
+
+    public JavaRuntimeModuleActivator() {
+    }
+
+    public void start(ExtensionPointRegistry registry) {
+
+        ModelFactoryExtensionPoint factories = registry.getExtensionPoint(ModelFactoryExtensionPoint.class);
+        AssemblyFactory assemblyFactory = factories.getFactory(AssemblyFactory.class);
+        PolicyFactory policyFactory = factories.getFactory(PolicyFactory.class);
+
+        MessageFactory messageFactory = factories.getFactory(MessageFactory.class);
+        ProxyFactoryExtensionPoint proxyFactory = registry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+        proxyFactory.setClassProxyFactory(new CglibProxyFactory(messageFactory, proxyFactory
+            .getInterfaceContractMapper()));
+
+        JavaInterfaceFactory javaFactory = factories.getFactory(JavaInterfaceFactory.class);
+        JavaImplementationFactory javaImplementationFactory = factories.getFactory(JavaImplementationFactory.class);
+        
+        if (javaImplementationFactory == null) {
+        	javaImplementationFactory = new DefaultJavaImplementationFactory();
+        	factories.addFactory(javaImplementationFactory);
+        	
+        }
+        
+        BaseJavaClassVisitor[] extensions =
+            new BaseJavaClassVisitor[] {new ConstructorProcessor(assemblyFactory),
+        		
+                                        // should not be loaded when running on Android platform, cause 
+        								// this class uses the Class.isAnnotationPresent method, which is 
+        								// not supported yet by the Android platform
+        								//new AllowsPassByReferenceProcessor(assemblyFactory),
+                                        
+                                        new ComponentNameProcessor(assemblyFactory),
+                                        new ContextProcessor(assemblyFactory),
+                                        new ConversationIDProcessor(assemblyFactory),
+                                        
+                                        // should not be loaded when running on Android platform, cause 
+        								// this class uses the Class.getAnnotation method, which is 
+        								// not supported yet by the Android platform
+        								//new ConversationProcessor(assemblyFactory),
+                                        
+                                        new DestroyProcessor(assemblyFactory),
+                                        
+                                        // should not be loaded when running on Android platform, cause 
+        								// this class uses the Class.getAnnotation method, which is 
+        								// not supported yet by the Android platform
+                                        //new EagerInitProcessor(assemblyFactory),
+                                        
+                                        new InitProcessor(assemblyFactory), 
+                                        new PropertyProcessor(assemblyFactory),
+                                        new ReferenceProcessor(assemblyFactory, javaFactory),
+                                        new ResourceProcessor(assemblyFactory),
+                                        
+                                        // should not be loaded when running on Android platform, cause 
+        								// this class uses the Class.getAnnotation method, which is 
+        								// not supported yet by the Android platform
+                                        //new ScopeProcessor(assemblyFactory),
+                                        
+                                        // this class uses the org.osoa.sca.annotations.Service class, but
+                                        // Android seems not being able to convert this class to its internal class
+                                        // representation. The Android compiler is outputing the following message:
+                                        
+                                       /* [2008-04-25 19:36:22 - CalculatorAndroid] 
+                                         trouble processing:
+                                         [2008-04-25 19:36:22 - CalculatorAndroid] truncated annotation attribute
+                                         ...while parsing AnnotationDefault attribute at offset 0000020b
+                                         ...while parsing attributes[1]
+                                         ...while parsing methods[0]
+                                         ...while parsing org/osoa/sca/annotations/Service.class
+                                         ...while processing org/osoa/sca/annotations/Service.class
+                                         [2008-04-25 19:36:26 - CalculatorAndroid] 1 warning*/
+                                         
+                                        // So, the class will not be loaded
+                                        //new ServiceProcessor(assemblyFactory, javaFactory),
+                                        
+                                        // should not be loaded when running on Android platform, cause 
+        								// this class uses the Class.getAnnotation method, which is 
+        								// not supported yet by the Android platform
+                                        //new HeuristicPojoProcessor(assemblyFactory, javaFactory)
+                                        
+                                        // should not be loaded when running on Android platform, cause 
+        								// this class uses the Class.getAnnotation method, which is 
+        								// not supported yet by the Android platform
+                                        //new PolicyProcessor(assemblyFactory, policyFactory)
+            };
+        
+        for (JavaClassVisitor extension : extensions) {
+            javaImplementationFactory.addClassVisitor(extension);
+        }
+
+        registry.addExtensionPoint(new DefaultDataBindingExtensionPoint());
+        registry.addExtensionPoint(new DefaultTransformerExtensionPoint());
+        DataBindingExtensionPoint dataBindings = registry.getExtensionPoint(DataBindingExtensionPoint.class);
+        TransformerExtensionPoint transformers = registry.getExtensionPoint(TransformerExtensionPoint.class);
+        MediatorImpl mediator = new MediatorImpl(dataBindings, transformers);
+        JavaPropertyValueObjectFactory factory = new JavaPropertyValueObjectFactory(mediator);
+
+        ContextFactoryExtensionPoint contextFactories = registry.getExtensionPoint(ContextFactoryExtensionPoint.class);
+        ComponentContextFactory componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class);
+        RequestContextFactory requestContextFactory = contextFactories.getFactory(RequestContextFactory.class);
+
+        Map<ClassLoader, List<PolicyHandlerTuple>> policyHandlerClassNames = null;
+        policyHandlerClassNames = PolicyHandlerDefinitionsLoader.loadPolicyHandlerClassnames();
+        
+         JavaImplementationProviderFactory javaImplementationProviderFactory =
+            new JavaImplementationProviderFactory(proxyFactory, dataBindings, factory, componentContextFactory,
+                                                  requestContextFactory, policyHandlerClassNames);
+         
+         ProviderFactoryExtensionPoint providerFactories =
+             registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+         
+         if (providerFactories == null) {
+        	 providerFactories = new DefaultProviderFactoryExtensionPoint(registry);
+        	 registry.addExtensionPoint(providerFactories);
+        	 
+         }
+         
+         providerFactories.addProviderFactory(javaImplementationProviderFactory);
+
+        InterfaceContractMapper interfaceContractMapper = registry.getExtensionPoint(InterfaceContractMapper.class);
+        RuntimeWireProcessorExtensionPoint wireProcessorExtensionPoint =
+            registry.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class);
+        
+        if (wireProcessorExtensionPoint == null) {
+        	wireProcessorExtensionPoint = new DefaultWireProcessorExtensionPoint();
+        	registry.addExtensionPoint(wireProcessorExtensionPoint);
+        	
+        }
+        
+        if (wireProcessorExtensionPoint != null) {
+            wireProcessorExtensionPoint.addWireProcessor(new JavaCallbackRuntimeWireProcessor(interfaceContractMapper,
+                                                                                              javaFactory));
+            //wireProcessorExtensionPoint.addWireProcessor(new JavaPolicyHandlingRuntimeWireProcessor());
+        }
+    }
+
+    public void stop(ExtensionPointRegistry registry) {
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.ModuleActivator Sat May  3 13:52:41 2008
@@ -0,0 +1,18 @@
+# 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.
+# Implementation class for the ModuleActivator
+org.apache.tuscany.sca.implementation.java.module.JavaRuntimeModuleActivator

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/test/java/org/apache/tuscany/sca/implementation/java/context/MultiplicityTestCase.java Sat May  3 13:52:41 2008
@@ -0,0 +1,34 @@
+/*
+ * 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.context;
+
+import junit.framework.TestCase;
+
+
+/**
+ * Tests wires that are configured with a multiplicity
+ *
+ * @version $Rev: 537424 $ $Date: 2007-05-12 06:47:18 -0700 (Sat, 12 May 2007) $
+ */
+public class MultiplicityTestCase extends TestCase {
+
+    public void testMultiplicity() throws Exception {
+        // TODO implement
+    }
+}