summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/core
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-06-23 22:48:13 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2009-06-23 22:48:13 +0000
commit90ba7b1a18706b434520d531358619438a43b4f0 (patch)
tree4c571d7829da8a0df07368ac51292bc07db5526e /java/sca/modules/core
parent40ddf83655bc926c1babc72ba36a1c658eadb516 (diff)
Add a QName as the type for binding/implementation and use it to compare model types instead of class
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@787865 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/core')
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java13
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java6
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java56
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java36
4 files changed, 54 insertions, 57 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
index ff49effc0f..cd27763885 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
@@ -49,7 +49,6 @@ import org.apache.tuscany.sca.core.context.CompositeContext;
import org.apache.tuscany.sca.core.context.impl.CompositeContextImpl;
import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
-import org.apache.tuscany.sca.core.scope.Scope;
import org.apache.tuscany.sca.core.scope.ScopeContainer;
import org.apache.tuscany.sca.core.scope.ScopeRegistry;
import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
@@ -303,7 +302,7 @@ public class CompositeActivatorImpl implements CompositeActivator {
}
private ServiceBindingProvider addServiceBindingProvider(
- Endpoint endpoint,
+ Endpoint endpoint,
RuntimeComponent component, RuntimeComponentService service,
Binding binding) {
BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories
@@ -327,8 +326,8 @@ public class CompositeActivatorImpl implements CompositeActivator {
return bindingProvider;
} else {
throw new IllegalStateException(
- "Provider factory not found for class: "
- + binding.getClass().getName());
+ "Provider factory not found for binding: "
+ + binding.getType());
}
}
@@ -459,8 +458,8 @@ public class CompositeActivatorImpl implements CompositeActivator {
return bindingProvider;
} else {
throw new IllegalStateException(
- "Provider factory not found for class: "
- + binding.getClass().getName());
+ "Provider factory not found for binding: "
+ + binding.getClass().getType());
}
}
*/
@@ -531,7 +530,6 @@ public class CompositeActivatorImpl implements CompositeActivator {
}
RuntimeComponentService runtimeService = (RuntimeComponentService)service;
for (Endpoint endpoint : service.getEndpoints()) {
- endpointRegistry.addEndpoint(endpoint);
final ServiceBindingProvider bindingProvider = runtimeService.getBindingProvider(endpoint.getBinding());
if (bindingProvider != null) {
// bindingProvider.start();
@@ -542,6 +540,7 @@ public class CompositeActivatorImpl implements CompositeActivator {
return null;
}
});
+ endpointRegistry.addEndpoint(endpoint);
}
}
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
index e639bb5ea6..32645244fb 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
@@ -361,7 +361,7 @@ public class RuntimeWireImpl implements RuntimeWire {
}
private ReferenceBindingProvider addReferenceBindingProvider(
- EndpointReference endpointReference,
+ EndpointReference endpointReference,
RuntimeComponent component, RuntimeComponentReference reference,
Binding binding) {
BindingProviderFactory providerFactory = (BindingProviderFactory) providerFactories
@@ -387,8 +387,8 @@ public class RuntimeWireImpl implements RuntimeWire {
return bindingProvider;
} else {
throw new IllegalStateException(
- "Provider factory not found for class: "
- + binding.getClass().getName());
+ "Provider factory not found for binding: "
+ + binding.getType());
}
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
index b52b97c5c6..b5abc48a33 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
@@ -6,15 +6,15 @@
* 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.
+ * under the License.
*/
package org.apache.tuscany.sca.core.context.impl;
@@ -59,7 +59,7 @@ import org.oasisopen.sca.ServiceRuntimeException;
/**
* Base class for implementations of service and callback references.
- *
+ *
* @version $Rev$ $Date$
* @param <B> the type of the business interface
*/
@@ -81,7 +81,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
private transient RuntimeComponentReference clonedRef;
private transient ReferenceParameters refParams;
private transient XMLStreamReader xmlReader;
-
+
private FactoryExtensionPoint modelFactories;
protected RuntimeAssemblyFactory assemblyFactory;
@@ -111,29 +111,29 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
this.component = component;
this.reference = reference;
this.endpointReference = endpointReference;
-
+
ExtensionPointRegistry registry = compositeActivator.getCompositeContext().getExtensionPointRegistry();
this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
-
- // FIXME: The SCA Specification is not clear how we should handle multiplicity
+
+ // FIXME: The SCA Specification is not clear how we should handle multiplicity
// for CallableReference
if (this.endpointReference == null) {
-
+
// TODO - EPR - If no endpoint reference specified assume the first one
- // This will happen when a self reference is created in which case the
- // the reference should only have on endpointReference so use that
+ // This will happen when a self reference is created in which case the
+ // the reference should only have on endpointReference so use that
if (this.reference.getEndpointReferences().size() == 0){
- throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " +
+ throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " +
component.getName() + " has no endpoint references");
}
-
+
if (this.reference.getEndpointReferences().size() > 1){
- throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " +
+ throw new ServiceRuntimeException("The reference " + reference.getName() + " in component " +
component.getName() + " has more than one endpoint reference");
}
-
+
this.endpointReference = this.reference.getEndpointReferences().get(0);
}
@@ -251,7 +251,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
* @throws IOException
*/
// TODO - EPR all needs sorting out for endpoint references
-
+
private synchronized void resolve() throws Exception {
if ((scdl != null || xmlReader != null) && component == null && reference == null) {
CompositeContext componentContextHelper = CompositeContext.getCurrentCompositeContext();
@@ -308,7 +308,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
optimizableBinding.setTargetComponentService(targetService);
if (targetService != null) {
for (Binding serviceBinding : targetService.getBindings()) {
- if (serviceBinding.getClass() == binding.getClass()) {
+ if (serviceBinding.getType().equals(binding.getType())) {
optimizableBinding.setTargetBinding(serviceBinding);
break;
}
@@ -317,7 +317,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
}
}
/*
- // FIXME: The SCA Specification is not clear how we should handle multiplicity
+ // FIXME: The SCA Specification is not clear how we should handle multiplicity
// for CallableReference
if (binding == null) {
binding = reference.getBinding(SCABinding.class);
@@ -326,7 +326,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
}
}
*/
-
+
Interface i = reference.getInterfaceContract().getInterface();
if (i instanceof JavaInterface) {
JavaInterface javaInterface = (JavaInterface)i;
@@ -348,7 +348,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
}
this.businessInterface = (Class<B>)javaInterface.getJavaClass();
}
-/*
+/*
if (binding instanceof BindingBuilderExtension) {
((BindingBuilderExtension)binding).getBuilder().build(component, reference, binding, null);
}
@@ -366,7 +366,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
/**
* Follow a service promotion chain down to the inner most (non composite)
* component service.
- *
+ *
* @param topCompositeService
* @return
*/
@@ -421,7 +421,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
if (refParams == null) {
refParams = new ReferenceParametersImpl();
- // remove any existing reference parameters from the clone
+ // remove any existing reference parameters from the clone
Object toRemove = null;
for (Object extension : clonedRef.getExtensions()) {
if (extension instanceof ReferenceParameters) {
@@ -445,7 +445,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
/**
* Create a callback id
- *
+ *
* @return the callback id
*/
private String createCallbackID() {
@@ -472,16 +472,16 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
InterfaceContract sourceContract =
componentTypeRef == null ? reference.getInterfaceContract() : componentTypeRef.getInterfaceContract();
sourceContract = sourceContract.makeUnidirectional(false);
-
+
EndpointReference epr = assemblyFactory.createEndpointReference();
epr.setComponent(component);
epr.setReference(reference);
//epr.setBinding(binding);
epr.setInterfaceContract(sourceContract);
-
+
Endpoint endpoint = assemblyFactory.createEndpoint();
epr.setTargetEndpoint(endpoint);
-
+
return epr;
} catch (Exception e) {
throw new ServiceRuntimeException(e);
@@ -499,7 +499,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
* <li>URI containing just Composite name(s) (i.e. no Service name specified)
* <li>URI containing Composite name(s) and a Service Name
* </ul>
- *
+ *
* @param componentURI The URI of the Component to resolve
* @return The Component for the specified URI or null if not founds
*/
@@ -530,7 +530,7 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
/**
* Examines the Services on the specified Component and returns the Service that matches the
* specified Binding URI.
- *
+ *
* @param bindingURI The Binding URI to resolve on the Component
* @param targetComponent The Component containing the Services
* @return The Service with the specified serviceName or null if no such Service found.
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java
index ac977cbf37..c87426bac2 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/CallbackReferenceImpl.java
@@ -6,15 +6,15 @@
* 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.
+ * under the License.
*/
package org.apache.tuscany.sca.core.invocation.impl;
@@ -26,10 +26,8 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Component;
import org.apache.tuscany.sca.assembly.ComponentService;
-import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeComponentReferenceImpl;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
import org.apache.tuscany.sca.core.context.CompositeContext;
@@ -124,8 +122,8 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
// if no match, look for callback binding with same type as service binding
for (RuntimeWire wire : wires) {
- if (wire.getEndpointReference().getBinding().getClass() == to.getBinding().getClass()) {
- return wire;
+ if (wire.getEndpointReference().getBinding().getType().equals(to.getBinding().getType())) {
+ return wire;
}
}
@@ -142,7 +140,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
}
try {
// TODO - EPR - is this correct?
-
+
// test if the call back wire is manually configured
if ((wire.getEndpointReference().isUnresolved()== false) &&
(wire.getEndpointReference().getTargetEndpoint().isUnresolved()== false)){
@@ -154,12 +152,12 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
RuntimeComponentReference ref =
bind((RuntimeComponentReference)wire.getEndpointReference().getReference(),
resolvedEndpoint);
-
+
boundWire = ref.getRuntimeWires().get(0);
}
-
+
Binding binding = wire.getEndpointReference().getBinding();
-
+
((RuntimeWireImpl)wire).addToCache(resolvedEndpoint, boundWire);
} catch (CloneNotSupportedException e) {
// will not happen
@@ -171,24 +169,24 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
// TODO - EPR - why static?
private static RuntimeComponentReference bind(RuntimeComponentReference reference,
Endpoint callbackEndpoint) throws CloneNotSupportedException {
-
+
// clone the callback reference ready to configure it for this callback endpoint
RuntimeComponentReference ref = (RuntimeComponentReference)reference.clone();
ref.getTargets().clear();
ref.getBindings().clear();
ref.getEndpointReferences().clear();
-
+
// no access to the assembly factory so clone an existing epr
EndpointReference callbackEndpointReference = (EndpointReference)reference.getEndpointReferences().get(0).clone();
callbackEndpointReference.setReference(ref);
callbackEndpointReference.setTargetEndpoint(callbackEndpoint);
callbackEndpointReference.setUnresolved(true);
-
- // The callback endpoint will be resolved with the registry
+
+ // The callback endpoint will be resolved with the registry
// when the wire chains are created
ref.getEndpointReferences().add(callbackEndpointReference);
-
+
return ref;
}
@@ -218,7 +216,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
// Copy the Java Interface from the Service
final JavaInterface ji = (JavaInterface) targetServiceIfaceContract.getInterface();
this.businessInterface = (Class<B>) ji.getJavaClass();
-
+
// We need to re-create the callback wire. We need to do this on a clone of the Service
// wire since we need to change some details on it.
// FIXME: Is this the best way to do this?
@@ -229,7 +227,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
throw new IOException(e.toString());
}
- // TODO - EPR - This doesn't sound right to me.
+ // TODO - EPR - This doesn't sound right to me.
// Setup the reference on the cloned wire
final RuntimeComponentReference ref = new RuntimeComponentReferenceImpl();
ref.setComponent((RuntimeComponent) targetComponent);
@@ -245,7 +243,7 @@ public class CallbackReferenceImpl<B> extends CallableReferenceImpl<B> {
super.writeExternal(out);
out.writeObject(this.callbackID);
out.writeObject(this.convID);
-
+
// TODO - EPR - What to do about URI?
out.writeUTF(this.resolvedEndpoint.getBinding().getURI());
}