summaryrefslogtreecommitdiffstats
path: root/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider')
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java60
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java370
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java89
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java68
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java42
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java38
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java41
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java63
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java36
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java63
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java76
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProvider.java31
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderException.java30
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderExtensionPoint.java33
-rw-r--r--sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java63
15 files changed, 1103 insertions, 0 deletions
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java
new file mode 100644
index 0000000000..900450f206
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java
@@ -0,0 +1,60 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * A factory for creating the runtime artifacts that represent bindings.
+ *
+ * @version $Rev: 539355 $ $Date: 2007-05-18 03:05:14 -0700 (Fri, 18 May 2007) $
+ */
+public interface BindingProviderFactory<M extends Binding> extends ProviderFactory<M> {
+
+ /**
+ * Creates a new reference binding provider for the given component and
+ * reference.
+ *
+ * @param component The runtime component
+ * @param reference The reference on the runtime component
+ * @param binding The binding assembly model object
+ * @return The binding provider
+ */
+ ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ M binding);
+
+ /**
+ * Creates a new service binding provider for the given component and
+ * service.
+ *
+ * @param component The runtime component
+ * @param service The service on the runtime component
+ * @param binding The binding assembly model object
+ * @return The binding provider
+ */
+ ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ M binding);
+
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
new file mode 100644
index 0000000000..371f9c9af2
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
@@ -0,0 +1,370 @@
+/*
+ * 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.provider;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * Default implementation of a provider factory extension point.
+ *
+ * @version $Rev: 634558 $ $Date: 2008-03-06 22:35:52 -0800 (Thu, 06 Mar 2008) $
+ */
+public class DefaultProviderFactoryExtensionPoint implements ProviderFactoryExtensionPoint {
+
+ private ExtensionPointRegistry registry;
+ private final Map<Class<?>, ProviderFactory> providerFactories = new HashMap<Class<?>, ProviderFactory>();
+ private final List<PolicyProviderFactory> policyProviderFactories = new ArrayList<PolicyProviderFactory>();
+ private boolean loaded;
+
+ /**
+ * The default constructor. Does nothing.
+ *
+ */
+ public DefaultProviderFactoryExtensionPoint(ExtensionPointRegistry registry) {
+ this.registry = registry;
+ }
+
+ /**
+ * Add a provider factory.
+ *
+ * @param providerFactory The provider factory
+ */
+ public void addProviderFactory(ProviderFactory providerFactory) {
+ if(providerFactory instanceof PolicyProviderFactory) {
+ policyProviderFactories.add((PolicyProviderFactory)providerFactory);
+ }
+ providerFactories.put(providerFactory.getModelType(), providerFactory);
+ }
+
+ /**
+ * Remove a provider factory.
+ *
+ * @param providerFactory The provider factory
+ */
+ public void removeProviderFactory(ProviderFactory providerFactory) {
+ if(providerFactory instanceof PolicyProviderFactory) {
+ policyProviderFactories.remove((PolicyProviderFactory)providerFactory);
+ }
+ providerFactories.remove(providerFactory.getModelType());
+ }
+
+ /**
+ * Returns the provider factory associated with the given model type.
+ * @param modelType A model type
+ * @return The provider factory associated with the given model type
+ */
+ public ProviderFactory getProviderFactory(Class<?> modelType) {
+ loadProviderFactories();
+
+ Class<?>[] classes = modelType.getInterfaces();
+ for (Class<?> c : classes) {
+ ProviderFactory factory = providerFactories.get(c);
+ if (factory != null) {
+ return factory;
+ }
+ }
+ return providerFactories.get(modelType);
+ }
+
+ public List<PolicyProviderFactory> getPolicyProviderFactories() {
+ loadProviderFactories();
+ return policyProviderFactories;
+ }
+
+ /**
+ * Load provider factories declared under META-INF/services.
+ * @param registry
+ */
+ private void loadProviderFactories() {
+ if (loaded)
+ return;
+
+ loadProviderFactories(BindingProviderFactory.class);
+ loadProviderFactories(ImplementationProviderFactory.class);
+ loadProviderFactories(PolicyProviderFactory.class);
+
+ loaded = true;
+ }
+
+ /**
+ * Load provider factories declared under META-INF/services.
+ * @param registry
+ * @param factoryClass
+ * @return
+ */
+ private List<ProviderFactory> loadProviderFactories(Class<?> factoryClass) {
+
+ // Get the provider factory service declarations
+ Set<ServiceDeclaration> factoryDeclarations;
+ ServiceDiscovery serviceDiscovery = ServiceDiscovery.getInstance();
+ try {
+ factoryDeclarations = serviceDiscovery.getServiceDeclarations(factoryClass);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ // Get the target extension point
+
+ ProviderFactoryExtensionPoint factoryExtensionPoint =
+ registry.getExtensionPoint(ProviderFactoryExtensionPoint.class);
+
+ if (factoryExtensionPoint == null) {
+ factoryExtensionPoint = new DefaultProviderFactoryExtensionPoint(registry);
+ registry.addExtensionPoint(factoryExtensionPoint);
+
+ }
+
+ List<ProviderFactory> factories = new ArrayList<ProviderFactory>();
+
+ for (ServiceDeclaration factoryDeclaration : factoryDeclarations) {
+ Map<String, String> attributes = factoryDeclaration.getAttributes();
+
+ // Load an implementation provider factory
+ if (factoryClass == ImplementationProviderFactory.class) {
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ ImplementationProviderFactory factory =
+ new LazyImplementationProviderFactory(registry, modelTypeName, factoryDeclaration);
+ factoryExtensionPoint.addProviderFactory(factory);
+ factories.add(factory);
+
+ } else if (factoryClass == BindingProviderFactory.class) {
+
+ // Load a binding provider factory
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ BindingProviderFactory factory =
+ new LazyBindingProviderFactory(registry, modelTypeName, factoryDeclaration);
+ factoryExtensionPoint.addProviderFactory(factory);
+ factories.add(factory);
+ } else if (factoryClass == PolicyProviderFactory.class) {
+ // Load a policy provider factory
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ PolicyProviderFactory factory =
+ new LazyPolicyProviderFactory(registry, modelTypeName, factoryDeclaration);
+ factoryExtensionPoint.addProviderFactory(factory);
+ factories.add(factory);
+
+ }
+ }
+ return factories;
+ }
+
+ /**
+ * A wrapper around an implementation provider factory allowing lazy
+ * loading and initialization of implementation providers.
+ */
+ private static class LazyBindingProviderFactory implements BindingProviderFactory {
+
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration factoryDeclaration;
+ private BindingProviderFactory factory;
+ private Class modelType;
+
+ private LazyBindingProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration factoryDeclaration) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.factoryDeclaration = factoryDeclaration;
+ }
+
+ @SuppressWarnings("unchecked")
+ private BindingProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<BindingProviderFactory> factoryClass =
+ (Class<BindingProviderFactory>)factoryDeclaration.loadClass();
+ Constructor<BindingProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ReferenceBindingProvider createReferenceBindingProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return getFactory().createReferenceBindingProvider(component, reference, binding);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return getFactory().createServiceBindingProvider(component, service, binding);
+ }
+
+ public Class getModelType() {
+ if (modelType == null) {
+ try {
+ modelType = factoryDeclaration.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+
+ }
+
+ /**
+ * A wrapper around an implementation provider factory allowing lazy
+ * loading and initialization of implementation providers.
+ */
+ private class LazyImplementationProviderFactory implements ImplementationProviderFactory {
+
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration providerClass;
+ private ImplementationProviderFactory factory;
+ private Class modelType;
+
+ private LazyImplementationProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration providerClass) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.providerClass = providerClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private ImplementationProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<ImplementationProviderFactory> factoryClass =
+ (Class<ImplementationProviderFactory>)providerClass.loadClass();
+ Constructor<ImplementationProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ @SuppressWarnings("unchecked")
+ public ImplementationProvider createImplementationProvider(RuntimeComponent component,
+ Implementation Implementation) {
+ return getFactory().createImplementationProvider(component, Implementation);
+ }
+
+ public Class getModelType() {
+ if (modelType == null) {
+ try {
+
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+
+ }
+
+ /**
+ * A wrapper around an policy provider factory allowing lazy
+ * loading and initialization of policy providers.
+ */
+ private class LazyPolicyProviderFactory implements PolicyProviderFactory {
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration providerClass;
+ private PolicyProviderFactory factory;
+ private Class modelType;
+
+ private LazyPolicyProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration providerClass) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.providerClass = providerClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private PolicyProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<PolicyProviderFactory> factoryClass = (Class<PolicyProviderFactory>)providerClass.loadClass();
+ Constructor<PolicyProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ public PolicyProvider createImplementationPolicyProvider(RuntimeComponent component,
+ Implementation implementation) {
+ return getFactory().createImplementationPolicyProvider(component, implementation);
+ }
+
+ public PolicyProvider createReferencePolicyProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding) {
+ return getFactory().createReferencePolicyProvider(component, reference, binding);
+ }
+
+ public PolicyProvider createServicePolicyProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding) {
+ return getFactory().createServicePolicyProvider(component, service, binding);
+ }
+
+ public Class getModelType() {
+ if (modelType == null) {
+ try {
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+
+ }
+
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java
new file mode 100644
index 0000000000..4cca3b1e32
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultSCADefinitionsProviderExtensionPoint.java
@@ -0,0 +1,89 @@
+/*
+ * 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.provider;
+
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
+import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
+
+/**
+ * Concrete Implementation for the SCADefinitionsProviderExtensionPoint
+ */
+public class DefaultSCADefinitionsProviderExtensionPoint implements
+ SCADefinitionsProviderExtensionPoint {
+
+ private ExtensionPointRegistry extensionPointRegistry = null;
+
+ private List<SCADefinitionsProvider> scaDefnsProviders = new ArrayList<SCADefinitionsProvider>();
+
+ public DefaultSCADefinitionsProviderExtensionPoint(ExtensionPointRegistry extnPtReg) {
+ this.extensionPointRegistry = extnPtReg;
+ }
+
+ public void addSCADefinitionsProvider(SCADefinitionsProvider provider) {
+ scaDefnsProviders.add(provider);
+ }
+
+ public void removeSCADefinitionsProvider(SCADefinitionsProvider provider) {
+ scaDefnsProviders.remove(provider);
+ }
+
+ public List<SCADefinitionsProvider> getSCADefinitionsProviders() {
+ if (scaDefnsProviders.isEmpty()) {
+ loadProviders();
+ }
+ return scaDefnsProviders;
+ }
+
+ private void loadProviders() {
+ // Get the provider service declarations
+ Set<ServiceDeclaration> defnProviderDecls;
+ SCADefinitionsProvider aProvider = null;
+ Class providerClass = null;
+ Constructor constructor = null;
+
+ try {
+ defnProviderDecls =
+ ServiceDiscovery.getInstance().getServiceDeclarations(SCADefinitionsProvider.class);
+
+ for (ServiceDeclaration aDefnProviderDecl : defnProviderDecls) {
+ providerClass = aDefnProviderDecl.loadClass();
+
+ try {
+ constructor = providerClass.getConstructor();
+ aProvider = (SCADefinitionsProvider)constructor.newInstance();
+ } catch (NoSuchMethodException e1) {
+ constructor = providerClass.getConstructor(ExtensionPointRegistry.class);
+ aProvider = (SCADefinitionsProvider)constructor.newInstance(extensionPointRegistry);
+ }
+
+ scaDefnsProviders.add(aProvider);
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java
new file mode 100644
index 0000000000..a9f86c45ca
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java
@@ -0,0 +1,68 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * A component implementation can implement this interface in order to tie
+ * into the Tuscany runtime
+ *
+ * @version $Rev: 576260 $ $Date: 2007-09-16 22:17:22 -0700 (Sun, 16 Sep 2007) $
+ */
+public interface ImplementationProvider {
+
+ /**
+ * This method will be invoked when the component implementation
+ * is activated.
+ */
+ void start();
+
+ /**
+ * This method will be invoked when the component implementation
+ * is deactivated.
+ */
+ void stop();
+
+ /**
+ * Create an invoker for the component implementation in the invocation
+ * chain. The invoker will be responsible for calling the implementation
+ * logic for the given component.
+ *
+ * @param service The component service
+ * @param operation The operation that the interceptor will handle
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
+ */
+ Invoker createInvoker(RuntimeComponentService service, Operation operation);
+
+ /**
+ * For bindings that invoke one-way callback operations asynchronously,
+ * there is no need to perform a thread switch before calling the invoker.
+ * This method indicates whether the binding has this capability.
+ *
+ * @return true if the callback invoker is able to invoke one-way operations
+ * asynchronously, false if all invocations are synchronous
+ */
+ boolean supportsOneWayInvocation();
+
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java
new file mode 100644
index 0000000000..084056278c
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.provider;
+
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * An interface for factories that create implementation providers.
+ *
+ * @version $Rev: 539355 $ $Date: 2007-05-18 03:05:14 -0700 (Fri, 18 May 2007) $
+ */
+public interface ImplementationProviderFactory<M extends Implementation> extends ProviderFactory<M> {
+
+ /**
+ * Creates a new implementation provider for the given
+ * component.
+ *
+ * @param component The runtime component
+ * @param Implementation The implementation type
+ * @return The implementation provider
+ */
+ ImplementationProvider createImplementationProvider(RuntimeComponent component, M Implementation);
+
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java
new file mode 100644
index 0000000000..7e798549b3
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java
@@ -0,0 +1,38 @@
+/*
+ * 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.provider;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This interface can be optionally implemented by the Binding or Implementation providers to
+ * indicate if they implement the policies in the binding/implementation provider.
+ *
+ * @version $Rev: 634558 $ $Date: 2008-03-06 22:35:52 -0800 (Thu, 06 Mar 2008) $
+ */
+public interface PolicyImplementor {
+ /**
+ * Get a list of policy names that are implemented by this policy implementor
+ * @return A list of policy names
+ */
+ List<QName> getImplementedPolicies();
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java
new file mode 100644
index 0000000000..b7306e48dd
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java
@@ -0,0 +1,41 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Interceptor;
+
+/**
+ * @version $Rev: 634558 $ $Date: 2008-03-06 22:35:52 -0800 (Thu, 06 Mar 2008) $
+ */
+public interface PolicyProvider {
+ /**
+ * Create an interceptor for a given operation
+ * @param operation
+ * @return An interceptor that realize the policySet
+ */
+ Interceptor createInterceptor(Operation operation);
+
+ /**
+ * Get the phase that the interceptor should be added
+ * @return The phase that this interceptor belongs to
+ */
+ String getPhase();
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
new file mode 100644
index 0000000000..d7e4fee1d9
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
@@ -0,0 +1,63 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.Implementation;
+import org.apache.tuscany.sca.policy.Policy;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * @version $Rev: 634558 $ $Date: 2008-03-06 22:35:52 -0800 (Thu, 06 Mar 2008) $
+ */
+public interface PolicyProviderFactory<M extends Policy> extends ProviderFactory<M> {
+ /**
+ * Create policy provider for a given reference binding
+ * @param component
+ * @param reference
+ * @param binding
+ * @return
+ */
+ PolicyProvider createReferencePolicyProvider(RuntimeComponent component,
+ RuntimeComponentReference reference,
+ Binding binding);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param component
+ * @param service
+ * @param binding
+ * @return
+ */
+ PolicyProvider createServicePolicyProvider(RuntimeComponent component,
+ RuntimeComponentService service,
+ Binding binding);
+
+ /**
+ * Create policy provider for a given component implementation
+ * @param component
+ * @param implementation
+ * @return
+ */
+ PolicyProvider createImplementationPolicyProvider(RuntimeComponent component, Implementation implementation);
+
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java
new file mode 100644
index 0000000000..e0c03b3db1
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.provider;
+
+/**
+ * A factory for runtime providers.
+ *
+ * @version $Rev: 537206 $ $Date: 2007-05-11 08:14:19 -0700 (Fri, 11 May 2007) $
+ */
+public interface ProviderFactory<M> {
+
+ /**
+ * The model type that this factory creates providers for.
+ *
+ * @return the model type
+ */
+ Class<M> getModelType();
+
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java
new file mode 100644
index 0000000000..63c8cc162b
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java
@@ -0,0 +1,63 @@
+/*
+ * 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.provider;
+
+import java.util.List;
+
+
+/**
+ * An extension point for provider factories. Holds all of the provider
+ * factories from loaded extension points. Allows a provider factory
+ * to be located based on a given model type. Hence the runtime can
+ * generate runtime artifacts from the in memory assembly model.
+ *
+ * @version $Rev: 634558 $ $Date: 2008-03-06 22:35:52 -0800 (Thu, 06 Mar 2008) $
+ */
+public interface ProviderFactoryExtensionPoint {
+
+
+ /**
+ * Add a provider factory.
+ *
+ * @param providerFactory The provider factory
+ */
+ void addProviderFactory(ProviderFactory providerFactory);
+
+ /**
+ * Remove a provider factory.
+ *
+ * @param providerFactory The provider factory
+ */
+ void removeProviderFactory(ProviderFactory providerFactory);
+
+ /**
+ * Returns the provider factory associated with the given model type.
+ * @param modelType A model type
+ * @return The provider factory associated with the given model type
+ */
+ ProviderFactory getProviderFactory(Class<?> modelType);
+
+ /**
+ * Get a list of registered PolicyProviderFactory
+ * @return a list of registered PolicyProviderFactory
+ */
+ List<PolicyProviderFactory> getPolicyProviderFactories();
+
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java
new file mode 100644
index 0000000000..d0a1b53563
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java
@@ -0,0 +1,76 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+
+/**
+ * A reference binding implementation can options implement this
+ * interface to tie into the Tuscany SCA runtime
+ *
+ * @version $Rev: 576260 $ $Date: 2007-09-16 22:17:22 -0700 (Sun, 16 Sep 2007) $
+ */
+public interface ReferenceBindingProvider {
+
+ /**
+ * This method will be invoked when the component reference binding is
+ * activated.
+ */
+ void start();
+
+ /**
+ * This method will be invoked when the component reference binding is
+ * deactivated.
+ */
+ void stop();
+
+ /**
+ * Create an invoker for the reference binding in the invocation chain. The
+ * invoker is responsible for making the outbound invocation over the
+ * binding protocol.
+ *
+ * @param operation The operation that the interceptor will handle
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
+ */
+ Invoker createInvoker(Operation operation);
+
+ /**
+ * Get the effective interface contract imposed by the binding. For example,
+ * it will be interface contract introspected from the WSDL portType used by
+ * the endpoint for a WebService binding.
+ *
+ * @return The effective interface contract, if null is returned, the
+ * interface contract for the component reference will be used
+ */
+ InterfaceContract getBindingInterfaceContract();
+
+ /**
+ * For bindings that invoke one-way operations asynchronously, there is no
+ * need to perform a thread switch before calling the invoker. This method
+ * indicates whether the binding has this capability.
+ *
+ * @return true if the binding invoker is able to invoke one-way operations
+ * asynchronously, false if all invocations are synchronous
+ */
+ boolean supportsOneWayInvocation();
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProvider.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProvider.java
new file mode 100644
index 0000000000..b85d19ba9a
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProvider.java
@@ -0,0 +1,31 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.definitions.SCADefinitions;
+
+/**
+ * Models a provider of SCA Definitions. Typically SCA Definitions providers
+ * may either load a definitions.xml file or create the SCA Definitions model
+ * programmatically.
+ */
+public interface SCADefinitionsProvider {
+ SCADefinitions getSCADefinition() throws SCADefinitionsProviderException ;
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderException.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderException.java
new file mode 100644
index 0000000000..9be99c389c
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderException.java
@@ -0,0 +1,30 @@
+/*
+ * 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.provider;
+
+/**
+ * @version $Rev: 643489 $ $Date: 2008-04-01 10:06:42 -0800 (Tue, 01 Apr 2008) $
+ */
+public class SCADefinitionsProviderException extends Exception {
+
+ public SCADefinitionsProviderException(Throwable e) {
+ super(e);
+ }
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderExtensionPoint.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderExtensionPoint.java
new file mode 100644
index 0000000000..4d91480295
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/SCADefinitionsProviderExtensionPoint.java
@@ -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.provider;
+
+import java.util.List;
+
+/**
+ * An extension point for SCA Definitions Providers. SCA Definition providers, load SCA Definitions
+ * items that are being specifically contributed by the module that hosts the provider in question.
+ */
+public interface SCADefinitionsProviderExtensionPoint {
+
+ void addSCADefinitionsProvider(SCADefinitionsProvider provider);
+ void removeSCADefinitionsProvider(SCADefinitionsProvider provider);
+ List<SCADefinitionsProvider> getSCADefinitionsProviders();
+}
diff --git a/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java
new file mode 100644
index 0000000000..db08098ae8
--- /dev/null
+++ b/sandbox/mobile-android/tuscany-core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java
@@ -0,0 +1,63 @@
+/*
+ * 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.provider;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+
+/**
+ * A service binding can optionally implement this interface to tie
+ * into the Tuscany SCA runtime
+ *
+ * @version $Rev: 576260 $ $Date: 2007-09-16 22:17:22 -0700 (Sun, 16 Sep 2007) $
+ */
+public interface ServiceBindingProvider {
+ /**
+ * This method will be invoked when the component service binding is
+ * activated.
+ */
+ void start();
+
+ /**
+ * This method will be invoked when the component service binding is
+ * deactivated.
+ */
+ void stop();
+
+ /**
+ * Get the effective interface contract imposed by the binding. For example,
+ * it will be interface contract introspected from the WSDL portType used by
+ * the endpoint for a WebService binding.
+ *
+ * @return The effective interface contract, if null is returned, the
+ * interface contract for the component service will be used
+ */
+ InterfaceContract getBindingInterfaceContract();
+
+ /**
+ * For bindings that invoke one-way callback operations asynchronously,
+ * there is no need to perform a thread switch before calling the invoker.
+ * This method indicates whether the binding has this capability.
+ *
+ * @return true if the callback invoker is able to invoke one-way operations
+ * asynchronously, false if all invocations are synchronous
+ */
+ boolean supportsOneWayInvocation();
+
+}