summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/core
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/core')
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java17
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java20
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java7
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java3
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java56
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java6
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java21
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationExt.java66
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationListener.java40
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationManager.java72
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationState.java29
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java230
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ExtendedConversationImpl.java267
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java19
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java26
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java26
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java3
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ConversationalScopeContainer.java294
-rw-r--r--java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ConversationalScopeContainerFactory.java44
19 files changed, 7 insertions, 1239 deletions
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
index cff7dbd21a..ff49effc0f 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/CompositeActivatorImpl.java
@@ -47,14 +47,12 @@ import org.apache.tuscany.sca.core.assembly.ActivationException;
import org.apache.tuscany.sca.core.assembly.CompositeActivator;
import org.apache.tuscany.sca.core.context.CompositeContext;
import org.apache.tuscany.sca.core.context.impl.CompositeContextImpl;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.core.scope.Scope;
import org.apache.tuscany.sca.core.scope.ScopeContainer;
import org.apache.tuscany.sca.core.scope.ScopeRegistry;
import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
-import org.apache.tuscany.sca.core.scope.impl.ConversationalScopeContainer;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
@@ -99,8 +97,6 @@ public class CompositeActivatorImpl implements CompositeActivator {
private final PropertyValueFactory propertyValueFactory;
private final EndpointRegistry endpointRegistry;
- private final ConversationManager conversationManager;
-
private final CompositeContext compositeContext;
private Composite domainComposite;
@@ -123,7 +119,6 @@ public class CompositeActivatorImpl implements CompositeActivator {
this.componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class);
this.requestContextFactory = contextFactories.getFactory(RequestContextFactory.class);
proxyFactory = compositeContext.getProxyFactory();
- this.conversationManager = compositeContext.getConversationManager();
this.endpointRegistry = utilities.getUtility(EndpointRegistry.class);
}
@@ -255,9 +250,6 @@ public class CompositeActivatorImpl implements CompositeActivator {
}
ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
ScopeContainer scopeContainer = scopeRegistry.getScopeContainer(runtimeComponent);
- if (scopeContainer != null && scopeContainer.getScope() == Scope.CONVERSATION) {
- conversationManager.addListener((ConversationalScopeContainer)scopeContainer);
- }
runtimeComponent.setScopeContainer(scopeContainer);
}
@@ -267,9 +259,6 @@ public class CompositeActivatorImpl implements CompositeActivator {
}
ScopedRuntimeComponent runtimeComponent = (ScopedRuntimeComponent)component;
ScopeContainer scopeContainer = runtimeComponent.getScopeContainer();
- if(scopeContainer != null && scopeContainer.getScope() == Scope.CONVERSATION) {
- conversationManager.removeListener((ConversationalScopeContainer) scopeContainer);
- }
runtimeComponent.setScopeContainer(null);
}
@@ -388,8 +377,7 @@ public class CompositeActivatorImpl implements CompositeActivator {
interfaceContractMapper,
workScheduler,
wireProcessor,
- messageFactory,
- conversationManager);
+ messageFactory);
runtimeService.getRuntimeWires().add(wire);
}
@@ -811,8 +799,7 @@ public class CompositeActivatorImpl implements CompositeActivator {
interfaceContractMapper,
workScheduler,
wireProcessor,
- messageFactory,
- conversationManager);
+ messageFactory);
runtimeRef.getRuntimeWires().add(wire);
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
index bbc074fea1..e639bb5ea6 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeWireImpl.java
@@ -38,7 +38,6 @@ import org.apache.tuscany.sca.assembly.builder.EndpointReferenceBuilder;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
import org.apache.tuscany.sca.core.invocation.ExtensibleWireProcessor;
import org.apache.tuscany.sca.core.invocation.NonBlockingInterceptor;
import org.apache.tuscany.sca.core.invocation.RuntimeWireInvoker;
@@ -86,7 +85,6 @@ public class RuntimeWireImpl implements RuntimeWire {
private transient InterfaceContractMapper interfaceContractMapper;
private transient WorkScheduler workScheduler;
private transient MessageFactory messageFactory;
- private transient ConversationManager conversationManager;
private transient RuntimeWireInvoker invoker;
// the following is a very simple cache that avoids re-cloning a wire
@@ -118,8 +116,7 @@ public class RuntimeWireImpl implements RuntimeWire {
InterfaceContractMapper interfaceContractMapper,
WorkScheduler workScheduler,
RuntimeWireProcessor wireProcessor,
- MessageFactory messageFactory,
- ConversationManager conversationManager) {
+ MessageFactory messageFactory) {
super();
this.extensionPoints = extensionPoints;
this.isReferenceWire = isReferenceWire;
@@ -129,8 +126,7 @@ public class RuntimeWireImpl implements RuntimeWire {
this.workScheduler = workScheduler;
this.wireProcessor = wireProcessor;
this.messageFactory = messageFactory;
- this.conversationManager = conversationManager;
- this.invoker = new RuntimeWireInvoker(this.messageFactory, this.conversationManager, this);
+ this.invoker = new RuntimeWireInvoker(this.messageFactory, this);
UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
this.endpointReferenceBuilder = utilities.getUtility(EndpointReferenceBuilder.class);
@@ -153,8 +149,7 @@ public class RuntimeWireImpl implements RuntimeWire {
this.wireProcessor = new ExtensibleWireProcessor(extensionPoints.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class));
FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
this.messageFactory = factories.getFactory(MessageFactory.class);
- this.conversationManager = utilities.getUtility(ConversationManager.class);
- this.invoker = new RuntimeWireInvoker(this.messageFactory, this.conversationManager, this);
+ this.invoker = new RuntimeWireInvoker(this.messageFactory, this);
this.endpointReferenceBuilder = utilities.getUtility(EndpointReferenceBuilder.class);
this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class);
@@ -659,18 +654,11 @@ public class RuntimeWireImpl implements RuntimeWire {
RuntimeWireImpl copy = (RuntimeWireImpl)super.clone();
copy.endpointReference = (EndpointReference)endpointReference.clone();
copy.endpoint = copy.endpointReference.getTargetEndpoint();
- copy.invoker = new RuntimeWireInvoker(copy.messageFactory, copy.conversationManager, copy);
+ copy.invoker = new RuntimeWireInvoker(copy.messageFactory, copy);
copy.cachedWire = null; // TUSCANY-2630
return copy;
}
- /**
- * @return the conversationManager
- */
- public ConversationManager getConversationManager() {
- return conversationManager;
- }
-
public synchronized RuntimeWire lookupCache(Endpoint callback) {
if (lastCallback != null &&
callback.getURI().equals(lastCallback.getURI()) &&
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java
index 6762896652..76f3eb2d81 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CallableReferenceExt.java
@@ -25,7 +25,6 @@ import java.io.IOException;
import javax.xml.stream.XMLStreamReader;
import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
import org.apache.tuscany.sca.runtime.RuntimeWire;
import org.oasisopen.sca.CallableReference;
@@ -49,12 +48,6 @@ public interface CallableReferenceExt<B> extends CallableReference<B>, Externali
*/
void attachCallbackID(Object callbackID);
- void attachConversationID(Object conversationID);
-
- void attachConversation(ConversationExt conversation);
-
- void attachConversation(Object conversationID);
-
/**
* @return
*/
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java
index 5d26670f3b..3b8309f573 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java
@@ -33,7 +33,6 @@ import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.assembly.CompositeActivator;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
@@ -208,8 +207,6 @@ public abstract class CompositeContext {
public abstract ExtensionPointRegistry getExtensionPointRegistry();
- public abstract ConversationManager getConversationManager();
-
/**
* Get the java interface factory
* @return
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
index af42b4a76a..b52b97c5c6 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallableReferenceImpl.java
@@ -36,9 +36,7 @@ import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.Reference;
-import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.assembly.Service;
-import org.apache.tuscany.sca.assembly.builder.BindingBuilderExtension;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.assembly.CompositeActivator;
@@ -48,9 +46,6 @@ import org.apache.tuscany.sca.core.assembly.impl.ReferenceParametersImpl;
import org.apache.tuscany.sca.core.context.CallableReferenceExt;
import org.apache.tuscany.sca.core.context.ComponentContextExt;
import org.apache.tuscany.sca.core.context.CompositeContext;
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
-import org.apache.tuscany.sca.core.conversation.ConversationState;
import org.apache.tuscany.sca.core.factory.ObjectCreationException;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.interfacedef.Interface;
@@ -60,7 +55,6 @@ import org.apache.tuscany.sca.runtime.ReferenceParameters;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeWire;
-import org.oasisopen.sca.Conversation;
import org.oasisopen.sca.ServiceRuntimeException;
/**
@@ -76,10 +70,6 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
protected transient Class<B> businessInterface;
protected transient Object proxy;
- // if the wire targets a conversational service this holds the conversation state
- protected transient ConversationManager conversationManager;
- protected transient ConversationExt conversation;
- protected transient Object conversationID;
protected Object callbackID; // The callbackID should be serializable
protected transient RuntimeComponent component;
@@ -150,7 +140,6 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
// FIXME: Should we normalize the componentName/serviceName URI into an absolute SCA URI in the SCA binding?
// sca:component1/component11/component112/service1?
this.compositeActivator = compositeActivator;
- this.conversationManager = this.compositeActivator.getCompositeContext().getConversationManager();
initCallbackID();
}
@@ -179,7 +168,6 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
this.reference = (RuntimeComponentReference)wire.getEndpointReference().getReference();
this.endpointReference = wire.getEndpointReference();
this.compositeActivator = ((ComponentContextExt)component.getComponentContext()).getCompositeActivator();
- this.conversationManager = this.compositeActivator.getCompositeContext().getConversationManager();
initCallbackID();
}
}
@@ -238,22 +226,6 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
}
}
- public Conversation getConversation() {
- try {
- // resolve from XML just in case this CallableReference is the result of
- // passing a CallableReference as a parameter
- resolve();
-
- if (conversation == null || conversation.getState() == ConversationState.ENDED) {
- conversation = null;
- }
- return conversation;
-
- } catch (Exception e) {
- throw new ServiceRuntimeException(e);
- }
- }
-
public Object getCallbackID() {
try {
resolve();
@@ -285,7 +257,6 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
CompositeContext componentContextHelper = CompositeContext.getCurrentCompositeContext();
if (componentContextHelper != null) {
this.compositeActivator = CompositeContext.getCurrentCompositeActivator();
- this.conversationManager = componentContextHelper.getConversationManager();
Component c;
if (xmlReader != null) {
c = componentContextHelper.fromXML(xmlReader);
@@ -309,7 +280,6 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
if (parameters != null) {
refParams = parameters;
this.callbackID = parameters.getCallbackID();
- attachConversation(parameters.getConversationID());
}
// TODO - EPR all needs sorting out for endpoint references
@@ -467,9 +437,6 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
clonedRef.getExtensions().add(refParams);
}
refParams.setCallbackID(callbackID);
- if (conversation != null) {
- refParams.setConversationID(conversation.getConversationID());
- }
return ((CompositeActivatorImpl)compositeActivator).getCompositeContext().toXML(component, clonedRef);
} else {
return scdl;
@@ -489,32 +456,9 @@ public class CallableReferenceImpl<B> implements CallableReferenceExt<B> {
this.callbackID = callbackID;
}
- public void attachConversationID(Object conversationID) {
- this.conversationID = conversationID;
- }
-
- public void attachConversation(ConversationExt conversation) {
- this.conversation = conversation;
- }
-
- public void attachConversation(Object conversationID) {
- if (conversationID != null) {
- ConversationExt conversation = conversationManager.getConversation(conversationID);
- if (conversation == null) {
- conversation = conversationManager.startConversation(conversationID);
- }
- this.conversation = conversation;
- } else {
- this.conversation = null;
- }
- }
-
protected ReferenceParameters getReferenceParameters() {
ReferenceParameters parameters = new ReferenceParametersImpl();
parameters.setCallbackID(callbackID);
- if (getConversation() != null) {
- parameters.setConversationID(conversation.getConversationID());
- }
return parameters;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java
index 2fe223c523..d0810efd10 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CompositeContextImpl.java
@@ -40,7 +40,6 @@ import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Composite;
import org.apache.tuscany.sca.assembly.Endpoint;
-import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.assembly.Multiplicity;
import org.apache.tuscany.sca.assembly.OptimizableBinding;
import org.apache.tuscany.sca.assembly.Reference;
@@ -52,7 +51,6 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.core.assembly.CompositeActivator;
import org.apache.tuscany.sca.core.context.CompositeContext;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint;
@@ -333,10 +331,6 @@ public class CompositeContextImpl extends CompositeContext {
return extensionPointRegistry;
}
- public ConversationManager getConversationManager() {
- return utilityExtensionPoint.getUtility(ConversationManager.class);
- }
-
/**
* Get the java interface factory
* @return
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
index 086c32ee24..348feaf8e9 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ServiceReferenceImpl.java
@@ -20,19 +20,14 @@ package org.apache.tuscany.sca.core.context.impl;
import javax.xml.stream.XMLStreamReader;
-import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.EndpointReference;
import org.apache.tuscany.sca.core.assembly.CompositeActivator;
-import org.apache.tuscany.sca.core.context.CallableReferenceExt;
import org.apache.tuscany.sca.core.context.ServiceReferenceExt;
-import org.apache.tuscany.sca.core.conversation.ConversationState;
import org.apache.tuscany.sca.core.invocation.ProxyFactory;
-import org.apache.tuscany.sca.runtime.ReferenceParameters;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
import org.apache.tuscany.sca.runtime.RuntimeWire;
import org.oasisopen.sca.CallableReference;
-import org.oasisopen.sca.ServiceReference;
/**
* Default implementation of a ServiceReference.
@@ -85,22 +80,6 @@ public class ServiceReferenceImpl<B> extends CallableReferenceImpl<B> implements
super(businessInterface, component, reference, endpointReference, proxyFactory, compositeActivator);
}
- public Object getConversationID() {
- return conversationID;
- }
-
- public void setConversationID(Object conversationID) throws IllegalStateException {
- if (conversation == null || conversation.getState() != ConversationState.ENDED) {
- this.conversationID = conversationID;
- this.conversation = null;
- } else {
- throw new IllegalStateException("Trying to set the conversationId on a service reference but the state of the conversation "
- + conversation.getConversationID()
- + " is "
- + conversation.getState());
- }
- }
-
public void setCallbackID(Object callbackID) {
this.callbackID = callbackID;
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationExt.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationExt.java
deleted file mode 100644
index 9182b080fe..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationExt.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.conversation;
-
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-import org.oasisopen.sca.Conversation;
-
-/**
- * An extended interface over org.oasisopen.Conversation
- *
- * @version $Rev$ $Date$
- */
-public interface ConversationExt extends Conversation {
- /**
- * Get the state of a conversation
- * @return The state
- */
- ConversationState getState();
-
- /**
- * @param state the state to set
- */
- void setState(ConversationState state);
-
- /**
- * @param conversationID the conversationID to set
- */
- void setConversationID(Object conversationID);
-
-
- /**
- * will check whether this conversation has expired and update state if it has
- * @return true if it has expired
- */
- boolean isExpired();
-
- /**
- * updates the last time this conversation was referenced
- */
- void updateLastReferencedTime();
-
- void initializeConversationAttributes(RuntimeComponent targetComponent);
-
-
- /**
- * @return true if the conversational attributes have been initialized
- */
- boolean conversationalAttributesInitialized();
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationListener.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationListener.java
deleted file mode 100644
index 425fa3af9c..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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.conversation;
-
-/**
- * Listener for the events of a conversation
- *
- * @version $Rev$ $Date$
- */
-public interface ConversationListener {
- /**
- * The conversation is started
- */
- void conversationStarted(ConversationExt conversation);
- /**
- * The conversation is ended
- */
- void conversationEnded(ConversationExt conversation);
- /**
- * The conversation is expired
- */
- void conversationExpired(ConversationExt conversation);
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationManager.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationManager.java
deleted file mode 100644
index 89987a1117..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationManager.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.conversation;
-
-/**
- * The manager of conversations
- *
- * @version $Rev$ $Date$
- */
-public interface ConversationManager {
- /**
- * @param conversationID
- * @return
- */
- ConversationExt startConversation(Object conversationID);
-
- /**
- * @param conversationID
- */
- void endConversation(Object conversationID);
-
- /**
- * @param conversationID
- * @return
- */
- ConversationExt getConversation(Object conversationID);
-
- /**
- * @param conversationID
- */
- void expireConversation(Object conversationID);
-
- /**
- * Add a listener to this conversation
- * @param listener
- */
- void addListener(ConversationListener listener);
-
- /**
- * Remove a listener from this conversation
- * @param listener
- */
- void removeListener(ConversationListener listener);
-
- /**
- * @return the default max age for a conversation
- */
- long getMaxAge();
-
- /**
- * @return the default max idle time for a conversation
- */
- long getMaxIdleTime();
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationState.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationState.java
deleted file mode 100644
index 692d6861ba..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/ConversationState.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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.conversation;
-
-/**
- * The states of a conversation
- *
- * @version $Rev$ $Date$
- */
-public enum ConversationState {
- STARTED, ENDED, EXPIRED
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java
deleted file mode 100644
index d2dff6ea09..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ConversationManagerImpl.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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.conversation.impl;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.tuscany.sca.core.LifeCycleListener;
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
-import org.apache.tuscany.sca.core.conversation.ConversationListener;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
-import org.apache.tuscany.sca.core.conversation.ConversationState;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ConversationManagerImpl implements ConversationManager, LifeCycleListener {
-
- private List<ConversationListener> listeners = Collections.synchronizedList(new ArrayList<ConversationListener>());
- private Map<Object, ConversationExt> conversations = new ConcurrentHashMap<Object, ConversationExt>();
-
- /**
- * the default max age. this is set to 1 hour
- */
- private static final long DEFAULT_MAX_AGE = 60 * 60 * 1000;;
-
- /**
- * the default max idle time. this is set to 1 hour
- */
- private static final long DEFAULT_MAX_IDLE_TIME = 60 * 60 * 1000;
-
- /**
- * the globally used max age
- */
- private final long maxAge;
-
- /**
- * the globally used max idle time
- */
- private final long maxIdleTime;
-
- /**
- * the reaper thread
- */
- private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
-
- /**
- * constructor
- */
- public ConversationManagerImpl() {
- long mit = DEFAULT_MAX_IDLE_TIME;
- long ma = DEFAULT_MAX_AGE;
-
- // Allow privileged access to read system property. Requires PropertyPermission in security
- // policy.
- String aProperty = AccessController.doPrivileged(new PrivilegedAction<String>() {
- public String run() {
- return System.getProperty(ConversationManager.class.getName() + ".MaxIdleTime");
- }
- });
- if (aProperty != null) {
- try {
- mit = Long.parseLong(aProperty) * 1000;
- } catch (NumberFormatException nfe) {
- // Ignore
- }
- }
-
- // Allow privileged access to read system property. Requires PropertyPermission in security
- // policy.
- aProperty = AccessController.doPrivileged(new PrivilegedAction<String>() {
- public String run() {
- return System.getProperty(ConversationManager.class.getName() + ".MaxAge");
- }
- });
- if (aProperty != null) {
- try {
- ma = Long.parseLong(aProperty) * 1000;
- } catch (NumberFormatException nfe) {
- // Ignore
- }
- }
-
- maxAge = ma;
- maxIdleTime = mit;
- }
-
- /**
- * @see org.apache.tuscany.sca.core.conversation.ConversationManager#addListener(org.apache.tuscany.sca.core.conversation.ConversationListener)
- */
- public void addListener(ConversationListener listener) {
- listeners.add(listener);
- }
-
- /**
- * @see org.apache.tuscany.sca.core.conversation.ConversationManager#endConversation(org.apache.tuscany.sca.core.conversation.ConversationExt)
- */
- public void endConversation(Object conversationID) {
- ConversationExt conv = getConversation(conversationID);
- if (conv != null) {
- conv.setState(ConversationState.ENDED);
- for (ConversationListener listener : listeners) {
- listener.conversationEnded(conv);
- }
- conv.setConversationID(null);
- conversations.remove(conversationID);
- } else {
- throw new IllegalStateException("Conversation " + conversationID + " doesn't exist.");
- }
- }
-
- public void expireConversation(Object conversationID) {
- ConversationExt conv = getConversation(conversationID);
- if (conv != null) {
- for (ConversationListener listener : listeners) {
- listener.conversationExpired(conv);
- }
- conversations.remove(conversationID);
- } else {
- throw new IllegalStateException("Conversation " + conversationID + " doesn't exist.");
- }
-
- }
-
- /**
- * @see org.apache.tuscany.sca.core.conversation.ConversationManager#getConversation(java.lang.Object)
- */
- public ConversationExt getConversation(Object conversationID) {
- // ConcurrentHashMap cannot take null key
- return conversationID == null ? null : conversations.get(conversationID);
- }
-
- /**
- * @see org.apache.tuscany.sca.core.conversation.ConversationManager#removeListener(org.apache.tuscany.sca.core.conversation.ConversationListener)
- */
- public void removeListener(ConversationListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * starts the reaper thread
- */
- public void scheduleConversation(ExtendedConversationImpl aConversation, long time) {
- this.scheduler.schedule(aConversation, time, TimeUnit.MILLISECONDS);
- }
-
- /**
- * stops the reaper thread
- */
- public synchronized void stopReaper() {
-
- // Prevent the scheduler from submitting any additional reapers,
- // initiate an orderly shutdown if a reaper task is in progress.
- this.scheduler.shutdown();
- }
-
- /**
- * @see org.apache.tuscany.sca.core.conversation.ConversationManager#startConversation(java.lang.Object)
- */
- public ConversationExt startConversation(Object conversationID) {
-
- if (conversationID == null) {
- conversationID = UUID.randomUUID().toString();
- }
- ConversationExt conversation = getConversation(conversationID);
- if (conversation != null && conversation.getState() != ConversationState.ENDED) {
- throw new IllegalStateException(conversation + " already exists.");
- }
-
- conversation = new ExtendedConversationImpl(this, conversationID, ConversationState.STARTED);
- conversations.put(conversationID, conversation);
- for (ConversationListener listener : listeners) {
- listener.conversationStarted(conversation);
- }
- return conversation;
- }
-
- /**
- * return the default max idle time
- * @param impProvider the implementation Provider to extract any ConversationAttribute details
- */
- public long getMaxIdleTime() {
- return maxIdleTime;
- }
-
- /**
- * returns the default max age
- * @param impProvider the implementation Provider to extract any ConversationAttribute details
- */
- public long getMaxAge() {
- return maxAge;
- }
-
- public void stop() {
- // REVIEW: A more graceful way?
- scheduler.shutdownNow();
- this.listeners.clear();
- this.conversations.clear();
- }
-
- public void start() {
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ExtendedConversationImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ExtendedConversationImpl.java
deleted file mode 100644
index 34bf8a12d5..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/conversation/impl/ExtendedConversationImpl.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * 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.conversation.impl;
-
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
-import org.apache.tuscany.sca.core.conversation.ConversationState;
-import org.apache.tuscany.sca.core.scope.ScopedImplementationProvider;
-import org.apache.tuscany.sca.provider.ImplementationProvider;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-
-/**
- *
- * @version $Rev$ $Date$
- */
-public class ExtendedConversationImpl implements ConversationExt, Runnable {
-
- private final ConversationManagerImpl manager;
- private volatile Object conversationID;
- private ConversationState state;
-
- /**
- * syncs access to the state
- */
- private final Object stateSync = new Object();
-
- /**
- * the maximum time a conversation can exist
- */
- private long expirationTime = 0;
-
- /**
- * the maximum time this conversation can be idle
- */
- private long maxIdleTime = 0;
-
- /**
- * the maximum age of this conversation
- */
- private long maxAge = 0;
-
- /**
- * the time that this object was created
- */
- private long creationTime;
-
- /**
- * the time that this object was last referenced
- */
- private long lastReferencedTime;
-
- /**
- * boolean to ensure expiry only occurs once
- */
- private boolean expired = false;
-
- /**
- * boolean to indicate if the conversation attributes have
- * been set. In the case where a remote binding is used
- * within a composite the JDKInvocationHandler can create the
- * conversation but the conversationAttributes are not available
- * until the conversation is retrieved by the RuntimeWireInvoker
- */
- private boolean conversationAttributesInitialized = false;
-
- /**
- * Constructor
- * @param manager the conversation manager
- * @param conversationID the conversation id associated with this conversation
- * @param state the initial state of this conversation
- * @param aMaxAge the maximum age of the conversation
- * @param aMaxIdleTime the maximum idle time
- */
- public ExtendedConversationImpl(ConversationManagerImpl manager,
- Object conversationID, ConversationState state) {
- super();
-
- this.creationTime = System.currentTimeMillis();
- this.lastReferencedTime = creationTime;
- this.manager = manager;
- this.conversationID = conversationID;
- this.state = state;
- }
-
- /**
- * will check whether this conversation has expired and update state if it has
- * @return true if it has expired
- */
- public boolean isExpired() {
- long currentTime;
- synchronized (stateSync) {
-
- // if the attributes haven't been initialized then
- // this conversation object can't expire
- if (conversationAttributesInitialized == false) {
- return false;
- }
-
- // check state first
- if (state == ConversationState.EXPIRED) {
- return true;
- }
-
- // check whether the time is finished
- currentTime = System.currentTimeMillis();
- if (((this.lastReferencedTime + this.maxIdleTime) <= currentTime)
- || (this.expirationTime <= currentTime)) {
- setState(ConversationState.EXPIRED);
- return true;
- }
- }
- scheduleNextExpiryTime(currentTime);
- return false;
- }
-
- /**
- * schedule next expiry time
- */
- public void scheduleNextExpiryTime(long currentTime) {
- if ((lastReferencedTime + maxIdleTime) < expirationTime){
- manager.scheduleConversation(this, (lastReferencedTime + maxIdleTime) - currentTime);
- } else {
- manager.scheduleConversation(this, expirationTime - currentTime);
- }
- }
- /**
- * updates the last time this conversation was referenced
- */
- public void updateLastReferencedTime() {
- this.lastReferencedTime = System.currentTimeMillis();
- if (conversationAttributesInitialized == true){
- scheduleNextExpiryTime(lastReferencedTime);
- }
- }
-
- public ConversationState getState() {
- synchronized (stateSync){
- return state;
- }
- }
-
- public void end() {
- manager.endConversation(conversationID);
- }
-
- public Object getConversationID() {
- return conversationID;
- }
-
- /**
- * @param state the state to set
- */
- public void setState(ConversationState state) {
- synchronized (stateSync){
- this.state = state;
- }
- }
-
- /**
- * @param conversationID the conversationID to set
- */
- public void setConversationID(Object conversationID) {
- synchronized (stateSync){
- if (state != ConversationState.ENDED) {
- throw new IllegalStateException("The state of conversation " + conversationID + " " + state);
- }
- }
- this.conversationID = conversationID;
- }
-
- /**
- * @param maxAge the maximum age of this conversation
- */
- public void initializeConversationAttributes(RuntimeComponent targetComponent){
- if (targetComponent != null){
- this.maxAge = getMaxIdleTime(targetComponent.getImplementationProvider());
- this.maxIdleTime = getMaxAge(targetComponent.getImplementationProvider());
- this.expirationTime = creationTime + maxAge;
- this.conversationAttributesInitialized = true;
- }
- }
-
- /**
- * @return true if the conversational attributes have been initialized
- */
- public boolean conversationalAttributesInitialized(){
- return this.conversationAttributesInitialized;
- }
-
- /**
- * return the max idle time
- * @param impProvider the implementation Provider to extract any ConversationAttribute details
- */
- private long getMaxIdleTime(ImplementationProvider impProvider) {
- // Check to see if the maxIdleTime has been specified using @ConversationAttributes.
- // Implementation annotated attributes are honoured first.
- if ((impProvider != null) &&
- (impProvider instanceof ScopedImplementationProvider)) {
- ScopedImplementationProvider aScopedImpl =
- (ScopedImplementationProvider) impProvider;
-
- long maxIdleTime = aScopedImpl.getMaxIdleTime();
- if (maxIdleTime > 0) {
- return maxIdleTime;
- }
- }
- return manager.getMaxIdleTime();
- }
-
- /**
- * returns the max age
- * @param impProvider the implementation Provider to extract any ConversationAttribute details
- */
- private long getMaxAge(ImplementationProvider impProvider){
-
- // Check to see if the maxAge has been specified using @ConversationAttributes.
- // Implementation annotated attributes are honoured first.
- if ((impProvider != null) &&
- (impProvider instanceof ScopedImplementationProvider)) {
- ScopedImplementationProvider aScopedImpl =
- (ScopedImplementationProvider) impProvider;
-
- long maxAge = aScopedImpl.getMaxAge();
- if (maxAge > 0) {
- return maxAge;
- }
- }
- return manager.getMaxAge();
- }
-
- /**
- * called when expiring
- */
- public void run() {
- synchronized (stateSync){
- if (!expired){
- if (isExpired()) {
- expired = true;
- try {
- manager.expireConversation(getConversationID());
- } catch (IllegalStateException ise) {
- // ignore this.. this can occur if another thread has subsequently ended
- // the conversation
- }
- }
- }
- }
-
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
index f785cb8f37..7901a7fa55 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/RuntimeWireInvoker.java
@@ -22,45 +22,28 @@ package org.apache.tuscany.sca.core.invocation;
import java.lang.reflect.InvocationTargetException;
import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
-import org.apache.tuscany.sca.core.conversation.ConversationState;
import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
-import org.apache.tuscany.sca.core.scope.TargetDestructionException;
-import org.apache.tuscany.sca.core.scope.TargetResolutionException;
-import org.apache.tuscany.sca.interfacedef.ConversationSequence;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
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.ReferenceParameters;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeWire;
-import org.oasisopen.sca.ConversationEndedException;
import org.oasisopen.sca.ServiceRuntimeException;
/**
* @version $Rev$ $Date$
*/
public class RuntimeWireInvoker implements Invoker{
- protected ConversationManager conversationManager;
- protected boolean conversational;
- protected ConversationExt conversation;
protected MessageFactory messageFactory;
protected Object conversationID;
protected Object callbackID;
protected Object callbackObject;
protected RuntimeWire wire;
- public RuntimeWireInvoker(MessageFactory messageFactory, ConversationManager conversationManager, RuntimeWire wire) {
+ public RuntimeWireInvoker(MessageFactory messageFactory, RuntimeWire wire) {
this.messageFactory = messageFactory;
this.wire = wire;
- this.conversationManager = conversationManager;
//init(wire);
}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
index b0e108dd93..312d0b47cc 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKCallbackInvocationHandler.java
@@ -22,8 +22,6 @@ 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.CallableReferenceImpl;
-import org.apache.tuscany.sca.core.conversation.ConversationState;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.MessageFactory;
import org.apache.tuscany.sca.runtime.RuntimeWire;
@@ -63,30 +61,6 @@ public class JDKCallbackInvocationHandler extends JDKInvocationHandler {
// TODO - EPR - not required for OASIS
//initConversational(wire);
- // set the conversation id into the conversation object. This is
- // a special case for callbacks as, unless otherwise set manually,
- // the callback should use the same conversation id as was received
- // on the incoming call to this component
- if (conversational) {
-
- if (conversation == null || conversation.getState() == ConversationState.ENDED) {
- conversation = null;
- }
- Object convID = conversation == null ? null : conversation.getConversationID();
-
- // create a conversation id if one doesn't exist
- // already, i.e. the conversation is just starting
- if (convID == null) {
- convID = ((CallbackReferenceImpl)callableReference).getConvID();
- if (convID != null) {
- conversation = ((RuntimeWireImpl)wire).getConversationManager().getConversation(convID);
- if (callableReference != null) {
- ((CallableReferenceImpl)callableReference).attachConversation(conversation);
- }
- }
- }
- }
-
setEndpoint(((CallbackReferenceImpl)callableReference).getResolvedEndpoint());
InvocationChain chain = getInvocationChain(method, wire);
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
index 49b9d87096..f66dc79915 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/JDKInvocationHandler.java
@@ -26,38 +26,22 @@ import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.UUID;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.EndpointReference;
-import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl;
import org.apache.tuscany.sca.core.context.CallableReferenceExt;
-import org.apache.tuscany.sca.core.context.impl.CallableReferenceImpl;
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
-import org.apache.tuscany.sca.core.conversation.ConversationState;
import org.apache.tuscany.sca.core.factory.InstanceWrapper;
import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopedRuntimeComponent;
-import org.apache.tuscany.sca.core.scope.TargetDestructionException;
import org.apache.tuscany.sca.core.scope.TargetResolutionException;
-import org.apache.tuscany.sca.interfacedef.ConversationSequence;
import org.apache.tuscany.sca.interfacedef.DataType;
-import org.apache.tuscany.sca.interfacedef.Interface;
-import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.java.JavaOperation;
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.ReferenceParameters;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.runtime.RuntimeWire;
import org.oasisopen.sca.CallableReference;
-import org.oasisopen.sca.ConversationEndedException;
import org.oasisopen.sca.ServiceReference;
import org.oasisopen.sca.ServiceRuntimeException;
@@ -68,7 +52,6 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
private static final long serialVersionUID = -3366410500152201371L;
protected boolean conversational;
- protected ConversationExt conversation;
protected MessageFactory messageFactory;
protected EndpointReference source;
protected Endpoint target;
@@ -92,7 +75,6 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
this.callableReference = callableReference;
if (callableReference != null) {
this.businessInterface = callableReference.getBusinessInterface();
- this.conversation = (ConversationExt)callableReference.getConversation();
this.wire = ((CallableReferenceExt<?>)callableReference).getRuntimeWire();
if (wire != null) {
init(wire);
@@ -130,14 +112,6 @@ public class JDKInvocationHandler implements InvocationHandler, Serializable {
}
}
- protected Object getConversationID() {
- if (callableReference != null && callableReference instanceof ServiceReference) {
- return ((ServiceReference)callableReference).getConversationID();
- } else {
- return null;
- }
- }
-
protected Object getCallbackObject() {
if (callableReference != null && callableReference instanceof ServiceReference) {
return ((ServiceReference)callableReference).getCallback();
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
index b6857be97a..931a530f36 100644
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
+++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/DefaultScopeRegistry.java
@@ -20,7 +20,6 @@
package org.apache.tuscany.sca.core.scope;
import org.apache.tuscany.sca.core.scope.impl.CompositeScopeContainerFactory;
-import org.apache.tuscany.sca.core.scope.impl.ConversationalScopeContainerFactory;
import org.apache.tuscany.sca.core.scope.impl.RequestScopeContainerFactory;
import org.apache.tuscany.sca.core.scope.impl.ScopeRegistryImpl;
import org.apache.tuscany.sca.core.scope.impl.StatelessScopeContainerFactory;
@@ -36,8 +35,6 @@ public class DefaultScopeRegistry extends ScopeRegistryImpl implements ScopeRegi
ScopeContainerFactory[] factories =
new ScopeContainerFactory[] {new CompositeScopeContainerFactory(), new StatelessScopeContainerFactory(),
new RequestScopeContainerFactory(),
- new ConversationalScopeContainerFactory(),
- // new HttpSessionScopeContainer(monitor)
};
for (ScopeContainerFactory f : factories) {
register(f);
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ConversationalScopeContainer.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ConversationalScopeContainer.java
deleted file mode 100644
index 8dfe77f61b..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ConversationalScopeContainer.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*
- * 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.scope.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.tuscany.sca.core.conversation.ConversationExt;
-import org.apache.tuscany.sca.core.conversation.ConversationListener;
-import org.apache.tuscany.sca.core.conversation.ConversationManager;
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.invocation.ThreadMessageContext;
-import org.apache.tuscany.sca.core.scope.AbstractScopeContainer;
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.TargetDestructionException;
-import org.apache.tuscany.sca.core.scope.TargetResolutionException;
-import org.apache.tuscany.sca.invocation.Message;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * A scope context which manages atomic component instances keyed on ConversationID
- *
- * @version $Rev$ $Date$
- */
-public class ConversationalScopeContainer extends AbstractScopeContainer<Object> implements ConversationListener {
- private ConversationManager conversationManager;
- private Map<Object, InstanceLifeCycleWrapper> instanceLifecycleCollection =
- new ConcurrentHashMap<Object, InstanceLifeCycleWrapper>();
-
- public ConversationalScopeContainer(RuntimeComponent component) {
- super(Scope.CONVERSATION, component);
-
- // Note: aStore is here to preserve the original factory interface. It is not currently used in this
- // implementation since we do not support instance persistence.
-
- // Check System properties to see if timeout values have been specified. All timeout values
- // will be specified in seconds.
- //
-
- }
-
-
- protected InstanceWrapper getInstanceWrapper(boolean create, Object contextId) throws TargetResolutionException {
-
- // we might get a null context if the target service has
- // conversational scope but only its callback interface
- // is conversational. In this case we need to invent a
- // conversation Id here to store the service against
- // and populate the thread context
- if (contextId == null) {
- contextId = UUID.randomUUID().toString();
- Message msgContext = ThreadMessageContext.getMessageContext();
-
- if (msgContext != null) {
- // TODO - EPR - not required for OASIS
- //msgContext.getFrom().getReferenceParameters().setConversationID(contextId);
- }
- }
-
- InstanceLifeCycleWrapper anInstanceWrapper = this.instanceLifecycleCollection.get(contextId);
-
- if (anInstanceWrapper == null && !create)
- return null;
-
- if (anInstanceWrapper == null) {
- anInstanceWrapper = new InstanceLifeCycleWrapper(contextId);
- this.instanceLifecycleCollection.put(contextId, anInstanceWrapper);
- }
-
- return anInstanceWrapper.getInstanceWrapper(contextId);
-
- }
-
- @Override
- public InstanceWrapper getWrapper(Object contextId) throws TargetResolutionException {
- return getInstanceWrapper(true, contextId);
- }
-
- /**
- * This method allows a new context id to be registered alongside an existing one. This happens in
- * one case, when a conversation includes a stateful callback. The client component instance
- * must be registered against all outgoing conversation ids so that the component instance
- * can be found when the callback arrives
- *
- * @param existingContextId the context id against which the component is already registered
- * @param context this should be a conversation object so that the conversation can b stored
- * and reset when the component instance is removed
- */
- @Override
- public void addWrapperReference(Object existingContextId, Object contextId) throws TargetResolutionException {
-
-
- // get the instance wrapper via the existing id
- InstanceLifeCycleWrapper existingInstanceWrapper = this.instanceLifecycleCollection.get(existingContextId);
- InstanceLifeCycleWrapper newInstanceWrapper = this.instanceLifecycleCollection.get(contextId);
-
- // only add the extra reference once
- if (newInstanceWrapper == null) {
- // add the id to the list of ids that the wrapper holds. Used for reference
- // counting and conversation resetting on destruction.
- existingInstanceWrapper.addCallbackConversation(contextId);
-
- // add the reference to the collection
- this.instanceLifecycleCollection.put(contextId, existingInstanceWrapper);
- }
- }
-
- @Override
- public void registerWrapper(InstanceWrapper wrapper, Object contextId) throws TargetResolutionException {
- // if a wrapper for a different instance is already registered for this contextId, remove it
- InstanceLifeCycleWrapper anInstanceWrapper = this.instanceLifecycleCollection.get(contextId);
- if (anInstanceWrapper != null) {
- if (anInstanceWrapper.getInstanceWrapper(contextId).getInstance() != wrapper.getInstance()) {
- remove(contextId);
- } else {
- return;
- }
- }
-
- anInstanceWrapper = new InstanceLifeCycleWrapper(wrapper, contextId);
- this.instanceLifecycleCollection.put(contextId, anInstanceWrapper);
- }
-
- // The remove is invoked when a conversation is explicitly ended. This can occur by using the @EndsConversation or API.
- // In this case the instance is immediately removed. A new conversation will be started on the next operation
- // associated with this conversationId's service reference.
- //
- @Override
- public void remove(Object contextId) throws TargetDestructionException {
- if (contextId != null) {
- if (this.instanceLifecycleCollection.containsKey(contextId)) {
- InstanceLifeCycleWrapper anInstanceLifeCycleWrapper = this.instanceLifecycleCollection.get(contextId);
- this.instanceLifecycleCollection.remove(contextId);
- anInstanceLifeCycleWrapper.removeInstanceWrapper(contextId);
- }
- }
- }
-
- /*
- * This is an inner class that keeps track of the lifecycle of a conversation scoped
- * implementation instance.
- *
- */
-
- private class InstanceLifeCycleWrapper {
- private Object clientConversationId;
- private List<Object> callbackConversations = new ArrayList<Object>();
-
- private InstanceLifeCycleWrapper(Object contextId) throws TargetResolutionException {
- this.clientConversationId = contextId;
- this.createInstance(contextId);
- }
-
- private InstanceLifeCycleWrapper(InstanceWrapper wrapper, Object contextId) throws TargetResolutionException {
- this.clientConversationId = contextId;
- wrappers.put(contextId, wrapper);
- }
-
-
- // Associates a callback conversation with this instance. Each time the scope container
- // is asked to remove an object given a ontextId an associated conversation object will
- // have its conversationId reset to null. When the list of ids is empty the component instance
- // will be removed from the scope container
- private void addCallbackConversation(Object conversationID) {
- InstanceWrapper ctx = getInstanceWrapper(clientConversationId);
- callbackConversations.add(conversationID);
- wrappers.put(conversationID, ctx);
- }
-
- //
- // Return the backing implementation instance
- //
- private InstanceWrapper getInstanceWrapper(Object contextId) {
- InstanceWrapper ctx = wrappers.get(contextId);
- return ctx;
- }
-
- private void removeInstanceWrapper(Object contextId) throws TargetDestructionException {
- InstanceWrapper ctx = getInstanceWrapper(contextId);
- wrappers.remove(contextId);
-
- // find out if we are dealing with the original client conversation id
- // and reset accordingly
- if ( ( clientConversationId != null ) && ( clientConversationId.equals(contextId)) ) {
- clientConversationId = null;
- } else {
- // reset the conversationId in the conversation object if present
- // so that and ending callback causes the conversation in the originating
- // service reference in the client to be reset
- callbackConversations.remove(contextId);
- }
-
- // stop the component if this removes the last reference
- if (clientConversationId == null && callbackConversations.isEmpty()) {
- ctx.stop();
- }
- }
-
- private void createInstance(Object contextId) throws TargetResolutionException {
- InstanceWrapper instanceWrapper = createInstanceWrapper();
- instanceWrapper.start();
- wrappers.put(contextId, instanceWrapper);
- }
-
- }
-
- /**
- * @see org.apache.tuscany.sca.core.conversation.ConversationListener#conversationEnded(org.apache.tuscany.sca.core.conversation.ConversationExt)
- */
- public void conversationEnded(ConversationExt conversation) {
- try {
- remove(conversation.getConversationID());
- } catch (Exception ex) {
-
- }
- }
-
- /**
- * @see org.apache.tuscany.sca.core.conversation.ConversationListener#conversationExpired(org.apache.tuscany.sca.core.conversation.ConversationExt)
- */
- public void conversationExpired(ConversationExt conversation) {
-
- Object conversationId = conversation.getConversationID();
- InstanceLifeCycleWrapper ilcw = instanceLifecycleCollection.get(conversationId);
- if (ilcw != null) {
- // cycle through all the references to this instance and
- // remove them from the underlying wrappers collection and
- // from the lifecycle wrappers collection
-
- for (Object conversationID : ilcw.callbackConversations) {
- try{
- ilcw.removeInstanceWrapper(conversationID);
- remove(conversationID);
- } catch(TargetDestructionException tde) {
- System.out.println("Could not remove conversation id " + conversationID);
- }
- }
-
-
- if (ilcw.clientConversationId != null) {
- try{
- ilcw.removeInstanceWrapper(ilcw.clientConversationId);
- remove(ilcw.clientConversationId);
- } catch(TargetDestructionException tde) {
- System.out.println("Could not remove conversation id " + ilcw.clientConversationId);
- }
- }
-
- }
-
- }
-
- /**
- * @see org.apache.tuscany.sca.core.conversation.ConversationListener#conversationStarted(org.apache.tuscany.sca.core.conversation.ConversationExt)
- */
- public void conversationStarted(ConversationExt conversation) {
- startContext(conversation.getConversationID());
- }
-
- /**
- * @return the conversationManager
- */
- public ConversationManager getConversationManager() {
- return conversationManager;
- }
-
- /**
- * @param conversationManager the conversationManager to set
- */
- public void setConversationManager(ConversationManager conversationManager) {
- this.conversationManager = conversationManager;
- }
-
-}
diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ConversationalScopeContainerFactory.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ConversationalScopeContainerFactory.java
deleted file mode 100644
index f8ffc027a1..0000000000
--- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/scope/impl/ConversationalScopeContainerFactory.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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.scope.impl;
-
-import org.apache.tuscany.sca.core.scope.Scope;
-import org.apache.tuscany.sca.core.scope.ScopeContainer;
-import org.apache.tuscany.sca.core.scope.ScopeContainerFactory;
-import org.apache.tuscany.sca.runtime.RuntimeComponent;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ConversationalScopeContainerFactory implements ScopeContainerFactory {
-
- public ConversationalScopeContainerFactory() {
- super();
- }
-
- public ScopeContainer createScopeContainer(RuntimeComponent component) {
- return new ConversationalScopeContainer(component);
- }
-
- public Scope getScope() {
- return Scope.CONVERSATION;
- }
-
-}