summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider')
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BaseBindingImpl.java94
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java235
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java37
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java51
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java500
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointAsyncProvider.java56
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java35
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceAsyncProvider.java40
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.java36
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationAsyncProvider.java68
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java57
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java43
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java40
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java44
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OptimisingBindingProvider.java34
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java38
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java55
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java52
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java36
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java74
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java64
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/RuntimeProvider.java35
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCABindingMapper.java44
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java53
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java55
-rw-r--r--sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java44
26 files changed, 1920 insertions, 0 deletions
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BaseBindingImpl.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BaseBindingImpl.java
new file mode 100644
index 0000000000..3d47bd22f0
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BaseBindingImpl.java
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sca.provider;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.assembly.OperationSelector;
+import org.apache.tuscany.sca.assembly.WireFormat;
+
+/**
+ * Base abstract impl for a binding model.
+ */
+public abstract class BaseBindingImpl implements Binding {
+
+ private String name;
+ private String uri;
+ private boolean unresolved;
+ private OperationSelector operationSelector;
+ private WireFormat requestWireFormat;
+ private WireFormat responseWireFormat;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getURI() {
+ return uri;
+ }
+
+ public void setURI(String uri) {
+ this.uri = uri;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+ public boolean isUnresolved() {
+ return unresolved;
+ }
+
+ public void setUnresolved(boolean unresolved) {
+ this.unresolved = unresolved;
+ }
+
+ public abstract QName getType();
+
+ public WireFormat getRequestWireFormat() {
+ return requestWireFormat;
+ }
+
+ public void setRequestWireFormat(WireFormat wireFormat) {
+ this.requestWireFormat = wireFormat;
+ }
+
+ public WireFormat getResponseWireFormat() {
+ return responseWireFormat;
+ }
+
+ public void setResponseWireFormat(WireFormat wireFormat) {
+ this.responseWireFormat = wireFormat;
+ }
+
+ public OperationSelector getOperationSelector() {
+ return operationSelector;
+ }
+
+ public void setOperationSelector(OperationSelector operationSelector) {
+ this.operationSelector = operationSelector;
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java
new file mode 100644
index 0000000000..ba6d6f5df0
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BasePolicyProvider.java
@@ -0,0 +1,235 @@
+/*
+ * 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.security.Policy;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.sca.assembly.Component;
+import org.apache.tuscany.sca.assembly.ComponentService;
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+import org.apache.tuscany.sca.policy.Intent;
+import org.apache.tuscany.sca.policy.PolicyContainer;
+import org.apache.tuscany.sca.policy.PolicyExpression;
+import org.apache.tuscany.sca.policy.PolicySet;
+import org.apache.tuscany.sca.policy.PolicySubject;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Abstract base class for policy providers
+ * @tuscany.spi.extension.inheritfrom
+ */
+public abstract class BasePolicyProvider<T> implements PolicyProvider {
+ protected Class<T> policyType;
+ protected PolicySubject subject;
+
+ protected BasePolicyProvider(Class<T> policyType, PolicySubject subject) {
+ this.policyType = policyType;
+ this.subject = subject;
+ }
+
+ protected List<T> findPoliciesWithProvidedIntents(List<Intent> intents) {
+ List<PolicySet> applicablePolicySets = new ArrayList<PolicySet>();
+ List<PolicySet> policySets = subject.getPolicySets();
+ for ( PolicySet ps : policySets ) {
+ List<Intent> provided = ps.getProvidedIntents();
+ for ( Intent intent : intents ) {
+ if ( provided.contains(intent) ) {
+ applicablePolicySets.add(ps);
+ continue;
+ }
+
+ }
+ }
+ return findPolicies(applicablePolicySets);
+ }
+
+ /*
+ * return policies for the service as a whole not including
+ * operation specific policies
+ */
+ protected List<T> findPolicies() {
+ return findPolicies(subject.getPolicySets());
+ }
+
+ /*
+ * return policies for the service as a whole including
+ * operation specific policies
+ */
+ protected List<T> findPolicies(Operation operation) {
+ // collect together all the candidate policy sets
+ List<PolicySet> policySets = new ArrayList<PolicySet>();
+ // add endpoint or endpoint reference policy sets
+ policySets.addAll(subject.getPolicySets());
+ // add interface operation policy sets
+ policySets.addAll(operation.getPolicySets());
+ // add implementation operation policy sets
+ if (subject instanceof Endpoint){
+ for(Operation op :((Endpoint)subject).getComponent().getImplementation().getOperations()){
+ if (op.getName().equals(operation.getName())){
+ policySets.addAll(op.getPolicySets());
+ break;
+ }
+ }
+ }
+
+ return findPolicies(policySets);
+ }
+
+ private List<T> findPolicies(List<PolicySet> policySets) {
+ List<T> policies = new ArrayList<T>();
+
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (policyType.isInstance(p)) {
+ policies.add(policyType.cast(p));
+ }
+
+ if (p instanceof PolicyExpression) {
+ PolicyExpression exp = (PolicyExpression)p;
+ if (policyType.isInstance(exp.getPolicy())) {
+ policies.add(policyType.cast(exp.getPolicy()));
+ }
+
+ // TODO - some code to handle the case where the
+ // policy expression is a WS-Policy
+ // Experimental at the moment.
+ if (PolicyContainer.class.isInstance(exp.getPolicy())){
+ Object policy = ((PolicyContainer)exp.getPolicy()).getChildPolicy(policyType);
+ if(policy != null){
+ policies.add(policyType.cast(policy));
+ }
+ }
+ }
+ }
+ }
+ return policies;
+ }
+
+ protected List<PolicySet> findPolicySets() {
+ List<PolicySet> policies = new ArrayList<PolicySet>();
+ List<PolicySet> policySets = subject.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (policyType.isInstance(p)) {
+ policies.add(ps);
+ }
+ if (p instanceof PolicyExpression) {
+ PolicyExpression exp = (PolicyExpression)p;
+ if (policyType.isInstance(exp.getPolicy())) {
+ policies.add(ps);
+ }
+ }
+ }
+ }
+ return policies;
+ }
+
+ protected PolicySet findPolicySet() {
+ List<PolicySet> policySets = subject.getPolicySets();
+ for (PolicySet ps : policySets) {
+ for (Object p : ps.getPolicies()) {
+ if (policyType.isInstance(p)) {
+ return ps;
+ }
+ if (p instanceof PolicyExpression) {
+ PolicyExpression exp = (PolicyExpression)p;
+ if (policyType.isInstance(exp.getPolicy())) {
+ return ps;
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ protected String getContext() {
+ if (subject instanceof Endpoint) {
+ Endpoint endpoint = (Endpoint)subject;
+ return endpoint.getURI();
+ } else if (subject instanceof EndpointReference) {
+ EndpointReference endpointReference = (EndpointReference)subject;
+ return endpointReference.getURI();
+ } else if (subject instanceof Component) {
+ Component component = (Component)subject;
+ return component.getURI();
+ }
+ return null;
+ }
+
+ public void start() {
+ }
+
+ public void stop() {
+ }
+
+ public PhasedInterceptor createInterceptor(Operation operation) {
+ return null;
+ }
+
+ public PhasedInterceptor createBindingInterceptor() {
+ return null;
+ }
+
+ public void configureBinding(Object configuration){
+ }
+
+ protected InvocationChain getInvocationChain() {
+ if (subject instanceof RuntimeEndpoint) {
+ RuntimeEndpoint endpoint = (RuntimeEndpoint)subject;
+ List<InvocationChain> chains = endpoint.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getTargetOperation());
+ }
+
+ } else if (subject instanceof RuntimeEndpointReference) {
+ RuntimeEndpointReference endpointReference = (RuntimeEndpointReference)subject;
+ List<InvocationChain> chains = endpointReference.getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getSourceOperation());
+ }
+ } else if (subject instanceof RuntimeComponent) {
+ RuntimeComponent component = (RuntimeComponent)subject;
+ for (ComponentService s : component.getServices()) {
+ RuntimeComponentService service = (RuntimeComponentService)s;
+ for (Endpoint ep : service.getEndpoints()) {
+ List<InvocationChain> chains = ((RuntimeEndpoint)ep).getInvocationChains();
+ for (InvocationChain chain : chains) {
+ configure(chain, chain.getTargetOperation());
+ }
+ }
+
+ }
+ }
+ return null;
+ }
+
+ protected void configure(InvocationChain invocationChain, Operation operation) {
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java
new file mode 100644
index 0000000000..5f2e6bd315
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingPolicyProvider.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.tuscany.sca.provider;
+
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+
+/**
+ * TODO RRB experiment
+ * This is an experiment extension to try out the request response
+ * binding function
+ * @version $Rev$ $Date$
+ */
+public interface BindingPolicyProvider extends PolicyProvider {
+ /**
+ * Create a binding interceptor
+ * @return An interceptor that realize the policySet
+ */
+ PhasedInterceptor createBindingInterceptor();
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java
new file mode 100644
index 0000000000..36e34c11b7
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/BindingProviderFactory.java
@@ -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.provider;
+
+import org.apache.tuscany.sca.assembly.Binding;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * A factory for creating the runtime artifacts that represent bindings.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface BindingProviderFactory<M extends Binding> extends ProviderFactory<M> {
+
+ /**
+ * Creates a new reference binding provider for the given endpoint reference
+ *
+ * @param endpointReference defines the component/reference/binding against which to create the provider
+ * @return The binding provider
+ */
+ ReferenceBindingProvider createReferenceBindingProvider(RuntimeEndpointReference endpointReference);
+
+ /**
+ * Creates a new service binding provider for the given component and
+ * service.
+ *
+ * @param endpoint defines the component/service/binding against which to create the provider
+ * @return The binding provider
+ */
+ ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint);
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
new file mode 100644
index 0000000000..40b6275667
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/DefaultProviderFactoryExtensionPoint.java
@@ -0,0 +1,500 @@
+/*
+ * 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.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+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.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * Default implementation of a provider factory extension point.
+ *
+ * @version $Rev$ $Date$
+ */
+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);
+ }
+ // Only add the 1st instance so that the ones with higher ranking with prevail
+ if (!providerFactories.containsKey(providerFactory.getModelType())) {
+ 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;
+ }
+
+ public <P extends ProviderFactory> Collection<P> getProviderFactories(Class<P> factoryType) {
+ loadProviderFactories();
+ List<P> factories = new ArrayList<P>();
+ for (ProviderFactory pf : providerFactories.values()) {
+ if (factoryType.isInstance(pf)) {
+ factories.add(factoryType.cast(pf));
+ }
+ }
+ return factories;
+ }
+
+ /**
+ * Load provider factories declared under META-INF/services.
+ * @param registry
+ */
+ private synchronized void loadProviderFactories() {
+ if (loaded)
+ return;
+
+ loadProviderFactories(BindingProviderFactory.class);
+ loadProviderFactories(ImplementationProviderFactory.class);
+ loadProviderFactories(PolicyProviderFactory.class);
+ loadProviderFactories(WireFormatProviderFactory.class);
+ loadProviderFactories(OperationSelectorProviderFactory.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
+ Collection<ServiceDeclaration> factoryDeclarations;
+ ServiceDiscovery serviceDiscovery = registry.getServiceDiscovery();
+ try {
+ factoryDeclarations = serviceDiscovery.getServiceDeclarations(factoryClass.getName(), true);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+
+ 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);
+ 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);
+ 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);
+ addProviderFactory(factory);
+ factories.add(factory);
+ } else if (factoryClass == WireFormatProviderFactory.class) {
+
+ // Load a wire format provider factory
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ WireFormatProviderFactory factory =
+ new LazyWireFormatProviderFactory(registry, modelTypeName, factoryDeclaration);
+ addProviderFactory(factory);
+ factories.add(factory);
+ } else if (factoryClass == OperationSelectorProviderFactory.class) {
+
+ // Load a wire format provider factory
+ String modelTypeName = attributes.get("model");
+
+ // Create a provider factory wrapper and register it
+ OperationSelectorProviderFactory factory =
+ new LazyOperationSelectorProviderFactory(registry, modelTypeName, factoryDeclaration);
+ 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(RuntimeEndpointReference endpointReference) {
+ return getFactory().createReferenceBindingProvider(endpointReference);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ServiceBindingProvider createServiceBindingProvider(RuntimeEndpoint endpoint) {
+ return getFactory().createServiceBindingProvider(endpoint);
+ }
+
+ 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) {
+ return getFactory().createImplementationPolicyProvider(component);
+ }
+
+ public PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference) {
+ return getFactory().createReferencePolicyProvider(endpointReference);
+ }
+
+ public PolicyProvider createServicePolicyProvider(Endpoint endpoint) {
+ return getFactory().createServicePolicyProvider(endpoint);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+ }
+
+ /**
+ * A wrapper around a wire format provider factory allowing lazy
+ * loading and initialization of wire format providers.
+ */
+ private class LazyWireFormatProviderFactory implements WireFormatProviderFactory {
+
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration providerClass;
+ private WireFormatProviderFactory factory;
+ private Class<?> modelType;
+
+ private LazyWireFormatProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration providerClass) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.providerClass = providerClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private WireFormatProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<WireFormatProviderFactory> factoryClass =
+ (Class<WireFormatProviderFactory>)providerClass.loadClass();
+ Constructor<WireFormatProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ public WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference){
+ return getFactory().createReferenceWireFormatProvider(endpointReference);
+ }
+
+ public WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint){
+ return getFactory().createServiceWireFormatProvider(endpoint);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+ }
+
+ /**
+ * A wrapper around a operation selector provider factory allowing lazy
+ * loading and initialization of operation selector providers.
+ */
+ private class LazyOperationSelectorProviderFactory implements OperationSelectorProviderFactory {
+
+ private ExtensionPointRegistry registry;
+ private String modelTypeName;
+ private ServiceDeclaration providerClass;
+ private OperationSelectorProviderFactory factory;
+ private Class<?> modelType;
+
+ private LazyOperationSelectorProviderFactory(ExtensionPointRegistry registry,
+ String modelTypeName,
+ ServiceDeclaration providerClass) {
+ this.registry = registry;
+ this.modelTypeName = modelTypeName;
+ this.providerClass = providerClass;
+ }
+
+ @SuppressWarnings("unchecked")
+ private OperationSelectorProviderFactory getFactory() {
+ if (factory == null) {
+ try {
+ Class<OperationSelectorProviderFactory> factoryClass =
+ (Class<OperationSelectorProviderFactory>)providerClass.loadClass();
+ Constructor<OperationSelectorProviderFactory> constructor =
+ factoryClass.getConstructor(ExtensionPointRegistry.class);
+ factory = constructor.newInstance(registry);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return factory;
+ }
+
+ public OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference){
+ return getFactory().createReferenceOperationSelectorProvider(endpointReference);
+ }
+
+ public OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint){
+ return getFactory().createServiceOperationSelectorProvider(endpoint);
+ }
+
+ public Class<?> getModelType() {
+ if (modelType == null) {
+ try {
+
+ modelType = providerClass.loadClass(modelTypeName);
+ } catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ return modelType;
+ }
+ }
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointAsyncProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointAsyncProvider.java
new file mode 100644
index 0000000000..b74b1dd9a7
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointAsyncProvider.java
@@ -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.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.InvokerAsyncResponse;
+
+
+/**
+ * TUSCANY-3783
+ *
+ * Async related operations that are here rather than higher up
+ * while we develop them.
+ *
+ */
+public interface EndpointAsyncProvider extends EndpointProvider {
+
+ /**
+ * TUSCANY-3801
+ * Returns true if the service binding provider is natively able
+ * to dispatch async responses.
+ *
+ * @return true if the service provide support async operation natively
+ */
+ boolean supportsNativeAsync();
+
+ /**
+ * TUSCANY-3801
+ * Create an async response invoker. This is used when
+ * supportsNativeAsync = true so that the endpoint
+ * has somewhere to send the async response when it
+ * eventually returns from the implementation.
+ *
+ * @para operation
+ * @return the invoker that will dispatch the async response
+ */
+ InvokerAsyncResponse createAsyncResponseInvoker();
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java
new file mode 100644
index 0000000000..a25814234a
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointProvider.java
@@ -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.provider;
+
+
+/**
+ * Defines the extra operation that service binding providers implement
+ * to configure the binding chain.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface EndpointProvider extends ServiceBindingProvider {
+ /**
+ * Configure the binding invocation chain
+ */
+ void configure();
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceAsyncProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceAsyncProvider.java
new file mode 100644
index 0000000000..044ba523b9
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceAsyncProvider.java
@@ -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.provider;
+
+
+/**
+ * TUSCANY-3783
+ *
+ * Async related operations that are here rather than higher up
+ * while we develop them.
+ *
+ */
+public interface EndpointReferenceAsyncProvider extends EndpointReferenceProvider {
+
+ /**
+ * TUSCANY-3801
+ * Returns true if the reference binding provider is natively able
+ * to receive async responses.
+ *
+ * @return true if the service provide support async operation natively
+ */
+ boolean supportsNativeAsync();
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.java
new file mode 100644
index 0000000000..209b057859
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/EndpointReferenceProvider.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;
+
+
+/**
+ * Defines the extra operation that reference binding providers implement
+ * to configure the binding chain.
+ *
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface EndpointReferenceProvider extends ReferenceBindingProvider {
+ /**
+ * Configure the binding invocation chain
+ */
+ void configure();
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationAsyncProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationAsyncProvider.java
new file mode 100644
index 0000000000..2941483ede
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationAsyncProvider.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.assembly.Endpoint;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.InvokerAsyncRequest;
+import org.apache.tuscany.sca.invocation.InvokerAsyncResponse;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
+
+/**
+ * TUSCANY-3786 - Possibly temporary interface to describe an
+ * async invocation. Need to make it work end to
+ * end before committing to this.
+ *
+ * A component implementation can implement this interface in order to tie
+ * into the Tuscany runtime to process asynchronous responses.
+ *
+ */
+public interface ImplementationAsyncProvider extends ImplementationProvider {
+
+ /**
+ * TUSCANY-3801
+ * Create an async invoker for the component implementation in the invocation
+ * chain. The invoker will be responsible for calling the implementation
+ * logic for the given component. The only real difference between this and
+ * createInvoker is that the Endpoint is passed in so that the invoker can
+ * engineer the async response
+ *
+ * @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
+ */
+ InvokerAsyncRequest createAsyncInvoker(RuntimeComponentService service, Operation operation);
+
+ /**
+ * TUSCANY-3801
+ * Create an invoker for the asynchronous responses in the invocation
+ * chain. The invoker will be responsible for processing the async
+ * response including correlating it with the forward call using
+ * the MESAGE_ID that appears in the message header.
+ *
+ * @param service The component service
+ * @param operation The operation that the interceptor will handle
+ * @return An AsyncResponseHandler<T> instance
+ */
+ InvokerAsyncResponse createAsyncResponseInvoker(Operation operation);
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java
new file mode 100644
index 0000000000..4e9fddb135
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProvider.java
@@ -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.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$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ImplementationProvider extends RuntimeProvider {
+
+ /**
+ * 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/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java
new file mode 100644
index 0000000000..cfb06d9c70
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ImplementationProviderFactory.java
@@ -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.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$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+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/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java
new file mode 100644
index 0000000000..c0346780d8
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProvider.java
@@ -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.provider;
+
+import org.apache.tuscany.sca.invocation.Interceptor;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface OperationSelectorProvider {
+ /**
+ * Create an interceptor for the operation selector
+ * @return An interceptor that realize the policySet
+ */
+ Interceptor createInterceptor();
+
+ /**
+ * Get the phase that the interceptor should be added
+ * @return The phase that this interceptor belongs to
+ */
+ String getPhase();
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java
new file mode 100644
index 0000000000..43ea8d171b
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OperationSelectorProviderFactory.java
@@ -0,0 +1,44 @@
+/*
+ * 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.OperationSelector;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface OperationSelectorProviderFactory<M extends OperationSelector> extends ProviderFactory<M> {
+ /**
+ * Create wire format provider for a given reference binding
+ * @param endpointReference TODO
+ * @return
+ */
+ OperationSelectorProvider createReferenceOperationSelectorProvider(RuntimeEndpointReference endpointReference);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param endpoint TODO
+ * @return
+ */
+ OperationSelectorProvider createServiceOperationSelectorProvider(RuntimeEndpoint endpoint);
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OptimisingBindingProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OptimisingBindingProvider.java
new file mode 100644
index 0000000000..57c9b48349
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/OptimisingBindingProvider.java
@@ -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.provider;
+
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+
+/**
+ * Defines the extra operation that binding providers implement
+ * when they provide local optimisation of reference to service invocations
+ */
+public interface OptimisingBindingProvider {
+ /**
+ * Optimise the binding chain for a service endpoint
+ */
+ void optimiseBinding( RuntimeEndpoint ep );
+
+} // end interface OptimisingBindingProvider
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyImplementor.java
new file mode 100644
index 0000000000..f2b59a7c54
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/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$ $Date$
+ */
+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/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java
new file mode 100644
index 0000000000..de0b62eecd
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProvider.java
@@ -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.provider;
+
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.PhasedInterceptor;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+public interface PolicyProvider extends RuntimeProvider {
+ /**
+ * Create an interceptor for a given operation
+ *
+ * @param operation
+ * @return An interceptor that realizes the policySet
+ */
+ PhasedInterceptor createInterceptor(Operation operation);
+
+ /**
+ * Create a binding interceptor. The binding wire is
+ * not operation specific so an operation parameter
+ * isn't required
+ *
+ * @return An interceptor that realizes the policySet
+ */
+ PhasedInterceptor createBindingInterceptor();
+
+ /**
+ * Give the provider an opportunity to affect the
+ * binding configuration if required
+ *
+ * @param configurationContext the configuration context of the
+ * binding that will be modified
+ */
+ void configureBinding(Object configuration);
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
new file mode 100644
index 0000000000..134df1c37e
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/PolicyProviderFactory.java
@@ -0,0 +1,52 @@
+/*
+ * 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.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface PolicyProviderFactory<M> extends ProviderFactory<M> {
+ /**
+ * Create policy provider for a given reference binding
+ * @param endpointReference The endpoint reference
+ * @return A policy provider for the endpoint reference
+ */
+ PolicyProvider createReferencePolicyProvider(EndpointReference endpointReference);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param endpoint The endpoint
+ * @return A policy provider for the endpoint
+ */
+ PolicyProvider createServicePolicyProvider(Endpoint endpoint);
+
+ /**
+ * Create policy provider for a given component implementation
+ * @param component
+ * @return A policy provider for the implementation
+ */
+ PolicyProvider createImplementationPolicyProvider(RuntimeComponent component);
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactory.java
new file mode 100644
index 0000000000..2102806881
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/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$ $Date$
+ */
+public interface ProviderFactory<M> {
+
+ /**
+ * The model type that this factory creates providers for.
+ *
+ * @return the model type
+ */
+ Class<M> getModelType();
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java
new file mode 100644
index 0000000000..75c5544aa3
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ProviderFactoryExtensionPoint.java
@@ -0,0 +1,74 @@
+/*
+ * 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.Collection;
+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$ $Date$
+ * @tuscany.spi.extension.asclient
+ */
+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();
+
+ /**
+ * Get a collection of provider factories by the factory type
+ * @param <P>
+ * @param factoryType The factory type such as BindingProviderFactory
+ * @return a collection of provider factories of the factory type
+ */
+ <P extends ProviderFactory> Collection<P> getProviderFactories(Class<P> factoryType);
+
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java
new file mode 100644
index 0000000000..ab864dba3f
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ReferenceBindingProvider.java
@@ -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.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$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ReferenceBindingProvider extends RuntimeProvider {
+ /**
+ * 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/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/RuntimeProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/RuntimeProvider.java
new file mode 100644
index 0000000000..2afd44af31
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/RuntimeProvider.java
@@ -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.provider;
+
+/**
+ * The base interface for runtime providers that can be started or stoppped
+ */
+public interface RuntimeProvider {
+ /**
+ * This method will be invoked when the corresponding SCA component is started.
+ */
+ void start();
+
+ /**
+ * This method will be invoked when the corresponding SCA component is stopped
+ */
+ void stop();
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCABindingMapper.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCABindingMapper.java
new file mode 100644
index 0000000000..706bf7d319
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/SCABindingMapper.java
@@ -0,0 +1,44 @@
+/*
+ * 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.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * SCABindingMapper allows us to map binding.sca to any of the bindings available to the runtime
+ */
+public interface SCABindingMapper {
+
+ /**
+ * Map an endpoint with binding.sca to an endpoint
+ * @param endpoint The endpoint for binding.sca
+ * @return The endpoint for the mapped binding
+ */
+ public RuntimeEndpoint map(RuntimeEndpoint endpoint);
+
+ /**
+ * Map an endpoint reference with binding.sca to an endpoint reference with the mapped binding
+ * @param endpointReference
+ * @return The endpoint reference for the mapped binding
+ */
+ public RuntimeEndpointReference map(RuntimeEndpointReference endpointReference);
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java
new file mode 100644
index 0000000000..e7df45bfa8
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/ServiceBindingProvider.java
@@ -0,0 +1,53 @@
+/*
+ * 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$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface ServiceBindingProvider extends RuntimeProvider {
+
+ /**
+ * 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();
+
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java
new file mode 100644
index 0000000000..674b708ef8
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProvider.java
@@ -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.provider;
+
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.invocation.Interceptor;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface WireFormatProvider {
+
+ /**
+ * Set up the contract that describes the interface that
+ * is providing data to or accepting data from the
+ * wire format interceptor. The wire format's job
+ * is to translate between this interface contract and the
+ * format on the wire. The interface contract may be
+ * configured separately for request and response
+ * wire formats
+ *
+ * @return the wire format interface contract
+ */
+ public InterfaceContract configureWireFormatInterfaceContract(InterfaceContract interfaceContract);
+
+ /**
+ * Create an interceptor for the wire format
+ * @return An interceptor that realize the policySet
+ */
+ Interceptor createInterceptor();
+
+ /**
+ * Get the phase that the interceptor should be added
+ * @return The phase that this interceptor belongs to
+ */
+ String getPhase();
+}
diff --git a/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java
new file mode 100644
index 0000000000..3f629ddeef
--- /dev/null
+++ b/sca-java-2.x/tags/2.0.1-RC1/modules/core-spi/src/main/java/org/apache/tuscany/sca/provider/WireFormatProviderFactory.java
@@ -0,0 +1,44 @@
+/*
+ * 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.WireFormat;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+
+/**
+ * @version $Rev$ $Date$
+ * @tuscany.spi.extension.inheritfrom
+ */
+public interface WireFormatProviderFactory<M extends WireFormat> extends ProviderFactory<M> {
+ /**
+ * Create wire format provider for a given reference binding
+ * @param endpointReference The endpoint reference
+ * @return
+ */
+ WireFormatProvider createReferenceWireFormatProvider(RuntimeEndpointReference endpointReference);
+
+ /**
+ * Create policy provider for a given service binding
+ * @param endpoint TODO
+ * @return
+ */
+ WireFormatProvider createServiceWireFormatProvider(RuntimeEndpoint endpoint);
+}