Author: lresende
Date: Tue Jan 29 09:52:17 2008
New Revision: 616463
URL: http://svn.apache.org/viewvc?rev=616463&view=rev
Log:
Updates around BPEL Reference support. Strawman for EPR support.
Added:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java
(with props)
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELInvoker.java
incubator/tuscany/java/sca/modules/implementation-bpel/src/test/resources/log4j.properties
Added:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java?rev=616463&view=auto
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java
(added)
+++
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java
Tue Jan 29 09:52:17 2008
@@ -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();
+ }
+
+}
Propchange:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/impl/ThreadRuntimeComponentContext.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java?rev=616463&r1=616462&r2=616463&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEBindingContext.java
Tue Jan 29 09:52:17 2008
@@ -3,11 +3,15 @@
import javax.wsdl.PortType;
import javax.xml.namespace.QName;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.iapi.BindingContext;
import org.apache.ode.bpel.iapi.Endpoint;
import org.apache.ode.bpel.iapi.EndpointReference;
import org.apache.ode.bpel.iapi.PartnerRoleChannel;
+import org.apache.ode.utils.DOMUtils;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* Binding Context information
@@ -15,6 +19,7 @@
* @version $Rev: 573789 $ $Date: 2007-09-07 23:59:49 -0700 (Fri, 07 Sep 2007)
$
*/
public class ODEBindingContext implements BindingContext {
+ private static final Log __log =
LogFactory.getLog(ODEBindingContext.class);
private EmbeddedODEServer _server;
@@ -23,23 +28,81 @@
}
public EndpointReference activateMyRoleEndpoint(QName pid, Endpoint
endpoint) {
- return new TuscanyEPR();
+ // This will be needed when we support callBacks
+ if (__log.isDebugEnabled())
+ __log.debug("Activating MyRole Endpoint : " + pid + " - " +
endpoint.serviceName);
+
+ System.out.println(">>> Activating MyRole Endpoint : " + pid + " - " +
endpoint.serviceName);
+
+ return new TuscanyEPR(endpoint);
}
public void deactivateMyRoleEndpoint(Endpoint endpoint) {
- // TODO
+ if (__log.isDebugEnabled())
+ __log.debug("Deactivate MyRole Endpoint : " +
endpoint.serviceName);
+
}
public PartnerRoleChannel createPartnerRoleChannel(QName qName, PortType
portType, Endpoint endpoint) {
- // TODO
- return null;
+ if (__log.isDebugEnabled())
+ __log.debug("Create PartnerRole channel : " + qName + " - " +
portType.getQName() + " - "+ endpoint.serviceName);
+
+ System.out.println(">>> Create PartnerRole channel : " + qName + " - "
+ portType.getQName() + " - "+ endpoint.serviceName);
+
+ return new TuscanyPRC();
}
- // TODO This should hold something that makes sense for Tuscany so that
the process has
- // an address that makes sense from the outside world perspective
+ // TODO This should hold something that makes sense for Tuscany so that the
+ // process has an address that makes sense from the outside world
perspective
private class TuscanyEPR implements EndpointReference {
+ private final Endpoint endpoint;
+ private final Document doc = DOMUtils.newDocument();
+
+ public TuscanyEPR() {
+ this.endpoint = null;
+ }
+
+ public TuscanyEPR(Endpoint endpoint) {
+ this.endpoint = endpoint;
+
+ Element serviceref =
doc.createElementNS(EndpointReference.SERVICE_REF_QNAME.getNamespaceURI(),
+
EndpointReference.SERVICE_REF_QNAME.getLocalPart());
+ serviceref.setNodeValue(endpoint.serviceName + ":" +
endpoint.portName);
+ doc.appendChild(serviceref);
+ }
+
public Document toXML() {
- return null;
+ return doc;
+ }
+ }
+
+ private class TuscanyPRC implements PartnerRoleChannel {
+ private TuscanyEPR tuscanyEPR;
+
+ public TuscanyPRC() {
+ this.tuscanyEPR = null;
}
+
+ public TuscanyPRC(TuscanyEPR tuscanyEPR){
+ this.tuscanyEPR = tuscanyEPR;
+ }
+
+ public void close() {
+
+ }
+
+ public EndpointReference getInitialEndpointReference() {
+ final Document doc = DOMUtils.newDocument();
+ Element serviceref =
doc.createElementNS(EndpointReference.SERVICE_REF_QNAME.getNamespaceURI(),
+
EndpointReference.SERVICE_REF_QNAME.getLocalPart());
+ doc.appendChild(serviceref);
+
+ return new EndpointReference() {
+ public Document toXML() {
+ return doc;
+ }
+ };
+ }
+
}
}
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java?rev=616463&r1=616462&r2=616463&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/ode/ODEMessageExchangeContext.java
Tue Jan 29 09:52:17 2008
@@ -1,10 +1,15 @@
package org.apache.tuscany.sca.implementation.bpel.ode;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.ode.bpel.iapi.BpelEngineException;
import org.apache.ode.bpel.iapi.ContextException;
import org.apache.ode.bpel.iapi.MessageExchangeContext;
import org.apache.ode.bpel.iapi.MyRoleMessageExchange;
import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import
org.apache.tuscany.sca.implementation.bpel.impl.ThreadRuntimeComponentContext;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
/**
* Message Exchange Context information
@@ -12,6 +17,8 @@
* @version $Rev: 573789 $ $Date: 2007-09-07 23:59:49 -0700 (Fri, 07 Sep 2007)
$
*/
public class ODEMessageExchangeContext implements MessageExchangeContext {
+ private static final Log __log =
LogFactory.getLog(ODEMessageExchangeContext.class);
+
private EmbeddedODEServer _server;
public ODEMessageExchangeContext(EmbeddedODEServer _server) {
@@ -19,10 +26,20 @@
}
public void invokePartner(PartnerRoleMessageExchange
partnerRoleMessageExchange) throws ContextException {
-
+ if (__log.isDebugEnabled())
+ __log.debug("Invoking a partner operation: " +
partnerRoleMessageExchange.getOperationName());
+
+ System.out.println(">>> Invoking a partner operation: " +
partnerRoleMessageExchange.getOperationName());
+
+ RuntimeComponent tuscanyRuntimeComponent =
ThreadRuntimeComponentContext.getRuntimeComponent();
+ for(ComponentReference componentReference :
tuscanyRuntimeComponent.getReferences()) {
+ System.out.println("Reference : " + componentReference.getName());
+ componentReference.getBindings().get(0);
+ }
}
public void onAsyncReply(MyRoleMessageExchange myRoleMessageExchange)
throws BpelEngineException {
-
+ if (__log.isDebugEnabled())
+ __log.debug("Processing an async reply from service " +
myRoleMessageExchange.getServiceName());
}
}
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java?rev=616463&r1=616462&r2=616463&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELImplementationProvider.java
Tue Jan 29 09:52:17 2008
@@ -65,7 +65,7 @@
}
public Invoker createInvoker(RuntimeComponentService service, Operation
operation) {
- BPELInvoker invoker = new BPELInvoker(operation, odeServer, txMgr);
+ BPELInvoker invoker = new BPELInvoker(component, service, operation,
odeServer, txMgr);
return invoker;
}
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELInvoker.java
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELInvoker.java?rev=616463&r1=616462&r2=616463&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELInvoker.java
(original)
+++
incubator/tuscany/java/sca/modules/implementation-bpel/src/main/java/org/apache/tuscany/sca/implementation/bpel/provider/BPELInvoker.java
Tue Jan 29 09:52:17 2008
@@ -32,12 +32,16 @@
import org.apache.ode.bpel.iapi.MessageExchange.Status;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.GUID;
+import org.apache.tuscany.sca.assembly.ComponentReference;
+import
org.apache.tuscany.sca.implementation.bpel.impl.ThreadRuntimeComponentContext;
import org.apache.tuscany.sca.implementation.bpel.ode.EmbeddedODEServer;
import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.wsdl.WSDLInterface;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.runtime.RuntimeComponent;
+import org.apache.tuscany.sca.runtime.RuntimeComponentService;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -53,13 +57,17 @@
private EmbeddedODEServer odeServer;
private TransactionManager txMgr;
+ private RuntimeComponent component;
+ private RuntimeComponentService service;
private Operation operation;
private QName bpelServiceName;
private String bpelOperationName;
private Part bpelOperationInputPart;
private Part bpelOperationOutputPart;
- public BPELInvoker(Operation operation, EmbeddedODEServer odeServer,
TransactionManager txMgr) {
+ public BPELInvoker(RuntimeComponent component, RuntimeComponentService
service, Operation operation, EmbeddedODEServer odeServer, TransactionManager
txMgr) {
+ this.component = component;
+ this.service = service;
this.operation = operation;
this.bpelOperationName = operation.getName();
this.odeServer = odeServer;
@@ -101,6 +109,10 @@
if(! (operation.getInterface() instanceof WSDLInterface)) {
throw new InvocationTargetException(null,"Unsupported service
contract");
}
+
+ System.out.println(">>> Set ThreadLocal with runtime component !");
+
+ ThreadRuntimeComponentContext.setRuntimeComponent(component);
org.apache.ode.bpel.iapi.MyRoleMessageExchange mex = null;
Future onhold = null;
Modified:
incubator/tuscany/java/sca/modules/implementation-bpel/src/test/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-bpel/src/test/resources/log4j.properties?rev=616463&r1=616462&r2=616463&view=diff
==============================================================================
---
incubator/tuscany/java/sca/modules/implementation-bpel/src/test/resources/log4j.properties
(original)
+++
incubator/tuscany/java/sca/modules/implementation-bpel/src/test/resources/log4j.properties
Tue Jan 29 09:52:17 2008
@@ -25,7 +25,9 @@
log4j.category.org.apache.ode.axis2=OFF
log4j.category.org.apache.ode.bpel.engine=OFF
log4j.category.org.apache.ode.daohib.bpel.CorrelatorDaoImpl=OFF
-log4j.category.org.apache.ode.bpel.epr=OFF
+log4j.category.org.apache.ode.bpel.epr=OFF
+log4j.category.org.apache.tuscany.sca.implementation.bpel=DEBUG
+log4j.category.org.apache.tuscany.sca.implementation.bpel.ode=DEBUG
# Console appender
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]