You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2007/05/08 03:49:31 UTC
svn commit: r536039 - in /incubator/tuscany/java/sca:
modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/
modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/
modules/core-databinding/src/main/java/org/apache/tuscany/c...
Author: jsdelfino
Date: Mon May 7 18:49:29 2007
New Revision: 536039
URL: http://svn.apache.org/viewvc?view=rev&rev=536039
Log:
Changes to allow binding and implementation providers to return an invoker, simpler than an interceptor.
Added:
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInvoker.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeBinding.java (with props)
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeImplementation.java (with props)
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/TargetInvokerInvoker.java (with props)
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingInvoker.java (with props)
incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInvoker.java (with props)
Removed:
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInterceptor.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/TargetInvokerInterceptor.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/implementation/spi/AbstractInterceptor.java
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingInterceptor.java
incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInterceptor.java
Modified:
incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java
incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java
incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ReferenceBindingProvider.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/Interceptor.java
incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/InvocationChain.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/CallbackInterfaceInterceptor.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/InvocationChainImpl.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java
incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeSCABindingImpl.java
incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java
incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDImplementationProvider.java
incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDInvoker.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/JavaImplementationProvider.java
incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/mock/MockSyncInterceptor.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java
incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingProvider.java
incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoService.java
incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java
incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationProvider.java
incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java
Added: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInvoker.java?view=auto&rev=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInvoker.java (added)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInvoker.java Mon May 7 18:49:29 2007
@@ -0,0 +1,83 @@
+/**
+ * * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed 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.binding.rmi;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.rmi.Remote;
+
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
+import org.apache.tuscany.rmi.RMIHost;
+import org.apache.tuscany.rmi.RMIHostException;
+
+public class RMIBindingInvoker implements Invoker {
+ private RMIHost rmiHost;
+ private String host;
+ private String port;
+ private String svcName;
+ private Method remoteMethod;
+ private Remote proxy;
+
+ public RMIBindingInvoker(RMIHost rmiHost, String host, String port, String svcName, Method remoteMethod) {
+ this.rmiHost = rmiHost;
+ this.remoteMethod = remoteMethod;
+ this.host = host;
+ this.port = port;
+ this.svcName = svcName;
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object[] args = msg.getBody();
+ Object resp = invokeTarget(args);
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+
+
+ public Object invokeTarget(final Object payload) throws InvocationTargetException {
+ try {
+ if (proxy == null) {
+ proxy = rmiHost.findService(host, port, svcName);
+ // proxy = Naming.lookup(serviceURI);
+ }
+ remoteMethod = proxy.getClass().getMethod(remoteMethod.getName(), remoteMethod.getParameterTypes());
+
+ if (payload != null && !payload.getClass().isArray()) {
+ return remoteMethod.invoke(proxy, payload);
+ } else {
+ return remoteMethod.invoke(proxy, (Object[])payload);
+
+ }
+ } catch (RMIHostException e) {
+ // the method we are passed must be accessible
+ throw new AssertionError(e);
+ } catch (IllegalAccessException e) {
+ // the method we are passed must be accessible
+ throw new AssertionError(e);
+ } catch (NoSuchMethodException e) {
+ throw new AssertionError(e);
+ }
+
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/binding-rmi/src/main/java/org/apache/tuscany/binding/rmi/RMIBindingProvider.java Mon May 7 18:49:29 2007
@@ -43,8 +43,8 @@
import org.apache.tuscany.interfacedef.Operation;
import org.apache.tuscany.interfacedef.java.JavaInterface;
import org.apache.tuscany.interfacedef.java.impl.JavaInterfaceUtil;
-import org.apache.tuscany.invocation.Interceptor;
import org.apache.tuscany.invocation.InvocationChain;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
import org.apache.tuscany.invocation.MessageImpl;
import org.apache.tuscany.rmi.RMIHost;
@@ -112,12 +112,12 @@
}
- public Interceptor createInterceptor(RuntimeComponent component, RuntimeComponentReference reference, Operation operation, boolean isCallback) {
+ public Invoker createInvoker(RuntimeComponent component, RuntimeComponentReference reference, Operation operation, boolean isCallback) {
try {
Method remoteMethod =
JavaInterfaceUtil.findMethod(((JavaInterface)reference.getInterfaceContract().getInterface()).getJavaClass(),
operation);
- return new RMIBindingInterceptor(rmiHost,
+ return new RMIBindingInvoker(rmiHost,
getRmiHostName(),
getRmiPort(),
getRmiServiceName(),
@@ -203,7 +203,7 @@
throw new IllegalStateException("no InvocationChain on wire for operation " + op);
}
- Interceptor headInterceptor = chain.getHeadInterceptor();
+ Invoker headInvoker = chain.getHeadInvoker();
WorkContext workContext = WorkContextTunnel.getThreadWorkContext();
Message msg = new MessageImpl();
@@ -212,7 +212,7 @@
Message resp;
// dispatch the wire down the chain and get the response
- resp = headInterceptor.invoke(msg);
+ resp = headInvoker.invoke(msg);
Object body = resp.getBody();
if (resp.isFault()) {
throw new InvocationTargetException((Throwable) body);
Modified: incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java (original)
+++ incubator/tuscany/java/sca/modules/binding-ws-axis2/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceBinding.java Mon May 7 18:49:29 2007
@@ -189,7 +189,7 @@
throw new IllegalStateException("no InvocationChain on wire for operation " + op);
}
- Interceptor headInterceptor = chain.getHeadInterceptor();
+ Interceptor headInterceptor = chain.getHeadInvoker();
WorkContext workContext = WorkContextTunnel.getThreadWorkContext();
String oldConversationID = (String) workContext.getIdentifier(Scope.CONVERSATION);
if (isConversational() && conversationID != null) {
Modified: incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java (original)
+++ incubator/tuscany/java/sca/modules/core-databinding/src/main/java/org/apache/tuscany/core/databinding/wire/DataTransformationInteceptor.java Mon May 7 18:49:29 2007
@@ -33,6 +33,7 @@
import org.apache.tuscany.interfacedef.impl.DataTypeImpl;
import org.apache.tuscany.interfacedef.util.FaultException;
import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
/**
@@ -41,7 +42,7 @@
* @version $Rev$ $Date$
*/
public class DataTransformationInteceptor implements Interceptor {
- private Interceptor next;
+ private Invoker next;
private Operation sourceOperation;
@@ -57,10 +58,7 @@
this.targetOperation = targetOperation;
}
- /**
- * @see org.apache.tuscany.invocation.Interceptor#getNext()
- */
- public Interceptor getNext() {
+ public Invoker getNext() {
return next;
}
@@ -212,10 +210,7 @@
return mediator.mediate(source, eSourceDataType, eTargetDataType, metadata);
}
- /**
- * @see org.apache.tuscany.invocation.Interceptor#setNext(org.apache.tuscany.invocation.Interceptor)
- */
- public void setNext(Interceptor next) {
+ public void setNext(Invoker next) {
this.next = next;
}
Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ImplementationProvider.java Mon May 7 18:49:29 2007
@@ -21,7 +21,7 @@
import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
/**
* A component implementation can implement this interface to provide additional logic
@@ -31,25 +31,26 @@
*/
public interface ImplementationProvider {
/**
- * Create an intercetor for the component implementation in the invocation
- * chain. The interceptor will be responsible for calling the implementation
+ * Create an invoker for the component implementation in the invocation
+ * chain. The invoker will be responsible for calling the implementation
* logic for the given component.
*
* @param component The component that owns the component service
* @param service The component service
* @param operation The operation that the interceptor will handle
- * @return An interceptor that handles the invocation logic, null should be
- * returned if no interceptor is required
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
*/
- Interceptor createInterceptor(RuntimeComponent component, RuntimeComponentService service, Operation operation);
+ Invoker createInvoker(RuntimeComponent component, RuntimeComponentService service, Operation operation);
/**
- * Create an interceptor to call back to the given component
+ * Create an invoker to call back to the given component
* @param component The component that receives the callback
* @param operation The operation
- * @return
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
*/
- Interceptor createCallbackInterceptor(RuntimeComponent component, Operation operation);
+ Invoker createCallbackInvoker(RuntimeComponent component, Operation operation);
/**
* Get the effective interface contract imposed by the implementation.
Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ReferenceBindingProvider.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ReferenceBindingProvider.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/ReferenceBindingProvider.java Mon May 7 18:49:29 2007
@@ -21,24 +21,24 @@
import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
/**
* @version $Rev$ $Date$
*/
public interface ReferenceBindingProvider {
/**
- * Create an intercetor for the reference binding in the invocation chain.
- * The interceptor is responsible for making the outbound invocation over
+ * Create an invoker for the reference binding in the invocation chain.
+ * The invoker is responsible for making the outbound invocation over
* the binding protocol.
*
* @param model The service that defines the binding
* @param operation The operation that the interceptor will handle
* @param isCallback A flag to tell if the operation is for the callback
- * @return An interceptor that handles the invocation logic, null should be
- * returned if no interceptor is required
+ * @return An invoker that handles the invocation logic, null should be
+ * returned if no invoker is required
*/
- Interceptor createInterceptor(RuntimeComponent component, RuntimeComponentReference reference, Operation operation, boolean isCallback);
+ Invoker createInvoker(RuntimeComponent component, RuntimeComponentReference reference, Operation operation, boolean isCallback);
/**
* Get the effective interface contract imposed by the binding. For example,
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeBinding.java?view=auto&rev=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeBinding.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeBinding.java Mon May 7 18:49:29 2007
@@ -0,0 +1,36 @@
+/*
+ * 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.core;
+
+import org.apache.tuscany.assembly.Binding;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeBinding extends Binding {
+
+ ReferenceBindingActivator getReferenceBindingActivator();
+
+ ReferenceBindingProvider getReferenceBindingProvider();
+
+ ServiceBindingActivator getServiceBindingActivator();
+
+ ServiceBindingProvider getServiceBindingProvider();
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeBinding.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeBinding.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeImplementation.java?view=auto&rev=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeImplementation.java (added)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeImplementation.java Mon May 7 18:49:29 2007
@@ -0,0 +1,33 @@
+/*
+ * 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.core;
+
+import org.apache.tuscany.assembly.Implementation;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface RuntimeImplementation extends Implementation {
+
+ ImplementationActivator getImplementationActivator();
+
+ ImplementationProvider getImplementationProvider();
+
+}
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeImplementation.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/core/RuntimeImplementation.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/AbstractInvocationHandler.java Mon May 7 18:49:29 2007
@@ -47,7 +47,7 @@
Object correlationId,
LinkedList<URI> callbackUris, WorkContext workContext)
throws Throwable {
- Interceptor headInterceptor = chain.getHeadInterceptor();
+ Invoker headInvoker = chain.getHeadInvoker();
Message msg = new MessageImpl();
msg.setWorkContext(workContext);
msg.setCorrelationID(workContext.getCorrelationId());
@@ -69,7 +69,7 @@
}
msg.setBody(args);
// dispatch the wire down the chain and get the response
- Message resp = headInterceptor.invoke(msg);
+ Message resp = headInvoker.invoke(msg);
Object body = resp.getBody();
if (resp.isFault()) {
throw (Throwable) body;
Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/Interceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/Interceptor.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/Interceptor.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/Interceptor.java Mon May 7 18:49:29 2007
@@ -26,13 +26,13 @@
public interface Interceptor extends Invoker {
/**
- * Sets the next interceptor
+ * Sets the next invoker
*/
- void setNext(Interceptor next);
+ void setNext(Invoker next);
/**
- * Returns the next interceptor or null
+ * Returns the next invoker or null
*/
- Interceptor getNext();
+ Invoker getNext();
}
Modified: incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/InvocationChain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/InvocationChain.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/InvocationChain.java (original)
+++ incubator/tuscany/java/sca/modules/core-spi/src/main/java/org/apache/tuscany/invocation/InvocationChain.java Mon May 7 18:49:29 2007
@@ -52,25 +52,32 @@
void addInterceptor(Interceptor interceptor);
/**
- * Adds an interceptor at the given position in the interceptor stack
+ * Adds an invoker to the chain
*
- * @param index the position in the interceptor stack to add the interceptor
- * @param interceptor the interceptor to add
+ * @param invoker the invoker to add
*/
- void addInterceptor(int index, Interceptor interceptor);
+ void addInvoker(Invoker invoker);
+
+ /**
+ * Returns the first invoker in the chain.
+ *
+ * @return the first invoker in the chain
+ */
+ Invoker getHeadInvoker();
/**
- * Returns the first interceptor in the chain.
+ * Returns the last invoker in the chain.
*
- * @return the first interceptor in the chain
+ * @return the last invoker in the chain
*/
- Interceptor getHeadInterceptor();
+ Invoker getTailInvoker();
/**
- * Returns the last interceptor in the chain.
+ * Adds an interceptor at the given position in the interceptor stack
*
- * @return the last interceptor in the chain
+ * @param index the position in the interceptor stack to add the interceptor
+ * @param interceptor the interceptor to add
*/
- Interceptor getTailInterceptor();
+ void addInterceptor(int index, Interceptor interceptor);
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/CallbackInterfaceInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/CallbackInterfaceInterceptor.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/CallbackInterfaceInterceptor.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/CallbackInterfaceInterceptor.java Mon May 7 18:49:29 2007
@@ -21,6 +21,7 @@
import org.osoa.sca.NoRegisteredCallbackException;
import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
/**
@@ -31,7 +32,7 @@
*/
public class CallbackInterfaceInterceptor implements Interceptor {
private boolean invokingServiceImplements;
- private Interceptor next;
+ private Invoker next;
public CallbackInterfaceInterceptor(boolean invokingServiceImplements) {
this.invokingServiceImplements = invokingServiceImplements;
@@ -46,11 +47,11 @@
return next.invoke(msg);
}
- public void setNext(Interceptor next) {
+ public void setNext(Invoker next) {
this.next = next;
}
- public Interceptor getNext() {
+ public Invoker getNext() {
return next;
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/InvocationChainImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/InvocationChainImpl.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/InvocationChainImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/InvocationChainImpl.java Mon May 7 18:49:29 2007
@@ -21,6 +21,7 @@
import org.apache.tuscany.interfacedef.Operation;
import org.apache.tuscany.invocation.Interceptor;
import org.apache.tuscany.invocation.InvocationChain;
+import org.apache.tuscany.invocation.Invoker;
/**
* Default implementation of an invocation chain
@@ -28,10 +29,10 @@
* @version $Rev$ $Date$
*/
public class InvocationChainImpl implements InvocationChain {
- protected Operation sourceOperation;
- protected Operation targetOperation;
- protected Interceptor interceptorChainHead;
- protected Interceptor interceptorChainTail;
+ private Operation sourceOperation;
+ private Operation targetOperation;
+ private Invoker invokerChainHead;
+ private Invoker invokerChainTail;
public InvocationChainImpl(Operation operation) {
assert operation != null;
@@ -51,46 +52,35 @@
}
public void addInterceptor(Interceptor interceptor) {
- if (interceptorChainHead == null) {
- interceptorChainHead = interceptor;
+ if (invokerChainHead == null) {
+ invokerChainHead = interceptor;
} else {
- interceptorChainTail.setNext(interceptor);
+ if (invokerChainHead instanceof Interceptor) {
+ ((Interceptor)invokerChainTail).setNext(interceptor);
+ }
}
- interceptorChainTail = interceptor;
+ invokerChainTail = interceptor;
}
- public void addInterceptor(int index, Interceptor interceptor) {
- int i = 0;
- Interceptor next = interceptorChainHead;
- Interceptor prev = null;
- while (next != null && i < index) {
- prev = next;
- next = next.getNext();
- i++;
- }
- if (i == index) {
- if (prev != null) {
- prev.setNext(interceptor);
- } else {
- interceptorChainHead = interceptor;
- }
- interceptor.setNext(next);
- if (next == null) {
- interceptorChainTail = interceptor;
- }
+ public void addInvoker(Invoker invoker) {
+ if (invokerChainHead == null) {
+ invokerChainHead = invoker;
} else {
- throw new ArrayIndexOutOfBoundsException(index);
+ if (invokerChainTail instanceof Interceptor) {
+ ((Interceptor)invokerChainTail).setNext(invoker);
+ }
}
+ invokerChainTail = invoker;
}
- public Interceptor getHeadInterceptor() {
- return interceptorChainHead;
+ public Invoker getHeadInvoker() {
+ return invokerChainHead;
}
- public Interceptor getTailInterceptor() {
- return interceptorChainTail;
+ public Invoker getTailInvoker() {
+ return invokerChainTail;
}
-
+
/**
* @return the sourceOperation
*/
@@ -103,6 +93,34 @@
*/
public void setSourceOperation(Operation sourceOperation) {
this.sourceOperation = sourceOperation;
+ }
+
+ public void addInterceptor(int index, Interceptor interceptor) {
+ int i = 0;
+ Invoker next = invokerChainHead;
+ Invoker prev = null;
+ while (next != null && i < index) {
+ prev = next;
+ if (next instanceof Interceptor) {
+ next = ((Interceptor)next).getNext();
+ i++;
+ } else {
+ throw new ArrayIndexOutOfBoundsException(index);
+ }
+ }
+ if (i == index) {
+ if (prev != null) {
+ ((Interceptor)prev).setNext(interceptor);
+ } else {
+ invokerChainHead = interceptor;
+ }
+ interceptor.setNext(next);
+ if (next == null) {
+ invokerChainTail = interceptor;
+ }
+ } else {
+ throw new ArrayIndexOutOfBoundsException(index);
+ }
}
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/invocation/NonBlockingInterceptor.java Mon May 7 18:49:29 2007
@@ -23,6 +23,7 @@
import org.apache.tuscany.core.RuntimeWire;
import org.apache.tuscany.invocation.ConversationSequence;
import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
import org.apache.tuscany.scope.Scope;
import org.apache.tuscany.spi.component.WorkContext;
@@ -40,7 +41,7 @@
private WorkScheduler workScheduler;
private WorkContext workContext;
- private Interceptor next;
+ private Invoker next;
public NonBlockingInterceptor(WorkScheduler workScheduler, WorkContext workContext) {
this.workScheduler = workScheduler;
@@ -75,11 +76,11 @@
return RESPONSE;
}
- public Interceptor getNext() {
+ public Invoker getNext() {
return next;
}
- public void setNext(Interceptor next) {
+ public void setNext(Invoker next) {
this.next = next;
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/DefaultCompositeActivator.java Mon May 7 18:49:29 2007
@@ -49,8 +49,8 @@
import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Interceptor;
import org.apache.tuscany.invocation.InvocationChain;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.scope.Scope;
import org.apache.tuscany.scope.ScopeRegistry;
import org.apache.tuscany.spi.component.WorkContext;
@@ -440,15 +440,15 @@
boolean isCallback) {
if (component.getImplementation() instanceof ImplementationProvider) {
ImplementationProvider provider = (ImplementationProvider)component.getImplementation();
- Interceptor interceptor = null;
+ Invoker invoker = null;
if (!isCallback) {
- interceptor = provider.createInterceptor((RuntimeComponent)component,
+ invoker = provider.createInvoker((RuntimeComponent)component,
(RuntimeComponentService)service,
operation);
} else {
- interceptor = provider.createCallbackInterceptor((RuntimeComponent)component, operation);
+ invoker = provider.createCallbackInvoker((RuntimeComponent)component, operation);
}
- chain.addInterceptor(interceptor);
+ chain.addInvoker(invoker);
}
}
@@ -470,12 +470,12 @@
boolean isCallback) {
if (binding instanceof ReferenceBindingProvider) {
ReferenceBindingProvider provider = (ReferenceBindingProvider)binding;
- Interceptor interceptor = provider.createInterceptor((RuntimeComponent)component,
+ Invoker invoker = provider.createInvoker((RuntimeComponent)component,
(RuntimeComponentReference)reference,
operation,
isCallback);
- if (interceptor != null) {
- chain.addInterceptor(interceptor);
+ if (invoker != null) {
+ chain.addInvoker(invoker);
}
}
}
Modified: incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeSCABindingImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeSCABindingImpl.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeSCABindingImpl.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/main/java/org/apache/tuscany/core/runtime/RuntimeSCABindingImpl.java Mon May 7 18:49:29 2007
@@ -56,7 +56,7 @@
return wires;
}
- public Interceptor createInterceptor(RuntimeComponent component, RuntimeComponentReference reference, Operation operation, boolean isCallback) {
+ public Interceptor createInvoker(RuntimeComponent component, RuntimeComponentReference reference, Operation operation, boolean isCallback) {
return null;
}
Modified: incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java (original)
+++ incubator/tuscany/java/sca/modules/core/src/test/java/org/apache/tuscany/core/wire/InvocationChainImplTestCase.java Mon May 7 18:49:29 2007
@@ -24,6 +24,7 @@
import org.apache.tuscany.interfacedef.impl.OperationImpl;
import org.apache.tuscany.invocation.Interceptor;
import org.apache.tuscany.invocation.InvocationChain;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
/**
@@ -31,46 +32,32 @@
*/
public class InvocationChainImplTestCase extends TestCase {
- public void testInsertAtPos() throws Exception {
- InvocationChain chain = new InvocationChainImpl(new OperationImpl("foo"));
- Interceptor inter3 = new MockInterceptor();
- Interceptor inter2 = new MockInterceptor();
- Interceptor inter1 = new MockInterceptor();
- chain.addInterceptor(inter3);
- chain.addInterceptor(0, inter1);
- chain.addInterceptor(1, inter2);
- Interceptor head = chain.getHeadInterceptor();
- assertEquals(inter1, head);
- assertEquals(inter2, head.getNext());
- assertEquals(inter3, head.getNext().getNext());
- }
-
public void testInsertAtEnd() throws Exception {
InvocationChain chain = new InvocationChainImpl(new OperationImpl("foo"));
Interceptor inter2 = new MockInterceptor();
Interceptor inter1 = new MockInterceptor();
- chain.addInterceptor(0, inter1);
- chain.addInterceptor(1, inter2);
- Interceptor head = chain.getHeadInterceptor();
+ chain.addInterceptor(inter1);
+ chain.addInterceptor(inter2);
+ Interceptor head = (Interceptor)chain.getHeadInvoker();
assertEquals(inter1, head);
assertEquals(inter2, head.getNext());
- assertEquals(inter2, chain.getTailInterceptor());
+ assertEquals(inter2, chain.getTailInvoker());
}
private class MockInterceptor implements Interceptor {
- private Interceptor next;
+ private Invoker next;
public Message invoke(Message msg) {
return null;
}
- public void setNext(Interceptor next) {
+ public void setNext(Invoker next) {
this.next = next;
}
- public Interceptor getNext() {
+ public Invoker getNext() {
return next;
}
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDImplementationProvider.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDImplementationProvider.java Mon May 7 18:49:29 2007
@@ -27,7 +27,7 @@
import org.apache.tuscany.interfacedef.Operation;
import org.apache.tuscany.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.interfacedef.java.introspect.JavaInterfaceIntrospector;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
/**
* The model representing a sample CRUD implementation in an SCA assembly model.
@@ -53,12 +53,12 @@
super(assemblyFactory, javaFactory, introspector);
}
- public Interceptor createInterceptor(RuntimeComponent component, RuntimeComponentService service, Operation operation) {
+ public Invoker createInvoker(RuntimeComponent component, RuntimeComponentService service, Operation operation) {
CRUDInvoker invoker = new CRUDInvoker(operation, new ResourceManager(getDirectory()));
return invoker;
}
- public Interceptor createCallbackInterceptor(RuntimeComponent component, Operation operation) {
+ public Invoker createCallbackInvoker(RuntimeComponent component, Operation operation) {
CRUDImplementation impl = (CRUDImplementation)component.getImplementation();
CRUDInvoker invoker = new CRUDInvoker(operation, new ResourceManager(impl.getDirectory()));
return invoker;
Modified: incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDInvoker.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/host-embedded/src/test/java/crud/CRUDInvoker.java Mon May 7 18:49:29 2007
@@ -22,7 +22,7 @@
import java.lang.reflect.InvocationTargetException;
import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
/**
@@ -35,7 +35,7 @@
*
* @version $Rev$ $Date$
*/
-public class CRUDInvoker implements Interceptor {
+public class CRUDInvoker implements Invoker {
private Operation operation;
private ResourceManager resourceManager;
@@ -74,10 +74,4 @@
}
}
- public Interceptor getNext() {
- return null;
- }
-
- public void setNext(Interceptor next) {
- }
}
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/JavaImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/JavaImplementationProvider.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/JavaImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/JavaImplementationProvider.java Mon May 7 18:49:29 2007
@@ -38,6 +38,7 @@
import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.Operation;
import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.ProxyFactory;
import org.apache.tuscany.scope.InstanceWrapper;
import org.apache.tuscany.scope.Scope;
@@ -154,19 +155,19 @@
return atomicComponent.createInstance();
}
- public Interceptor createInterceptor(RuntimeComponent component, RuntimeComponentService service, Operation operation) {
+ public Invoker createInvoker(RuntimeComponent component, RuntimeComponentService service, Operation operation) {
JavaComponentInfo atomicComponent = (JavaComponentInfo)component.getImplementationConfiguration();
try {
- return new TargetInvokerInterceptor(atomicComponent.createTargetInvoker(operation));
+ return new TargetInvokerInvoker(atomicComponent.createTargetInvoker(operation));
} catch (TargetInvokerCreationException e) {
throw new IllegalArgumentException(e);
}
}
- public Interceptor createCallbackInterceptor(RuntimeComponent component, Operation operation) {
+ public Invoker createCallbackInvoker(RuntimeComponent component, Operation operation) {
JavaComponentInfo atomicComponent = (JavaComponentInfo)component.getImplementationConfiguration();
try {
- return new TargetInvokerInterceptor(atomicComponent.createTargetInvoker(operation));
+ return new TargetInvokerInvoker(atomicComponent.createTargetInvoker(operation));
} catch (TargetInvokerCreationException e) {
throw new IllegalArgumentException(e);
}
Added: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/TargetInvokerInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/TargetInvokerInvoker.java?view=auto&rev=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/TargetInvokerInvoker.java (added)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/TargetInvokerInvoker.java Mon May 7 18:49:29 2007
@@ -0,0 +1,49 @@
+/*
+ * 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.implementation.java.invocation;
+
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
+import org.osoa.sca.ServiceRuntimeException;
+
+
+/**
+ * Serves as a tail interceptor on a target wire chain. This implementation dispatches to the target invoker passed
+ * inside the wire message. Target invokers are passed from the source in order to allow for caching of target
+ * instances.
+ *
+ * @version $Rev$ $Date$
+ * @Deprecated
+ * @see org.apache.tuscany.implementation.java.invocation.TargetInvoker
+ */
+public class TargetInvokerInvoker implements Invoker {
+ private TargetInvoker invoker;
+
+ public TargetInvokerInvoker(TargetInvoker invoker) {
+ this.invoker = invoker;
+ }
+
+ public Message invoke(Message msg) {
+ if (invoker == null) {
+ throw new ServiceRuntimeException("No target invoker specified on message");
+ }
+ return invoker.invoke(msg);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/TargetInvokerInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/implementation/java/invocation/TargetInvokerInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/mock/MockSyncInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/mock/MockSyncInterceptor.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/mock/MockSyncInterceptor.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-java-runtime/src/test/java/org/apache/tuscany/implementation/java/mock/MockSyncInterceptor.java Mon May 7 18:49:29 2007
@@ -19,13 +19,14 @@
package org.apache.tuscany.implementation.java.mock;
import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
public class MockSyncInterceptor implements Interceptor {
private int count;
- private Interceptor next;
+ private Invoker next;
public MockSyncInterceptor() {
}
@@ -39,11 +40,11 @@
return count;
}
- public void setNext(Interceptor next) {
+ public void setNext(Invoker next) {
this.next = next;
}
- public Interceptor getNext() {
+ public Invoker getNext() {
return next;
}
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptImplementation.java Mon May 7 18:49:29 2007
@@ -32,7 +32,7 @@
import org.apache.tuscany.implementation.spi.AbstractImplementation;
import org.apache.tuscany.implementation.spi.PropertyValueObjectFactory;
import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.sca.implementation.script.engines.TuscanyJRubyScriptEngine;
import org.apache.tuscany.spi.ObjectCreationException;
import org.apache.tuscany.spi.ObjectFactory;
@@ -73,11 +73,11 @@
this.scriptSrc = scriptSrc;
}
- public Interceptor createInterceptor(RuntimeComponent component, RuntimeComponentService service, Operation operation) {
+ public Invoker createInvoker(RuntimeComponent component, RuntimeComponentService service, Operation operation) {
return new ScriptInvoker(this, operation.getName());
}
- public Interceptor createCallbackInterceptor(RuntimeComponent component, Operation operation) {
+ public Invoker createCallbackInvoker(RuntimeComponent component, Operation operation) {
return new ScriptInvoker(this, operation.getName());
}
Modified: incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java (original)
+++ incubator/tuscany/java/sca/modules/implementation-script/src/main/java/org/apache/tuscany/sca/implementation/script/ScriptInvoker.java Mon May 7 18:49:29 2007
@@ -24,18 +24,19 @@
import javax.script.Invocable;
import javax.script.ScriptException;
-import org.apache.tuscany.implementation.spi.AbstractInterceptor;
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
/**
* Perform the actual script invocation
*/
-public class ScriptInvoker extends AbstractInterceptor {
+public class ScriptInvoker implements Invoker {
protected ScriptImplementation impl;
protected String operationName;
/**
- * TODO: pasing in the impl is a bit of a hack to get at scriptEngine as thats all this uses
+ * TODO: passing in the impl is a bit of a hack to get at scriptEngine as thats all this uses
* but its not created till the start method which is called after the invokers are created
*/
public ScriptInvoker(ScriptImplementation impl, String operationName) {
@@ -43,8 +44,7 @@
this.operationName = operationName;
}
- @Override
- public Object doInvoke(Object[] objects) throws InvocationTargetException {
+ private Object doInvoke(Object[] objects) throws InvocationTargetException {
try {
return ((Invocable)impl.scriptEngine).invokeFunction(operationName, objects);
@@ -52,6 +52,16 @@
} catch (ScriptException e) {
throw new InvocationTargetException(e);
}
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = doInvoke((Object[])msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ }
+ return msg;
}
}
Added: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingInvoker.java?view=auto&rev=536039
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingInvoker.java (added)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingInvoker.java Mon May 7 18:49:29 2007
@@ -0,0 +1,50 @@
+/*
+ * 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 echo;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
+
+/**
+ * Interceptor for the sample echo binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingInvoker implements Invoker {
+
+ private Object echo(Object[] args) throws InvocationTargetException {
+ // echo back the result, a real binding would invoke some API for flowing the request
+ return args[0];
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = echo((Object[])msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingProvider.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingProvider.java (original)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoBindingProvider.java Mon May 7 18:49:29 2007
@@ -31,8 +31,8 @@
import org.apache.tuscany.core.ServiceBindingProvider;
import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Interceptor;
import org.apache.tuscany.invocation.InvocationChain;
+import org.apache.tuscany.invocation.Invoker;
/**
* Implementation of the Echo binding provider.
@@ -42,14 +42,14 @@
public class EchoBindingProvider extends EchoBindingImpl implements ReferenceBindingActivator,
ReferenceBindingProvider, ServiceBindingActivator, ServiceBindingProvider {
- public Interceptor createInterceptor(RuntimeComponent component,
+ public Invoker createInvoker(RuntimeComponent component,
RuntimeComponentReference reference,
Operation operation,
boolean isCallback) {
if (isCallback) {
throw new UnsupportedOperationException();
} else {
- return new EchoBindingInterceptor();
+ return new EchoBindingInvoker();
}
}
@@ -74,7 +74,7 @@
RuntimeWire wire = componentService.getRuntimeWire(this);
InvocationChain chain = wire.getInvocationChains().get(0);
// Register with the hosting server
- EchoServer.getServer().register(new EchoService(chain.getHeadInterceptor()), uri);
+ EchoServer.getServer().register(new EchoService(chain.getHeadInvoker()), uri);
}
public void stop(RuntimeComponent component, RuntimeComponentService service) {
Modified: incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoService.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoService.java (original)
+++ incubator/tuscany/java/sca/samples/binding-echo/src/main/java/echo/EchoService.java Mon May 7 18:49:29 2007
@@ -20,7 +20,7 @@
import java.lang.reflect.InvocationTargetException;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
import org.apache.tuscany.invocation.MessageImpl;
import org.apache.tuscany.spi.component.WorkContext;
@@ -30,11 +30,11 @@
* @version $Rev$ $Date$
*/
public class EchoService {
- private Interceptor interceptor;
+ private Invoker invoker;
- public EchoService(Interceptor interceptor) {
+ public EchoService(Invoker invoker) {
super();
- this.interceptor = interceptor;
+ this.invoker = invoker;
}
public String sendReceive(String input) throws InvocationTargetException {
@@ -47,7 +47,7 @@
Message resp;
// dispatch and get the response
- resp = interceptor.invoke(msg);
+ resp = invoker.invoke(msg);
Object body = resp.getBody();
if (resp.isFault()) {
throw new InvocationTargetException((Throwable)body);
Added: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInvoker.java?view=auto&rev=536039
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInvoker.java (added)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInvoker.java Mon May 7 18:49:29 2007
@@ -0,0 +1,51 @@
+/*
+ * 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 echo;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
+import org.apache.tuscany.invocation.Message;
+
+/**
+ * Interceptor for the sample echo binding.
+ *
+ * @version $Rev$ $Date$
+ */
+public class EchoBindingInvoker implements Invoker {
+
+ private Object echo(Object[] args) throws InvocationTargetException {
+ // echo back the result, a real binding would invoke some API for flowing the request
+ return args[0];
+ }
+
+ public Message invoke(Message msg) {
+ try {
+ Object resp = echo((Object[])msg.getBody());
+ msg.setBody(resp);
+ } catch (InvocationTargetException e) {
+ msg.setFaultBody(e.getCause());
+ } catch (Throwable e) {
+ msg.setFaultBody(e);
+ }
+ return msg;
+ }
+
+}
Propchange: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoBindingProvider.java Mon May 7 18:49:29 2007
@@ -31,8 +31,8 @@
import org.apache.tuscany.core.ServiceBindingProvider;
import org.apache.tuscany.interfacedef.InterfaceContract;
import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Interceptor;
import org.apache.tuscany.invocation.InvocationChain;
+import org.apache.tuscany.invocation.Invoker;
/**
* Implementation of the Echo binding provider.
@@ -42,14 +42,14 @@
public class EchoBindingProvider extends EchoBindingImpl implements ReferenceBindingActivator,
ReferenceBindingProvider, ServiceBindingActivator, ServiceBindingProvider {
- public Interceptor createInterceptor(RuntimeComponent component,
+ public Invoker createInvoker(RuntimeComponent component,
RuntimeComponentReference reference,
Operation operation,
boolean isCallback) {
if (isCallback) {
throw new UnsupportedOperationException();
} else {
- return new EchoBindingInterceptor();
+ return new EchoBindingInvoker();
}
}
@@ -74,7 +74,7 @@
RuntimeWire wire = componentService.getRuntimeWire(this);
InvocationChain chain = wire.getInvocationChains().get(0);
// Register with the hosting server
- EchoServer.getServer().register(new EchoService(chain.getHeadInterceptor()), uri);
+ EchoServer.getServer().register(new EchoService(chain.getHeadInvoker()), uri);
}
public void stop(RuntimeComponent component, RuntimeComponentService service) {
Modified: incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java (original)
+++ incubator/tuscany/java/sca/samples/databinding-echo/src/main/java/echo/EchoService.java Mon May 7 18:49:29 2007
@@ -20,7 +20,7 @@
import java.lang.reflect.InvocationTargetException;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
import org.apache.tuscany.invocation.MessageImpl;
import org.apache.tuscany.spi.component.WorkContext;
@@ -30,11 +30,11 @@
* @version $Rev$ $Date$
*/
public class EchoService {
- private Interceptor interceptor;
+ private Invoker invoker;
- public EchoService(Interceptor interceptor) {
+ public EchoService(Invoker invoker) {
super();
- this.interceptor = interceptor;
+ this.invoker = invoker;
}
public String sendReceive(String input) throws InvocationTargetException {
@@ -47,7 +47,7 @@
Message resp;
// dispatch and get the response
- resp = interceptor.invoke(msg);
+ resp = invoker.invoke(msg);
Object body = resp.getBody();
if (resp.isFault()) {
throw new InvocationTargetException((Throwable)body);
Modified: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationProvider.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationProvider.java (original)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDImplementationProvider.java Mon May 7 18:49:29 2007
@@ -27,7 +27,7 @@
import org.apache.tuscany.interfacedef.Operation;
import org.apache.tuscany.interfacedef.java.JavaInterfaceFactory;
import org.apache.tuscany.interfacedef.java.introspect.JavaInterfaceIntrospector;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
/**
* The model representing a sample CRUD implementation in an SCA assembly model.
@@ -53,12 +53,12 @@
super(assemblyFactory, javaFactory, introspector);
}
- public Interceptor createInterceptor(RuntimeComponent component, RuntimeComponentService service, Operation operation) {
+ public Invoker createInvoker(RuntimeComponent component, RuntimeComponentService service, Operation operation) {
CRUDInvoker invoker = new CRUDInvoker(operation, new ResourceManager(getDirectory()));
return invoker;
}
- public Interceptor createCallbackInterceptor(RuntimeComponent component, Operation operation) {
+ public Invoker createCallbackInvoker(RuntimeComponent component, Operation operation) {
CRUDImplementation impl = (CRUDImplementation)component.getImplementation();
CRUDInvoker invoker = new CRUDInvoker(operation, new ResourceManager(impl.getDirectory()));
return invoker;
Modified: incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java?view=diff&rev=536039&r1=536038&r2=536039
==============================================================================
--- incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java (original)
+++ incubator/tuscany/java/sca/samples/implementation-crud/src/main/java/crud/CRUDInvoker.java Mon May 7 18:49:29 2007
@@ -22,7 +22,7 @@
import java.lang.reflect.InvocationTargetException;
import org.apache.tuscany.interfacedef.Operation;
-import org.apache.tuscany.invocation.Interceptor;
+import org.apache.tuscany.invocation.Invoker;
import org.apache.tuscany.invocation.Message;
/**
@@ -35,7 +35,7 @@
*
* @version $Rev$ $Date$
*/
-public class CRUDInvoker implements Interceptor {
+public class CRUDInvoker implements Invoker {
private Operation operation;
private ResourceManager resourceManager;
@@ -74,10 +74,4 @@
}
}
- public Interceptor getNext() {
- return null;
- }
-
- public void setNext(Interceptor next) {
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org