From cfb7e9a18f0cfdc2ca01874902e95adb61b4c6b8 Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 25 Sep 2009 21:08:37 +0000 Subject: Refactor CompositeActivator, ComponentContext and other related interfaces into core-spi module git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@819009 13f79535-47bb-0310-9956-ffa450edef68 --- .../sca/itest/builder/CustomCompositeBuilder.java | 2 +- java/sca/itest/properties/pom.xml | 32 --- .../org/apache/tuscany/sca/assembly/Composite.java | 4 + .../sca/assembly/builder/impl/BaseBuilderImpl.java | 8 +- .../builder/impl/CompositeCloneBuilderImpl.java | 20 +- .../assembly-validation-messages.properties | 6 +- .../tuscany/sca/context/CompositeContext.java | 215 ++++++++++++++++++++ .../tuscany/sca/context/ThreadMessageContext.java | 57 ++++++ .../tuscany/sca/runtime/ActivationException.java | 37 ++++ .../tuscany/sca/runtime/CompositeActivator.java | 127 ++++++++++++ .../tuscany/sca/runtime/EndpointSerializer.java | 38 ++++ .../sca/runtime/RuntimeComponentContext.java | 3 + .../sca/core/assembly/ActivationException.java | 37 ---- .../sca/core/assembly/CompositeActivator.java | 130 ------------ .../sca/core/assembly/EndpointSerializer.java | 38 ---- .../core/assembly/impl/CompositeActivatorImpl.java | 24 +-- .../core/assembly/impl/EndpointSerializerImpl.java | 2 +- .../core/assembly/impl/RuntimeEndpointImpl.java | 2 +- .../impl/RuntimeEndpointReferenceImpl.java | 2 +- .../sca/core/context/ComponentContextExt.java | 31 --- .../tuscany/sca/core/context/CompositeContext.java | 222 --------------------- .../sca/core/context/ServiceReferenceExt.java | 4 - .../core/context/impl/CallableReferenceImpl.java | 33 ++- .../context/impl/CallbackServiceReferenceImpl.java | 2 +- .../core/context/impl/ComponentContextImpl.java | 11 +- .../core/context/impl/CompositeContextImpl.java | 36 ++-- .../sca/core/context/impl/RequestContextImpl.java | 2 +- .../core/context/impl/ServiceReferenceImpl.java | 2 +- .../core/invocation/NonBlockingInterceptor.java | 1 + .../sca/core/invocation/RuntimeWireInvoker.java | 1 + .../sca/core/invocation/ThreadMessageContext.java | 81 -------- .../core/invocation/impl/JDKInvocationHandler.java | 2 +- ...he.tuscany.sca.core.assembly.CompositeActivator | 18 -- ...he.tuscany.sca.core.assembly.EndpointSerializer | 17 -- ...scany.sca.core.conversation.ConversationManager | 18 -- ...g.apache.tuscany.sca.runtime.CompositeActivator | 18 ++ ...g.apache.tuscany.sca.runtime.EndpointSerializer | 17 ++ .../tuscany/sca/binding/sca/EndpointTestCase.java | 2 +- .../impl/EndpointReferenceBuilderImpl.java | 11 +- .../tuscany/sca/binding/sca/EndpointTestCase.java | 4 +- .../injection/ConversationIDObjectFactory.java | 2 +- java/sca/modules/node-impl/META-INF/MANIFEST.MF | 1 + .../tuscany/sca/node/impl/NodeFactoryImpl.java | 2 +- .../org/apache/tuscany/sca/node/impl/NodeImpl.java | 6 +- 44 files changed, 618 insertions(+), 710 deletions(-) create mode 100644 java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java create mode 100644 java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java create mode 100644 java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java create mode 100644 java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java create mode 100644 java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java delete mode 100644 java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/ActivationException.java delete mode 100644 java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivator.java delete mode 100644 java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointSerializer.java delete mode 100644 java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextExt.java delete mode 100644 java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java delete mode 100644 java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java delete mode 100644 java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator delete mode 100644 java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.EndpointSerializer delete mode 100644 java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.conversation.ConversationManager create mode 100644 java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator create mode 100644 java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer (limited to 'java/sca') diff --git a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java index 2e06c845f2..c2ce5f87f2 100644 --- a/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java +++ b/java/sca/itest/builder/src/test/java/org/apache/tuscany/sca/itest/builder/CustomCompositeBuilder.java @@ -25,7 +25,6 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.node.Contribution; @@ -33,6 +32,7 @@ import org.apache.tuscany.sca.node.ContributionLocationHelper; import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.NodeFactory; import org.apache.tuscany.sca.node.impl.NodeImpl; +import org.apache.tuscany.sca.runtime.CompositeActivator; public class CustomCompositeBuilder { diff --git a/java/sca/itest/properties/pom.xml b/java/sca/itest/properties/pom.xml index 958c1b1a55..ec04cdba99 100644 --- a/java/sca/itest/properties/pom.xml +++ b/java/sca/itest/properties/pom.xml @@ -64,13 +64,6 @@ runtime - - org.apache.tuscany.sca - tuscany-databinding-sdo - 2.0-SNAPSHOT - compile - - org.apache.tuscany.sca tuscany-databinding-jaxb @@ -78,29 +71,4 @@ compile - - - - org.apache.tuscany.sdo - tuscany-sdo-plugin - 1.1.1 - - - generate-customer-sdo - generate-sources - - ${basedir}/src/main/resources/customer.xsd - com.example.customer.sdo - true - true - true - - - generate - - - - - - diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java index 6b2f16732d..64a55f1b44 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Composite.java @@ -30,6 +30,10 @@ import org.apache.tuscany.sca.policy.PolicySubject; * @version $Rev$ $Date$ */ public interface Composite extends Implementation, Extensible, Cloneable, PolicySubject { + /** + * Special name for the domain composite + */ + QName DOMAIN_COMPOSITE = new QName(SCA11_NS, ""); QName TYPE = new QName(SCA11_NS, "implementation.composite"); /** diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java index 4e8159b70c..cb74572fa9 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseBuilderImpl.java @@ -107,7 +107,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { * @param message * @param model */ - protected void warning(Monitor monitor, String message, Object model, String... messageParameters) { + protected void warning(Monitor monitor, String message, Object model, Object... messageParameters) { if (monitor != null) { Problem problem = monitor.createProblem(this.getClass().getName(), @@ -115,7 +115,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { Severity.WARNING, model, message, - (Object[])messageParameters); + messageParameters); monitor.problem(problem); } } @@ -128,7 +128,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { * @param message * @param model */ - protected void error(Monitor monitor, String message, Object model, String... messageParameters) { + protected void error(Monitor monitor, String message, Object model, Object... messageParameters) { if (monitor != null) { Problem problem = monitor.createProblem(this.getClass().getName(), @@ -136,7 +136,7 @@ public abstract class BaseBuilderImpl implements CompositeBuilder { Severity.ERROR, model, message, - (Object[])messageParameters); + messageParameters); monitor.problem(problem); } } diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java index 808ecf1993..57a87a7a0f 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/CompositeCloneBuilderImpl.java @@ -42,7 +42,22 @@ public class CompositeCloneBuilderImpl implements CompositeBuilder { public Composite build(Composite composite, Definitions definitions, Monitor monitor) throws CompositeBuilderException { - // Clone the includes + + if (Composite.DOMAIN_COMPOSITE.equals(composite.getName())) { + // Try to avoid clone for top-level composites that are added to the domain composite + for (Composite included : composite.getIncludes()) { + cloneIncludes(included); + } + } else { + // Clone the includes + cloneIncludes(composite); + } + + cloneCompositeImplementations(composite); + return composite; + } + + private void cloneIncludes(Composite composite) { List includes = new ArrayList(); for (Composite included : composite.getIncludes()) { try { @@ -53,9 +68,6 @@ public class CompositeCloneBuilderImpl implements CompositeBuilder { } composite.getIncludes().clear(); composite.getIncludes().addAll(includes); - - cloneCompositeImplementations(composite); - return composite; } public String getID() { diff --git a/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties b/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties index 4ef4101c37..05b36005a6 100644 --- a/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties +++ b/java/sca/modules/assembly/src/main/resources/assembly-validation-messages.properties @@ -49,7 +49,6 @@ NoSCABindingAvailableForUnresolvedService = A local service cannot be found for NoMatchingBinding = Component reference {0} does not have a binding which matches the bindings of service {1} NoMatchingCallbackBinding = Component reference {0} does not have a callback binding which matches the callback bindings of service {1} ReferenceEndPointMixWithTarget = Composite {0} Component {1} Reference {2} must not specify endpoints using both target attribute and with binding uri attribute -PolicyRelatedException = Policy Related Exception occured due to : {0} CompositeAlreadyIncluded = Composite {0} has already been included. ComponentReferenceMoreWire = Component reference {0} has more than one wires WireTargetNotFound = Wire target not found : {0} @@ -66,4 +65,7 @@ IllegalCompositeIncusion = Local Composite {0} cannot include a non-local compos PropertySourceNotFound = The property source {0} for property {1} in component {2} cannot be resolved to a composite property PropertySourceValueInvalid = The property source {0} for property {1} in component {2} has an invalid value. It should start with $ followed by the name of a composite property PropertySourceXPathInvalid = The property source {0} for property {1} in component {2} has an invalid XPath expression. The following error was returned while processing the XPath expression: {3} -PropertySourceXPathInvalid = The property file {0} for property {1} in component {2} is an invalid value. The following error was returned while processing the file name: {3} \ No newline at end of file +PropertySourceXPathInvalid = The property file {0} for property {1} in component {2} is an invalid value. The following error was returned while processing the file name: {3} +PolicyRelatedException = Policy Related Exception occured due to : {0} +IntentNotFound = Intent {0} is not defined in SCA definitions +MutuallyExclusiveIntents = Intent {0} and {1} are mutually exclusive [POL40009] \ No newline at end of file diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java new file mode 100644 index 0000000000..98a20d27d5 --- /dev/null +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/CompositeContext.java @@ -0,0 +1,215 @@ +/* + * 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.context; + +import java.io.IOException; +import java.io.Reader; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.ComponentReference; +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.interfacedef.InvalidInterfaceException; +import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.CompositeActivator; +import org.apache.tuscany.sca.runtime.EndpointRegistry; +import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentContext; +import org.apache.tuscany.sca.runtime.RuntimeComponentReference; +import org.apache.tuscany.sca.runtime.RuntimeComponentService; +import org.oasisopen.sca.ServiceRuntimeException; + +/** + * @version $Rev$ $Date$ + */ +public abstract class CompositeContext { + /** + * Create a self-reference for a component service + * @param component + * @param service + * @throws CloneNotSupportedException + * @throws InvalidInterfaceException + */ + public abstract ComponentReference createSelfReference(Component component, + ComponentService service, + Class businessInterface) + throws CloneNotSupportedException, InvalidInterfaceException; + + /** + * Bind a component reference to a component service + * @param + * @param businessInterface + * @param reference + * @param service + * @return + * @throws CloneNotSupportedException + * @throws InvalidInterfaceException + */ + public abstract RuntimeComponentReference bindComponentReference(Class businessInterface, + RuntimeComponentReference reference, + RuntimeComponent component, + RuntimeComponentService service) + throws CloneNotSupportedException, InvalidInterfaceException; + + /** + * @param component + * @param reference + * @param writer + * @throws IOException + */ + public abstract void write(Component component, ComponentReference reference, Writer writer) throws IOException; + + /** + * @param component + * @param reference + * @param service + * @param writer + * @throws IOException + */ + public abstract void write(Component component, + ComponentReference reference, + ComponentService service, + Writer writer) throws IOException; + + /** + * @param component + * @param reference + * @return + * @throws IOException + */ + public abstract String toXML(Component component, ComponentReference reference) throws IOException; + + /** + * @param component + * @param service + * @return + * @throws IOException + */ + public abstract String toXML(Component component, ComponentService service) throws IOException; + + /** + * @param reader + * @return + * @throws IOException + */ + public abstract RuntimeComponent read(Reader reader) throws IOException; + + /** + * @param streamReader + * @return + * @throws IOException + */ + public abstract RuntimeComponent read(XMLStreamReader streamReader) throws IOException; + + /** + * @param xml + * @return + * @throws IOException + */ + public abstract Component fromXML(String xml) throws IOException; + + /** + * @param streamReader + * @return + * @throws IOException + */ + public abstract Component fromXML(XMLStreamReader streamReader) throws IOException; + + /** + * @return + */ + public static RuntimeComponent getCurrentComponent() { + Message message = ThreadMessageContext.getMessageContext(); + if (message != null) { + Endpoint to = message.getTo(); + if (to == null) { + return null; + } + RuntimeComponent component = (RuntimeComponent) message.getTo().getComponent(); + return component; + } + return null; + } + + /** + * @return + */ + public static CompositeActivator getCurrentCompositeActivator() { + RuntimeComponent component = getCurrentComponent(); + if (component != null) { + RuntimeComponentContext context = component.getComponentContext(); + return context.getCompositeActivator(); + } + return null; + } + + /** + * @return + */ + public static CompositeContext getCurrentCompositeContext() { + CompositeActivator activator = getCurrentCompositeActivator(); + if (activator != null) { + return activator.getCompositeContext(); + } + return null; + } + + /** + * @param component + */ + public static ComponentService getSingleService(Component component) { + ComponentService targetService; + List services = component.getServices(); + List regularServices = new ArrayList(); + for (ComponentService service : services) { + if (service.isForCallback()) { + continue; + } + String name = service.getName(); + if (!name.startsWith("$") || name.startsWith("$dynamic$")) { + regularServices.add(service); + } + } + if (regularServices.size() == 0) { + throw new ServiceRuntimeException("No service is declared on component " + component.getURI()); + } + if (regularServices.size() != 1) { + throw new ServiceRuntimeException("More than one service is declared on component " + component.getURI() + + ". Service name is required to get the service."); + } + targetService = regularServices.get(0); + return targetService; + } + + public abstract ExtensionPointRegistry getExtensionPointRegistry(); + + /** + * Get the EndpointRegistry + * @return + */ + public abstract EndpointRegistry getEndpointRegistry(); + +} diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java new file mode 100644 index 0000000000..d6237b7ce3 --- /dev/null +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/context/ThreadMessageContext.java @@ -0,0 +1,57 @@ +/* + * 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.context; + +import org.apache.tuscany.sca.invocation.Message; + +/** + * Class for tunnelling a WorkContext through the invocation of a user class. + * + * @version $Rev$ $Date$ + */ +public final class ThreadMessageContext { + + private static final ThreadLocal CONTEXT = new ThreadLocal(); + + private ThreadMessageContext() { + } + + public static Message setMessageContext(Message context) { + Message old = CONTEXT.get(); + CONTEXT.set(context); + return old; + } + + /** + * Returns the WorkContext for the current thread. + * + * @return the WorkContext for the current thread + */ + public static Message getMessageContext() { + return CONTEXT.get(); + } + + /** + * Removes and state from the current thread to ensure that + * any associated classloaders can be GCd + */ + public static void removeMessageContext() { + CONTEXT.remove(); + } +} diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java new file mode 100644 index 0000000000..b015891e93 --- /dev/null +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/ActivationException.java @@ -0,0 +1,37 @@ +/* + * 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.runtime; + + +/** + * Denotes an error starting the runtime + * + * @version $Rev$ $Date$ + */ +public class ActivationException extends Exception { + private static final long serialVersionUID = 8612661660934426123L; + + public ActivationException(String message) { + super(message); + } + + public ActivationException(Throwable cause) { + super(cause); + } +} diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java new file mode 100644 index 0000000000..a80a14f7f2 --- /dev/null +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/CompositeActivator.java @@ -0,0 +1,127 @@ +/* + * 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.runtime; + +import org.apache.tuscany.sca.assembly.Component; +import org.apache.tuscany.sca.assembly.Composite; +import org.apache.tuscany.sca.context.CompositeContext; + +/** + * Start/stop a composite + * + * @version $Rev$ $Date$ + */ +public interface CompositeActivator { + /** + * Activate a composite + * @param composite + */ + void activate(Composite composite) throws ActivationException; + + /** + * Activate a component reference + * @param component + * @param ref + */ + void start(RuntimeComponent component, RuntimeComponentReference ref); + + /** + * Activate a component reference + * @param component + * @param ref + */ + void activate(RuntimeComponent component, RuntimeComponentReference ref); + + /** + * Activate a component reference + * @param component + * @param ref + */ + void activate(RuntimeComponent component, RuntimeComponentService service); + + /** + * De-activate a component reference + * @param component + * @param ref + */ + void deactivate(RuntimeComponent component, RuntimeComponentReference ref); + + /** + * De-activate a component reference + * @param component + * @param ref + */ + void deactivate(RuntimeComponent component, RuntimeComponentService service); + + /** + * Stop a composite + * @param composite + */ + void deactivate(Composite composite) throws ActivationException; + + /** + * Start a component + * @param component + */ + void start(Component component) throws ActivationException; + + /** + * Stop a component + * @param component + */ + void stop(Component component) throws ActivationException; + + /** + * Start components in a composite + * @param composite + */ + void start(Composite composite) throws ActivationException; + + /** + * Stop components in a composite + * @param composite + */ + void stop(Composite composite) throws ActivationException; + + /** + * Get the component context helper + * @return + */ + CompositeContext getCompositeContext(); + + /** + * Configure the runtime component with component context + * @param component + */ + void configureComponentContext(RuntimeComponent component); + + /** + * Set the domain composite + * @param domainComposite + */ + void setDomainComposite(Composite domainComposite); + + /** + * Get the domain composite + * @return + */ + Composite getDomainComposite(); + +} diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java new file mode 100644 index 0000000000..c56869170a --- /dev/null +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/EndpointSerializer.java @@ -0,0 +1,38 @@ +/* + * 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.runtime; + +import java.io.IOException; + +import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.assembly.EndpointReference; + +/** + * A utility to seralize/deserialize Endpoint/EndpointReference objects + */ +public interface EndpointSerializer { + void read(Endpoint endpoint, String xml) throws IOException; + + String write(Endpoint endpoint) throws IOException; + + void read(EndpointReference endpointReference, String xml) throws IOException; + + String write(EndpointReference endpointReference) throws IOException; +} diff --git a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java index 236a143fb3..eadfccf064 100644 --- a/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java +++ b/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/sca/runtime/RuntimeComponentContext.java @@ -25,6 +25,7 @@ import java.io.Writer; import org.apache.tuscany.sca.assembly.ComponentService; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.oasisopen.sca.ComponentContext; import org.oasisopen.sca.ServiceReference; @@ -102,4 +103,6 @@ public interface RuntimeComponentContext extends ComponentContext { ServiceReference createSelfReference(Class businessInterface, ComponentService service); ExtensionPointRegistry getExtensionPointRegistry(); + CompositeActivator getCompositeActivator(); + CompositeContext getCompositeContext(); } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/ActivationException.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/ActivationException.java deleted file mode 100644 index c86c876075..0000000000 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/ActivationException.java +++ /dev/null @@ -1,37 +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.assembly; - - -/** - * Denotes an error starting the runtime - * - * @version $Rev$ $Date$ - */ -public class ActivationException extends Exception { - private static final long serialVersionUID = 8612661660934426123L; - - public ActivationException(String message) { - super(message); - } - - public ActivationException(Throwable cause) { - super(cause); - } -} diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivator.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivator.java deleted file mode 100644 index c8518650fb..0000000000 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/CompositeActivator.java +++ /dev/null @@ -1,130 +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.assembly; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.core.context.CompositeContext; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; - -/** - * Start/stop a composite - * - * @version $Rev$ $Date$ - */ -public interface CompositeActivator { - /** - * Activate a composite - * @param composite - */ - void activate(Composite composite) throws ActivationException; - - /** - * Activate a component reference - * @param component - * @param ref - */ - void start(RuntimeComponent component, RuntimeComponentReference ref); - - /** - * Activate a component reference - * @param component - * @param ref - */ - void activate(RuntimeComponent component, RuntimeComponentReference ref); - - /** - * Activate a component reference - * @param component - * @param ref - */ - void activate(RuntimeComponent component, RuntimeComponentService service); - - /** - * De-activate a component reference - * @param component - * @param ref - */ - void deactivate(RuntimeComponent component, RuntimeComponentReference ref); - - /** - * De-activate a component reference - * @param component - * @param ref - */ - void deactivate(RuntimeComponent component, RuntimeComponentService service); - - /** - * Stop a composite - * @param composite - */ - void deactivate(Composite composite) throws ActivationException; - - /** - * Start a component - * @param component - */ - void start(Component component) throws ActivationException; - - /** - * Stop a component - * @param component - */ - void stop(Component component) throws ActivationException; - - /** - * Start components in a composite - * @param composite - */ - void start(Composite composite) throws ActivationException; - - /** - * Stop components in a composite - * @param composite - */ - void stop(Composite composite) throws ActivationException; - - /** - * Get the component context helper - * @return - */ - CompositeContext getCompositeContext(); - - /** - * Configure the runtime component with component context - * @param component - */ - void configureComponentContext(RuntimeComponent component); - - /** - * Set the domain composite - * @param domainComposite - */ - void setDomainComposite(Composite domainComposite); - - /** - * Get the domain composite - * @return - */ - Composite getDomainComposite(); - -} diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointSerializer.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointSerializer.java deleted file mode 100644 index b9c9c7032b..0000000000 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/EndpointSerializer.java +++ /dev/null @@ -1,38 +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.assembly; - -import java.io.IOException; - -import org.apache.tuscany.sca.assembly.Endpoint; -import org.apache.tuscany.sca.assembly.EndpointReference; - -/** - * A utility to seralize/deserialize Endpoint/EndpointReference objects - */ -public interface EndpointSerializer { - void read(Endpoint endpoint, String xml) throws IOException; - - String write(Endpoint endpoint) throws IOException; - - void read(EndpointReference endpointReference, String xml) throws IOException; - - String write(EndpointReference endpointReference) throws IOException; -} 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 50db444c2a..fd0302829d 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 @@ -37,24 +37,18 @@ import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.context.ComponentContextFactory; +import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint; -import org.apache.tuscany.sca.context.PropertyValueFactory; -import org.apache.tuscany.sca.context.RequestContextFactory; 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.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.invocation.ExtensibleWireProcessor; -import org.apache.tuscany.sca.core.invocation.ProxyFactory; 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.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; import org.apache.tuscany.sca.invocation.MessageFactory; import org.apache.tuscany.sca.provider.BindingProviderFactory; import org.apache.tuscany.sca.provider.ImplementationProvider; @@ -64,6 +58,8 @@ import org.apache.tuscany.sca.provider.PolicyProviderFactory; import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint; import org.apache.tuscany.sca.provider.ReferenceBindingProvider; import org.apache.tuscany.sca.provider.ServiceBindingProvider; +import org.apache.tuscany.sca.runtime.ActivationException; +import org.apache.tuscany.sca.runtime.CompositeActivator; import org.apache.tuscany.sca.runtime.EndpointRegistry; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentContext; @@ -90,10 +86,6 @@ public class CompositeActivatorImpl implements CompositeActivator { private final ProviderFactoryExtensionPoint providerFactories; private final ComponentContextFactory componentContextFactory; - private final RequestContextFactory requestContextFactory; - private final ProxyFactory proxyFactory; - private final JavaInterfaceFactory javaInterfaceFactory; - private final PropertyValueFactory propertyValueFactory; private final EndpointRegistry endpointRegistry; private final CompositeContext compositeContext; @@ -102,23 +94,19 @@ public class CompositeActivatorImpl implements CompositeActivator { public CompositeActivatorImpl(ExtensionPointRegistry extensionPoints) { this.extensionPoints = extensionPoints; - this.compositeContext = new CompositeContextImpl(extensionPoints); + UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); + this.endpointRegistry = utilities.getUtility(EndpointRegistry.class); + this.compositeContext = new CompositeContextImpl(extensionPoints, endpointRegistry); FactoryExtensionPoint factories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); this.assemblyFactory = factories.getFactory(AssemblyFactory.class); this.messageFactory = factories.getFactory(MessageFactory.class); - UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class); this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class); this.scopeRegistry = utilities.getUtility(ScopeRegistry.class); this.workScheduler = utilities.getUtility(WorkScheduler.class); this.wireProcessor = new ExtensibleWireProcessor(extensionPoints.getExtensionPoint(RuntimeWireProcessorExtensionPoint.class)); this.providerFactories = extensionPoints.getExtensionPoint(ProviderFactoryExtensionPoint.class); - this.javaInterfaceFactory = compositeContext.getJavaInterfaceFactory(); - this.propertyValueFactory = factories.getFactory(PropertyValueFactory.class); ContextFactoryExtensionPoint contextFactories = extensionPoints.getExtensionPoint(ContextFactoryExtensionPoint.class); this.componentContextFactory = contextFactories.getFactory(ComponentContextFactory.class); - this.requestContextFactory = contextFactories.getFactory(RequestContextFactory.class); - proxyFactory = compositeContext.getProxyFactory(); - this.endpointRegistry = utilities.getUtility(EndpointRegistry.class); } //========================================================================= diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java index f4cc957f26..c2fa113d5f 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/EndpointSerializerImpl.java @@ -34,7 +34,7 @@ import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.assembly.EndpointSerializer; +import org.apache.tuscany.sca.runtime.EndpointSerializer; public class EndpointSerializerImpl implements EndpointSerializer { private XMLInputFactory inputFactory; diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java index 3876776846..357d19091b 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointImpl.java @@ -27,7 +27,7 @@ import java.io.ObjectOutput; import org.apache.tuscany.sca.assembly.impl.EndpointImpl; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.EndpointSerializer; +import org.apache.tuscany.sca.runtime.EndpointSerializer; /** * Runtime model for Endpoint that supports java serialization diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java index 5543ec1225..2b1c85b95a 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java @@ -27,7 +27,7 @@ import java.io.ObjectOutput; import org.apache.tuscany.sca.assembly.impl.EndpointReferenceImpl; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.EndpointSerializer; +import org.apache.tuscany.sca.runtime.EndpointSerializer; /** * Runtime model for Endpoint that supports java serialization diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextExt.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextExt.java deleted file mode 100644 index 6db3af213d..0000000000 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ComponentContextExt.java +++ /dev/null @@ -1,31 +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.context; - -import org.apache.tuscany.sca.core.assembly.CompositeActivator; -import org.apache.tuscany.sca.runtime.RuntimeComponentContext; - -/** - * Extended ComponentContext - */ -public interface ComponentContextExt extends RuntimeComponentContext { - CompositeActivator getCompositeActivator(); - CompositeContext getCompositeContext(); -} 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 deleted file mode 100644 index 46643f643b..0000000000 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/CompositeContext.java +++ /dev/null @@ -1,222 +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.context; - -import java.io.IOException; -import java.io.Reader; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.sca.assembly.Component; -import org.apache.tuscany.sca.assembly.ComponentReference; -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.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; -import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; -import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; -import org.apache.tuscany.sca.invocation.Message; -import org.apache.tuscany.sca.runtime.RuntimeComponent; -import org.apache.tuscany.sca.runtime.RuntimeComponentReference; -import org.apache.tuscany.sca.runtime.RuntimeComponentService; -import org.oasisopen.sca.ServiceRuntimeException; - -/** - * @version $Rev$ $Date$ - */ -public abstract class CompositeContext { - /** - * Create a self-reference for a component service - * @param component - * @param service - * @throws CloneNotSupportedException - * @throws InvalidInterfaceException - */ - public abstract ComponentReference createSelfReference(Component component, - ComponentService service, - Class businessInterface) - throws CloneNotSupportedException, InvalidInterfaceException; - - /** - * Bind a component reference to a component service - * @param - * @param businessInterface - * @param reference - * @param service - * @return - * @throws CloneNotSupportedException - * @throws InvalidInterfaceException - */ - public abstract RuntimeComponentReference bindComponentReference(Class businessInterface, - RuntimeComponentReference reference, - RuntimeComponent component, - RuntimeComponentService service) - throws CloneNotSupportedException, InvalidInterfaceException; - - /** - * @param component - * @param reference - * @param writer - * @throws IOException - */ - public abstract void write(Component component, ComponentReference reference, Writer writer) throws IOException; - - /** - * @param component - * @param reference - * @param service - * @param writer - * @throws IOException - */ - public abstract void write(Component component, - ComponentReference reference, - ComponentService service, - Writer writer) throws IOException; - - /** - * @param component - * @param reference - * @return - * @throws IOException - */ - public abstract String toXML(Component component, ComponentReference reference) throws IOException; - - /** - * @param component - * @param service - * @return - * @throws IOException - */ - public abstract String toXML(Component component, ComponentService service) throws IOException; - - /** - * @param reader - * @return - * @throws IOException - */ - public abstract RuntimeComponent read(Reader reader) throws IOException; - - /** - * @param streamReader - * @return - * @throws IOException - */ - public abstract RuntimeComponent read(XMLStreamReader streamReader) throws IOException; - - /** - * @param xml - * @return - * @throws IOException - */ - public abstract Component fromXML(String xml) throws IOException; - - /** - * @param streamReader - * @return - * @throws IOException - */ - public abstract Component fromXML(XMLStreamReader streamReader) throws IOException; - - /** - * @return - */ - public static RuntimeComponent getCurrentComponent() { - Message message = ThreadMessageContext.getMessageContext(); - if (message != null) { - Endpoint to = message.getTo(); - if (to == null) { - return null; - } - RuntimeComponent component = (RuntimeComponent) message.getTo().getComponent(); - return component; - } - return null; - } - - /** - * @return - */ - public static CompositeActivator getCurrentCompositeActivator() { - RuntimeComponent component = getCurrentComponent(); - if (component != null) { - ComponentContextExt context = (ComponentContextExt)component.getComponentContext(); - return context.getCompositeActivator(); - } - return null; - } - - /** - * @return - */ - public static CompositeContext getCurrentCompositeContext() { - CompositeActivator activator = getCurrentCompositeActivator(); - if (activator != null) { - return activator.getCompositeContext(); - } - return null; - } - - /** - * @param component - */ - public static ComponentService getSingleService(Component component) { - ComponentService targetService; - List services = component.getServices(); - List regularServices = new ArrayList(); - for (ComponentService service : services) { - if (service.isForCallback()) { - continue; - } - String name = service.getName(); - if (!name.startsWith("$") || name.startsWith("$dynamic$")) { - regularServices.add(service); - } - } - if (regularServices.size() == 0) { - throw new ServiceRuntimeException("No service is declared on component " + component.getURI()); - } - if (regularServices.size() != 1) { - throw new ServiceRuntimeException("More than one service is declared on component " + component.getURI() - + ". Service name is required to get the service."); - } - targetService = regularServices.get(0); - return targetService; - } - - public abstract ExtensionPointRegistry getExtensionPointRegistry(); - - /** - * Get the java interface factory - * @return - */ - public abstract JavaInterfaceFactory getJavaInterfaceFactory(); - - /** - * Get the proxy factory - * @return - */ - public abstract ProxyFactory getProxyFactory(); - -} diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java index d590e0118c..9b60415132 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/ServiceReferenceExt.java @@ -20,14 +20,10 @@ package org.apache.tuscany.sca.core.context; import java.io.Externalizable; -import java.io.IOException; -import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.contribution.processor.ContributionReadException; -import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; import org.apache.tuscany.sca.runtime.RuntimeWire; import org.oasisopen.sca.ServiceReference; 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 86c3d2e199..d6a029cd55 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 @@ -42,22 +42,24 @@ import org.apache.tuscany.sca.assembly.EndpointReference; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.builder.BindingBuilder; import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint; +import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.contribution.processor.ContributionReadException; import org.apache.tuscany.sca.contribution.processor.ContributionWriteException; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory; import org.apache.tuscany.sca.core.assembly.impl.ReferenceParametersImpl; -import org.apache.tuscany.sca.core.context.ComponentContextExt; -import org.apache.tuscany.sca.core.context.CompositeContext; import org.apache.tuscany.sca.core.context.ServiceReferenceExt; import org.apache.tuscany.sca.core.factory.ObjectCreationException; +import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; +import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; +import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; +import org.apache.tuscany.sca.runtime.CompositeActivator; import org.apache.tuscany.sca.runtime.ReferenceParameters; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; @@ -200,7 +202,7 @@ public class CallableReferenceImpl implements ServiceReferenceExt { this.component = (RuntimeComponent)wire.getEndpointReference().getComponent(); this.reference = (RuntimeComponentReference)wire.getEndpointReference().getReference(); this.endpointReference = wire.getEndpointReference(); - this.compositeActivator = ((ComponentContextExt)component.getComponentContext()).getCompositeActivator(); + this.compositeActivator = component.getComponentContext().getCompositeActivator(); initCallbackID(); } } @@ -415,9 +417,11 @@ public class CallableReferenceImpl implements ServiceReferenceExt { return Thread.currentThread().getContextClassLoader(); } }); + javaInterface.setJavaClass(classLoader.loadClass(javaInterface.getName())); - compositeActivator.getCompositeContext().getJavaInterfaceFactory() - .createJavaInterface(javaInterface, javaInterface.getJavaClass()); + JavaInterfaceFactory javaInterfaceFactory = getJavaInterfaceFactory(compositeActivator); + + javaInterfaceFactory.createJavaInterface(javaInterface, javaInterface.getJavaClass()); //FIXME: If the interface needs XSDs to be loaded (e.g., for static SDO), // this needs to be done here. We usually search for XSDs in the current // contribution at resolve time. Is it possible to locate the current @@ -434,14 +438,27 @@ public class CallableReferenceImpl implements ServiceReferenceExt { } } - this.proxyFactory = compositeActivator.getCompositeContext().getProxyFactory(); + this.proxyFactory = getProxyFactory(this.compositeActivator); } else if (compositeActivator == null) { this.compositeActivator = CompositeContext.getCurrentCompositeActivator(); if (this.compositeActivator != null) { - this.proxyFactory = this.compositeActivator.getCompositeContext().getProxyFactory(); + this.proxyFactory = getProxyFactory(this.compositeActivator); } } } + + private JavaInterfaceFactory getJavaInterfaceFactory(CompositeActivator activator) { + ExtensionPointRegistry extensionPointRegistry = activator.getCompositeContext().getExtensionPointRegistry(); + FactoryExtensionPoint factories = extensionPointRegistry.getExtensionPoint(FactoryExtensionPoint.class); + JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class); + return javaInterfaceFactory; + } + + private ProxyFactory getProxyFactory(CompositeActivator activator) { + ExtensionPointRegistry extensionPointRegistry = activator.getCompositeContext().getExtensionPointRegistry(); + ProxyFactoryExtensionPoint proxyFactories = extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class); + return new ExtensibleProxyFactory(proxyFactories); + } // ================================================================================== diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java index 31db699063..5218a7fd01 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/CallbackServiceReferenceImpl.java @@ -24,9 +24,9 @@ import java.util.List; import org.apache.tuscany.sca.assembly.Binding; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.core.assembly.impl.RuntimeWireImpl; import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeWire; diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java index 21f907608c..fa8c1a4dfa 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/ComponentContextImpl.java @@ -37,15 +37,13 @@ import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.assembly.builder.EndpointReferenceBuilder; +import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.context.ContextFactoryExtensionPoint; import org.apache.tuscany.sca.context.PropertyValueFactory; import org.apache.tuscany.sca.context.RequestContextFactory; 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.assembly.CompositeActivator; -import org.apache.tuscany.sca.core.context.ComponentContextExt; -import org.apache.tuscany.sca.core.context.CompositeContext; import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; @@ -57,7 +55,9 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; +import org.apache.tuscany.sca.runtime.CompositeActivator; import org.apache.tuscany.sca.runtime.RuntimeComponent; +import org.apache.tuscany.sca.runtime.RuntimeComponentContext; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; import org.oasisopen.sca.RequestContext; @@ -70,7 +70,7 @@ import org.oasisopen.sca.ServiceRuntimeException; * * @version $Rev$ $Date$ */ -public class ComponentContextImpl implements ComponentContextExt { +public class ComponentContextImpl implements RuntimeComponentContext { private final RuntimeComponent component; private final CompositeActivator compositeActivator; @@ -87,8 +87,11 @@ public class ComponentContextImpl implements ComponentContextExt { FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); this.assemblyFactory = factories.getFactory(AssemblyFactory.class); this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class); + + // FIXME: We need to have node-specific compositeActivator UtilityExtensionPoint utilities = registry.getExtensionPoint(UtilityExtensionPoint.class); this.compositeActivator = utilities.getUtility(CompositeActivator.class); + this.requestContextFactory = registry.getExtensionPoint(ContextFactoryExtensionPoint.class).getFactory(RequestContextFactory.class); this.proxyFactory = new ExtensibleProxyFactory(registry.getExtensionPoint(ProxyFactoryExtensionPoint.class)); 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 1fa976cfb7..b26861aa79 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 @@ -44,23 +44,23 @@ import org.apache.tuscany.sca.assembly.Multiplicity; import org.apache.tuscany.sca.assembly.OptimizableBinding; import org.apache.tuscany.sca.assembly.Reference; import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.context.CompositeContext; +import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; 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.assembly.CompositeActivator; -import org.apache.tuscany.sca.core.context.CompositeContext; import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; import org.apache.tuscany.sca.interfacedef.Interface; import org.apache.tuscany.sca.interfacedef.InterfaceContract; import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory; import org.apache.tuscany.sca.invocation.Message; +import org.apache.tuscany.sca.runtime.CompositeActivator; +import org.apache.tuscany.sca.runtime.EndpointRegistry; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeComponentService; @@ -71,25 +71,27 @@ import org.oasisopen.sca.ServiceRuntimeException; */ public class CompositeContextImpl extends CompositeContext { private final ExtensionPointRegistry extensionPointRegistry; - private final UtilityExtensionPoint utilityExtensionPoint; + private final EndpointRegistry endpointRegistry; private final AssemblyFactory assemblyFactory; private final JavaInterfaceFactory javaInterfaceFactory; private final StAXArtifactProcessorExtensionPoint staxProcessors; private final XMLInputFactory xmlInputFactory; private final XMLOutputFactory xmlOutputFactory; - private final ProxyFactory proxyFactory; - public CompositeContextImpl(ExtensionPointRegistry registry) { + public CompositeContextImpl(ExtensionPointRegistry registry, EndpointRegistry endpointRegistry) { this.extensionPointRegistry = registry; - this.utilityExtensionPoint = extensionPointRegistry.getExtensionPoint(UtilityExtensionPoint.class); + this.endpointRegistry = endpointRegistry; FactoryExtensionPoint factories = registry.getExtensionPoint(FactoryExtensionPoint.class); this.xmlInputFactory = factories.getFactory(XMLInputFactory.class); this.xmlOutputFactory = factories.getFactory(XMLOutputFactory.class); this.assemblyFactory = factories.getFactory(AssemblyFactory.class); this.javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class); this.staxProcessors = registry.getExtensionPoint(StAXArtifactProcessorExtensionPoint.class); + } + + private ProxyFactory getProxyFactory() { ProxyFactoryExtensionPoint proxyFactories = extensionPointRegistry.getExtensionPoint(ProxyFactoryExtensionPoint.class); - this.proxyFactory = new ExtensibleProxyFactory(proxyFactories); + return new ExtensibleProxyFactory(proxyFactories); } /** @@ -331,20 +333,8 @@ public class CompositeContextImpl extends CompositeContext { return extensionPointRegistry; } - /** - * Get the java interface factory - * @return - */ - public JavaInterfaceFactory getJavaInterfaceFactory() { - return javaInterfaceFactory; - } - - /** - * Get the proxy factory - * @return - */ - public ProxyFactory getProxyFactory() { - return proxyFactory; + public EndpointRegistry getEndpointRegistry() { + return endpointRegistry; } } diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java index a4ea709fa1..e8a1254dc9 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/context/impl/RequestContextImpl.java @@ -23,11 +23,11 @@ import java.util.List; import javax.security.auth.Subject; import org.apache.tuscany.sca.assembly.Endpoint; +import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.invocation.ExtensibleProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactory; import org.apache.tuscany.sca.core.invocation.ProxyFactoryExtensionPoint; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; import org.apache.tuscany.sca.interfacedef.java.JavaInterface; import org.apache.tuscany.sca.invocation.Message; import org.apache.tuscany.sca.runtime.RuntimeComponent; 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 edd11aacc5..20b607ce74 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 @@ -21,8 +21,8 @@ package org.apache.tuscany.sca.core.context.impl; import javax.xml.stream.XMLStreamReader; import org.apache.tuscany.sca.assembly.EndpointReference; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; import org.apache.tuscany.sca.core.invocation.ProxyFactory; +import org.apache.tuscany.sca.runtime.CompositeActivator; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentReference; import org.apache.tuscany.sca.runtime.RuntimeWire; diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java index b08ded18c4..ec2f0a0664 100644 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java +++ b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/NonBlockingInterceptor.java @@ -26,6 +26,7 @@ import java.util.logging.Logger; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.Interceptor; import org.apache.tuscany.sca.invocation.Invoker; 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 7901a7fa55..0b50cbb2d3 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,6 +22,7 @@ package org.apache.tuscany.sca.core.invocation; import java.lang.reflect.InvocationTargetException; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.core.factory.InstanceWrapper; import org.apache.tuscany.sca.interfacedef.Operation; import org.apache.tuscany.sca.invocation.InvocationChain; diff --git a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java b/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java deleted file mode 100644 index 13ce6510ae..0000000000 --- a/java/sca/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/ThreadMessageContext.java +++ /dev/null @@ -1,81 +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.invocation; - -import org.apache.tuscany.sca.core.invocation.impl.MessageImpl; -import org.apache.tuscany.sca.invocation.Message; - -/** - * Class for tunnelling a WorkContext through the invocation of a user class. - * - * @version $Rev$ $Date$ - */ -public final class ThreadMessageContext { - - private static final ThreadLocal CONTEXT = new ThreadLocal() { - @Override - protected synchronized Message initialValue() { - //Message msg = new MessageImpl(); - // TODO - EPR - What to set as default? - //msg.setFrom(new EndpointReferenceImpl("/")); - return null;//msg; - } - }; - - private ThreadMessageContext() { - } - - /** - * Set the WorkContext for the current thread. - * The current work context is returned and must be restored after the invocation is complete. - * Typical usage would be: - *
-     *   WorkContext old = PojoWorkContextTunnel.setThreadWorkContext(newContext);
-     *   try {
-     *      ... invoke user code ...
-     *   } finally {
-     *     PojoWorkContextTunnel.setThreadWorkContext(old);
-     *   }
-     * 
- * @param context - * @return the current work context for the thread; this must be restored after the invocation is made - */ - public static Message setMessageContext(Message context) { - Message old = CONTEXT.get(); - CONTEXT.set(context); - return old; - } - - /** - * Returns the WorkContext for the current thread. - * - * @return the WorkContext for the current thread - */ - public static Message getMessageContext() { - return CONTEXT.get(); - } - - /** - * Removes and state from the current thread to ensure that - * any associated classloaders can be GCd - */ - public static void removeMessageContext() { - CONTEXT.remove(); - } -} 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 5e36d724f5..148749922e 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 @@ -29,9 +29,9 @@ import java.util.Map; import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.EndpointReference; +import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.core.context.ServiceReferenceExt; import org.apache.tuscany.sca.core.factory.InstanceWrapper; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; import org.apache.tuscany.sca.core.scope.TargetResolutionException; import org.apache.tuscany.sca.interfacedef.DataType; import org.apache.tuscany.sca.interfacedef.Operation; diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator deleted file mode 100644 index d5e13292d2..0000000000 --- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.CompositeActivator +++ /dev/null @@ -1,18 +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. - -org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.EndpointSerializer b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.EndpointSerializer deleted file mode 100644 index cc3306b325..0000000000 --- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.assembly.EndpointSerializer +++ /dev/null @@ -1,17 +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. -org.apache.tuscany.sca.core.assembly.impl.EndpointSerializerImpl \ No newline at end of file diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.conversation.ConversationManager b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.conversation.ConversationManager deleted file mode 100644 index 67cec934b4..0000000000 --- a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.core.conversation.ConversationManager +++ /dev/null @@ -1,18 +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. - -org.apache.tuscany.sca.core.conversation.impl.ConversationManagerImpl diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator new file mode 100644 index 0000000000..d5e13292d2 --- /dev/null +++ b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.CompositeActivator @@ -0,0 +1,18 @@ +# 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. + +org.apache.tuscany.sca.core.assembly.impl.CompositeActivatorImpl diff --git a/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer new file mode 100644 index 0000000000..cc3306b325 --- /dev/null +++ b/java/sca/modules/core/src/main/resources/META-INF/services/org.apache.tuscany.sca.runtime.EndpointSerializer @@ -0,0 +1,17 @@ +# 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. +org.apache.tuscany.sca.core.assembly.impl.EndpointSerializerImpl \ No newline at end of file diff --git a/java/sca/modules/endpoint-wrapper/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java b/java/sca/modules/endpoint-wrapper/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java index 79fd678922..51c02d544f 100644 --- a/java/sca/modules/endpoint-wrapper/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java +++ b/java/sca/modules/endpoint-wrapper/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java @@ -45,10 +45,10 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint; import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.runtime.CompositeActivator; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; diff --git a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java index 58285d3e03..8fb02d40a3 100644 --- a/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java +++ b/java/sca/modules/endpoint/src/main/java/org/apache/tuscany/sca/endpoint/impl/EndpointReferenceBuilderImpl.java @@ -33,8 +33,6 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; import org.apache.tuscany.sca.monitor.Problem; -import org.apache.tuscany.sca.policy.Intent; -import org.apache.tuscany.sca.policy.PolicySet; import org.apache.tuscany.sca.runtime.EndpointRegistry; /** @@ -223,9 +221,15 @@ public class EndpointReferenceBuilderImpl implements EndpointReferenceBuilder { return problem; } - + + // FIXME: [rfeng] This implementation is wrong. It is the responsibility of the policy language + // to compare the reference and service side setting to determine if they are compatible. Some of + // policies apply to the reference side only, some of the policies apply to the service side only, + // while others apply to both sides. Even for those policies that apply to both side, they can be + // independent or related. private boolean haveMatchingPolicy(EndpointReference endpointReference, Endpoint endpoint){ + /* // if no policy sets or intents are present then they match if ((endpointReference.getRequiredIntents().size() == 0) && (endpoint.getRequiredIntents().size() == 0) && @@ -290,6 +294,7 @@ public class EndpointReferenceBuilderImpl implements EndpointReferenceBuilder { return false; } } + */ return true; } diff --git a/java/sca/modules/endpoint/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java b/java/sca/modules/endpoint/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java index 7faefefc24..12a915c5db 100644 --- a/java/sca/modules/endpoint/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java +++ b/java/sca/modules/endpoint/src/test/java/org/apace/tuscany/sca/binding/sca/EndpointTestCase.java @@ -29,8 +29,8 @@ import javax.xml.stream.XMLOutputFactory; import org.apache.tuscany.sca.assembly.AssemblyFactory; import org.apache.tuscany.sca.assembly.ComponentReference; import org.apache.tuscany.sca.assembly.Composite; -import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.assembly.builder.BuilderExtensionPoint; +import org.apache.tuscany.sca.assembly.builder.CompositeBuilder; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.processor.ExtensibleStAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; @@ -45,10 +45,10 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.ModuleActivatorExtensionPoint; import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; import org.apache.tuscany.sca.core.assembly.RuntimeAssemblyFactory; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.MonitorFactory; +import org.apache.tuscany.sca.runtime.CompositeActivator; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Ignore; diff --git a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java index 4bf55e3a72..956225b9e6 100644 --- a/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java +++ b/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/injection/ConversationIDObjectFactory.java @@ -18,8 +18,8 @@ */ package org.apache.tuscany.sca.implementation.java.injection; +import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.core.factory.ObjectFactory; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; /** * Object Factory that is used to retrieve the ConversationID from the diff --git a/java/sca/modules/node-impl/META-INF/MANIFEST.MF b/java/sca/modules/node-impl/META-INF/MANIFEST.MF index 11f988243c..4ec6d5c84d 100644 --- a/java/sca/modules/node-impl/META-INF/MANIFEST.MF +++ b/java/sca/modules/node-impl/META-INF/MANIFEST.MF @@ -25,6 +25,7 @@ Import-Package: javax.management, org.apache.tuscany.sca.assembly.xml;version="2.0.0", org.apache.tuscany.sca.common.java.io;version="2.0.0", org.apache.tuscany.sca.common.xml.stax;version="2.0.0", + org.apache.tuscany.sca.context;version="2.0.0", org.apache.tuscany.sca.contribution;version="2.0.0", org.apache.tuscany.sca.contribution.processor;version="2.0.0", org.apache.tuscany.sca.contribution.resolver;version="2.0.0", diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java index 54277a5fc6..7978f9c256 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeFactoryImpl.java @@ -541,7 +541,7 @@ public class NodeFactoryImpl extends NodeFactory { // Create a top level composite to host our composite // This is temporary to make the activator happy Composite domainComposite = assemblyFactory.createComposite(); - domainComposite.setName(new QName(Base.SCA11_NS, "")); + domainComposite.setName(Composite.DOMAIN_COMPOSITE); domainComposite.setURI(Base.SCA11_NS); for (Contribution contribution : contributions) { diff --git a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java index fa9c2dcc1f..cd279f9fcd 100644 --- a/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java +++ b/java/sca/modules/node-impl/src/main/java/org/apache/tuscany/sca/node/impl/NodeImpl.java @@ -37,20 +37,20 @@ import org.apache.tuscany.sca.assembly.Endpoint; import org.apache.tuscany.sca.assembly.Implementation; import org.apache.tuscany.sca.assembly.Service; import org.apache.tuscany.sca.common.java.io.IOHelper; +import org.apache.tuscany.sca.context.ThreadMessageContext; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.core.ExtensionPointRegistry; import org.apache.tuscany.sca.core.UtilityExtensionPoint; -import org.apache.tuscany.sca.core.assembly.ActivationException; -import org.apache.tuscany.sca.core.assembly.CompositeActivator; import org.apache.tuscany.sca.core.invocation.ProxyFactory; -import org.apache.tuscany.sca.core.invocation.ThreadMessageContext; import org.apache.tuscany.sca.node.Client; import org.apache.tuscany.sca.node.Node; import org.apache.tuscany.sca.node.NodeFinder; import org.apache.tuscany.sca.node.configuration.NodeConfiguration; import org.apache.tuscany.sca.node.management.NodeManager; +import org.apache.tuscany.sca.runtime.ActivationException; +import org.apache.tuscany.sca.runtime.CompositeActivator; import org.apache.tuscany.sca.runtime.RuntimeComponent; import org.apache.tuscany.sca.runtime.RuntimeComponentContext; import org.apache.tuscany.sca.runtime.RuntimeComponentService; -- cgit v1.2.3