diff options
Diffstat (limited to 'sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl')
6 files changed, 670 insertions, 0 deletions
diff --git a/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java new file mode 100644 index 0000000000..a40d91b9bc --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELDocumentProcessor.java @@ -0,0 +1,133 @@ +/* + * 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.bpel.impl; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URL; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.implementation.bpel.BPELFactory; +import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition; + +/** + * BPEL document processor responsible for reading a BPEL file and producing necessary model info about it + * + * @version $Rev$ $Date$ + */ +public class BPELDocumentProcessor extends BaseStAXArtifactProcessor implements URLArtifactProcessor<BPELProcessDefinition> { + public final static QName BPEL_PROCESS_DEFINITION = new QName("http://schemas.xmlsoap.org/ws/2004/03/business-process/", "process"); + public final static QName BPEL_EXECUTABLE_DEFINITION = new QName("http://docs.oasis-open.org/wsbpel/2.0/process/executable", "process"); + public final static String NAME_ELEMENT = "name"; + + private final static XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + + private final BPELFactory factory; + + public BPELDocumentProcessor(ModelFactoryExtensionPoint modelFactories) { + this.factory = modelFactories.getFactory(BPELFactory.class); + } + + public String getArtifactType() { + return "*.bpel"; + } + + public Class<BPELProcessDefinition> getModelType() { + return BPELProcessDefinition.class; + } + + public BPELProcessDefinition read(URL contributionURL, URI artifactURI, URL artifactURL) throws ContributionReadException { + BPELProcessDefinition processDefinition = null; + try { + //for now we are just using process name + //and relying on componentType file for service definition + //so it's ok to set resolved for now + processDefinition = indexRead(artifactURL); + processDefinition.setURI(artifactURI); + processDefinition.setUnresolved(false); + } catch (Exception e) { + throw new ContributionReadException(e); + } + + return processDefinition; + } + + + public void resolve(BPELProcessDefinition model, ModelResolver resolver) throws ContributionResolveException { + + } + + /** + * Read the namespace for the WSDL definition and inline schemas + * + * @param doc + * @return + * @throws IOException + * @throws XMLStreamException + */ + protected BPELProcessDefinition indexRead(URL doc) throws Exception { + BPELProcessDefinition processDefinition = factory.createBPELProcessDefinition(); + processDefinition.setUnresolved(true); + processDefinition.setLocation(doc); + + InputStream is = doc.openStream(); + XMLStreamReader reader = null; + try { + reader = inputFactory.createXMLStreamReader(is); + int eventType = reader.getEventType(); + while (true) { + if (eventType == XMLStreamConstants.START_ELEMENT) { + QName elementName = reader.getName(); + if (BPEL_PROCESS_DEFINITION.equals(elementName) || BPEL_EXECUTABLE_DEFINITION.equals(elementName) ) { + QName processName = new QName(getString(reader, org.apache.tuscany.sca.assembly.xml.Constants.TARGET_NAMESPACE), getString(reader, NAME_ELEMENT)); + processDefinition.setName(processName); + break; + } + } + if (reader.hasNext()) { + eventType = reader.next(); + } else { + break; + } + } + } finally { + if(reader != null) { + reader.close(); + } + is.close(); + } + + return processDefinition; + } + + +} diff --git a/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java new file mode 100644 index 0000000000..3442d86c4e --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationImpl.java @@ -0,0 +1,110 @@ +/* + * 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.bpel.impl; + +import java.util.Collections; +import java.util.List; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ConstrainingType; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.impl.ImplementationImpl; +import org.apache.tuscany.sca.implementation.bpel.BPELImplementation; +import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition; +import org.apache.tuscany.sca.interfacedef.wsdl.WSDLFactory; + +/** + * The model representing a BPEL implementation in an SCA assembly model. + * + * @version $Rev$ $Date$ + */ +public class BPELImplementationImpl extends ImplementationImpl implements BPELImplementation { + + private QName _processName; + private BPELProcessDefinition _processDefinition; + + /** + * Constructs a new BPEL implementation. + */ + public BPELImplementationImpl(AssemblyFactory assemblyFactory, + WSDLFactory wsdlFactory) { + + } + + public QName getProcess() { + return _processName; + } + + public void setProcess(QName processName) { + _processName = processName; + } + + public BPELProcessDefinition getProcessDefinition() { + return this._processDefinition; + } + + public void setProcessDefinition(BPELProcessDefinition processDefinition) { + this._processDefinition = processDefinition; + } + + @Override + public String getURI() { + // The sample BPEL implementation does not have a URI + return null; + } + + @Override + public void setURI(String uri) { + // The sample BPEL implementation does not have a URI + } + + @Override + public ConstrainingType getConstrainingType() { + // The sample BPEL implementation does not support constrainingTypes + return null; + } + + @Override + public List<Property> getProperties() { + // The sample BPEL implementation does not support properties + return Collections.emptyList(); + } + + @Override + public int hashCode() { + return String.valueOf(this.getProcess()).hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (obj instanceof BPELImplementation) { + if (getProcess() != null) { + return getProcess().equals(((BPELImplementation)obj).getProcess()); + } else { + return ((BPELImplementation)obj).getProcess() == null; + } + } else { + return false; + } + } +} diff --git a/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java new file mode 100644 index 0000000000..e1144186be --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELImplementationProcessor.java @@ -0,0 +1,207 @@ +/* + * 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.bpel.impl; + +import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sca.assembly.AssemblyFactory; +import org.apache.tuscany.sca.assembly.ComponentType; +import org.apache.tuscany.sca.assembly.Property; +import org.apache.tuscany.sca.assembly.Reference; +import org.apache.tuscany.sca.assembly.Service; +import org.apache.tuscany.sca.assembly.xml.Constants; +import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; +import org.apache.tuscany.sca.contribution.processor.BaseStAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; +import org.apache.tuscany.sca.contribution.resolver.ModelResolver; +import org.apache.tuscany.sca.contribution.service.ContributionReadException; +import org.apache.tuscany.sca.contribution.service.ContributionResolveException; +import org.apache.tuscany.sca.contribution.service.ContributionWriteException; +import org.apache.tuscany.sca.databinding.xml.DOMDataBinding; +import org.apache.tuscany.sca.implementation.bpel.BPELFactory; +import org.apache.tuscany.sca.implementation.bpel.BPELImplementation; +import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition; +import org.apache.tuscany.sca.implementation.bpel.DefaultBPELFactory; + +/** + * Implements a STAX artifact processor for BPEL implementations. + * + * The artifact processor is responsible for processing <implementation.bpel> + * elements in SCA assembly XML composite files and populating the BPEL + * implementation model, resolving its references to other artifacts in the SCA + * contribution, and optionally write the model back to SCA assembly XML. + * + * @version $Rev$ $Date$ + */ +public class BPELImplementationProcessor extends BaseStAXArtifactProcessor implements StAXArtifactProcessor<BPELImplementation> { + private static final QName IMPLEMENTATION_BPEL = new QName(Constants.SCA10_NS, "implementation.bpel"); + + private AssemblyFactory assemblyFactory; + private BPELFactory bpelFactory; + + public BPELImplementationProcessor(ModelFactoryExtensionPoint modelFactories) { + this.assemblyFactory = modelFactories.getFactory(AssemblyFactory.class); + this.bpelFactory = new DefaultBPELFactory(modelFactories); + } + + public QName getArtifactType() { + // Returns the qname of the XML element processed by this processor + return IMPLEMENTATION_BPEL; + } + + public Class<BPELImplementation> getModelType() { + // Returns the type of model processed by this processor + return BPELImplementation.class; + } + + public BPELImplementation read(XMLStreamReader reader) throws ContributionReadException, XMLStreamException { + assert IMPLEMENTATION_BPEL.equals(reader.getName()); + + // Read an <implementation.bpel> element + + // Read the process attribute. + QName process = getAttributeValueNS(reader, "process"); + + + // Create an initialize the BPEL implementation model + BPELImplementation implementation = bpelFactory.createBPELImplementation(); + implementation.setProcess(process); + implementation.setUnresolved(true); + + // Skip to end element + while (reader.hasNext()) { + if (reader.next() == END_ELEMENT && IMPLEMENTATION_BPEL.equals(reader.getName())) { + break; + } + } + + return implementation; + } + + public void resolve(BPELImplementation impl, ModelResolver resolver) throws ContributionResolveException { + if( impl != null && impl.isUnresolved()) { + BPELProcessDefinition processDefinition = resolveBPELProcessDefinition(impl, resolver); + if(processDefinition.isUnresolved()) { + throw new ContributionResolveException("Can't find BPEL Process : " + processDefinition.getName()); + } + + impl.setProcessDefinition(processDefinition); + + //resolve component type + mergeComponentType(resolver, impl); + + //set current implementation resolved + impl.setUnresolved(false); + } + + } + + public void write(BPELImplementation model, XMLStreamWriter outputSource) throws ContributionWriteException { + //FIXME Implement + } + + private BPELProcessDefinition resolveBPELProcessDefinition(BPELImplementation impl, ModelResolver resolver) throws ContributionResolveException { + QName processName = impl.getProcess(); + BPELProcessDefinition processDefinition = this.bpelFactory.createBPELProcessDefinition(); + processDefinition.setName(processName); + processDefinition.setUnresolved(true); + + return resolver.resolveModel(BPELProcessDefinition.class, processDefinition); + } + + + /** + * Merge the componentType from introspection and external file + * @param resolver + * @param impl + */ + private void mergeComponentType(ModelResolver resolver, BPELImplementation impl) { + // FIXME: Need to clarify how to merge + ComponentType componentType = getComponentType(resolver, impl); + if (componentType != null && !componentType.isUnresolved()) { + + Map<String, Reference> refMap = new HashMap<String, Reference>(); + for (Reference ref : impl.getReferences()) { + refMap.put(ref.getName(), ref); + } + for (Reference reference : componentType.getReferences()) { + refMap.put(reference.getName(), reference); + } + impl.getReferences().clear(); + impl.getReferences().addAll(refMap.values()); + + Map<String, Service> serviceMap = new HashMap<String, Service>(); + for (Service svc : impl.getServices()) { + if(svc != null) { + serviceMap.put(svc.getName(), svc); + } + } + for (Service service : componentType.getServices()) { + //set default dataBinding to DOM + service.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME); + + serviceMap.put(service.getName(), service); + } + impl.getServices().clear(); + impl.getServices().addAll(serviceMap.values()); + + Map<String, Property> propMap = new HashMap<String, Property>(); + for (Property prop : impl.getProperties()) { + propMap.put(prop.getName(), prop); + } + } + } + + + private ComponentType getComponentType(ModelResolver resolver, BPELImplementation impl) { + String bpelProcessURI = impl.getProcessDefinition().getURI().toString(); + String componentTypeURI = bpelProcessURI.replace(".bpel", ".componentType"); + ComponentType componentType = assemblyFactory.createComponentType(); + componentType.setUnresolved(true); + componentType.setURI(componentTypeURI); + componentType = resolver.resolveModel(ComponentType.class, componentType); + if (!componentType.isUnresolved()) { + return componentType; + } + return null; + } + + private QName getAttributeValueNS(XMLStreamReader reader, String attribute) { + String fullValue = reader.getAttributeValue(null, "process"); + if (fullValue.indexOf(":") < 0) + throw new ODEProcessException("Attribute " + attribute + " with value " + fullValue + + " in your composite should be prefixed (process=\"prefix:name\")."); + String prefix = fullValue.substring(0, fullValue.indexOf(":")); + String name = fullValue.substring(fullValue.indexOf(":") + 1); + String nsUri = reader.getNamespaceContext().getNamespaceURI(prefix); + if (nsUri == null) + throw new ODEProcessException("Attribute " + attribute + " with value " + fullValue + + " in your composite has un unrecognized namespace prefix."); + return new QName(nsUri, name, prefix); + } + +} diff --git a/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java new file mode 100644 index 0000000000..98405c3489 --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/BPELProcessDefinitionImpl.java @@ -0,0 +1,110 @@ +/* + * 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.bpel.impl; + +import java.net.URI; +import java.net.URL; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sca.implementation.bpel.BPELProcessDefinition; + +/** + * The BPEL process definition implementation. + * + * @version $Rev$ $Date$ + */ +public class BPELProcessDefinitionImpl implements BPELProcessDefinition { + private QName name; + private URI uri; + private URL location; + private boolean unresolved; + + public QName getName() { + return name; + } + + public void setName(QName name) { + this.name = name; + } + + public URI getURI() { + return uri; + } + + public void setURI(URI uri) { + this.uri = uri; + } + + public URL getLocation() { + return location; + } + + public void setLocation(URL location) { + this.location = location; + } + + public boolean isUnresolved() { + return unresolved; + } + + public void setUnresolved(boolean undefined) { + this.unresolved = undefined; + } + + public void compile() { + /* + String bpelFile = reader.getAttributeValue(null, "file"); // FIXME: + + // Resolving the BPEL file and compiling it + URL bpelURL = getClass().getClassLoader().getResource(bpelFile); + if (bpelURL == null) + throw new ODEProcessException("Couldn't find referenced bpel file " + bpelFile); + BpelC bpelc = BpelC.newBpelCompiler(); + ByteArrayOutputStream compiledProcess = new ByteArrayOutputStream(); + bpelc.setOutputStream(compiledProcess); + try { + bpelc.compile(new File(bpelURL.getFile())); + } catch (IOException e) { + e.printStackTrace(); + } + */ + } + + @Override + public int hashCode() { + return String.valueOf(getName()).hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } else if (obj instanceof BPELProcessDefinition) { + if (getName() != null) { + return getName().equals(((BPELProcessDefinition)obj).getName()); + } else { + return ((BPELProcessDefinition)obj).getName() == null; + } + } else { + return false; + } + } +} diff --git a/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ODEProcessException.java b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ODEProcessException.java new file mode 100644 index 0000000000..b54b8b01c4 --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ODEProcessException.java @@ -0,0 +1,42 @@ +/* + * 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.bpel.impl; + +/** + * Thrown when a process can't be compiled properly or when its descriptors + * are invalid. + * + * @version $Rev$ $Date$ + */ +public class ODEProcessException extends RuntimeException { + private static final long serialVersionUID = 1047893235216756186L; + + public ODEProcessException(String message) { + super(message); + } + + public ODEProcessException(String message, Throwable cause) { + super(message, cause); + } + + public ODEProcessException(Throwable cause) { + super(cause); + } +} diff --git a/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java new file mode 100644 index 0000000000..c16201b147 --- /dev/null +++ b/sca-java-1.x/tags/1.2/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java @@ -0,0 +1,68 @@ +/* + * 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.bpel.impl; + +import org.apache.tuscany.sca.runtime.RuntimeComponent; + +/** + * Class for tuneling a RuntimeComponent for invocation of a BPEL process + * This is used for BPEL to invoke references + * +* @version $Rev$ $Date$ + */ +public class ThreadRuntimeComponentContext { + + private static final ThreadLocal<RuntimeComponent> CONTEXT = new ThreadLocal<RuntimeComponent>(); + + private ThreadRuntimeComponentContext() { + + } + + /** + * Set the RuntimeComponentContext for the current thread. + * The current runtime component context is returned and must be restored after the invocation is complete. + * Typical usage would be: + * <pre> + * RuntimeComponent old = ThreadRuntimeComponentContext.setRuntimeComponent(newContext); + * try { + * ... invoke user code ... + * } finally { + * ThreadRuntimeComponentContext.setThreadWorkContext(old); + * } + * </pre> + * @param context + * @return the current work context for the thread; this must be restored after the invocation is made + */ + public static RuntimeComponent setRuntimeComponent(RuntimeComponent runtimeComponent) { + RuntimeComponent old = CONTEXT.get(); + CONTEXT.set(runtimeComponent); + return old; + } + + /** + * Returns the RuntimeComponentContext for the current thread. + * + * @return the RuntimeComponentContext for the current thread + */ + public static RuntimeComponent getRuntimeComponent() { + return CONTEXT.get(); + } + +} |