You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2009/11/13 22:49:19 UTC
svn commit: r836009 [6/7] - in /tuscany/java/sca:
itest/jms/exceptions/src/test/java/org/apache/tuscany/sca/binding/jms/
itest/jms/exceptions1/src/test/java/org/apache/tuscany/sca/binding/jms/
itest/jms/format-jmsobject/src/test/java/org/apache/tuscany...
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java Fri Nov 13 21:49:15 2009
@@ -21,17 +21,13 @@
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.Reader;
-import java.io.StringReader;
import java.io.StringWriter;
import java.security.AccessController;
import java.security.PrivilegedAction;
-import java.util.UUID;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
@@ -44,7 +40,6 @@
import org.apache.tuscany.sca.assembly.builder.BuilderContext;
import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint;
import org.apache.tuscany.sca.context.CompositeContext;
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor;
@@ -52,19 +47,19 @@
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory;
-import org.apache.tuscany.sca.core.assembly.impl.ReferenceParametersImpl;
import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
import org.apache.tuscany.sca.interfacedef.Interface;
+import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.runtime.ReferenceParameters;
+import org.apache.tuscany.sca.runtime.Invocable;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.oasisopen.sca.ServiceRuntimeException;
/**
@@ -78,27 +73,25 @@
protected transient ProxyFactory proxyFactory;
protected transient Class<B> businessInterface;
- protected transient Object proxy;
+ protected transient B proxy;
protected Object callbackID; // The callbackID should be serializable
- protected transient RuntimeComponent component;
- protected transient RuntimeComponentReference reference;
- protected transient EndpointReference endpointReference;
+ protected transient RuntimeEndpointReference endpointReference;
- protected String scdl;
-
- private transient XMLStreamReader xmlReader;
+// protected String scdl;
+//
+// private transient XMLStreamReader xmlReader;
protected transient CompositeContext compositeContext;
- private ExtensionPointRegistry registry;
- private FactoryExtensionPoint modelFactories;
+ protected ExtensionPointRegistry registry;
+ protected FactoryExtensionPoint modelFactories;
protected RuntimeAssemblyFactory assemblyFactory;
- private StAXArtifactProcessorExtensionPoint staxProcessors;
- private StAXArtifactProcessor<EndpointReference> staxProcessor;
- private XMLInputFactory xmlInputFactory;
- private XMLOutputFactory xmlOutputFactory;
- private BuilderExtensionPoint builders;
+ protected StAXArtifactProcessorExtensionPoint staxProcessors;
+ protected StAXArtifactProcessor<EndpointReference> staxProcessor;
+ protected XMLInputFactory xmlInputFactory;
+ protected XMLOutputFactory xmlOutputFactory;
+ protected BuilderExtensionPoint builders;
/*
* Public constructor for Externalizable serialization/deserialization
@@ -107,56 +100,24 @@
super();
}
- /*
- * Public constructor for use by XMLStreamReader2CallableReference
- */
- // TODO - EPR - Is this required
- public ServiceReferenceImpl(XMLStreamReader xmlReader) throws Exception {
- this.xmlReader = xmlReader;
- resolve();
- }
-
- protected ServiceReferenceImpl(Class<B> businessInterface,
- RuntimeComponent component,
- RuntimeComponentReference reference,
- EndpointReference endpointReference,
- ProxyFactory proxyFactory,
- CompositeContext compositeContext) {
- this.proxyFactory = proxyFactory;
+ public ServiceReferenceImpl(Class<B> businessInterface,
+ Invocable endpointReference,
+ CompositeContext compositeContext) {
this.businessInterface = businessInterface;
- this.component = component;
- this.reference = reference;
- this.endpointReference = endpointReference;
- this.compositeContext = compositeContext;
-
- getExtensions();
-
- // 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 one endpointReference so use that
- if (this.reference.getEndpointReferences().size() == 0){
- 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 " +
- component.getName() + " has more than one endpoint reference");
- }
-
- this.endpointReference = this.reference.getEndpointReferences().get(0);
+ this.endpointReference = (RuntimeEndpointReference) endpointReference;
+ if (compositeContext == null) {
+ compositeContext = endpointReference.getCompositeContext();
}
-
- // FIXME: Should we normalize the componentName/serviceName URI into an absolute SCA URI in the SCA binding?
- // sca:component1/component11/component112/service1?
- initCallbackID();
+ bind(compositeContext);
}
- private void getExtensions() {
+ public ServiceReferenceImpl(Class<B> businessInterface,
+ Invocable endpointReference) {
+ this(businessInterface, endpointReference, null);
+ }
+
+ protected void bind(CompositeContext context) {
+ this.compositeContext = context;
this.registry = compositeContext.getExtensionPointRegistry();
this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
@@ -165,68 +126,29 @@
this.staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class);
this.staxProcessor = staxProcessors.getProcessor(EndpointReference.class);
this.builders = registry.getExtensionPoint(BuilderExtensionPoint.class);
+ this.proxyFactory = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class));
}
- public ServiceReferenceImpl(Class<B> businessInterface, RuntimeWire wire, ProxyFactory proxyFactory) {
- this.proxyFactory = proxyFactory;
- this.businessInterface = businessInterface;
- //ExtensionPointRegistry registry = ((RuntimeWireImpl)wire).getExtensionPoints();
- //this.modelFactories = registry.getExtensionPoint(FactoryExtensionPoint.class);
- //this.assemblyFactory = (RuntimeAssemblyFactory)modelFactories.getFactory(AssemblyFactory.class);
- bind(wire);
- }
-
- public RuntimeWire getRuntimeWire() {
- try {
- resolve();
- if (endpointReference != null){
- return reference.getRuntimeWire(endpointReference);
- } else {
- return null;
- }
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public EndpointReference getEndpointReference() {
+ public RuntimeEndpointReference getEndpointReference() {
return endpointReference;
}
- protected void bind(RuntimeWire wire) {
- if (wire != null) {
- this.component = (RuntimeComponent)wire.getEndpointReference().getComponent();
- this.reference = (RuntimeComponentReference)wire.getEndpointReference().getReference();
- this.endpointReference = wire.getEndpointReference();
- this.compositeContext = component.getComponentContext().getCompositeContext();
- initCallbackID();
- }
- }
-
- protected void initCallbackID() {
- if (reference.getInterfaceContract() != null) {
- if (reference.getInterfaceContract().getCallbackInterface() != null) {
- this.callbackID = createCallbackID();
- }
- }
- }
-
public B getProxy() throws ObjectCreationException {
try {
if (proxy == null) {
proxy = createProxy();
}
- return businessInterface.cast(proxy);
+ return proxy;
} catch (Exception e) {
throw new ObjectCreationException(e);
}
}
- public void setProxy(Object proxy) {
+ public void setProxy(B proxy) {
this.proxy = proxy;
}
- protected Object createProxy() throws Exception {
+ protected B createProxy() throws Exception {
return proxyFactory.createProxy(this);
}
@@ -248,24 +170,6 @@
}
}
- public boolean isConversational() {
- try {
- resolve();
- return reference == null ? false : reference.getInterfaceContract().getInterface().isConversational();
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
- public Object getCallbackID() {
- try {
- resolve();
- return callbackID;
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
/**
* Follow a service promotion chain down to the inner most (non composite)
* component service.
@@ -295,21 +199,23 @@
}
// ============ WRITE AND READ THE REFERENCE TO EXTERNAL XML ========================
-
+
/**
* write the reference to a stream
*
* @see java.io.Externalizable#writeExternal(java.io.ObjectOutput)
*/
public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeObject(endpointReference);
+ /*
try {
String xml = null;
- if (scdl == null){
+ if (scdl == null) {
xml = toXMLString();
} else {
xml = scdl;
}
-
+
if (xml == null) {
out.writeBoolean(false);
} else {
@@ -320,73 +226,128 @@
// e.printStackTrace();
throw new IOException(e.toString());
}
- }
-
+ */
+ }
+
/**
* write the endpoint reference into an xml string
*/
- public String toXMLString() throws IOException, XMLStreamException, ContributionWriteException{
+ public String toXMLString() throws IOException, XMLStreamException, ContributionWriteException {
StringWriter writer = new StringWriter();
XMLStreamWriter streamWriter = xmlOutputFactory.createXMLStreamWriter(writer);
staxProcessor.write(endpointReference, streamWriter, new ProcessorContext(registry));
return writer.toString();
- }
-
+ }
+
/**
* Read the reference from a stream
*
* @see java.io.Externalizable#readExternal(java.io.ObjectInput)
*/
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ this.endpointReference = (RuntimeEndpointReference) in.readObject();
+ // Force resolve
+ endpointReference.getComponent();
+ bind(endpointReference.getCompositeContext());
+
+ RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
+ reference.setComponent((RuntimeComponent)endpointReference.getComponent());
+
+ Interface i = reference.getInterfaceContract().getInterface();
+ if (i instanceof JavaInterface) {
+ JavaInterface javaInterface = (JavaInterface)i;
+ if (javaInterface.isUnresolved()) {
+ // Allow privileged access to get ClassLoader. Requires RuntimePermission in
+ // security policy.
+ ClassLoader classLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+ public ClassLoader run() {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+
+ javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName()));
+ JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeContext);
+
+ try {
+ javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass());
+ } catch (InvalidInterfaceException e) {
+ throw new ServiceRuntimeException(e);
+ }
+ //FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO),
+ // this needs to be done here. We usually search for XSDs in the current
+ // contribution at resolve time. Is it possible to locate the current
+ // contribution at runtime?
+ }
+ this.businessInterface = (Class<B>)javaInterface.getJavaClass();
+ }
+
+ Binding binding = endpointReference.getBinding();
+ if (binding != null) {
+ BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getType());
+ if (bindingBuilder != null) {
+ org.apache.tuscany.sca.assembly.builder.BuilderContext context = new BuilderContext(registry);
+ bindingBuilder.build(endpointReference.getComponent(), reference, endpointReference.getBinding(), context);
+ }
+ }
+
+ this.proxyFactory = getProxyFactory(this.compositeContext);
+
+ /*
+ endpointReference.bind(CompositeContext.getCurrentCompositeContext());
+ endpointReference.rebuild();
+ */
+ /*
final boolean hasSCDL = in.readBoolean();
if (hasSCDL) {
this.scdl = in.readUTF();
} else {
this.scdl = null;
}
- }
-
+ */
+ }
+
/**
* Read xml string into the endpoint reference
*/
+ /*
public void fromXMLString() throws IOException, XMLStreamException, ContributionReadException {
-
+
XMLStreamReader streamReader = xmlReader;
-
- if (scdl != null ){
+
+ if (scdl != null) {
Reader reader = new StringReader(scdl);
-
- if (xmlInputFactory == null){
+
+ if (xmlInputFactory == null) {
// this is a reference being read from a external stream
// so set up enough of the reference in order to resolved the
// xml being read
- this.compositeContext = CompositeContext.getCurrentCompositeContext();
- getExtensions();
+ bind(CompositeContext.getCurrentCompositeContext());
}
-
+
streamReader = xmlInputFactory.createXMLStreamReader(reader);
}
-
- endpointReference = staxProcessor.read(streamReader, new ProcessorContext(registry));
-
+
+ endpointReference = (RuntimeEndpointReference) staxProcessor.read(streamReader, new ProcessorContext(registry));
+
// ok to GC
xmlReader = null;
scdl = null;
}
-
+ */
+
/**
* @throws IOException
*/
private synchronized void resolve() throws Exception {
- if ((scdl != null || xmlReader != null) && component == null && reference == null) {
+ /*
+ if ((scdl != null || xmlReader != null) && endpointReference == null) {
fromXMLString();
-
- this.component = (RuntimeComponent)endpointReference.getComponent();
- compositeContext.bindComponent(this.component);
-
- this.reference = (RuntimeComponentReference)endpointReference.getReference();
- this.reference.setComponent(this.component);
-
+
+ compositeContext.bindComponent((RuntimeComponent) endpointReference.getComponent());
+
+ RuntimeComponentReference reference = (RuntimeComponentReference)endpointReference.getReference();
+ reference.setComponent((RuntimeComponent)endpointReference.getComponent());
+
ReferenceParameters parameters = null;
for (Object ext : reference.getExtensions()) {
if (ext instanceof ReferenceParameters) {
@@ -394,7 +355,7 @@
break;
}
}
-
+
if (parameters != null) {
this.callbackID = parameters.getCallbackID();
}
@@ -410,10 +371,10 @@
return Thread.currentThread().getContextClassLoader();
}
});
-
+
javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName()));
JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeContext);
-
+
javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass());
//FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO),
// this needs to be done here. We usually search for XSDs in the current
@@ -422,23 +383,24 @@
}
this.businessInterface = (Class<B>)javaInterface.getJavaClass();
}
-
+
Binding binding = endpointReference.getBinding();
if (binding != null) {
BindingBuilder bindingBuilder = builders.getBindingBuilder(binding.getType());
if (bindingBuilder != null) {
BuilderContext context = new BuilderContext(registry);
- bindingBuilder.build(component, reference, endpointReference.getBinding(), context);
+ bindingBuilder.build(endpointReference.getComponent(), reference, endpointReference.getBinding(), context);
}
}
- this.proxyFactory = getProxyFactory(this.compositeContext);
+ this.proxyFactory = getProxyFactory(this.compositeContext);
} else if (compositeContext == null) {
this.compositeContext = CompositeContext.getCurrentCompositeContext();
if (this.compositeContext != null) {
this.proxyFactory = getProxyFactory(this.compositeContext);
}
- }
+ }
+ */
}
private JavaInterfaceFactory getJavaInterfaceFactory(CompositeContext compositeContext) {
@@ -447,35 +409,19 @@
JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
return javaInterfaceFactory;
}
-
+
private ProxyFactory getProxyFactory(CompositeContext compositeContext) {
ExtensionPointRegistry extensionPointRegistry = compositeContext.getExtensionPointRegistry();
- ProxyFactoryExtensionPoint proxyFactories = extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
+ ProxyFactoryExtensionPoint proxyFactories =
+ extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class);
return new ExtensibleProxyFactory(proxyFactories);
}
-
- // ==================================================================================
-
- /**
- * Create a callback id
- *
- * @return the callback id
- */
- private String createCallbackID() {
- return UUID.randomUUID().toString();
- }
-
- public void attachCallbackID(Object callbackID) {
- this.callbackID = callbackID;
- }
- protected ReferenceParameters getReferenceParameters() {
- ReferenceParameters parameters = new ReferenceParametersImpl();
- parameters.setCallbackID(callbackID);
- return parameters;
- }
+ // ==================================================================================
+ /*
public XMLStreamReader getXMLReader() {
return xmlReader;
}
+ */
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallableReferenceObjectFactory.java Fri Nov 13 21:49:15 2009
@@ -18,11 +18,10 @@
*/
package org.apache.tuscany.sca.core.invocation;
-import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.factory.ObjectFactory;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.oasisopen.sca.ServiceReference;
/**
@@ -32,9 +31,7 @@
*/
public class CallableReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> {
private Class<?> businessInterface;
- private RuntimeComponent component;
- private RuntimeComponentReference reference;
- private EndpointReference endpointReference;
+ private RuntimeEndpointReference endpointReference;
/**
* Constructor.
@@ -47,17 +44,14 @@
* @param binding the binding for the reference
*/
public CallableReferenceObjectFactory(Class<?> businessInterface,
- RuntimeComponent component,
- RuntimeComponentReference reference,
- EndpointReference endpointReference) {
+ RuntimeEndpointReference endpointReference) {
this.businessInterface = businessInterface;
- this.component = component;
- this.reference = reference;
this.endpointReference = endpointReference;
}
public ServiceReference<?> getInstance() throws ObjectCreationException {
- return component.getComponentContext().getServiceReference(businessInterface, reference, endpointReference);
+ RuntimeComponent component = (RuntimeComponent) endpointReference.getComponent();
+ return component.getComponentContext().getServiceReference(businessInterface, endpointReference);
}
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackReferenceObjectFactory.java Fri Nov 13 21:49:15 2009
@@ -20,11 +20,10 @@
import java.util.List;
+import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
-import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
import org.oasisopen.sca.ServiceReference;
/**
@@ -35,16 +34,16 @@
public class CallbackReferenceObjectFactory implements ObjectFactory<ServiceReference<?>> {
private Class<?> businessInterface;
private ProxyFactory proxyFactory;
- private List<RuntimeWire> wires;
+ private List<EndpointReference> wires;
- public CallbackReferenceObjectFactory(Class<?> interfaze, ProxyFactory proxyFactory, List<RuntimeWire> wires) {
+ public CallbackReferenceObjectFactory(Class<?> interfaze, ProxyFactory proxyFactory, List<EndpointReference> wires) {
this.businessInterface = interfaze;
this.proxyFactory = proxyFactory;
this.wires = wires;
}
public ServiceReference<?> getInstance() throws ObjectCreationException {
- return new CallbackServiceReferenceImpl(businessInterface, wires, proxyFactory);
+ return new CallbackServiceReferenceImpl(businessInterface, wires);
}
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CallbackWireObjectFactory.java Fri Nov 13 21:49:15 2009
@@ -22,7 +22,7 @@
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.Invocable;
/**
* Returns proxy instance for a wire callback
@@ -32,9 +32,9 @@
public class CallbackWireObjectFactory<B> implements ObjectFactory<B> {
private Class<B> businessInterface;
private ProxyFactory proxyFactory;
- private List<RuntimeWire> wires;
+ private List<Invocable> wires;
- public CallbackWireObjectFactory(Class<B> interfaze, ProxyFactory proxyFactory, List<RuntimeWire> wires) {
+ public CallbackWireObjectFactory(Class<B> interfaze, ProxyFactory proxyFactory, List<Invocable> wires) {
this.businessInterface = interfaze;
this.proxyFactory = proxyFactory;
this.wires = wires;
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/CglibProxyFactory.java Fri Nov 13 21:49:15 2009
@@ -28,12 +28,13 @@
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
+import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
import org.apache.tuscany.sca.core.invocation.impl.JDKCallbackInvocationHandler;
import org.apache.tuscany.sca.core.invocation.impl.JDKInvocationHandler;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.Invocable;
import org.oasisopen.sca.ServiceReference;
/**
@@ -49,8 +50,8 @@
}
- public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
- ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, this);
+ public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException {
+ ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, null);
return createProxy(serviceReference);
}
@@ -72,8 +73,8 @@
* create the callback proxy with cglib. use the same
* JDKCallbackInvocationHandler as JDKProxyService.
*/
- public <T> T createCallbackProxy(Class<T> interfaze, final List<RuntimeWire> wires) throws ProxyCreationException {
- ServiceReferenceImpl<T> callbackReference = new ServiceReferenceImpl(interfaze, wires.get(0), this);
+ public <T> T createCallbackProxy(Class<T> interfaze, final List<? extends Invocable> wires) throws ProxyCreationException {
+ ServiceReferenceImpl<T> callbackReference = new ServiceReferenceImpl(interfaze, wires.get(0), null);
return callbackReference != null ? createCallbackProxy(callbackReference) : null;
}
@@ -81,14 +82,15 @@
* create the callback proxy with cglib. use the same
* JDKCallbackInvocationHandler as JDKProxyService.
*/
- public <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException {
+ public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
Enhancer enhancer = new Enhancer();
Class<T> interfaze = callbackReference.getBusinessInterface();
enhancer.setSuperclass(interfaze);
enhancer.setCallback(new CglibMethodInterceptor<T>(callbackReference));
- Object proxy = enhancer.create();
- callbackReference.setProxy(proxy);
- return interfaze.cast(proxy);
+ Object object = enhancer.create();
+ T proxy = interfaze.cast(object);
+ ((ServiceReferenceExt<T>)callbackReference).setProxy(proxy);
+ return proxy;
}
@SuppressWarnings("unchecked")
@@ -124,18 +126,6 @@
invocationHandler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
}
- /*
- public CglibMethodInterceptor(Class<T> interfaze, RuntimeWire wire) {
- ServiceReference<T> serviceRef = new ServiceReferenceImpl<T>(interfaze, wire, CglibProxyFactory.this);
- invocationHandler = new JDKInvocationHandler(messageFactory, serviceRef);
- }
-
- public CglibMethodInterceptor(Class<T> interfaze, List<RuntimeWire> wires) {
- CallbackReferenceImpl ref = new CallbackReferenceImpl(interfaze, CglibProxyFactory.this, wires);
- invocationHandler = new JDKCallbackInvocationHandler(messageFactory, ref);
- }
- */
-
/**
* @see net.sf.cglib.proxy.MethodInterceptor#intercept(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], net.sf.cglib.proxy.MethodProxy)
*/
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleProxyFactory.java Fri Nov 13 21:49:15 2009
@@ -21,8 +21,7 @@
import java.util.List;
-import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.Invocable;
import org.oasisopen.sca.ServiceReference;
/**
@@ -58,7 +57,7 @@
* @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createCallbackProxy(java.lang.Class,
* java.util.List)
*/
- public <T> T createCallbackProxy(Class<T> interfaze, List<RuntimeWire> wires) throws ProxyCreationException {
+ public <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> wires) throws ProxyCreationException {
ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
if (interfaze.isInterface()) {
@@ -78,7 +77,7 @@
}
}
- public <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException {
+ public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
if (callbackReference.getBusinessInterface().isInterface()) {
@@ -90,9 +89,9 @@
/**
* @see org.apache.tuscany.sca.core.invocation.ProxyFactory#createProxy(java.lang.Class,
- * org.apache.tuscany.sca.runtime.RuntimeWire)
+ * org.apache.tuscany.sca.runtime.Invocable)
*/
- public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
+ public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException {
ProxyFactory interfaceFactory = proxyFactories.getInterfaceProxyFactory();
ProxyFactory classFactory = proxyFactories.getClassProxyFactory();
if (interfaze.isInterface()) {
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ExtensibleWireProcessor.java Fri Nov 13 21:49:15 2009
@@ -18,7 +18,8 @@
*/
package org.apache.tuscany.sca.core.invocation;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
@@ -28,16 +29,22 @@
* @version $Rev$ $Date$
*/
public class ExtensibleWireProcessor implements RuntimeWireProcessor {
-
+
private RuntimeWireProcessorExtensionPoint processors;
public ExtensibleWireProcessor(RuntimeWireProcessorExtensionPoint processors) {
this.processors = processors;
}
-
- public void process(RuntimeWire wire) {
+
+ public void process(RuntimeEndpoint endpoint) {
+ for (RuntimeWireProcessor processor : processors.getWireProcessors()) {
+ processor.process(endpoint);
+ }
+ }
+
+ public void process(RuntimeEndpointReference endpointReference) {
for (RuntimeWireProcessor processor : processors.getWireProcessors()) {
- processor.process(wire);
+ processor.process(endpointReference);
}
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java Fri Nov 13 21:49:15 2009
@@ -18,9 +18,7 @@
*/
package org.apache.tuscany.sca.core.invocation;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -31,7 +29,6 @@
import org.apache.tuscany.sca.invocation.Interceptor;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
import org.apache.tuscany.sca.work.WorkScheduler;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -123,7 +120,7 @@
*/
private static class ImmutableMessage implements Message {
- public Object getBody() {
+ public <T> T getBody() {
return null;
}
@@ -133,10 +130,6 @@
}
}
- public void setCallbackWires(LinkedList<RuntimeWire> wires) {
-
- }
-
public Object getMessageID() {
return null;
}
@@ -176,17 +169,6 @@
public void setOperation(Operation op) {
throw new UnsupportedOperationException();
}
-
- /**
- * @see org.apache.tuscany.sca.invocation.Message#getReplyTo()
- */
- public EndpointReference getReplyTo() {
- return null;
- }
-
- public Map<String, Object> getQoSContext() {
- return null;
- }
public List<Object> getHeaders() {
return null;
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ProxyFactory.java Fri Nov 13 21:49:15 2009
@@ -20,8 +20,7 @@
import java.util.List;
-import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.Invocable;
import org.oasisopen.sca.ServiceReference;
/**
@@ -36,11 +35,11 @@
* Creates a Java proxy for the given wire
*
* @param interfaze the interface the proxy implements
- * @param wire the wire to proxy
+ * @param invocable the wire to proxy
* @return the proxy
* @throws ProxyCreationException
*/
- <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException;
+ <T> T createProxy(Class<T> interfaze, Invocable invocable) throws ProxyCreationException;
/**
* Creates a Java proxy for the given CallableReference
@@ -58,7 +57,7 @@
* @return the proxy
* @throws ProxyCreationException
*/
- <T> T createCallbackProxy(Class<T> interfaze, List<RuntimeWire> wires) throws ProxyCreationException;
+ <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> invocables) throws ProxyCreationException;
/**
* Creates a Java proxy for the given callback reference
@@ -67,7 +66,7 @@
* @return the proxy
* @throws ProxyCreationException
*/
- <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException;
+ <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException;
/**
* Cast a proxy to a CallableReference.
Added: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java?rev=836009&view=auto
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java (added)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java Fri Nov 13 21:49:15 2009
@@ -0,0 +1,97 @@
+/*
+ * 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.core.invocation;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
+import org.apache.tuscany.sca.context.ThreadMessageContext;
+import org.apache.tuscany.sca.interfacedef.Operation;
+import org.apache.tuscany.sca.invocation.InvocationChain;
+import org.apache.tuscany.sca.invocation.Invoker;
+import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.runtime.Invocable;
+
+/**
+ * Invoker for a endpoint or endpoint reference
+ * @version $Rev$ $Date$
+ */
+public class RuntimeInvoker implements Invoker {
+ protected MessageFactory messageFactory;
+ protected Invocable invocable;
+
+ public RuntimeInvoker(MessageFactory messageFactory, Invocable invocable) {
+ this.messageFactory = messageFactory;
+ this.invocable = invocable;
+ }
+
+ public Message invokeBinding(Message msg) {
+ Message context = ThreadMessageContext.setMessageContext(msg);
+ try {
+ return invocable.getBindingInvocationChain().getHeadInvoker().invoke(msg);
+ } finally {
+ ThreadMessageContext.setMessageContext(context);
+ }
+ }
+
+ public Message invoke(Message msg) {
+ return invoke(msg.getOperation(), msg);
+ }
+
+ public Object invoke(Operation operation, Object[] args) throws InvocationTargetException {
+ Message msg = messageFactory.createMessage();
+ msg.setBody(args);
+ Message resp = invoke(operation, msg);
+ Object body = resp.getBody();
+ if (resp.isFault()) {
+ throw new InvocationTargetException((Throwable)body);
+ }
+ return body;
+ }
+
+
+ public Message invoke(Operation operation, Message msg) {
+ InvocationChain chain = invocable.getInvocationChain(operation);
+ return invoke(chain, msg);
+ }
+
+ public Message invoke(InvocationChain chain, Message msg) {
+
+ if (invocable instanceof Endpoint) {
+ msg.setTo((Endpoint)invocable);
+ } else if (invocable instanceof EndpointReference) {
+ msg.setFrom((EndpointReference)invocable);
+ }
+
+ Invoker headInvoker = chain.getHeadInvoker();
+ Operation operation = chain.getTargetOperation();
+ msg.setOperation(operation);
+
+ Message msgContext = ThreadMessageContext.setMessageContext(msg);
+ try {
+ return headInvoker.invoke(msg);
+ } finally {
+ ThreadMessageContext.setMessageContext(msgContext);
+ }
+ }
+
+}
Propchange: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/WireObjectFactory.java Fri Nov 13 21:49:15 2009
@@ -22,7 +22,7 @@
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.factory.ObjectFactory;
import org.apache.tuscany.sca.core.invocation.impl.NoMethodForOperationException;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.Invocable;
/**
* Uses a wire to return an object instance
@@ -31,7 +31,7 @@
*/
public class WireObjectFactory<T> implements ObjectFactory<T> {
private Class<T> interfaze;
- private RuntimeWire wire;
+ private Invocable wire;
private ProxyFactory proxyService;
/**
@@ -42,14 +42,14 @@
* @param proxyService the wire service to create the proxy
* @throws NoMethodForOperationException
*/
- public WireObjectFactory(Class<T> interfaze, RuntimeWire wire, ProxyFactory proxyService) {
+ public WireObjectFactory(Class<T> interfaze, Invocable wire, ProxyFactory proxyService) {
this.interfaze = interfaze;
this.wire = wire;
this.proxyService = proxyService;
}
public T getInstance() throws ObjectCreationException {
- return new ServiceReferenceImpl<T>(interfaze, wire, proxyService).getProxy();
+ return new ServiceReferenceImpl<T>(interfaze, wire, null).getProxy();
}
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java Fri Nov 13 21:49:15 2009
@@ -21,13 +21,11 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
-import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceReference;
import org.oasisopen.sca.ServiceRuntimeException;
/**
@@ -39,7 +37,7 @@
public class JDKCallbackInvocationHandler extends JDKInvocationHandler {
private static final long serialVersionUID = -3350283555825935609L;
- public JDKCallbackInvocationHandler(MessageFactory messageFactory, ServiceReferenceImpl ref) {
+ public JDKCallbackInvocationHandler(MessageFactory messageFactory, ServiceReference<?> ref) {
super(messageFactory, ref);
this.fixedWire = false;
}
@@ -53,7 +51,7 @@
}
// obtain a dedicated wire to be used for this callback invocation
- RuntimeWire wire = ((CallbackServiceReferenceImpl)callableReference).getCallbackWire();
+ RuntimeEndpointReference wire = ((CallbackServiceReferenceImpl)callableReference).getCallbackEPR();
if (wire == null) {
//FIXME: need better exception
throw new ServiceRuntimeException("No callback wire found");
@@ -67,13 +65,12 @@
}
try {
- return invoke(chain, args, wire, wire.getEndpointReference());
+ return invoke(chain, args, wire);
} catch (InvocationTargetException e) {
Throwable t = e.getCause();
- throw e;
+ throw t;
} finally {
// allow the cloned wire to be reused by subsequent callbacks
- ((RuntimeWireImpl)wire).releaseWire();
}
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java Fri Nov 13 21:49:15 2009
@@ -28,11 +28,8 @@
import java.util.Map;
import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.context.ThreadMessageContext;
import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.scope.TargetResolutionException;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
@@ -40,7 +37,8 @@
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.Invocable;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.oasisopen.sca.ServiceReference;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -52,9 +50,8 @@
protected boolean conversational;
protected MessageFactory messageFactory;
- protected EndpointReference source;
protected Endpoint target;
- protected RuntimeWire wire;
+ protected RuntimeEndpointReference source;
protected ServiceReferenceExt<?> callableReference;
protected Class<?> businessInterface;
@@ -62,11 +59,10 @@
protected transient Map<Method, InvocationChain> chains = new IdentityHashMap<Method, InvocationChain>();
- public JDKInvocationHandler(MessageFactory messageFactory, Class<?> businessInterface, RuntimeWire wire) {
+ public JDKInvocationHandler(MessageFactory messageFactory, Class<?> businessInterface, RuntimeEndpointReference source) {
this.messageFactory = messageFactory;
- this.wire = wire;
+ this.source = source;
this.businessInterface = businessInterface;
- init(this.wire);
}
public JDKInvocationHandler(MessageFactory messageFactory, ServiceReference<?> callableReference) {
@@ -74,49 +70,40 @@
this.callableReference = (ServiceReferenceExt<?>)callableReference;
if (callableReference != null) {
this.businessInterface = callableReference.getBusinessInterface();
- this.wire = ((ServiceReferenceExt<?>)callableReference).getRuntimeWire();
- if (wire != null) {
- init(wire);
- }
+ this.source = (RuntimeEndpointReference) this.callableReference.getEndpointReference();
}
}
- protected void init(RuntimeWire wire) {
- }
public Class<?> getBusinessInterface() {
return businessInterface;
}
protected Object getCallbackID() {
- return null;
+ return null;
}
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (Object.class == method.getDeclaringClass()) {
return invokeObjectMethod(method, args);
}
- if (wire == null) {
- throw new ServiceRuntimeException("No runtime wire is available");
+ if (source == null) {
+ throw new ServiceRuntimeException("No runtime source is available");
}
- if (wire.isOutOfDate()) {
- wire.rebuild();
+ if (source.isOutOfDate()) {
+ source.rebuild();
chains.clear();
}
- InvocationChain chain = getInvocationChain(method, wire);
+ InvocationChain chain = getInvocationChain(method, source);
if (chain == null) {
throw new IllegalArgumentException("No matching operation is found: " + method);
}
-
- // The EndpointReference is not now resolved until the invocation chain
- // is first created so reset the source here
- source = wire.getEndpointReference();
- // send the invocation down the wire
- Object result = invoke(chain, args, wire, source);
+ // send the invocation down the source
+ Object result = invoke(chain, args, source);
return result;
}
@@ -200,12 +187,12 @@
}
- protected synchronized InvocationChain getInvocationChain(Method method, RuntimeWire wire) {
+ protected synchronized InvocationChain getInvocationChain(Method method, Invocable source) {
if (fixedWire && chains.containsKey(method)) {
return chains.get(method);
}
InvocationChain found = null;
- for (InvocationChain chain : wire.getInvocationChains()) {
+ for (InvocationChain chain : source.getInvocationChains()) {
Operation operation = chain.getSourceOperation();
if (operation.isDynamic()) {
operation.setName(method.getName());
@@ -226,14 +213,14 @@
this.target = endpoint;
}
- protected Object invoke(InvocationChain chain, Object[] args, RuntimeWire wire, EndpointReference source)
+ protected Object invoke(InvocationChain chain, Object[] args, RuntimeEndpointReference source)
throws Throwable {
Message msg = messageFactory.createMessage();
msg.setFrom(source);
if (target != null) {
msg.setTo(target);
} else {
- msg.setTo(wire.getEndpoint());
+ msg.setTo(source.getTargetEndpoint());
}
Invoker headInvoker = chain.getHeadInvoker();
Operation operation = chain.getTargetOperation();
@@ -241,12 +228,11 @@
msg.setBody(args);
Message msgContext = ThreadMessageContext.getMessageContext();
-
- handleCallback(msg, wire);
+
ThreadMessageContext.setMessageContext(msg);
- boolean abnormalEndConversation = false;
+
try {
- // dispatch the wire down the chain and get the response
+ // dispatch the source down the chain and get the response
Message resp = headInvoker.invoke(msg);
Object body = resp.getBody();
if (resp.isFault()) {
@@ -254,29 +240,12 @@
}
return body;
} finally {
- //conversationPostInvoke(msg, wire, abnormalEndConversation);
+ //conversationPostInvoke(msg, source, abnormalEndConversation);
ThreadMessageContext.setMessageContext(msgContext);
}
}
/**
- * @param msg
- * @param wire
- * @param interfaze
- * @throws TargetResolutionException
- */
- private void handleCallback(Message msg, RuntimeWire wire)
- throws TargetResolutionException {
-
- //ReferenceParameters parameters = msg.getFrom().getReferenceParameters();
- //parameters.setCallbackID(getCallbackID());
-
- if (msg.getFrom() == null || msg.getFrom().getCallbackEndpoint() == null) {
- return;
- }
- }
-
- /**
* @return the callableReference
*/
public ServiceReference<?> getCallableReference() {
@@ -290,29 +259,4 @@
this.callableReference = (ServiceReferenceExt<?>)callableReference;
}
- /**
- * Minimal wrapper for a callback object contained in a ServiceReference
- */
- private static class CallbackObjectWrapper<T> implements InstanceWrapper<T> {
-
- private T instance;
-
- private CallbackObjectWrapper(T instance) {
- this.instance = instance;
- }
-
- public T getInstance() {
- return instance;
- }
-
- public void start() {
- // do nothing
- }
-
- public void stop() {
- // do nothing
- }
-
- }
-
}
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKProxyFactory.java Fri Nov 13 21:49:15 2009
@@ -32,13 +32,14 @@
import org.apache.tuscany.sca.common.java.collection.LRUCache;
import org.apache.tuscany.sca.core.LifeCycleListener;
+import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
import org.apache.tuscany.sca.core.context.impl.CallbackServiceReferenceImpl;
import org.apache.tuscany.sca.core.context.impl.ServiceReferenceImpl;
import org.apache.tuscany.sca.core.invocation.ProxyCreationException;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.invocation.MessageFactory;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.Invocable;
import org.oasisopen.sca.ServiceReference;
@@ -60,8 +61,8 @@
* The original createProxy method assumes that the proxy doesn't want to
* share conversation state so sets the conversation object to null
*/
- public <T> T createProxy(Class<T> interfaze, RuntimeWire wire) throws ProxyCreationException {
- ServiceReference<T> serviceReference = new ServiceReferenceImpl(interfaze, wire, this);
+ public <T> T createProxy(Class<T> interfaze, Invocable wire) throws ProxyCreationException {
+ ServiceReference<T> serviceReference = new ServiceReferenceImpl<T>(interfaze, wire, null);
return createProxy(serviceReference);
}
@@ -80,9 +81,9 @@
return interfaze.getClassLoader();
}
});
- Object proxy = newProxyInstance(cl, new Class[] {interfaze}, handler);
- ((ServiceReferenceImpl)callableReference).setProxy(proxy);
- return interfaze.cast(proxy);
+ T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler));
+ ((ServiceReferenceExt<T>)callableReference).setProxy(proxy);
+ return proxy;
}
private boolean isAsync(Class<?> interfaze) {
@@ -103,19 +104,19 @@
return false;
}
- public <T> T createCallbackProxy(Class<T> interfaze, List<RuntimeWire> wires) throws ProxyCreationException {
- ServiceReferenceImpl<T> callbackReference = new CallbackServiceReferenceImpl(interfaze, wires, this);
+ public <T> T createCallbackProxy(Class<T> interfaze, List<? extends Invocable> wires) throws ProxyCreationException {
+ ServiceReferenceImpl<T> callbackReference = new CallbackServiceReferenceImpl(interfaze, wires);
return callbackReference != null ? createCallbackProxy(callbackReference) : null;
}
- public <T> T createCallbackProxy(ServiceReferenceImpl<T> callbackReference) throws ProxyCreationException {
+ public <T> T createCallbackProxy(ServiceReference<T> callbackReference) throws ProxyCreationException {
assert callbackReference != null;
Class<T> interfaze = callbackReference.getBusinessInterface();
InvocationHandler handler = new JDKCallbackInvocationHandler(messageFactory, callbackReference);
ClassLoader cl = interfaze.getClassLoader();
- Object proxy = newProxyInstance(cl, new Class[] {interfaze}, handler);
- callbackReference.setProxy(proxy);
- return interfaze.cast(proxy);
+ T proxy = interfaze.cast(newProxyInstance(cl, new Class[] {interfaze}, handler));
+ ((ServiceReferenceExt<T>) callbackReference).setProxy(proxy);
+ return proxy;
}
public <B, R extends ServiceReference<B>> R cast(B target) throws IllegalArgumentException {
Modified: tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java (original)
+++ tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/runtime/impl/EndpointReferenceBinderImpl.java Fri Nov 13 21:49:15 2009
@@ -68,7 +68,7 @@
/**
* Build a single endpoint reference
*
- * @param endpoint
+ * @param invocable
* @param monitor
*/
public boolean bind(EndpointRegistry endpointRegistry, EndpointReference endpointReference) {
Modified: tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java (original)
+++ tuscany/java/sca/modules/endpoint-tribes/src/main/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistry.java Fri Nov 13 21:49:15 2009
@@ -51,6 +51,7 @@
import org.apache.tuscany.sca.endpoint.tribes.MapStore.MapListener;
import org.apache.tuscany.sca.runtime.EndpointListener;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
/**
* A replicated EndpointRegistry based on Apache Tomcat Tribes
@@ -291,7 +292,7 @@
endpoint.setRemote(true);
}
// if (!entry.isPrimary()) {
- endpoint.setExtensionPointRegistry(registry);
+ ((RuntimeEndpoint) endpoint).bind(registry, this);
// }
foundEndpoints.add(endpoint);
logger.fine("Found endpoint with matching service - " + endpoint);
@@ -359,7 +360,7 @@
logger.info(id + " Remote endpoint added: " + entry.getValue());
newEp.setRemote(true);
}
- newEp.setExtensionPointRegistry(registry);
+ ((RuntimeEndpoint) newEp).bind(registry, this);
for (EndpointListener listener : listeners) {
listener.endpointAdded(newEp);
}
@@ -384,7 +385,7 @@
}
Endpoint oldEp = (Endpoint)oldEntry.getValue();
Endpoint newEp = (Endpoint)newEntry.getValue();
- newEp.setExtensionPointRegistry(registry);
+ ((RuntimeEndpoint) newEp).bind(registry, this);
for (EndpointListener listener : listeners) {
listener.endpointUpdated(oldEp, newEp);
}
Modified: tuscany/java/sca/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java (original)
+++ tuscany/java/sca/modules/endpoint-tribes/src/test/java/org/apache/tuscany/sca/endpoint/tribes/ReplicatedEndpointRegistryTestCase.java Fri Nov 13 21:49:15 2009
@@ -23,6 +23,7 @@
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@@ -42,7 +43,7 @@
Endpoint e1 = assemblyFactory.createEndpoint();
e1.setURI("e1uri");
- e1.setExtensionPointRegistry(extensionPoints);
+ ((RuntimeEndpoint) e1).bind(extensionPoints, ep1);
ep1.addEndpoint(e1);
Endpoint e1p = ep1.getEndpoint("e1uri");
Modified: tuscany/java/sca/modules/endpoint-zookeeper/src/main/java/org/apache/tuscany/sca/endpoint/zookeeper/DistributedRegistry.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/endpoint-zookeeper/src/main/java/org/apache/tuscany/sca/endpoint/zookeeper/DistributedRegistry.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/endpoint-zookeeper/src/main/java/org/apache/tuscany/sca/endpoint/zookeeper/DistributedRegistry.java (original)
+++ tuscany/java/sca/modules/endpoint-zookeeper/src/main/java/org/apache/tuscany/sca/endpoint/zookeeper/DistributedRegistry.java Fri Nov 13 21:49:15 2009
@@ -35,6 +35,7 @@
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.runtime.EndpointListener;
import org.apache.tuscany.sca.runtime.EndpointRegistry;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.ZooKeeper;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -187,7 +188,7 @@
logger.fine("Matching against - " + endpoint);
if (matches(targetEndpoint.getURI(), endpoint.getURI())) {
// if (!entry.isPrimary()) {
- endpoint.setExtensionPointRegistry(registry);
+ ((RuntimeEndpoint) endpoint).bind(registry, this);
// }
foundEndpoints.add(endpoint);
logger.fine("Found endpoint with matching service - " + endpoint);
@@ -241,7 +242,7 @@
}
public void entryAdded(Endpoint value) {
- value.setExtensionPointRegistry(registry);
+ ((RuntimeEndpoint) value).bind(registry, this);
for (EndpointListener listener : listeners) {
listener.endpointAdded(value);
}
@@ -254,7 +255,7 @@
}
public void entryUpdated(Endpoint oldEp, Endpoint newEp) {
- newEp.setExtensionPointRegistry(registry);
+ ((RuntimeEndpoint) newEp).bind(registry, this);
for (EndpointListener listener : listeners) {
listener.endpointUpdated(oldEp, newEp);
}
Modified: tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java (original)
+++ tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEExternalService.java Fri Nov 13 21:49:15 2009
@@ -26,7 +26,6 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.ode.bpel.iapi.Endpoint;
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MessageExchange;
import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
@@ -38,7 +37,7 @@
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -89,10 +88,10 @@
// Fetching the reference based on the data held in the PRC / Endpoint
String refName = channel.getEndpoint().serviceName.getLocalPart();
RuntimeComponentReference runtimeComponentReference = getReferenceByName( tuscanyRuntimeComponent, refName );
- RuntimeWire runtimeWire = getRuntimeWire( runtimeComponentReference, partnerRoleMessageExchange );
+ RuntimeEndpointReference epr = getEndpointReference( runtimeComponentReference, partnerRoleMessageExchange );
// convert operations
Operation operation =
- findOperation(partnerRoleMessageExchange.getOperation().getName(), runtimeComponentReference);
+ findOperation(partnerRoleMessageExchange.getOperation().getName(), epr);
/*
This is how a request looks like (payload is wrapped with extra info)
@@ -122,7 +121,7 @@
boolean success = false;
try {
- result = runtimeWire.invoke(operation, args);
+ result = epr.invoke(operation, args);
success = true;
} catch (Exception e) {
e.printStackTrace();
@@ -194,7 +193,7 @@
* @param componentReference - the reference
* @return - the RuntimeWire - null if it cannot be found
*/
- private RuntimeWire getRuntimeWire( RuntimeComponentReference componentReference,
+ private RuntimeEndpointReference getEndpointReference( RuntimeComponentReference componentReference,
PartnerRoleMessageExchange mex) {
if( componentReference.isForCallback() ) {
// Where there is a callback, it is necessary to create a specialized wire, based on callback information
@@ -205,42 +204,42 @@
Long processID = _server.getProcessIDFromMex(mex.getMessageExchangeId());
org.apache.tuscany.sca.assembly.EndpointReference callbackEPR =
_server.getCallbackMetadata(processID, componentReference.getName());
- RuntimeWire wire = selectCallbackWire( callbackEPR.getTargetEndpoint(), componentReference );
+ RuntimeEndpointReference wire = selectCallbackWire( callbackEPR.getTargetEndpoint(), componentReference );
wire = clone_bind( componentReference, callbackEPR.getCallbackEndpoint() );
return wire;
} else {
// No callback case...
//TODO - fix the x..n multiplicity case, which needs to select the correct ONE of multiple
// EndpointReferences here
- return componentReference.getRuntimeWire(componentReference.getEndpointReferences().get(0));
+ return (RuntimeEndpointReference) componentReference.getEndpointReferences().get(0);
} // end if
- } // end method getRuntimeWire
+ } // end method getEndpointReference
- private RuntimeWire selectCallbackWire( org.apache.tuscany.sca.assembly.Endpoint endpoint,
+ private RuntimeEndpointReference selectCallbackWire( org.apache.tuscany.sca.assembly.Endpoint endpoint,
RuntimeComponentReference componentReference) {
// Look for callback binding with same name as service binding
if (endpoint == null) {
throw new RuntimeException("Destination for forward call is not available");
}
- for (RuntimeWire wire : componentReference.getRuntimeWires()) {
- if (wire.getEndpointReference().getBinding().getName().equals(endpoint.getBinding().getName())) {
- return wire;
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ if (epr.getBinding().getName().equals(endpoint.getBinding().getName())) {
+ return (RuntimeEndpointReference) epr;
}
- } // end for
+ }
// if no match, look for callback binding with same type as service binding
- for (RuntimeWire wire : componentReference.getRuntimeWires()) {
- if (wire.getEndpointReference().getBinding().getClass() == endpoint.getBinding().getClass()) {
- return wire;
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ if (epr.getBinding().getType().equals(endpoint.getBinding().getType())) {
+ return (RuntimeEndpointReference) epr;
}
- } // end for
+ }
// no suitable callback wire was found
return null;
} // end method selectCallbackWire
- private RuntimeWire clone_bind(RuntimeComponentReference reference,
+ private RuntimeEndpointReference clone_bind(RuntimeComponentReference reference,
org.apache.tuscany.sca.assembly.Endpoint callbackEndpoint) {
try {
@@ -258,9 +257,7 @@
// The callback endpoint will be resolved when the wire chains are created
ref.getEndpointReferences().add(callbackEndpointReference);
- RuntimeWire wire = ref.getRuntimeWires().get(0);
-
- return wire;
+ return (RuntimeEndpointReference) ref.getEndpointReferences().get(0);
} catch ( CloneNotSupportedException e ) {
return null;
} // end try clone_bind
@@ -274,16 +271,16 @@
* @param runtimeComponentReference
* @return
*/
- private Operation findOperation(String operationName, RuntimeComponentReference runtimeComponentReference) {
- Operation reseultOperation = null;
-
- for(Operation operation : runtimeComponentReference.getInterfaceContract().getInterface().getOperations()) {
- if (operationName.equalsIgnoreCase(operation.getName())) {
- reseultOperation = operation;
- break;
- }
- }
- return reseultOperation;
+ private Operation findOperation(String operationName, RuntimeEndpointReference epr) {
+ Operation reseultOperation = null;
+
+ for (Operation operation : epr.getReferenceInterfaceContract().getInterface().getOperations()) {
+ if (operationName.equalsIgnoreCase(operation.getName())) {
+ reseultOperation = operation;
+ break;
+ }
+ }
+ return reseultOperation;
}
/**
Modified: tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java (original)
+++ tuscany/java/sca/modules/implementation-bpel-runtime/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/provider/BPELImplementationProvider.java Fri Nov 13 21:49:15 2009
@@ -28,11 +28,11 @@
import org.apache.commons.logging.LogFactory;
import org.apache.ode.dao.jpa.ProcessDAOImpl;
import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.databinding.xml.DOMDataBinding;
import org.apache.tuscany.sca.extensibility.ClassLoaderContext;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
import org.apache.tuscany.sca.implementation.bpel.BPELImplementation;
import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer;
import org.apache.tuscany.sca.implementation.bpel.ode.ODEDeployment;
@@ -42,6 +42,8 @@
import org.apache.tuscany.sca.provider.ImplementationProvider;
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;
/**
* BPEL Implementation provider
@@ -86,16 +88,20 @@
// contract and leave it to the Endpoints only
service.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
for( Endpoint endpoint : service.getEndpoints() ) {
- if (endpoint.getInterfaceContract() != null) {
- endpoint.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
+ if (ep.getServiceInterfaceContract() != null) {
+ ep.getServiceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
}
} // end for
} // end for
- for (Reference reference: component.getReferences()) {
+ for (Reference reference : component.getReferences()) {
reference.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
- /* for( EndpointReference epr : reference.getEndpointReferences() ) {
- epr.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ for (EndpointReference endpointReference : reference.getEndpointReferences()) {
+ RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference;
+ if (epr.getReferenceInterfaceContract() != null) {
+ epr.getReferenceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
+ }
} // end for */
} // end for
Modified: tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java (original)
+++ tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java Fri Nov 13 21:49:15 2009
@@ -80,7 +80,9 @@
try {
injector.inject(instance);
} catch (Exception e) {
- destroyInvoker.invokeEvent(instance);
+ if (destroyInvoker != null) {
+ destroyInvoker.invokeEvent(instance);
+ }
throw new ObjectCreationException("Exception invoking injector", e);
}
}
Modified: tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java?rev=836009&r1=836008&r2=836009&view=diff
==============================================================================
--- tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java (original)
+++ tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaCallbackRuntimeWireProcessor.java Fri Nov 13 21:49:15 2009
@@ -39,7 +39,8 @@
import org.apache.tuscany.sca.invocation.Phase;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
-import org.apache.tuscany.sca.runtime.RuntimeWire;
+import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
+import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
/**
@@ -69,16 +70,40 @@
this.javaInterfaceFactory = javaInterfaceFactory;
}
- public void process(RuntimeWire wire) {
- addCallbackInterfaceInterceptors(wire);
+
+ private boolean supportsCallbackInterface(Interface iface, JavaImplementation impl) {
+ if (iface instanceof JavaInterface) {
+ Class<?> ifaceClass = ((JavaInterface)iface).getJavaClass();
+ if (ifaceClass.isAssignableFrom(impl.getJavaClass())) {
+ return true;
+ }
+ }
+ try {
+ Interface implType = javaInterfaceFactory.createJavaInterface(impl.getJavaClass());
+ // Ignore the remotable/conversational testing
+ implType.setRemotable(iface.isRemotable());
+ implType.setConversational(iface.isConversational());
+ return interfaceContractMapper.isCompatible(iface, implType);
+ } catch (InvalidInterfaceException e) {
+ logger.log(Level.WARNING, e.getMessage(), e);
+ return false;
+ }
}
- private void addCallbackInterfaceInterceptors(RuntimeWire wire) {
- Contract contract = wire.getEndpointReference().getReference();
+ public void process(RuntimeEndpoint endpoint) {
+ // No operation
+ }
+
+ public void process(RuntimeEndpointReference endpointReference) {
+ if(!(endpointReference instanceof RuntimeEndpointReference)) {
+ return;
+ }
+ RuntimeEndpointReference epr = (RuntimeEndpointReference) endpointReference;
+ Contract contract = epr.getReference();
if (!(contract instanceof RuntimeComponentReference)) {
return;
}
- RuntimeComponent component = (RuntimeComponent) wire.getEndpointReference().getComponent();
+ RuntimeComponent component = (RuntimeComponent) epr.getComponent();
if (component == null) {
return;
}
@@ -87,34 +112,15 @@
return;
}
JavaImplementation javaImpl = (JavaImplementation)implementation;
- Endpoint callbackEndpoint = wire.getEndpointReference().getCallbackEndpoint();
+ Endpoint callbackEndpoint = epr.getCallbackEndpoint();
if (callbackEndpoint != null) {
Interface iface = callbackEndpoint.getService().getInterfaceContract().getInterface();
if (!supportsCallbackInterface(iface, javaImpl)) {
// callback to this impl is not possible, so ensure a callback object is set
- for (InvocationChain chain : wire.getInvocationChains()) {
+ for (InvocationChain chain : epr.getInvocationChains()) {
chain.addInterceptor(Phase.REFERENCE, new CallbackInterfaceInterceptor());
}
}
}
}
-
- private boolean supportsCallbackInterface(Interface iface, JavaImplementation impl) {
- if (iface instanceof JavaInterface) {
- Class<?> ifaceClass = ((JavaInterface)iface).getJavaClass();
- if (ifaceClass.isAssignableFrom(impl.getJavaClass())) {
- return true;
- }
- }
- try {
- Interface implType = javaInterfaceFactory.createJavaInterface(impl.getJavaClass());
- // Ignore the remotable/conversational testing
- implType.setRemotable(iface.isRemotable());
- implType.setConversational(iface.isConversational());
- return interfaceContractMapper.isCompatible(iface, implType);
- } catch (InvalidInterfaceException e) {
- logger.log(Level.WARNING, e.getMessage(), e);
- return false;
- }
- }
}