Rename the methods on RuntimeEndpoint/RuntimeEndpointReference

Defer the unmarshalling of XML into endpoint/endpointReference

git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@881883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
rfeng 2009-11-18 19:06:40 +00:00
parent b22c95d726
commit bf06eae38c
17 changed files with 194 additions and 174 deletions

View file

@ -64,7 +64,7 @@ class AtomServiceBindingProvider implements ServiceBindingProvider {
this.mediator = mediator;
// TUSCANY-3166
this.serviceContract = endpoint.getServiceInterfaceContract();
this.serviceContract = endpoint.getComponentTypeServiceInterfaceContract();
}
public InterfaceContract getBindingInterfaceContract() {

View file

@ -290,7 +290,7 @@ public class JSONRPCServiceServlet extends JSONRPCServlet {
method = method.substring(method.lastIndexOf(".") + 1);
}
List<Operation> operations = endpoint.getServiceInterfaceContract().getInterface().getOperations();
List<Operation> operations = endpoint.getComponentTypeServiceInterfaceContract().getInterface().getOperations();
//componentService.getBindingProvider(binding).getBindingInterfaceContract().getInterface().getOperations();

View file

@ -164,9 +164,9 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
// Check if there is a target
RuntimeEndpoint endpoint = (RuntimeEndpoint)endpointReference.getTargetEndpoint();
if (endpoint != null) {
return endpoint.getServiceInterfaceContract();
return endpoint.getComponentTypeServiceInterfaceContract();
} else {
return endpointReference.getReferenceInterfaceContract();
return endpointReference.getComponentTypeReferenceInterfaceContract();
}
}
}

View file

@ -118,7 +118,7 @@ public class RuntimeSCAServiceBindingProvider implements ServiceBindingProvider
if (distributedProvider != null) {
return distributedProvider.getBindingInterfaceContract();
} else {
return endpoint.getServiceInterfaceContract();
return endpoint.getComponentTypeServiceInterfaceContract();
}
}

View file

@ -148,7 +148,7 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor {
public void process(RuntimeEndpoint endpoint) {
InterfaceContract sourceContract = endpoint.getBindingInterfaceContract();
InterfaceContract targetContract = endpoint.getServiceInterfaceContract();
InterfaceContract targetContract = endpoint.getComponentTypeServiceInterfaceContract();
if (targetContract == null) {
targetContract = sourceContract;
}
@ -184,7 +184,7 @@ public class DataBindingRuntimeWireProcessor implements RuntimeWireProcessor {
}
public void process(RuntimeEndpointReference endpointReference) {
InterfaceContract sourceContract = endpointReference.getReferenceInterfaceContract();
InterfaceContract sourceContract = endpointReference.getComponentTypeReferenceInterfaceContract();
InterfaceContract targetContract = endpointReference.getBindingInterfaceContract();
if (targetContract == null) {
targetContract = sourceContract;

View file

@ -34,6 +34,7 @@ import org.apache.tuscany.sca.runtime.RuntimeComponentContext;
* @version $Rev$ $Date$
*/
public class CompositeContext {
protected final static InheritableThreadLocal<CompositeContext> context = new InheritableThreadLocal<CompositeContext>();
protected ExtensionPointRegistry extensionPointRegistry;
protected EndpointRegistry endpointRegistry;
protected ComponentContextFactory componentContextFactory;
@ -73,8 +74,12 @@ public class CompositeContext {
public static CompositeContext getCurrentCompositeContext() {
RuntimeComponent component = getCurrentComponent();
if (component != null) {
RuntimeComponentContext context = component.getComponentContext();
return context.getCompositeContext();
RuntimeComponentContext componentContext = component.getComponentContext();
return componentContext.getCompositeContext();
}
CompositeContext compositeContext = context.get();
if (compositeContext != null) {
return compositeContext;
}
return null;
}
@ -112,4 +117,11 @@ public class CompositeContext {
return domainComposite;
}
public static void setThreadCompositeContext(CompositeContext value) {
context.set(value);
}
public static void removeCompositeContext() {
context.remove();
}
}

View file

@ -19,8 +19,6 @@
package org.apache.tuscany.sca.runtime;
import java.io.IOException;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
@ -28,8 +26,11 @@ import org.apache.tuscany.sca.assembly.EndpointReference;
* A utility to seralize/deserialize Endpoint/EndpointReference objects
*/
public interface EndpointSerializer {
EndpointReference readEndpointReference(String xml) throws IOException;
String write(EndpointReference endpointReference) throws IOException;
Endpoint readEndpoint(String xml) throws IOException;
String write(Endpoint endpoint) throws IOException;
EndpointReference readEndpointReference(String xml);
String write(EndpointReference endpointReference);
Endpoint readEndpoint(String xml);
String write(Endpoint endpoint);
}

View file

@ -54,5 +54,5 @@ public interface RuntimeEndpoint extends Endpoint, Invocable, Serializable {
* code can process.
* @return The target component type service interface contract
*/
InterfaceContract getServiceInterfaceContract();
InterfaceContract getComponentTypeServiceInterfaceContract();
}

View file

@ -53,7 +53,7 @@ public interface RuntimeEndpointReference extends EndpointReference, Invocable,
* implementation code uses to make the outbound call.
* @return The source component type reference interface contract
*/
InterfaceContract getReferenceInterfaceContract();
InterfaceContract getComponentTypeReferenceInterfaceContract();
boolean isOutOfDate();
void rebuild();

View file

@ -513,14 +513,14 @@ public class CompositeActivatorImpl implements CompositeActivator {
epr.bind(compositeContext);
ComponentReference reference = endpointReference.getReference();
InterfaceContract sourceContract = epr.getReferenceInterfaceContract();
InterfaceContract sourceContract = epr.getComponentTypeReferenceInterfaceContract();
// TODO - EPR - interface contract seems to be null in the implementation.web
// case. Not introspecting the CT properly?
if (sourceContract == null){
// TODO - Can't do this with move of matching to wire
// take the contract from the service to which the reference is connected
sourceContract = ((RuntimeEndpoint) endpointReference.getTargetEndpoint()).getServiceInterfaceContract();
sourceContract = ((RuntimeEndpoint) endpointReference.getTargetEndpoint()).getComponentTypeServiceInterfaceContract();
reference.setInterfaceContract(sourceContract);
}

View file

@ -19,7 +19,6 @@
package org.apache.tuscany.sca.core.assembly.impl;
import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;
@ -36,6 +35,7 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtens
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.runtime.EndpointSerializer;
import org.oasisopen.sca.ServiceRuntimeException;
public class EndpointSerializerImpl implements EndpointSerializer {
private ExtensionPointRegistry registry;
@ -55,25 +55,18 @@ public class EndpointSerializerImpl implements EndpointSerializer {
refProcessor = processors.getProcessor(EndpointReference.class);
}
public Endpoint readEndpoint(String xml) throws IOException {
public Endpoint readEndpoint(String xml) {
try {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
Endpoint result = processor.read(reader, new ProcessorContext(registry));
reader.close();
return result;
} catch (Exception e) {
throw wrap(e);
throw new ServiceRuntimeException(e);
}
}
private IOException wrap(Exception e) {
IOException ex = new IOException(e.getMessage());
ex.initCause(e);
return ex;
}
public String write(Endpoint endpoint) throws IOException {
public String write(Endpoint endpoint) {
StringWriter sw = new StringWriter();
try {
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
@ -82,22 +75,22 @@ public class EndpointSerializerImpl implements EndpointSerializer {
writer.close();
return sw.toString();
} catch (Exception e) {
throw wrap(e);
throw new ServiceRuntimeException(e);
}
}
public EndpointReference readEndpointReference(String xml) throws IOException {
public EndpointReference readEndpointReference(String xml) {
try {
XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml));
EndpointReference result = refProcessor.read(reader, new ProcessorContext(registry));
reader.close();
return result;
} catch (Exception e) {
throw wrap(e);
throw new ServiceRuntimeException(e);
}
}
public String write(EndpointReference endpointReference) throws IOException {
public String write(EndpointReference endpointReference) {
StringWriter sw = new StringWriter();
try {
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(sw);
@ -106,7 +99,7 @@ public class EndpointSerializerImpl implements EndpointSerializer {
writer.close();
return sw.toString();
} catch (Exception e) {
throw wrap(e);
throw new ServiceRuntimeException(e);
}
}
}

View file

@ -19,9 +19,10 @@
package org.apache.tuscany.sca.core.assembly.impl;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@ -34,7 +35,6 @@ import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
import org.apache.tuscany.sca.assembly.Contract;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.Service;
import org.apache.tuscany.sca.assembly.impl.EndpointImpl;
import org.apache.tuscany.sca.context.CompositeContext;
@ -76,25 +76,25 @@ import org.oasisopen.sca.ServiceRuntimeException;
/**
* Runtime model for Endpoint that supports java serialization
*/
public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint {
public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint, Externalizable {
private transient CompositeContext compositeContext;
private transient EndpointRegistry endpointRegistry;
private transient RuntimeWireProcessor wireProcessor;
private transient ProviderFactoryExtensionPoint providerFactories;
private transient InterfaceContractMapper interfaceContractMapper;
private transient WorkScheduler workScheduler;
private transient PhaseManager phaseManager;
private transient MessageFactory messageFactory;
private transient RuntimeInvoker invoker;
private transient ProviderFactoryExtensionPoint providerFactories;
private transient EndpointSerializer serializer;
private transient List<InvocationChain> chains;
private transient final Map<Operation, InvocationChain> invocationChainMap =
private transient Map<Operation, InvocationChain> invocationChainMap =
new ConcurrentHashMap<Operation, InvocationChain>();
private transient InvocationChain bindingInvocationChain;
private transient ServiceBindingProvider bindingProvider;
private transient List<PolicyProvider> policyProviders;
private transient EndpointSerializer serializer;
private String xml;
protected InterfaceContract bindingInterfaceContract;
@ -111,6 +111,37 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
super(registry);
}
protected void copyFrom(RuntimeEndpointImpl copy) {
this.xml = copy.xml;
this.component = copy.component;
this.service = copy.service;
this.interfaceContract = copy.interfaceContract;
this.serviceInterfaceContract = copy.serviceInterfaceContract;
this.binding = copy.binding;
this.bindingInterfaceContract = copy.interfaceContract;
this.bindingInvocationChain = copy.bindingInvocationChain;
this.callbackEndpointReferences = copy.callbackEndpointReferences;
this.requiredIntents = copy.requiredIntents;
this.policySets = copy.policySets;
this.uri = copy.uri;
this.remote = copy.remote;
this.unresolved = copy.unresolved;
this.chains = copy.chains;
this.invocationChainMap = copy.invocationChainMap;
this.bindingProvider = copy.bindingProvider;
this.policyProviders = copy.policyProviders;
if (this.compositeContext == null && copy.compositeContext != null) {
bind(copy.compositeContext);
}
}
public void bind(CompositeContext compositeContext) {
this.compositeContext = compositeContext;
bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry());
@ -231,7 +262,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
//InterfaceContract targetContract = getInterfaceContract();
// TODO - EPR - why is this looking at the component types. The endpoint should have the right interface contract by this time
InterfaceContract targetContract = getServiceInterfaceContract();
InterfaceContract targetContract = getComponentTypeServiceInterfaceContract();
// setInterfaceContract(targetContract);
for (Operation operation : sourceContract.getInterface().getOperations()) {
Operation targetOperation = interfaceContractMapper.map(targetContract.getInterface(), operation);
@ -422,7 +453,7 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
}
}
public ServiceBindingProvider getBindingProvider() {
public synchronized ServiceBindingProvider getBindingProvider() {
if (bindingProvider == null) {
BindingProviderFactory factory =
(BindingProviderFactory)providerFactories.getProviderFactory(getBinding().getClass());
@ -460,18 +491,6 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
return compositeContext;
}
private synchronized EndpointSerializer getSerializer() {
if (serializer == null) {
if (registry != null) {
serializer =
registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(EndpointSerializer.class);
} else {
throw new IllegalStateException("No extension registry is set");
}
}
return serializer;
}
@Override
protected void reset() {
super.reset();
@ -479,7 +498,17 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
}
@Override
public void resolve() {
protected synchronized void resolve() {
if (xml != null && component == null) {
if (compositeContext == null) {
compositeContext = CompositeContext.getCurrentCompositeContext();
if (compositeContext != null) {
bind(compositeContext);
}
}
RuntimeEndpointImpl ep = (RuntimeEndpointImpl)serializer.readEndpoint(xml);
copyFrom(ep);
}
super.resolve();
}
@ -493,12 +522,12 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
bindingInterfaceContract = getInterfaceContract();
}
if (bindingInterfaceContract == null) {
bindingInterfaceContract = getServiceInterfaceContract();
bindingInterfaceContract = getComponentTypeServiceInterfaceContract();
}
return bindingInterfaceContract;
}
public InterfaceContract getServiceInterfaceContract() {
public InterfaceContract getComponentTypeServiceInterfaceContract() {
resolve();
if (serviceInterfaceContract != null) {
return serviceInterfaceContract;
@ -513,47 +542,20 @@ public class RuntimeEndpointImpl extends EndpointImpl implements RuntimeEndpoint
return serviceInterfaceContract;
}
public Object writeReplace() throws ObjectStreamException {
return new EndpointProxy(getSerializer(), this);
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.uri = in.readUTF();
this.xml = in.readUTF();
}
public static class EndpointProxy implements Serializable {
private static final long serialVersionUID = 6708978267158501975L;
private String xml;
/**
* @param serializer
*/
public EndpointProxy() {
super();
}
/**
* @param serializer
*/
public EndpointProxy(EndpointSerializer serializer, Endpoint endpoint) {
super();
try {
this.xml = serializer.write(endpoint);
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
}
public Object readResolve() throws ObjectStreamException {
CompositeContext context = CompositeContext.getCurrentCompositeContext();
if (context == null) {
throw new IllegalStateException("No context is available for deserializing the endpoint");
}
UtilityExtensionPoint utilities =
context.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
EndpointSerializer serializer = utilities.getUtility(EndpointSerializer.class);
try {
RuntimeEndpoint endpoint = (RuntimeEndpoint) serializer.readEndpoint(xml);
endpoint.bind(context);
return endpoint;
} catch (IOException e) {
throw new ServiceRuntimeException(e);
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(getURI());
if (serializer == null && xml != null) {
out.writeUTF(xml);
} else {
if (serializer != null) {
out.writeUTF(serializer.write(this));
} else {
throw new IllegalStateException("No serializer is configured");
}
}
}

View file

@ -19,9 +19,10 @@
package org.apache.tuscany.sca.core.assembly.impl;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectStreamException;
import java.io.Serializable;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.lang.reflect.InvocationTargetException;
import java.security.AccessController;
import java.security.PrivilegedAction;
@ -35,7 +36,6 @@ import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.CompositeService;
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.impl.EndpointReferenceImpl;
import org.apache.tuscany.sca.context.CompositeContext;
@ -77,7 +77,7 @@ import org.oasisopen.sca.ServiceRuntimeException;
/**
* Runtime model for Endpoint that supports java serialization
*/
public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implements RuntimeEndpointReference {
public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implements RuntimeEndpointReference, Externalizable {
private transient CompositeContext compositeContext;
private transient RuntimeWireProcessor wireProcessor;
private transient InterfaceContractMapper interfaceContractMapper;
@ -88,7 +88,7 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
private transient EndpointRegistry endpointRegistry;
private transient List<InvocationChain> chains;
private transient final Map<Operation, InvocationChain> invocationChainMap =
private transient Map<Operation, InvocationChain> invocationChainMap =
new ConcurrentHashMap<Operation, InvocationChain>();
private transient InvocationChain bindingInvocationChain;
@ -100,6 +100,9 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
protected InterfaceContract bindingInterfaceContract;
protected InterfaceContract referenceInterfaceContract;
private String xml;
/**
* No-arg constructor for Java serilization
*/
@ -111,6 +114,38 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
super(registry);
}
protected void copyFrom(RuntimeEndpointReferenceImpl copy) {
this.xml = copy.xml;
this.component = copy.component;
this.reference = copy.reference;
this.interfaceContract = copy.interfaceContract;
this.referenceInterfaceContract = copy.referenceInterfaceContract;
this.callbackEndpoint = copy.callbackEndpoint;
this.targetEndpoint = copy.targetEndpoint;
this.binding = copy.binding;
this.bindingInterfaceContract = copy.interfaceContract;
this.bindingInvocationChain = copy.bindingInvocationChain;
this.requiredIntents = copy.requiredIntents;
this.policySets = copy.policySets;
this.uri = copy.uri;
this.remote = copy.remote;
this.unresolved = copy.unresolved;
this.status = copy.status;
this.chains = copy.chains;
this.invocationChainMap = copy.invocationChainMap;
this.bindingProvider = copy.bindingProvider;
this.policyProviders = copy.policyProviders;
if (this.compositeContext == null && copy.compositeContext != null) {
bind(copy.compositeContext);
}
}
public void bind(CompositeContext compositeContext) {
this.compositeContext = compositeContext;
bind(compositeContext.getExtensionPointRegistry(), compositeContext.getEndpointRegistry());
@ -214,7 +249,7 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
*/
private void initInvocationChains() {
chains = new ArrayList<InvocationChain>();
InterfaceContract sourceContract = getReferenceInterfaceContract();
InterfaceContract sourceContract = getComponentTypeReferenceInterfaceContract();
// TODO - EPR why is this looking at the component types. The endpoint reference should have the right interface contract by this time
//InterfaceContract sourceContract = getLeafInterfaceContract(endpointReference);
@ -252,14 +287,13 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
* is first used
*/
private void resolveEndpointReference() {
resolve();
boolean ok = eprBinder.bind(endpointRegistry, this);
if (!ok) {
throw new SCARuntimeException("Unable to bind " + this);
}
// set the endpoint based on the resolved endpoint
Endpoint endpoint = getTargetEndpoint();
// start the binding provider
final ReferenceBindingProvider bindingProvider = getBindingProvider();
@ -280,7 +314,6 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
// endpoint.setInterfaceContract(bindingContract);
}
private void initReferenceBindingInvocationChains() {
// add the binding interceptors to the reference binding wire
@ -369,10 +402,12 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
}
public boolean isOutOfDate() {
resolve();
return eprBinder.isOutOfDate(endpointRegistry, this);
}
public ReferenceBindingProvider getBindingProvider() {
public synchronized ReferenceBindingProvider getBindingProvider() {
resolve();
// For the case that binding.sca is implemented by another binding
if (binding == null) {
return null;
@ -394,6 +429,7 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
}
public synchronized List<PolicyProvider> getPolicyProviders() {
resolve();
if (policyProviders == null) {
policyProviders = new ArrayList<PolicyProvider>();
for (PolicyProviderFactory factory : providerFactories.getPolicyProviderFactories()) {
@ -423,18 +459,6 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
return compositeContext;
}
private synchronized EndpointSerializer getSerializer() {
if (serializer == null) {
if (registry != null) {
serializer =
registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(EndpointSerializer.class);
} else {
throw new IllegalStateException("No extension registry is set");
}
}
return serializer;
}
public InterfaceContract getBindingInterfaceContract() {
resolve();
if (bindingInterfaceContract != null) {
@ -445,12 +469,12 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
bindingInterfaceContract = getInterfaceContract();
}
if (bindingInterfaceContract == null) {
bindingInterfaceContract = getReferenceInterfaceContract();
bindingInterfaceContract = getComponentTypeReferenceInterfaceContract();
}
return bindingInterfaceContract;
}
public InterfaceContract getReferenceInterfaceContract() {
public InterfaceContract getComponentTypeReferenceInterfaceContract() {
resolve();
if (referenceInterfaceContract != null) {
return referenceInterfaceContract;
@ -464,52 +488,38 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
}
return referenceInterfaceContract;
}
public Object writeReplace() throws ObjectStreamException {
return new EndpointReferenceProxy(getSerializer(), this);
@Override
protected synchronized void resolve() {
if (xml != null && component == null) {
if (compositeContext == null) {
compositeContext = CompositeContext.getCurrentCompositeContext();
if (compositeContext != null) {
bind(compositeContext);
}
}
RuntimeEndpointReferenceImpl epr = (RuntimeEndpointReferenceImpl)serializer.readEndpointReference(xml);
copyFrom(epr);
}
super.resolve();
}
public static class EndpointReferenceProxy implements Serializable {
private static final long serialVersionUID = 6708978267158501975L;
private String xml;
/**
* @param serializer
*/
public EndpointReferenceProxy() {
super();
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
this.uri = in.readUTF();
this.xml = in.readUTF();
}
/**
* @param serializer
*/
public EndpointReferenceProxy(EndpointSerializer serializer, EndpointReference endpointReference) {
super();
try {
this.xml = serializer.write(endpointReference);
} catch (Exception e) {
throw new ServiceRuntimeException(e);
}
}
public Object readResolve() throws ObjectStreamException {
CompositeContext context = CompositeContext.getCurrentCompositeContext();
if (context == null) {
throw new IllegalStateException("No context is available for deserializing the endpoint");
}
UtilityExtensionPoint utilities =
context.getExtensionPointRegistry().getExtensionPoint(UtilityExtensionPoint.class);
EndpointSerializer serializer = utilities.getUtility(EndpointSerializer.class);
EndpointReferenceBinder eprBinder = utilities.getUtility(EndpointReferenceBinder.class);
try {
RuntimeEndpointReference epr = (RuntimeEndpointReference) serializer.readEndpointReference(xml);
epr.bind(context);
eprBinder.bind(context.getEndpointRegistry(), epr);
return epr;
} catch (IOException e) {
throw new ServiceRuntimeException(e);
public void writeExternal(ObjectOutput out) throws IOException {
out.writeUTF(getURI());
if (serializer == null && xml != null) {
out.writeUTF(xml);
} else {
if (serializer != null) {
out.writeUTF(serializer.write(this));
} else {
throw new IllegalStateException("No serializer is configured");
}
}
}
}

View file

@ -274,7 +274,7 @@ public class ODEExternalService {
private Operation findOperation(String operationName, RuntimeEndpointReference epr) {
Operation reseultOperation = null;
for (Operation operation : epr.getReferenceInterfaceContract().getInterface().getOperations()) {
for (Operation operation : epr.getComponentTypeReferenceInterfaceContract().getInterface().getOperations()) {
if (operationName.equalsIgnoreCase(operation.getName())) {
reseultOperation = operation;
break;

View file

@ -89,8 +89,8 @@ public class BPELImplementationProvider implements ImplementationProvider {
service.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
for( Endpoint endpoint : service.getEndpoints() ) {
RuntimeEndpoint ep = (RuntimeEndpoint) endpoint;
if (ep.getServiceInterfaceContract() != null) {
ep.getServiceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
if (ep.getComponentTypeServiceInterfaceContract() != null) {
ep.getComponentTypeServiceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
}
} // end for
} // end for
@ -99,8 +99,8 @@ public class BPELImplementationProvider implements ImplementationProvider {
reference.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
for (EndpointReference endpointReference : reference.getEndpointReferences()) {
RuntimeEndpointReference epr = (RuntimeEndpointReference)endpointReference;
if (epr.getReferenceInterfaceContract() != null) {
epr.getReferenceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
if (epr.getComponentTypeReferenceInterfaceContract() != null) {
epr.getComponentTypeReferenceInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
}
} // end for */
} // end for

View file

@ -149,7 +149,7 @@ public class JavaComponentContextProvider {
List<EndpointReference> wires = callbackReference.getEndpointReferences();
if (!wires.isEmpty()) {
RuntimeEndpointReference epr = (RuntimeEndpointReference) wires.get(0);
callbackWires.put(epr.getReferenceInterfaceContract().getInterface().toString(),
callbackWires.put(epr.getComponentTypeReferenceInterfaceContract().getInterface().toString(),
wires);
}
}

View file

@ -134,6 +134,7 @@ public class NodeImpl implements Node, Client {
this.compositeContext =
new CompositeContext(manager.registry, endpointRegistry, domainComposite);
CompositeContext.setThreadCompositeContext(compositeContext);
} finally {
// Reset the thread context monitor
manager.monitorFactory.setContextMonitor(tcm);
@ -216,6 +217,7 @@ public class NodeImpl implements Node, Client {
this.compositeContext = null;
ThreadMessageContext.removeMessageContext();
CompositeContext.removeCompositeContext();
} catch (ActivationException e) {
throw new IllegalStateException(e);