diff options
Diffstat (limited to 'java/sca/modules')
37 files changed, 8 insertions, 2227 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; - } - -} diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java index 8e90ddb577..a5513a0c3c 100644 --- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java +++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaComponentContextProvider.java @@ -21,7 +21,6 @@ package org.apache.tuscany.sca.implementation.java.invocation; import java.lang.annotation.ElementType; import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.lang.reflect.Member; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Type; @@ -53,8 +52,6 @@ import org.apache.tuscany.sca.databinding.DataBindingExtensionPoint; import org.apache.tuscany.sca.implementation.java.JavaConstructorImpl; import org.apache.tuscany.sca.implementation.java.JavaElementImpl; import org.apache.tuscany.sca.implementation.java.JavaResourceImpl; -import org.apache.tuscany.sca.implementation.java.injection.ConversationIDObjectFactory; -import org.apache.tuscany.sca.implementation.java.injection.InvalidAccessorException; import org.apache.tuscany.sca.implementation.java.injection.JavaPropertyValueObjectFactory; import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper; import org.apache.tuscany.sca.interfacedef.Operation; @@ -64,7 +61,6 @@ 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.annotation.ConversationID; /** * The runtime instantiation of Java component implementations @@ -275,24 +271,6 @@ public class JavaComponentContextProvider { instanceFactoryProvider.setObjectFactory(resource.getElement(), factory); } - void addConversationIDFactories(List<Member> names) { - ObjectFactory<String> factory = new ConversationIDObjectFactory(); - for (Member name : names) { - if (name instanceof Field) { - JavaElementImpl element = new JavaElementImpl((Field)name); - element.setClassifer(ConversationID.class); - instanceFactoryProvider.setObjectFactory(element, factory); - } else if (name instanceof Method) { - JavaElementImpl element = new JavaElementImpl((Method)name, 0); - element.setName(JavaIntrospectionHelper.toPropertyName(name.getName())); - element.setClassifer(ConversationID.class); - instanceFactoryProvider.setObjectFactory(element, factory); - } else { - throw new InvalidAccessorException("Member must be a field or method: " + name.getName()); - } - } - } - Object createInstance() throws ObjectCreationException { return createInstanceWrapper().getInstance(); } diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java index 9f716c8059..55765ef6e4 100644 --- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java +++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationProvider.java @@ -21,7 +21,6 @@ package org.apache.tuscany.sca.implementation.java.invocation; import java.lang.reflect.Method; -import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.context.ComponentContextFactory; import org.apache.tuscany.sca.context.PropertyValueFactory; import org.apache.tuscany.sca.context.RequestContextFactory; @@ -78,29 +77,6 @@ public class JavaImplementationProvider implements ScopedImplementationProvider Scope scope = getScope(); - if (scope == Scope.SYSTEM || scope == Scope.COMPOSITE) { - // Nothing - } else { - // Check for conversational contract if conversational scope - if (scope == Scope.CONVERSATION) { - boolean hasConversationalContract = false; - for (Service serviceDef : implementation.getServices()) { - if (serviceDef.getInterfaceContract().getInterface().isConversational()) { - hasConversationalContract = true; - break; - } - } - if (!hasConversationalContract) { - String name = implementation.getJavaClass().getName(); - throw new NoConversationalContractException(name); - } - } - } - - if (implementation.getConversationIDMembers().size() > 0) { - componentContextProvider.addConversationIDFactories(implementation.getConversationIDMembers()); - } - componentContextProvider.configureProperties(component.getProperties()); handleResources(implementation, proxyService); } catch (Exception e) { diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java index 39484b8840..f72b40d794 100644 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java +++ b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/JavaImplementationActivator.java @@ -29,8 +29,6 @@ import org.apache.tuscany.sca.implementation.java.introspect.impl.AllowsPassByRe import org.apache.tuscany.sca.implementation.java.introspect.impl.ComponentNameProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ConstructorProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.ContextProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationIDProcessor; -import org.apache.tuscany.sca.implementation.java.introspect.impl.ConversationProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.DestroyProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.EagerInitProcessor; import org.apache.tuscany.sca.implementation.java.introspect.impl.HeuristicPojoProcessor; @@ -62,8 +60,6 @@ public class JavaImplementationActivator implements ModuleActivator { new AllowsPassByReferenceProcessor(assemblyFactory), new ComponentNameProcessor(assemblyFactory), new ContextProcessor(assemblyFactory), - new ConversationIDProcessor(assemblyFactory), - new ConversationProcessor(assemblyFactory), new DestroyProcessor(assemblyFactory), new EagerInitProcessor(assemblyFactory), new InitProcessor(assemblyFactory), new PropertyProcessor(assemblyFactory), new ReferenceProcessor(assemblyFactory, javaFactory), diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessor.java deleted file mode 100644 index ef94104cbd..0000000000 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessor.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.implementation.java.introspect.impl; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.implementation.java.IntrospectionException; -import org.apache.tuscany.sca.implementation.java.JavaElementImpl; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.JavaResourceImpl; -import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor; -import org.apache.tuscany.sca.implementation.java.introspect.JavaIntrospectionHelper; -import org.oasisopen.sca.annotation.ConversationID; - -/** - * Processes {@link @ConversationID} annotations on a component implementation and adds - * a {@link JavaMappedProperty} to the component type which will be used to - * inject the appropriate conversationId - * - * @version $Rev$ $Date$ - */ -public class ConversationIDProcessor extends BaseJavaClassVisitor { - - public ConversationIDProcessor(AssemblyFactory factory) { - super(factory); - } - - @Override - public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException { - if (method.getAnnotation(ConversationID.class) == null) { - return; - } - if (method.getParameterTypes().length != 1) { - throw new IllegalContextException("ConversationID setter must have one parameter", method); - } - String name = JavaIntrospectionHelper.toPropertyName(method.getName()); - JavaElementImpl element = new JavaElementImpl(method, 0); - element.setName(name); - element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class); - JavaResourceImpl resource = new JavaResourceImpl(element); - type.getResources().put(resource.getName(), resource); - } - - @Override - public void visitField(Field field, JavaImplementation type) throws IntrospectionException { - if (field.getAnnotation(ConversationID.class) == null) { - return; - } - JavaElementImpl element = new JavaElementImpl(field); - element.setClassifer(org.apache.tuscany.sca.implementation.java.introspect.impl.Resource.class); - JavaResourceImpl resource = new JavaResourceImpl(element); - type.getResources().put(resource.getName(), resource); - } -} diff --git a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessor.java b/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessor.java deleted file mode 100644 index 2fb657159b..0000000000 --- a/java/sca/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessor.java +++ /dev/null @@ -1,133 +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.implementation.java.introspect.impl; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.assembly.AssemblyFactory; -import org.apache.tuscany.sca.implementation.java.IntrospectionException; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.introspect.BaseJavaClassVisitor; -import org.oasisopen.sca.annotation.ConversationAttributes; -import org.oasisopen.sca.annotation.ConversationID; -import org.oasisopen.sca.annotation.Scope; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationProcessor extends BaseJavaClassVisitor { - private static final String SECONDS = " SECONDS"; - private static final String MINUTES = " MINUTES"; - private static final String HOURS = " HOURS"; - private static final String DAYS = " DAYS"; - private static final String YEARS = " YEARS"; - - public ConversationProcessor(AssemblyFactory factory) { - super(factory); - } - - @Override - public <T> void visitClass(Class<T> clazz, JavaImplementation type) throws IntrospectionException { - - ConversationAttributes conversation = clazz.getAnnotation(ConversationAttributes.class); - if (conversation == null) { - return; - } - Scope scope = clazz.getAnnotation(Scope.class); - if (scope == null) { - // implicitly assume conversation - type.setJavaScope(org.apache.tuscany.sca.implementation.java.JavaScopeImpl.CONVERSATION); - } else if (conversation != null) { - long maxAge; - long maxIdleTime; - String maxAgeVal = conversation.maxAge(); - String maxIdleTimeVal = conversation.maxIdleTime(); - try { - if (maxAgeVal.length() > 0) { - maxAge = convertTimeMillis(maxAgeVal); - type.setMaxAge(maxAge); - } - } catch (NumberFormatException e) { - throw new InvalidConversationalImplementationException("Invalid maximum age", e); - } - try { - if (maxIdleTimeVal.length() > 0) { - maxIdleTime = convertTimeMillis(maxIdleTimeVal); - type.setMaxIdleTime(maxIdleTime); - } - } catch (NumberFormatException e) { - throw new InvalidConversationalImplementationException("Invalid maximum idle time", e); - } - } - - } - - @Override - public void visitMethod(Method method, - JavaImplementation type) throws IntrospectionException { - ConversationID conversationID = method.getAnnotation(ConversationID.class); - if (conversationID == null) { - return; - } - type.addConversationIDMember(method); - } - - @Override - public void visitField(Field field, - JavaImplementation type) throws IntrospectionException { - ConversationID conversationID = field.getAnnotation(ConversationID.class); - if (conversationID == null) { - return; - } - type.addConversationIDMember(field); - } - - static long convertTimeMillis(String expr) throws NumberFormatException { - expr = expr.trim().toUpperCase(); - int i = expr.lastIndexOf(SECONDS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 1000; - } - i = expr.lastIndexOf(MINUTES); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 60000; - } - - i = expr.lastIndexOf(HOURS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 3600000; - } - i = expr.lastIndexOf(DAYS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 86400000; - } - i = expr.lastIndexOf(YEARS); - if (i >= 0) { - String units = expr.substring(0, i); - return Long.parseLong(units) * 31556926000L; - } - return Long.parseLong(expr) * 1000; // assume seconds if no suffix - // specified - } -} diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java deleted file mode 100644 index 9bff2aa556..0000000000 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationIDProcessorTestCase.java +++ /dev/null @@ -1,99 +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.implementation.java.introspect.impl; - -import static org.junit.Assert.assertNotNull; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; -import org.junit.Before; -import org.junit.Test; -import org.oasisopen.sca.annotation.ConversationID; - -/** - * Test the ConversationIDProcessor - * - * @version $Rev$ $Date$ - */ -public class ConversationIDProcessorTestCase { - private ConversationIDProcessor processor; - private JavaImplementationFactory javaImplementationFactory; - - @Test - public void testConversationIDMethod() throws Exception { - Method method = Foo.class.getMethod("setConversationID", String.class); - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitMethod(method, type); - assertNotNull(type.getResources().get("conversationID")); - } - - @Test - public void testConversationIDField() throws Exception { - Field field = Foo.class.getDeclaredField("cid"); - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitField(field, type); - assertNotNull(type.getResources().get("cid")); - } - - @Test - public void testConversationIDMethodNotString() throws Exception { - Method method = Foo.class.getMethod("setConversationID", Long.class); - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitMethod(method, type); - assertNotNull(type.getResources().get("conversationID")); - } - - @Test - public void testConversationIDFieldNotString() throws Exception { - Field field = Foo.class.getDeclaredField("longCID"); - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitField(field, type); - assertNotNull(type.getResources().get("longCID")); - } - - @Before - public void setUp() throws Exception { - javaImplementationFactory = new DefaultJavaImplementationFactory(); - processor = new ConversationIDProcessor(new DefaultAssemblyFactory()); - } - - private class Foo { - - @ConversationID - protected String cid; - - @ConversationID - public void setConversationID(String cid) { - - } - - @ConversationID - protected Long longCID; - - @ConversationID - public void setConversationID(Long cid) { - - } - } -} diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java deleted file mode 100644 index 9978cd456d..0000000000 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConversationProcessorTestCase.java +++ /dev/null @@ -1,153 +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.implementation.java.introspect.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.apache.tuscany.sca.implementation.java.DefaultJavaImplementationFactory; -import org.apache.tuscany.sca.implementation.java.JavaImplementation; -import org.apache.tuscany.sca.implementation.java.JavaImplementationFactory; -import org.junit.Test; -import org.oasisopen.sca.annotation.ConversationAttributes; -import org.oasisopen.sca.annotation.ConversationID; -import org.oasisopen.sca.annotation.Scope; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationProcessorTestCase { - private ConversationProcessor processor = new ConversationProcessor(new DefaultAssemblyFactory()); - private JavaImplementationFactory javaImplementationFactory = new DefaultJavaImplementationFactory(); - - @Test - public void testMaxIdleTime() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(FooMaxIdle.class, type); - assertEquals(10000L, type.getMaxIdleTime()); - assertEquals(-1, type.getMaxAge()); - } - - @Test - public void testMaxAge() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(FooMaxAge.class, type); - assertEquals(10000L, type.getMaxAge()); - assertEquals(-1, type.getMaxIdleTime()); - } - - @Test - public void testImplicitScope() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(ImplicitFooScope.class, type); - assertEquals(org.apache.tuscany.sca.implementation.java.JavaScopeImpl.CONVERSATION, type.getJavaScope()); - } - - /* TUSCANY-1999 - apply conversation properties to all scopes - public void testBadFooScope() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - try { - processor.visitClass(BadFooScope.class, type); - fail(); - } catch (InvalidConversationalImplementation e) { - // expected - } - } - */ - - @Test - public void testBadFooBoth() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(BadFooBoth.class, type); - assertEquals(10000L, type.getMaxAge()); - assertEquals(10000L, type.getMaxIdleTime()); - } - - @Test - public void testJustConversation() throws Exception { - // TODO do we want these semantics - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - processor.visitClass(FooJustConversation.class, type); - assertEquals(org.apache.tuscany.sca.implementation.java.JavaScopeImpl.CONVERSATION, type.getJavaScope()); - assertEquals(-1, type.getMaxAge()); - assertEquals(-1, type.getMaxIdleTime()); - } - - @Test - public void testSetConversationIDField() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - Field field = FooWithConversationIDField.class.getDeclaredField("conversationID"); - processor.visitField(field, type); - assertNotNull(type.getConversationIDMembers()); - assertEquals(field, type.getConversationIDMembers().get(0)); - } - - @Test - public void testSetConversationIDMethod() throws Exception { - JavaImplementation type = javaImplementationFactory.createJavaImplementation(); - Method method = FooWithConversationIDMethod.class.getDeclaredMethods()[0]; - processor.visitMethod(method, type); - assertNotNull(type.getConversationIDMembers()); - assertEquals(method, type.getConversationIDMembers().get(0)); - } - - @Scope("CONVERSATION") - @ConversationAttributes(maxIdleTime = "10 seconds") - private class FooMaxIdle { - } - - @Scope("CONVERSATION") - @ConversationAttributes(maxAge = "10 seconds") - private class FooMaxAge { - } - - @Scope("CONVERSATION") - @ConversationAttributes(maxAge = "10 seconds", maxIdleTime = "10 seconds") - private class BadFooBoth { - } - - @ConversationAttributes(maxAge = "10 seconds") - private class ImplicitFooScope { - } - - @Scope("STATELESS") - @ConversationAttributes(maxAge = "10 seconds") - private class BadFooScope { - } - - @ConversationAttributes - private class FooJustConversation { - } - - private class FooWithConversationIDField { - - @ConversationID - String conversationID; - } - - private class FooWithConversationIDMethod { - @ConversationID - void setConversationID(String conversationID) { - } - } -} diff --git a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java b/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java deleted file mode 100644 index 4e5a2dfee6..0000000000 --- a/java/sca/modules/implementation-java/src/test/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ConvertTimeMillisTestCase.java +++ /dev/null @@ -1,114 +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.implementation.java.introspect.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.apache.tuscany.sca.assembly.DefaultAssemblyFactory; -import org.junit.Test; - -/** - * @version $Rev$ $Date$ - */ -public class ConvertTimeMillisTestCase { - - @Test - public void testConvertSeconds() throws Exception { - assertEquals(10000L, MockProcessor.convertTimeMillis("10 seconds")); - assertEquals(10000L, MockProcessor.convertTimeMillis("10 SECONDS")); - try { - MockProcessor.convertTimeMillis("10seconds"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertMinutes() throws Exception { - assertEquals(600000L, MockProcessor.convertTimeMillis("10 minutes")); - assertEquals(600000L, MockProcessor.convertTimeMillis("10 MINUTES")); - try { - MockProcessor.convertTimeMillis("10minutes"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertHours() throws Exception { - assertEquals(36000000L, MockProcessor.convertTimeMillis("10 hours")); - assertEquals(36000000L, MockProcessor.convertTimeMillis("10 HOURS")); - try { - MockProcessor.convertTimeMillis("10hours"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertDays() throws Exception { - assertEquals(864000000L, MockProcessor.convertTimeMillis("10 days")); - assertEquals(864000000L, MockProcessor.convertTimeMillis("10 DAYS")); - try { - MockProcessor.convertTimeMillis("10days"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertYears() throws Exception { - assertEquals(315569260000L, MockProcessor.convertTimeMillis("10 years")); - assertEquals(315569260000L, MockProcessor.convertTimeMillis("10 YEARS")); - try { - MockProcessor.convertTimeMillis("10years"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - @Test - public void testConvertDefault() throws Exception { - assertEquals(10000L, MockProcessor.convertTimeMillis("10 ")); - assertEquals(10000L, MockProcessor.convertTimeMillis("10")); - } - - @Test - public void testInvalid() throws Exception { - try { - MockProcessor.convertTimeMillis("foo"); - fail(); - } catch (NumberFormatException e) { - // expected - } - } - - private class MockProcessor extends ConversationProcessor { - - public MockProcessor() { - super(new DefaultAssemblyFactory()); - } - } -} diff --git a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java index 029af36d55..894b2f705c 100644 --- a/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java +++ b/java/sca/modules/interface-java/src/main/java/org/apache/tuscany/sca/interfacedef/java/impl/JavaInterfaceIntrospectorImpl.java @@ -34,7 +34,6 @@ import java.util.Set; import javax.xml.namespace.QName; -import org.apache.tuscany.sca.interfacedef.ConversationSequence; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.InvalidCallbackException; import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; @@ -48,8 +47,6 @@ import org.apache.tuscany.sca.interfacedef.java.JavaOperation; import org.apache.tuscany.sca.interfacedef.java.introspect.JavaInterfaceVisitor; import org.apache.tuscany.sca.interfacedef.util.JavaXMLMapper; import org.apache.tuscany.sca.interfacedef.util.XMLType; -import org.oasisopen.sca.annotation.Conversational; -import org.oasisopen.sca.annotation.EndsConversation; import org.oasisopen.sca.annotation.OneWay; import org.oasisopen.sca.annotation.Remotable; @@ -96,9 +93,6 @@ public class JavaInterfaceIntrospectorImpl { javaInterface.setRemotable(remotable); - boolean conversational = clazz.isAnnotationPresent(Conversational.class); - javaInterface.setConversational(conversational); - Class<?> callbackClass = null; org.oasisopen.sca.annotation.Callback callback = clazz.getAnnotation(org.oasisopen.sca.annotation.Callback.class); if (callback != null && !Void.class.equals(callback.value())) { @@ -118,7 +112,7 @@ public class JavaInterfaceIntrospectorImpl { javaInterface.setCallbackClass(callbackClass); String ns = JavaXMLMapper.getNamespace(clazz); - javaInterface.getOperations().addAll(getOperations(clazz, remotable, conversational, ns)); + javaInterface.getOperations().addAll(getOperations(clazz, remotable, ns)); for (JavaInterfaceVisitor extension : visitors) { extension.visitInterface(javaInterface); @@ -146,7 +140,6 @@ public class JavaInterfaceIntrospectorImpl { private <T> List<Operation> getOperations(Class<T> clazz, boolean remotable, - boolean conversational, String ns) throws InvalidInterfaceException { Set<Type> genericInterfaces = new HashSet<Type>(); @@ -201,18 +194,6 @@ public class JavaInterfaceIntrospectorImpl { } } - ConversationSequence conversationSequence = ConversationSequence.CONVERSATION_NONE; - if (method.isAnnotationPresent(EndsConversation.class)) { - if (!conversational) { - throw new InvalidOperationException( - "Method is marked as end conversation but contract is not conversational", - method); - } - conversationSequence = ConversationSequence.CONVERSATION_END; - } else if (conversational) { - conversationSequence = ConversationSequence.CONVERSATION_CONTINUE; - } - // Set outputType to null for void XMLType xmlReturnType = new XMLType(new QName(ns, "return"), null); DataType<XMLType> returnDataType = @@ -249,7 +230,6 @@ public class JavaInterfaceIntrospectorImpl { operation.setInputType(inputType); operation.setOutputType(returnDataType); operation.setFaultTypes(faultDataTypes); - operation.setConversationSequence(conversationSequence); operation.setNonBlocking(nonBlocking); operation.setJavaMethod(method); operations.add(operation); diff --git a/java/sca/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/ConversationalIntrospectionTestCase.java b/java/sca/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/ConversationalIntrospectionTestCase.java deleted file mode 100644 index 638603a02e..0000000000 --- a/java/sca/modules/interface-java/src/test/java/org/apache/tuscany/sca/interfacedef/java/introspection/impl/ConversationalIntrospectionTestCase.java +++ /dev/null @@ -1,107 +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.interfacedef.java.introspection.impl; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import org.apache.tuscany.sca.interfacedef.ConversationSequence; -import org.apache.tuscany.sca.interfacedef.Interface; -import org.apache.tuscany.sca.interfacedef.InvalidOperationException; -import org.apache.tuscany.sca.interfacedef.Operation; -import org.apache.tuscany.sca.interfacedef.java.DefaultJavaInterfaceFactory; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.junit.Before; -import org.junit.Test; -import org.oasisopen.sca.annotation.Conversational; -import org.oasisopen.sca.annotation.EndsConversation; - -/** - * @version $Rev$ $Date$ - */ -public class ConversationalIntrospectionTestCase { - private JavaInterfaceFactory javaFactory; - - @Before - public void setUp() throws Exception { - javaFactory = new DefaultJavaInterfaceFactory(); - } - - private Operation getOperation(Interface i, String name) { - for (Operation op : i.getOperations()) { - if (op.getName().equals(name)) { - return op; - } - } - return null; - } - - @Test - public void testServiceContractConversationalInformationIntrospection() throws Exception { - Interface i = javaFactory.createJavaInterface(Foo.class); - assertNotNull(i); - assertTrue(i.isConversational()); - ConversationSequence seq = getOperation(i, "operation").getConversationSequence(); - assertEquals(ConversationSequence.CONVERSATION_CONTINUE, seq); - seq = getOperation(i, "endOperation").getConversationSequence(); - assertEquals(ConversationSequence.CONVERSATION_END, seq); - } - - @Test - public void testBadServiceContract() throws Exception { - try { - javaFactory.createJavaInterface(BadFoo.class); - fail(); - } catch (InvalidOperationException e) { - // expected - } - } - - @Test - public void testNonConversationalInformationIntrospection() throws Exception { - Interface i = javaFactory.createJavaInterface(NonConversationalFoo.class); - assertFalse(i.isConversational()); - ConversationSequence seq = getOperation(i, "operation") - .getConversationSequence(); - assertEquals(ConversationSequence.CONVERSATION_NONE, seq); - } - - @Conversational - private interface Foo { - void operation(); - - @EndsConversation - void endOperation(); - } - - private interface BadFoo { - void operation(); - - @EndsConversation - void endOperation(); - } - - private interface NonConversationalFoo { - void operation(); - } - -} diff --git a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/CallableReference.java b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/CallableReference.java index cdfaded693..ac36dec8f1 100644 --- a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/CallableReference.java +++ b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/CallableReference.java @@ -31,21 +31,6 @@ public interface CallableReference<B> { Class<B> getBusinessInterface(); /** - * Returns true if this reference is conversational. - * - * @return true if this reference is conversational - */ - boolean isConversational(); - - /** - * Returns the conversation associated with this reference. - * Returns null if no conversation is currently active. - * - * @return the conversation associated with this reference; may be null - */ - Conversation getConversation(); - - /** * Returns the callback ID. * * @return the callback ID diff --git a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/Conversation.java b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/Conversation.java deleted file mode 100644 index d4e4034eed..0000000000 --- a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/Conversation.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * (c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA Technologies, - * Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens AG., Software AG., Sybase - * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved. - * - * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications - */ -package org.oasisopen.sca; - -/** - * Interface representing a Conversation providing access to the conversation id and and a mechanism - * to terminate the conversation. - * - * @version $Rev$ $Date$ - */ -public interface Conversation { - /** - * Returns the identifier for this conversation. - * If a user-defined identity had been supplied for this reference then its value will be returned; - * otherwise the identity generated by the system when the conversation was initiated will be returned. - * - * @return the identifier for this conversation - */ - Object getConversationID(); - - /** - * End this conversation. - */ - void end(); -} diff --git a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/ConversationEndedException.java b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/ConversationEndedException.java deleted file mode 100644 index 72944d6dfc..0000000000 --- a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/ConversationEndedException.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * (c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA Technologies, - * Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens AG., Software AG., Sybase - * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved. - * - * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications - */ -package org.oasisopen.sca; - -/** - * Exception thrown to indicate the conversation being used for a stateful interaction has been ended. - * - * @version $Rev$ $Date$ - */ -public class ConversationEndedException extends ServiceRuntimeException { - private static final long serialVersionUID = 3734864942222558406L; - - /** - * Override constructor from ServiceRuntimeException. - * - * @see ServiceRuntimeException - */ - public ConversationEndedException() { - } - - /** - * Override constructor from ServiceRuntimeException. - * - * @param message passed to ServiceRuntimeException - * @see ServiceRuntimeException - */ - public ConversationEndedException(String message) { - super(message); - } - - /** - * Override constructor from ServiceRuntimeException. - * - * @param message passed to ServiceRuntimeException - * @param cause passed to ServiceRuntimeException - * @see ServiceRuntimeException - */ - public ConversationEndedException(String message, Throwable cause) { - super(message, cause); - } - - /** - * Override constructor from ServiceRuntimeException. - * - * @param cause passed to ServiceRuntimeException - * @see ServiceRuntimeException - */ - public ConversationEndedException(Throwable cause) { - super(cause); - } -} diff --git a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java index 55d875a5f3..c8392edf36 100644 --- a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java +++ b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/ServiceReference.java @@ -16,22 +16,6 @@ package org.oasisopen.sca; */ public interface ServiceReference<B> extends CallableReference<B> { /** - * Returns the id supplied by the user that will be associated with conversations initiated through this reference. - * - * @return the id to associated with any conversation initiated through this reference - */ - Object getConversationID(); - - /** - * Set the id to associate with any conversation started through this reference. - * If the value supplied is null then the id will be generated by the implementation. - * - * @param conversationId the user-defined id to associated with a conversation - * @throws IllegalStateException if a conversation is currently associated with this reference - */ - void setConversationID(Object conversationId) throws IllegalStateException; - - /** * Sets the callback ID. * * @param callbackID the callback ID diff --git a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ConversationAttributes.java b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ConversationAttributes.java deleted file mode 100644 index 498cc3eea3..0000000000 --- a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ConversationAttributes.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA Technologies, - * Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens AG., Software AG., Sybase - * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved. - * - * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications - */ -package org.oasisopen.sca.annotation; - -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Annotation used to indicate the characteristics of a conversation. - * - * @version $Rev$ $Date$ - */ -@Target(ElementType.TYPE) -@Retention(RUNTIME) -public @interface ConversationAttributes { - /** - * The maximum time that can pass between operations in a single conversation. If this time is exceeded the - * container may end the conversation. - * - * @return the maximum time that can pass between operations in a single conversation - */ - String maxIdleTime() default ""; - - /** - * The maximum time that a conversation may remain active. If this time is exceeded the container may end the - * conversation. - * - * @return the maximum time that a conversation may remain active - */ - String maxAge() default ""; - - /** - * If true, indicates that only the user that initiated the conversation has the authority to continue it. - * - * @return true if only the user that initiated the conversation has the authority to continue it - */ - boolean singlePrincipal() default false; -} diff --git a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ConversationID.java b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ConversationID.java deleted file mode 100644 index 2cc62afdbf..0000000000 --- a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/ConversationID.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA Technologies, - * Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens AG., Software AG., Sybase - * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved. - * - * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications - */ -package org.oasisopen.sca.annotation; - -import static java.lang.annotation.ElementType.FIELD; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Annotation used to indicate a field or method that is used to inject the conversation ID. - * - * @version $Rev$ $Date$ - */ -@Target({METHOD, FIELD}) -@Retention(RUNTIME) -public @interface ConversationID { -} diff --git a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Conversational.java b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Conversational.java deleted file mode 100644 index 6a406f2acc..0000000000 --- a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/Conversational.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * (c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA Technologies, - * Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens AG., Software AG., Sybase - * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved. - * - * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications - */ -package org.oasisopen.sca.annotation; - -import static java.lang.annotation.ElementType.TYPE; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Used on a Java interface to denote a conversational service contract. - * <p/> - * The draft spec erroneously defines the targets for this as {TYPE, METHOD, FIELD} - * but this annotation is only applicable to interfaces. - * - * @version $Rev$ $Date$ - */ -@Target({TYPE}) -@Retention(RUNTIME) -public @interface Conversational { -} diff --git a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EndsConversation.java b/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EndsConversation.java deleted file mode 100644 index 4f58c50802..0000000000 --- a/java/sca/modules/sca-api/src/main/java/org/oasisopen/sca/annotation/EndsConversation.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * (c) Copyright BEA Systems, Inc., Cape Clear Software, International Business Machines Corp, Interface21, IONA Technologies, - * Oracle, Primeton Technologies, Progress Software, Red Hat, Rogue Wave Software, SAP AG., Siemens AG., Software AG., Sybase - * Inc., TIBCO Software Inc., 2005, 2007. All rights reserved. - * - * see http://www.osoa.org/display/Main/Service+Component+Architecture+Specifications - */ -package org.oasisopen.sca.annotation; - -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.RetentionPolicy.RUNTIME; - -import java.lang.annotation.Retention; -import java.lang.annotation.Target; - -/** - * Annotation used to indicate a method ends a conversation. - * - * @version $Rev$ $Date$ - */ -@Target({METHOD}) -@Retention(RUNTIME) -public @interface EndsConversation { -} |