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 [23/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/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/pom.xml?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/pom.xml (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/pom.xml Sat May  3 13:52:41 2008
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    * 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.    
+-->
+<project>
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.tuscany.sca</groupId>
+        <artifactId>tuscany-modules</artifactId>
+        <version>2.0-incubating-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <artifactId>tuscany-implementation-java-runtime</artifactId>
+    <name>Apache Tuscany SCA Java Implementation Model</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-core-spi</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-implementation-java-xml</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tuscany.sca</groupId>
+            <artifactId>tuscany-databinding</artifactId>
+            <version>2.0-incubating-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+</project>

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.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/context/InstanceFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java Sat May  3 13:52:41 2008
@@ -0,0 +1,43 @@
+/*
+ * 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 org.apache.tuscany.sca.core.context.InstanceWrapper;
+
+/**
+ * Interface for a factory that returns an injected component instance.
+ * This is used by a Component implementation to create new instances of
+ * application implementation objects as determined by the component scope's
+ * lifecycle.
+ * <p/>
+ * The implementation of this interface may be supplied by the user,
+ * may be generated during deployment, or may be dynamic.
+ *
+ * @version $Rev: 568826 $ $Date: 2007-08-22 22:27:34 -0700 (Wed, 22 Aug 2007) $
+ * @param <T> Type of the instance generated by the factory.
+ */
+public interface InstanceFactory<T> {
+    /**
+     * Creates a new instance of the component.
+     * All injected values must be set but any @Init methods must not have been invoked.
+     * 
+     * @return A wrapper for the created component instance.
+     */
+    InstanceWrapper<T> newInstance();
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.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/context/InstanceFactoryProvider.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java Sat May  3 13:52:41 2008
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.context;
+
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+
+/**
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public interface InstanceFactoryProvider<T> {
+    /**
+     * Return the implementation class.
+     *
+     * @return the implementation class.
+     */
+    Class<T> getImplementationClass();
+
+    /**
+     * Sets an object factory for an injection site
+     *
+     * @param element          the injection site name
+     * @param objectFactory the object factory
+     */
+    void setObjectFactory(JavaElementImpl element, ObjectFactory<?> objectFactory);
+
+    /**
+     * Create an instance factory that can be used to create component instances.
+     *
+     * @return a new instance factory
+     */
+    InstanceFactory<T> createFactory();
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.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/context/ReflectiveInstanceFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.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.implementation.java.context;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
+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.implementation.java.injection.Injector;
+import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
+
+/**
+ * @version $Rev: 568826 $ $Date: 2007-08-22 22:27:34 -0700 (Wed, 22 Aug 2007) $
+ */
+public class ReflectiveInstanceFactory<T> implements InstanceFactory<T> {
+    private final Constructor<T> ctr;
+    private final ObjectFactory<?>[] ctrArgs;
+    private final Injector<T>[] injectors;
+    private final EventInvoker<T> initInvoker;
+    private final EventInvoker<T> destroyInvoker;
+
+    public ReflectiveInstanceFactory(Constructor<T> ctr,
+                                     ObjectFactory<?>[] ctrArgs,
+                                     Injector<T>[] injectors,
+                                     EventInvoker<T> initInvoker,
+                                     EventInvoker<T> destroyInvoker) {
+        this.ctr = ctr;
+        this.ctrArgs = ctrArgs;
+        this.injectors = injectors;
+        this.initInvoker = initInvoker;
+        this.destroyInvoker = destroyInvoker;
+    }
+
+    public InstanceWrapper<T> newInstance() {
+        T instance;
+        try {
+            if (ctrArgs != null) {
+                Object[] args = new Object[ctrArgs.length];
+                for (int i = 0; i < args.length; i++) {
+                    args[i] = ctrArgs[i].getInstance();
+                }
+                instance = ctr.newInstance(args);
+            } else {
+                instance = ctr.newInstance();
+            }
+        } catch (InstantiationException e) {
+            String name = ctr.getDeclaringClass().getName();
+            throw new AssertionError("Class is not instantiable [" + name + "]");
+        } catch (IllegalAccessException e) {
+            String name = ctr.getName();
+            throw new AssertionError("Constructor is not accessible [" + name + "]");
+        } catch (
+            InvocationTargetException e) {
+            String name = ctr.getName();
+            throw new ObjectCreationException("Exception thrown by constructor: " + name, e);
+        }
+
+        if (injectors != null) {
+            for (Injector<T> injector : injectors) {
+                //FIXME Injectors should never be null
+                if (injector != null)
+                    injector.inject(instance);
+            }
+        }
+
+        return new ReflectiveInstanceWrapper<T>(instance, initInvoker, destroyInvoker);
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.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/context/ReflectiveInstanceWrapper.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.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.context;
+
+import org.apache.tuscany.sca.core.context.InstanceWrapper;
+import org.apache.tuscany.sca.core.scope.TargetDestructionException;
+import org.apache.tuscany.sca.core.scope.TargetInitializationException;
+import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
+
+/**
+ * @version $Rev: 568826 $ $Date: 2007-08-22 22:27:34 -0700 (Wed, 22 Aug 2007) $
+ */
+public class ReflectiveInstanceWrapper<T> implements InstanceWrapper<T> {
+    private final EventInvoker<T> initInvoker;
+    private final EventInvoker<T> destroyInvoker;
+    private final T instance;
+
+    public ReflectiveInstanceWrapper(T instance, EventInvoker<T> initInvoker, EventInvoker<T> destroyInvoker) {
+        this.instance = instance;
+        this.initInvoker = initInvoker;
+        this.destroyInvoker = destroyInvoker;
+    }
+    
+    public T getInstance() {
+        return instance;
+    }
+
+    public void start() throws TargetInitializationException {
+        if (initInvoker != null) {
+            initInvoker.invokeEvent(instance);
+        }
+    }
+
+
+    public void stop() throws TargetDestructionException {
+        if (destroyInvoker != null) {
+            destroyInvoker.invokeEvent(instance);
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.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/injection/ArrayMultiplicityObjectFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ArrayMultiplicityObjectFactory.java Sat May  3 13:52:41 2008
@@ -0,0 +1,54 @@
+/*
+ * 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.injection;
+
+import java.lang.reflect.Array;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Resolves targets configured in a multiplicity by delegating to object factories and returning an <code>Array</code>
+ * containing object instances
+ *
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public class ArrayMultiplicityObjectFactory implements ObjectFactory<Object> {
+
+    private ObjectFactory[] factories;
+
+    private Class interfaceType;
+
+    public ArrayMultiplicityObjectFactory(Class interfaceType, List<ObjectFactory<?>> factories) {
+        assert interfaceType != null : "Interface type was null";
+        assert factories != null : "Object factories were null";
+        this.interfaceType = interfaceType;
+        this.factories = factories.toArray(new ObjectFactory[factories.size()]);
+    }
+
+    public Object getInstance() throws ObjectCreationException {
+        Object array = Array.newInstance(interfaceType, factories.length);
+        for (int i = 0; i < factories.length; i++) {
+            Array.set(array, i, factories[i].getInstance());
+        }
+        return array;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.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/injection/ContextInjector.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ContextInjector.java Sat May  3 13:52:41 2008
@@ -0,0 +1,32 @@
+/*
+ * 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.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+
+/**
+ * Implementations inject a pre-configured context type (interface) on an instance.
+ *
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public interface ContextInjector<S, T> extends Injector<T> {
+
+    void setContext(S context) throws ObjectCreationException;
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.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/injection/ConversationIDObjectFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java Sat May  3 13:52:41 2008
@@ -0,0 +1,33 @@
+/*
+ * 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.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
+
+public class ConversationIDObjectFactory implements ObjectFactory {
+
+    public ConversationIDObjectFactory() {
+    }
+
+    public Object getInstance() {
+        return ThreadMessageContext.getMessageContext().getFrom().getReferenceParameters().getConversationID();
+
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.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/injection/FieldInjector.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/FieldInjector.java Sat May  3 13:52:41 2008
@@ -0,0 +1,57 @@
+/*
+ * 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.injection;
+
+import java.lang.reflect.Field;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link org.apache.tuscany.sca.core.factory.ObjectFactory} on a given field
+ *
+ * @version $Rev: 639649 $ $Date: 2008-03-21 06:04:01 -0800 (Fri, 21 Mar 2008) $
+ */
+public class FieldInjector<T> implements Injector<T> {
+
+    private final Field field;
+
+    private final ObjectFactory<?> objectFactory;
+
+    /**
+     * Create an injector and have it use the given <code>ObjectFactory</code> to inject a value on the instance using
+     * the reflected <code>Field</code>
+     */
+    public FieldInjector(Field field, ObjectFactory<?> objectFactory) {
+        this.field = field;
+        this.field.setAccessible(true);
+        this.objectFactory = objectFactory;
+    }
+
+    /**
+     * Inject a new value on the given instance
+     */
+    public void inject(T instance) throws ObjectCreationException {
+        try {
+            field.set(instance, objectFactory.getInstance());
+        } catch (IllegalAccessException e) {
+            throw new AssertionError("Field is not accessible [" + field + "]");
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.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/injection/InjectionRuntimeException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InjectionRuntimeException.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.implementation.java.injection;
+
+
+/**
+ * Root unchecked exception for the injection package
+ *
+ * @version $Rev: 537424 $ $Date: 2007-05-12 06:47:18 -0700 (Sat, 12 May 2007) $
+ */
+public abstract class InjectionRuntimeException extends RuntimeException {
+
+    public InjectionRuntimeException() {
+        super();
+    }
+
+    public InjectionRuntimeException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public InjectionRuntimeException(String message) {
+        super(message);
+    }
+
+    public InjectionRuntimeException(Throwable cause) {
+        super(cause);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.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/injection/Injector.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/Injector.java Sat May  3 13:52:41 2008
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+
+/**
+ * Implementations inject a pre-configured value on an instance
+ *
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public interface Injector<T> {
+
+    /**
+     * Inject a value on the given instance
+     */
+    void inject(T instance) throws ObjectCreationException;
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.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/injection/InvalidAccessorException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/InvalidAccessorException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.injection;
+
+/**
+ * @version $$Rev: 567313 $$ $$Date: 2007-08-18 11:38:44 -0700 (Sat, 18 Aug 2007) $$
+ */
+public class InvalidAccessorException extends InjectionRuntimeException {
+    private static final long serialVersionUID = 9196299279363310978L;
+
+    public InvalidAccessorException() {
+        super();
+    }
+
+    public InvalidAccessorException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public InvalidAccessorException(String message) {
+        super(message);
+    }
+
+    public InvalidAccessorException(Throwable cause) {
+        super(cause);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.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/injection/JavaPropertyValueObjectFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/JavaPropertyValueObjectFactory.java Sat May  3 13:52:41 2008
@@ -0,0 +1,293 @@
+/*
+ * 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.injection;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.apache.tuscany.sca.assembly.ComponentProperty;
+import org.apache.tuscany.sca.assembly.Property;
+import org.apache.tuscany.sca.context.PropertyValueFactory;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.databinding.SimpleTypeMapper;
+import org.apache.tuscany.sca.databinding.impl.DOMHelper;
+import org.apache.tuscany.sca.databinding.impl.SimpleTypeMapperImpl;
+import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
+import org.apache.tuscany.sca.implementation.java.impl.JavaElementImpl;
+import org.apache.tuscany.sca.implementation.java.introspect.impl.JavaIntrospectionHelper;
+import org.apache.tuscany.sca.interfacedef.DataType;
+import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
+import org.apache.tuscany.sca.interfacedef.util.TypeInfo;
+import org.apache.tuscany.sca.interfacedef.util.XMLType;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class JavaPropertyValueObjectFactory implements PropertyValueFactory {
+    private Mediator mediator = null;
+    private boolean isSimpleType;
+
+    public JavaPropertyValueObjectFactory(Mediator mediator) {
+        this.mediator = mediator;
+    }
+    
+    public ObjectFactory createValueFactory(Property property, Object propertyValue, JavaElementImpl javaElement) {
+        isSimpleType = isSimpleType(property);
+        Document doc = (Document)propertyValue;
+        Class javaType = JavaIntrospectionHelper.getBaseType(javaElement.getType(), javaElement.getGenericType());
+        Element rootElement = doc.getDocumentElement();
+        if (property.isMany()) {
+            if (isSimpleType) {
+                String value = "";
+                if (rootElement.getChildNodes().getLength() > 0) {
+                    value = rootElement.getChildNodes().item(0).getTextContent();
+                }
+                List<String> values = getSimplePropertyValues(value, javaType);
+                if ( javaElement.getType().isArray() ) {
+                    return new ArrayObjectFactoryImpl(property, values, isSimpleType, javaType);
+                } else {
+                    return new ListObjectFactoryImpl(property, values, isSimpleType, javaType);
+                }
+            } else {
+                if ( javaElement.getType().isArray() ) {
+                    return new ArrayObjectFactoryImpl(property, getComplexPropertyValues(doc), isSimpleType, javaType);
+                } else {
+                    return new ListObjectFactoryImpl(property, getComplexPropertyValues(doc), isSimpleType, javaType);
+                }
+            }
+        } else {
+            if (isSimpleType) {
+                String value = "";
+                if (rootElement.getChildNodes().getLength() > 0) {
+                    value = rootElement.getChildNodes().item(0).getTextContent();
+                }
+                return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
+            } else {
+                List<Node> nodes = getComplexPropertyValues(doc);
+                Object value = null;
+                if (!nodes.isEmpty()) {
+                    value = nodes.get(0);
+                }
+                return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
+            }
+
+        }
+    }
+
+    public ObjectFactory createValueFactory(Property property, Object propertyValue, Class javaType) {
+        isSimpleType = isSimpleType(property);
+        Document doc = (Document)propertyValue;
+        Element rootElement = doc.getDocumentElement();
+        if (property.isMany()) {
+            if (isSimpleType) {
+                String value = "";
+                if (rootElement.getChildNodes().getLength() > 0) {
+                    value = rootElement.getChildNodes().item(0).getTextContent();
+                }
+                List<String> values = getSimplePropertyValues(value, javaType);
+                return new ListObjectFactoryImpl(property, values, isSimpleType, javaType);
+            } else {
+                return new ListObjectFactoryImpl(property, getComplexPropertyValues(doc), isSimpleType, javaType);
+            }
+        } else {
+            if (isSimpleType) {
+                String value = "";
+                if (rootElement.getChildNodes().getLength() > 0) {
+                    value = rootElement.getChildNodes().item(0).getTextContent();
+                }
+                return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
+            } else {
+                List<Node> nodes = getComplexPropertyValues(doc);
+                Object value = null;
+                if (!nodes.isEmpty()) {
+                    value = nodes.get(0);
+                }
+                return new ObjectFactoryImpl(property, value, isSimpleType, javaType);
+            }
+
+        }
+    } 
+
+    private boolean isSimpleType(Property property) {
+        if (property.getXSDType() != null) {
+            return SimpleTypeMapperImpl.isSimpleXSDType(property.getXSDType());
+        } else {
+            if (property instanceof Document) {
+                Document doc = (Document)property;
+                Element element = doc.getDocumentElement();
+                if (element.getChildNodes().getLength() == 1 && element.getChildNodes().item(0).getNodeType() == Element.TEXT_NODE) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    private List<String> getSimplePropertyValues(String concatenatedValue, Class javaType) {
+        List<String> propValues = new ArrayList<String>();
+        StringTokenizer st = null;
+        if (javaType.getName().equals("java.lang.String")) {
+            st = new StringTokenizer(concatenatedValue, "\"");
+        } else {
+            st = new StringTokenizer(concatenatedValue);
+        }
+        String aToken = null;
+        while (st.hasMoreTokens()) {
+            aToken = st.nextToken();
+            if (aToken.trim().length() > 0) {
+                propValues.add(aToken);
+            }
+        }
+        return propValues;
+    }
+
+    private List<Node> getComplexPropertyValues(Document document) {
+        Element rootElement = document.getDocumentElement();
+        List<Node> propValues = new ArrayList<Node>();
+        NodeList nodes = rootElement.getChildNodes();
+        for (int count = 0; count < nodes.getLength(); ++count) {
+            if (nodes.item(count).getNodeType() == Document.ELEMENT_NODE) {
+                propValues.add(DOMHelper.promote(nodes.item(count)));
+            }
+        }
+        return propValues;
+    }
+
+    public abstract class ObjectFactoryImplBase implements ObjectFactory {
+        protected SimpleTypeMapper simpleTypeMapper = new SimpleTypeMapperImpl();
+        protected Property property;
+        protected Object propertyValue;
+        protected Class javaType;
+        protected DataType<XMLType> sourceDataType;
+        protected DataType<?> targetDataType;
+        boolean isSimpleType;
+
+        public ObjectFactoryImplBase(Property property, Object propertyValue, boolean isSimpleType, Class javaType) {
+            this.isSimpleType = isSimpleType;
+            this.property = property;
+            this.propertyValue = propertyValue;
+            this.javaType = javaType;
+            sourceDataType = new DataTypeImpl<XMLType>(DOMDataBinding.NAME, Node.class, new XMLType(null, this.property
+                .getXSDType()));
+            TypeInfo typeInfo = null;
+            if (this.property.getXSDType() != null) {
+                if (SimpleTypeMapperImpl.isSimpleXSDType(this.property.getXSDType())) {
+                    typeInfo = new TypeInfo(property.getXSDType(), true, null);
+                } else {
+                    typeInfo = new TypeInfo(property.getXSDType(), false, null);
+                }
+            } else {
+                typeInfo = new TypeInfo(property.getXSDType(), false, null);
+            }
+
+            XMLType xmlType = new XMLType(typeInfo);
+            String dataBinding = null; // (String)property.getExtensions().get(DataBinding.class.getName());
+            if (dataBinding != null) {
+                targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+            } else {
+                targetDataType = new DataTypeImpl<XMLType>(dataBinding, javaType, xmlType);
+                mediator.getDataBindings().introspectType(targetDataType, null);
+            }
+        }
+    }
+
+    public class ObjectFactoryImpl extends ObjectFactoryImplBase {
+        public ObjectFactoryImpl(Property property, Object propertyValue, boolean isSimpleType, Class javaType) {
+            super(property, propertyValue, isSimpleType, javaType);
+        }
+
+        @SuppressWarnings("unchecked")
+        public Object getInstance() throws ObjectCreationException {
+            if (isSimpleType) {
+                return simpleTypeMapper.toJavaObject(property.getXSDType(), (String)propertyValue, null);
+            } else {
+                return mediator.mediate(propertyValue, sourceDataType, targetDataType, null);
+                // return null;
+            }
+        }
+    }
+
+    public class ListObjectFactoryImpl extends ObjectFactoryImplBase {
+        public ListObjectFactoryImpl(Property property, List<?> propertyValues, boolean isSimpleType, Class javaType) {
+            super(property, propertyValues, isSimpleType, javaType);
+        }
+
+        @SuppressWarnings("unchecked")
+        public List<?> getInstance() throws ObjectCreationException {
+            if (isSimpleType) {
+                List<Object> values = new ArrayList<Object>();
+                for (String aValue : (List<String>)propertyValue) {
+                    values.add(simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+                }
+                return values;
+            } else {
+                List instances = new ArrayList();
+                for (Node aValue : (List<Node>)propertyValue) {
+                    instances.add(mediator.mediate(aValue, sourceDataType, targetDataType, null));
+                }
+                return instances;
+            }
+        }
+    }
+    
+    public class ArrayObjectFactoryImpl extends ObjectFactoryImplBase {
+        public ArrayObjectFactoryImpl(Property property, List<?> propertyValues, boolean isSimpleType, Class javaType) {
+            super(property, propertyValues, isSimpleType, javaType);
+        }
+
+        @SuppressWarnings("unchecked")
+        public Object getInstance() throws ObjectCreationException {
+            if (isSimpleType) {
+                int count = 0;
+                Object values = Array.newInstance(javaType, ((List<Object>)propertyValue).size());
+                for (String aValue : (List<String>)propertyValue) {
+                    Array.set(values, count++, simpleTypeMapper.toJavaObject(property.getXSDType(), aValue, null));
+                }
+                return values;
+            } else {
+                Object instances = Array.newInstance(javaType, ((List<Object>)propertyValue).size());
+                int count = 0;
+                for (Node aValue : (List<Node>)propertyValue) {
+                    Array.set(instances, count++, mediator.mediate(aValue, sourceDataType, targetDataType, null));
+                }
+                return instances;
+            }
+        }
+    }
+
+    /**
+     * This method will create an instance of the value for the specified Property.
+     * 
+     * @param property The Property from which to retrieve the property value
+     * @param type The type of the property value being retrieved from the Property
+     * @param <B> Type type of the property value being looked up
+     * 
+     * @return the value for the Property
+     */
+    public <B> B createPropertyValue(ComponentProperty property, Class<B> type)
+    {
+        ObjectFactory<B> factory = this.createValueFactory(property, property.getValue(), type);
+        return factory.getInstance();
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.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/injection/ListMultiplicityObjectFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ListMultiplicityObjectFactory.java Sat May  3 13:52:41 2008
@@ -0,0 +1,50 @@
+/*
+ * 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.injection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Resolves targets configured in a multiplicity by delegating to object factories and returning an <code>List</code>
+ * containing object instances
+ *
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public class ListMultiplicityObjectFactory implements ObjectFactory<List> {
+
+    private ObjectFactory[] factories;
+
+    public ListMultiplicityObjectFactory(List<ObjectFactory<?>> factories) {
+        assert factories != null : "Object factories were null";
+        this.factories = factories.toArray(new ObjectFactory[factories.size()]);
+    }
+
+    public List getInstance() throws ObjectCreationException {
+        List<Object> list = new ArrayList<Object>();
+        for (ObjectFactory factory : factories) {
+            list.add(factory.getInstance());
+        }
+        return list;
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.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/injection/MethodInjector.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/MethodInjector.java Sat May  3 13:52:41 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Injects a value created by an {@link org.apache.tuscany.sca.core.factory.ObjectFactory} using a given method
+ *
+ * @version $Rev: 641645 $ $Date: 2008-03-26 15:37:28 -0800 (Wed, 26 Mar 2008) $
+ */
+public class MethodInjector<T> implements Injector<T> {
+    private final Method method;
+    private final ObjectFactory<?> objectFactory;
+
+    public MethodInjector(Method aMethod, ObjectFactory<?> objectFactory) {
+        assert aMethod != null;
+        assert objectFactory != null;
+        this.method = aMethod;
+        // Allow privileged access to set accessibility. Requires ReflectPermission in security
+        // policy.
+        AccessController.doPrivileged(new PrivilegedAction<Object>() {
+            public Object run() {
+                method.setAccessible(true);
+                return null;
+            }
+        });           
+        this.objectFactory = objectFactory;
+    }
+
+    public void inject(T instance) throws ObjectCreationException {
+        try {
+            method.invoke(instance, objectFactory.getInstance());
+        } catch (IllegalAccessException e) {
+            throw new AssertionError("Method is not accessible [" + method + "]");
+        } catch (IllegalArgumentException e) {
+            throw new ObjectCreationException("Exception thrown by setter: " + method.getName(), e);
+        } catch (InvocationTargetException e) {
+            throw new ObjectCreationException("Exception thrown by setter: " + method.getName(), e);
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.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/injection/RequestContextObjectFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/RequestContextObjectFactory.java Sat May  3 13:52:41 2008
@@ -0,0 +1,55 @@
+/*
+ * 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.injection;
+
+import org.apache.tuscany.sca.context.RequestContextFactory;
+import org.apache.tuscany.sca.core.context.RequestContextImpl;
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+import org.apache.tuscany.sca.core.invocation.ProxyFactory;
+import org.osoa.sca.RequestContext;
+
+/**
+ * Creates instances of
+ * {@link org.apache.tuscany.sca.core.context.RequestContextImpl} for
+ * injection on component implementation instances
+ * 
+ * @version $Rev: 568826 $ $Date: 2007-08-22 22:27:34 -0700 (Wed, 22 Aug 2007) $
+ */
+public class RequestContextObjectFactory implements ObjectFactory<RequestContext> {
+    private RequestContextFactory factory;
+    private ProxyFactory proxyFactory;
+
+    public RequestContextObjectFactory(RequestContextFactory factory) {
+        this(factory, null);
+    }
+
+    public RequestContextObjectFactory(RequestContextFactory factory, ProxyFactory proxyFactory) {
+        this.factory = factory;
+        this.proxyFactory = proxyFactory;
+    }
+
+    public RequestContext getInstance() throws ObjectCreationException {
+        if (factory != null) {
+            return factory.createRequestContext();
+        } else {
+            return new RequestContextImpl(proxyFactory);
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.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/injection/ResourceHost.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceHost.java Sat May  3 13:52:41 2008
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.injection;
+
+/**
+ * Interface implemented by host environments that allow for resolution of component implementation resources, e.g.
+ * items bound in a JNDI tree.
+ *
+ * @version $Rev: 537424 $ $Date: 2007-05-12 06:47:18 -0700 (Sat, 12 May 2007) $
+ */
+public interface ResourceHost {
+
+    /**
+     * Resolve a resource matching the given type
+     *
+     * @param type the type of the resources
+     * @throws ResourceResolutionException if an error is encountered during resolution
+     */
+    <T> T resolveResource(Class<T> type) throws ResourceResolutionException;
+
+    /**
+     * Resolve a resource matching the given type and name
+     *
+     * @param type       the type of the resources
+     * @param mappedName the mapped name of the resource
+     * @throws ResourceResolutionException if an error is encountered during resolution
+     */
+    <T> T resolveResource(Class<T> type, String mappedName) throws ResourceResolutionException;
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.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/injection/ResourceNotFoundException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceNotFoundException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,51 @@
+/*
+ * 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.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+
+/**
+ * Denotes an exception thrown when a runtime resource is not found
+ *
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public class ResourceNotFoundException extends ObjectCreationException {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1L;
+
+    public ResourceNotFoundException() {
+        super();
+    }
+
+    public ResourceNotFoundException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public ResourceNotFoundException(String message) {
+        super(message);
+    }
+
+    public ResourceNotFoundException(Throwable cause) {
+        super(cause);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.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/injection/ResourceObjectFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceObjectFactory.java Sat May  3 13:52:41 2008
@@ -0,0 +1,87 @@
+/*
+ * 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.injection;
+
+import org.apache.tuscany.sca.core.factory.ObjectCreationException;
+import org.apache.tuscany.sca.core.factory.ObjectFactory;
+
+/**
+ * Resolves a runtime resource to be injected on a field or method of a Java component type marked with {@link
+ * javax.annotation.Resource}. If the mapped name of the resource is an absolute URI such as
+ * <code>sca://localhost</code> or <code>jndi://localhost</code> the host container namespace is searched; otherwise the
+ * URI is assumed to be relative and the parent composite is searched. If a mapped name is not provided, i.e. resolution
+ * is by type, the parent composite is first searched followed by the host namespace.
+ *
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public class ResourceObjectFactory<T> implements ObjectFactory<T> {
+
+    private Class<T> type;
+    private String mappedName;
+    private ResourceHost host;
+    private boolean optional;
+
+    /**
+     * Instantiates a factory that resolves resources by type
+     *
+     * @param type     the type of the resource to inject
+     * @param optional true if an error should be thrown if the resource is not found
+     * @param host     the runtime resource provider
+     */
+    public ResourceObjectFactory(Class<T> type, boolean optional, ResourceHost host) {
+        this(type, null, optional, host);
+    }
+
+    /**
+     * Instantiates a factory that resolves resources by mapped name
+     *
+     * @param type       the type of the resource to inject
+     * @param mappedName the resource name
+     * @param optional   true if an error should be thrown if the resource is not found
+     * @param host       the runtime resource provider
+     */
+    public ResourceObjectFactory(Class<T> type, String mappedName, boolean optional, ResourceHost host) {
+        this.type = type;
+        this.host = host;
+        this.mappedName = mappedName;
+        this.optional = optional;
+    }
+
+    @SuppressWarnings({"unchecked"})
+    public T getInstance() throws ObjectCreationException {
+        try {
+            T resource;
+            if (mappedName == null) {
+                resource = host.resolveResource(type);
+                if (!optional && resource == null) {
+                    throw new ResourceNotFoundException("Resource not found: " + type.getName());
+                }
+            } else {
+                resource = host.resolveResource(type, mappedName);
+                if (!optional && resource == null) {
+                    throw new ResourceNotFoundException("Resource not found: " + mappedName);
+                }
+            }
+            return resource;
+        } catch (ResourceResolutionException e) {
+            throw new ObjectCreationException(e);
+        }
+
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.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/injection/ResourceResolutionException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ResourceResolutionException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.injection;
+
+
+/**
+ * @version $Rev: 537424 $ $Date: 2007-05-12 06:47:18 -0700 (Sat, 12 May 2007) $
+ */
+public class ResourceResolutionException extends Exception {
+    private static final long serialVersionUID = 13421352711315479L;
+
+    public ResourceResolutionException() {
+        super();
+    }
+
+    public ResourceResolutionException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public ResourceResolutionException(String message) {
+        super(message);
+    }
+
+    public ResourceResolutionException(Throwable cause) {
+        super(cause);
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.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/EventInvocationException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvocationException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,47 @@
+/*
+ * 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.implementation.java.injection.InjectionRuntimeException;
+
+/**
+ * Denotes an error when invoking an event on an object
+ *
+ * @version $Rev: 567313 $ $Date: 2007-08-18 11:38:44 -0700 (Sat, 18 Aug 2007) $
+ */
+public class EventInvocationException extends InjectionRuntimeException {
+    private static final long serialVersionUID = 1480018831708211581L;
+
+    public EventInvocationException() {
+        super();
+    }
+
+    public EventInvocationException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public EventInvocationException(String message) {
+        super(message);
+    }
+
+    public EventInvocationException(Throwable cause) {
+        super(cause);
+    }
+
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.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/EventInvoker.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/EventInvoker.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;
+
+/**
+ * Performs an invocation on an instance
+ *
+ * @version $Rev: 567313 $ $Date: 2007-08-18 11:38:44 -0700 (Sat, 18 Aug 2007) $
+ */
+public interface EventInvoker<T> {
+
+    /**
+     * Performs the invocation on a given instance
+     *
+     * @throws EventInvocationException
+     */
+    void invokeEvent(T instance) throws EventInvocationException;
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.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/InvalidConversationSequenceException.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/InvalidConversationSequenceException.java Sat May  3 13:52:41 2008
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.implementation.java.invocation;
+
+import org.apache.tuscany.sca.core.invocation.TargetInvocationException;
+
+/**
+ * Denotes an unknown operation sequence in a conversation
+ *
+ * @version $Rev: 568826 $ $Date: 2007-08-22 22:27:34 -0700 (Wed, 22 Aug 2007) $
+ */
+public class InvalidConversationSequenceException extends TargetInvocationException {
+    private static final long serialVersionUID = -5744028391493899147L;
+
+    public InvalidConversationSequenceException() {
+        super();
+    }
+
+    public InvalidConversationSequenceException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public InvalidConversationSequenceException(String message) {
+        super(message);
+    }
+
+    public InvalidConversationSequenceException(Throwable cause) {
+        super(cause);
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.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/JavaCallbackRuntimeWireProcessor.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java Sat May  3 13:52:41 2008
@@ -0,0 +1,106 @@
+/*
+ * 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.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.tuscany.sca.assembly.Contract;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.invocation.CallbackInterfaceInterceptor;
+import org.apache.tuscany.sca.implementation.java.JavaImplementation;
+import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
+import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Phase;
+import org.apache.tuscany.sca.runtime.EndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
+
+/**
+ * @version $Rev: 632064 $ $Date: 2008-02-28 09:18:51 -0800 (Thu, 28 Feb 2008) $
+ */
+public class JavaCallbackRuntimeWireProcessor implements RuntimeWireProcessor {
+    private final static Logger logger = Logger.getLogger(JavaCallbackRuntimeWireProcessor.class.getName());
+    private InterfaceContractMapper interfaceContractMapper;
+    private JavaInterfaceFactory javaInterfaceFactory;
+
+    /**
+     * @param interfaceContractMapper
+     * @param javaInterfaceFactory
+     */
+    public JavaCallbackRuntimeWireProcessor(InterfaceContractMapper interfaceContractMapper,
+                                            JavaInterfaceFactory javaInterfaceFactory) {
+        super();
+        this.interfaceContractMapper = interfaceContractMapper;
+        this.javaInterfaceFactory = javaInterfaceFactory;
+    }
+
+    public void process(RuntimeWire wire) {
+        addCallbackInterfaceInterceptors(wire);
+    }
+
+    private void addCallbackInterfaceInterceptors(RuntimeWire wire) {
+        Contract contract = wire.getSource().getContract();
+        if (!(contract instanceof RuntimeComponentReference)) {
+            return;
+        }
+        RuntimeComponent component = wire.getSource().getComponent();
+        Implementation implementation = component.getImplementation();
+        if (!(implementation instanceof JavaImplementation)) {
+            return;
+        }
+        JavaImplementation javaImpl = (JavaImplementation)implementation;
+        EndpointReference callbackEndpoint = wire.getSource().getCallbackEndpoint();
+        if (callbackEndpoint != null) {
+            Interface iface = callbackEndpoint.getContract().getInterfaceContract().getInterface();
+            if (!supportsCallbackInterface(iface, javaImpl)) {
+                // callback to this impl is not possible, so ensure a callback object is set
+                for (InvocationChain chain : wire.getInvocationChains()) {
+                    chain.addInterceptor(Phase.REFERENCE, new CallbackInterfaceInterceptor());
+                }
+            }
+        }
+    }
+
+    private boolean supportsCallbackInterface(Interface iface, JavaImplementation impl) {
+        if (iface instanceof JavaInterface) {
+            Class<?> ifaceClass = ((JavaInterface)iface).getJavaClass();
+            if (ifaceClass.isAssignableFrom(impl.getJavaClass())) {
+                return true;
+            }
+        }
+        try {
+            Interface implType = javaInterfaceFactory.createJavaInterface(impl.getJavaClass());
+            // Ignore the remotable/conversational testing
+            implType.setRemotable(iface.isRemotable());
+            implType.setConversational(iface.isConversational());
+            return interfaceContractMapper.isCompatible(iface, implType);
+        } catch (InvalidInterfaceException e) {
+            logger.log(Level.WARNING, e.getMessage(), e);
+            return false;
+        }
+    }
+}

Added: incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.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/JavaComponentContextFactory.java?rev=653133&view=auto
==============================================================================
--- incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.java (added)
+++ incubator/tuscany/sandbox/mobile-android/tuscany-implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextFactory.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;
+import org.osoa.sca.ComponentContext;
+
+/**
+ * @version $Rev: 567619 $ $Date: 2007-08-20 02:29:57 -0700 (Mon, 20 Aug 2007) $
+ */
+public class JavaComponentContextFactory implements ObjectFactory<ComponentContext> {
+    private final JavaComponentContextProvider component;
+
+
+    public JavaComponentContextFactory(JavaComponentContextProvider component) {
+        this.component = component;
+    }
+
+
+    public ComponentContext getInstance() throws ObjectCreationException {
+        return component.getComponent().getComponentContext();
+    }
+}