You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jm...@apache.org on 2006/08/31 06:31:15 UTC
svn commit: r438785 [2/4] - in /incubator/tuscany/java/sca:
bindings/binding.axis2/src/main/java/org/apache/tuscany/binding/axis2/
bindings/binding.axis2/src/test/java/org/apache/tuscany/binding/axis2/
bindings/binding.celtix/src/main/java/org/apache/t...
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemSingletonAtomicComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemSingletonAtomicComponent.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemSingletonAtomicComponent.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemSingletonAtomicComponent.java Wed Aug 30 21:31:11 2006
@@ -18,7 +18,6 @@
*/
package org.apache.tuscany.core.implementation.system.component;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -28,6 +27,7 @@
import org.apache.tuscany.spi.component.AbstractSCAObject;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.Scope;
import org.apache.tuscany.spi.wire.InboundWire;
import org.apache.tuscany.spi.wire.OutboundWire;
@@ -116,11 +116,11 @@
}
- public TargetInvoker createTargetInvoker(String serviceName, Method operation) {
+ public TargetInvoker createTargetInvoker(String targetName, Operation operation) {
return null;
}
- public TargetInvoker createAsyncTargetInvoker(String serviceName, Method operation, OutboundWire wire) {
+ public TargetInvoker createAsyncTargetInvoker(OutboundWire wire, Operation operation) {
return null;
}
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWireImpl.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWireImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemInboundWireImpl.java Wed Aug 30 21:31:11 2006
@@ -18,13 +18,13 @@
*/
package org.apache.tuscany.core.implementation.system.wire;
-import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
import org.apache.tuscany.spi.component.Component;
import org.apache.tuscany.spi.component.TargetException;
import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.OutboundWire;
@@ -85,11 +85,11 @@
return new Class[0];
}
- public Map<Method, InboundInvocationChain> getInvocationChains() {
+ public Map<Operation, InboundInvocationChain> getInvocationChains() {
return Collections.emptyMap();
}
- public void addInvocationChain(Method method, InboundInvocationChain chain) {
+ public void addInvocationChain(Operation operation, InboundInvocationChain chain) {
throw new UnsupportedOperationException();
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundAutowire.java Wed Aug 30 21:31:11 2006
@@ -18,7 +18,6 @@
*/
package org.apache.tuscany.core.implementation.system.wire;
-import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
@@ -26,6 +25,7 @@
import org.apache.tuscany.spi.component.TargetException;
import org.apache.tuscany.spi.component.TargetNotFoundException;
import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
@@ -105,39 +105,39 @@
throw new UnsupportedOperationException();
}
- public Map<Method, OutboundInvocationChain> getInvocationChains() {
+ public Map<Operation<?>, OutboundInvocationChain> getInvocationChains() {
return Collections.emptyMap();
}
- public void addInvocationChain(Method method, OutboundInvocationChain chains) {
+ public void addInvocationChain(Operation operation, OutboundInvocationChain chains) {
throw new UnsupportedOperationException();
}
- public void addInvocationChains(Map chains) {
+ public void addInvocationChains(Map<Operation<?>, OutboundInvocationChain> chains) {
throw new UnsupportedOperationException();
}
- public Map<Method, InboundInvocationChain> getTargetCallbackInvocationChains() {
+ public Map<Operation<?>, InboundInvocationChain> getTargetCallbackInvocationChains() {
throw new UnsupportedOperationException();
}
- public void addTargetCallbackInvocationChains(Map<Method, InboundInvocationChain> chains) {
+ public void addTargetCallbackInvocationChains(Map<Operation<?>, InboundInvocationChain> chains) {
throw new UnsupportedOperationException();
}
- public void addTargetCallbackInvocationChain(Method method, InboundInvocationChain chain) {
+ public void addTargetCallbackInvocationChain(Operation operation, InboundInvocationChain chain) {
throw new UnsupportedOperationException();
}
- public Map<Method, OutboundInvocationChain> getSourceCallbackInvocationChains() {
+ public Map<Operation<?>, OutboundInvocationChain> getSourceCallbackInvocationChains() {
return null;
}
- public void addSourceCallbackInvocationChains(Map<Method, OutboundInvocationChain> chains) {
+ public void addSourceCallbackInvocationChains(Map<Operation<?>, OutboundInvocationChain> chains) {
}
- public void addSourceCallbackInvocationChain(Method method, OutboundInvocationChain chain) {
+ public void addSourceCallbackInvocationChain(Operation operation, OutboundInvocationChain chain) {
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWireImpl.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWireImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/implementation/system/wire/SystemOutboundWireImpl.java Wed Aug 30 21:31:11 2006
@@ -18,13 +18,13 @@
*/
package org.apache.tuscany.core.implementation.system.wire;
-import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
import org.apache.tuscany.spi.QualifiedName;
import org.apache.tuscany.spi.component.TargetException;
import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
@@ -95,11 +95,11 @@
throw new UnsupportedOperationException();
}
- public Map<Method, OutboundInvocationChain> getInvocationChains() {
+ public Map<Operation<?>, OutboundInvocationChain> getInvocationChains() {
return Collections.emptyMap();
}
- public void addInvocationChain(Method method, OutboundInvocationChain chains) {
+ public void addInvocationChain(Operation operation, OutboundInvocationChain chains) {
throw new UnsupportedOperationException();
}
@@ -107,27 +107,27 @@
throw new UnsupportedOperationException();
}
- public Map<Method, InboundInvocationChain> getTargetCallbackInvocationChains() {
+ public Map<Operation<?>, InboundInvocationChain> getTargetCallbackInvocationChains() {
throw new UnsupportedOperationException();
}
- public void addTargetCallbackInvocationChains(Map<Method, InboundInvocationChain> chains) {
+ public void addTargetCallbackInvocationChains(Map<Operation<?>, InboundInvocationChain> chains) {
throw new UnsupportedOperationException();
}
- public void addTargetCallbackInvocationChain(Method method, InboundInvocationChain chain) {
+ public void addTargetCallbackInvocationChain(Operation operation, InboundInvocationChain chain) {
throw new UnsupportedOperationException();
}
- public Map<Method, OutboundInvocationChain> getSourceCallbackInvocationChains() {
+ public Map<Operation<?>, OutboundInvocationChain> getSourceCallbackInvocationChains() {
return null;
}
- public void addSourceCallbackInvocationChains(Map<Method, OutboundInvocationChain> chains) {
+ public void addSourceCallbackInvocationChains(Map<Operation<?>, OutboundInvocationChain> chains) {
throw new UnsupportedOperationException();
}
- public void addSourceCallbackInvocationChain(Method method, OutboundInvocationChain chain) {
+ public void addSourceCallbackInvocationChain(Operation operation, OutboundInvocationChain chain) {
throw new UnsupportedOperationException();
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/injection/CallbackWireObjectFactory.java Wed Aug 30 21:31:11 2006
@@ -20,6 +20,7 @@
import org.apache.tuscany.spi.ObjectCreationException;
import org.apache.tuscany.spi.ObjectFactory;
+import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.WireService;
/**
@@ -30,15 +31,15 @@
public class CallbackWireObjectFactory implements ObjectFactory {
private WireService wireService;
- private Class<?> interfaze;
+ private ServiceContract<?> contract;
- public CallbackWireObjectFactory(Class<?> interfaze, WireService wireService) {
- this.interfaze = interfaze;
+ public CallbackWireObjectFactory(ServiceContract<?> contract, WireService wireService) {
+ this.contract = contract;
this.wireService = wireService;
}
public Object getInstance() throws ObjectCreationException {
- return wireService.createCallbackProxy(interfaze);
+ return wireService.createCallbackProxy(contract);
}
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InboundInvocationChainImpl.java Wed Aug 30 21:31:11 2006
@@ -22,6 +22,7 @@
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.MessageHandler;
+import org.apache.tuscany.spi.model.Operation;
/**
* Contains a target-side invocation chain
@@ -33,7 +34,7 @@
/**
* Creates an new target-side chain for the given operation
*/
- public InboundInvocationChainImpl(Method operation) {
+ public InboundInvocationChainImpl(Operation operation) {
super(operation);
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InboundWireImpl.java Wed Aug 30 21:31:11 2006
@@ -18,10 +18,11 @@
*/
package org.apache.tuscany.core.wire;
-import java.lang.reflect.Method;
+import java.util.HashMap;
import java.util.Map;
import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
@@ -29,8 +30,6 @@
import org.apache.tuscany.spi.wire.MessageHandler;
import org.apache.tuscany.spi.wire.OutboundWire;
-import org.apache.tuscany.core.util.MethodHashMap;
-
/**
* Default implementation of an inbound wire
*
@@ -42,7 +41,7 @@
private ServiceContract serviceContract;
private OutboundWire<T> targetWire;
private String callbackReferenceName;
- private Map<Method, InboundInvocationChain> chains = new MethodHashMap<InboundInvocationChain>();
+ private Map<Operation, InboundInvocationChain> chains = new HashMap<Operation, InboundInvocationChain>();
@SuppressWarnings("unchecked")
public T getTargetService() throws TargetException {
@@ -73,16 +72,16 @@
this.serviceName = serviceName;
}
- public Map<Method, InboundInvocationChain> getInvocationChains() {
+ public Map<Operation, InboundInvocationChain> getInvocationChains() {
return chains;
}
- public void addInvocationChains(Map<Method, InboundInvocationChain> chains) {
+ public void addInvocationChains(Map<Operation, InboundInvocationChain> chains) {
this.chains.putAll(chains);
}
- public void addInvocationChain(Method method, InboundInvocationChain chain) {
- chains.put(method, chain);
+ public void addInvocationChain(Operation operation, InboundInvocationChain chain) {
+ chains.put(operation, chain);
}
public void setTargetWire(OutboundWire<T> wire) {
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/InvocationChainImpl.java Wed Aug 30 21:31:11 2006
@@ -18,10 +18,10 @@
*/
package org.apache.tuscany.core.wire;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.wire.Interceptor;
import org.apache.tuscany.spi.wire.InvocationChain;
import org.apache.tuscany.spi.wire.MessageChannel;
@@ -35,7 +35,7 @@
* @version $Rev$ $Date$
*/
public abstract class InvocationChainImpl implements InvocationChain {
- protected Method operation;
+ protected Operation operation;
protected TargetInvoker targetInvoker;
protected Interceptor interceptorChainHead;
protected Interceptor interceptorChainTail;
@@ -51,12 +51,12 @@
// the pointer to a bridged target head interceptor or null if the target has no interceptors
protected Interceptor targetInterceptorChainHead;
- public InvocationChainImpl(Method operation) {
+ public InvocationChainImpl(Operation operation) {
assert operation != null : "No operation type specified";
this.operation = operation;
}
- public Method getMethod() {
+ public Operation getOperation() {
return operation;
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/OutboundInvocationChainImpl.java Wed Aug 30 21:31:11 2006
@@ -18,9 +18,9 @@
*/
package org.apache.tuscany.core.wire;
-import java.lang.reflect.Method;
import java.util.ArrayList;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.wire.Interceptor;
import org.apache.tuscany.spi.wire.MessageHandler;
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
@@ -35,7 +35,7 @@
/**
* Creates an new outbound chain
*/
- public OutboundInvocationChainImpl(Method operation) {
+ public OutboundInvocationChainImpl(Operation operation) {
super(operation);
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java Wed Aug 30 21:31:11 2006
@@ -18,11 +18,12 @@
*/
package org.apache.tuscany.core.wire;
-import java.lang.reflect.Method;
+import java.util.HashMap;
import java.util.Map;
import org.apache.tuscany.spi.QualifiedName;
import org.apache.tuscany.spi.component.TargetException;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
@@ -31,8 +32,6 @@
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
import org.apache.tuscany.spi.wire.OutboundWire;
-import org.apache.tuscany.core.util.MethodHashMap;
-
/**
* Default implementation of an outbound wire
*
@@ -42,9 +41,11 @@
private ServiceContract serviceContract;
private Class<T>[] callbackInterfaces;
- private Map<Method, OutboundInvocationChain> chains = new MethodHashMap<OutboundInvocationChain>();
- private Map<Method, InboundInvocationChain> callbackTargetChains = new MethodHashMap<InboundInvocationChain>();
- private Map<Method, OutboundInvocationChain> callbackSourceChains = new MethodHashMap<OutboundInvocationChain>();
+ private Map<Operation<?>, OutboundInvocationChain> chains = new HashMap<Operation<?>, OutboundInvocationChain>();
+ private Map<Operation<?>, InboundInvocationChain> callbackTargetChains =
+ new HashMap<Operation<?>, InboundInvocationChain>();
+ private Map<Operation<?>, OutboundInvocationChain> callbackSourceChains =
+ new HashMap<Operation<?>, OutboundInvocationChain>();
private String referenceName;
private QualifiedName targetName;
private InboundWire<T> targetWire;
@@ -90,40 +91,40 @@
this.targetWire = wire;
}
- public Map<Method, OutboundInvocationChain> getInvocationChains() {
+ public Map<Operation<?>, OutboundInvocationChain> getInvocationChains() {
return chains;
}
- public void addInvocationChains(Map<Method, OutboundInvocationChain> chains) {
+ public void addInvocationChains(Map<Operation<?>, OutboundInvocationChain> chains) {
this.chains.putAll(chains);
}
- public void addInvocationChain(Method method, OutboundInvocationChain chain) {
- chains.put(method, chain);
+ public void addInvocationChain(Operation<?> operation, OutboundInvocationChain chain) {
+ chains.put(operation, chain);
}
- public Map<Method, InboundInvocationChain> getTargetCallbackInvocationChains() {
+ public Map<Operation<?>, InboundInvocationChain> getTargetCallbackInvocationChains() {
return callbackTargetChains;
}
- public void addTargetCallbackInvocationChains(Map<Method, InboundInvocationChain> chains) {
+ public void addTargetCallbackInvocationChains(Map<Operation<?>, InboundInvocationChain> chains) {
callbackTargetChains.putAll(chains);
}
- public void addTargetCallbackInvocationChain(Method method, InboundInvocationChain chain) {
- callbackTargetChains.put(method, chain);
+ public void addTargetCallbackInvocationChain(Operation operation, InboundInvocationChain chain) {
+ callbackTargetChains.put(operation, chain);
}
- public Map<Method, OutboundInvocationChain> getSourceCallbackInvocationChains() {
+ public Map<Operation<?>, OutboundInvocationChain> getSourceCallbackInvocationChains() {
return callbackSourceChains;
}
- public void addSourceCallbackInvocationChains(Map<Method, OutboundInvocationChain> chains) {
+ public void addSourceCallbackInvocationChains(Map<Operation<?>, OutboundInvocationChain> chains) {
callbackSourceChains.putAll(chains);
}
- public void addSourceCallbackInvocationChain(Method method, OutboundInvocationChain chain) {
- callbackSourceChains.put(method, chain);
+ public void addSourceCallbackInvocationChain(Operation opeation, OutboundInvocationChain chain) {
+ callbackSourceChains.put(opeation, chain);
}
public String getReferenceName() {
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/AbstractJDKOutboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/AbstractJDKOutboundInvocationHandler.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/AbstractJDKOutboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/AbstractJDKOutboundInvocationHandler.java Wed Aug 30 21:31:11 2006
@@ -42,13 +42,13 @@
protected Object invoke(OutboundInvocationChain chain, TargetInvoker invoker, Object[] args) throws Throwable {
Interceptor headInterceptor = chain.getHeadInterceptor();
- Method method = chain.getMethod();
if (chain.getTargetRequestChannel() == null && chain.getTargetResponseChannel() == null
&& headInterceptor == null) {
try {
// short-circuit the dispatch and invoke the target directly
if (chain.getTargetInvoker() == null) {
- throw new AssertionError("No target invoker [" + method.getName() + "]");
+ String name = chain.getOperation().getName();
+ throw new AssertionError("No target invoker [" + name + "]");
}
return chain.getTargetInvoker().invokeTarget(args);
} catch (InvocationTargetException e) {
@@ -69,7 +69,8 @@
return body;
} else if (headInterceptor == null) {
- throw new AssertionError("No target interceptor configured [" + method.getName() + "]");
+ String name = chain.getOperation().getName();
+ throw new AssertionError("No target interceptor configured [" + name + "]");
} else {
Message resp = headInterceptor.invoke(msg);
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKCallbackInvocationHandler.java Wed Aug 30 21:31:11 2006
@@ -21,15 +21,18 @@
import java.lang.reflect.Method;
import org.apache.tuscany.spi.component.WorkContext;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findOperation;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
import org.apache.tuscany.spi.wire.OutboundWire;
import org.apache.tuscany.spi.wire.TargetInvoker;
/**
* Responsible for invoking on an outbound wire associated with a callback. The handler retrieves the correct outbound
- * callback wire from the work context.
- *
+ * callback wire from the work context.
+ * <p/>
* TODO cache target invoker
+ *
* @version $Rev$ $Date$
*/
public class JDKCallbackInvocationHandler extends AbstractJDKOutboundInvocationHandler {
@@ -43,7 +46,9 @@
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
OutboundWire<?> wire = context.getCurrentInvocationWire();
context.setCurrentInvocationWire(null);
- OutboundInvocationChain chain = wire.getSourceCallbackInvocationChains().get(method);
+ //TODO optimize as this is slow in local invocations
+ Operation operation = findOperation(method, wire.getSourceCallbackInvocationChains().keySet());
+ OutboundInvocationChain chain = wire.getSourceCallbackInvocationChains().get(operation);
TargetInvoker invoker = chain.getTargetInvoker();
return invoke(chain, invoker, args);
}
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java Wed Aug 30 21:31:11 2006
@@ -73,7 +73,7 @@
assert chain != null;
if (chain.getTargetInvoker() == null) {
TargetException e = new TargetException("No target invoker configured for operation");
- e.setIdentifier(chain.getMethod().getName());
+ e.setIdentifier(chain.getOperation().getName());
throw e;
}
if (chain.getTargetInvoker().isCacheable()) {
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKOutboundInvocationHandler.java Wed Aug 30 21:31:11 2006
@@ -23,6 +23,8 @@
import java.util.Map;
import org.apache.tuscany.spi.component.TargetException;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
import org.apache.tuscany.spi.wire.OutboundWire;
import org.apache.tuscany.spi.wire.TargetInvoker;
@@ -44,11 +46,18 @@
*/
private Map<Method, ChainHolder> chains;
- public JDKOutboundInvocationHandler(OutboundWire<?> wire) {
- Map<Method, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
+ public JDKOutboundInvocationHandler(OutboundWire<?> wire) throws NoMethodForOperationException {
+ Map<Operation<?>, OutboundInvocationChain> invocationChains = wire.getInvocationChains();
this.chains = new HashMap<Method, ChainHolder>(invocationChains.size());
- for (Map.Entry<Method, OutboundInvocationChain> entry : invocationChains.entrySet()) {
- this.chains.put(entry.getKey(), new ChainHolder(entry.getValue()));
+ Method[] methods = wire.getServiceContract().getInterfaceClass().getMethods();
+ // TODO optimize this
+ for (Map.Entry<Operation<?>, OutboundInvocationChain> entry : invocationChains.entrySet()) {
+ Operation operation = entry.getKey();
+ Method method = findMethod(operation, methods);
+ if (method == null) {
+ throw new NoMethodForOperationException(operation.getName());
+ }
+ this.chains.put(method, new ChainHolder(entry.getValue()));
}
}
@@ -66,7 +75,7 @@
assert chain != null;
if (chain.getTargetInvoker() == null) {
TargetException e = new TargetException("No target invoker configured for operation");
- e.setIdentifier(chain.getMethod().getName());
+ e.setIdentifier(chain.getOperation().getName());
throw e;
}
if (chain.getTargetInvoker().isCacheable()) {
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java Wed Aug 30 21:31:11 2006
@@ -20,6 +20,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
+import java.util.HashMap;
import java.util.Map;
import org.osoa.sca.annotations.Constructor;
@@ -33,12 +34,14 @@
import org.apache.tuscany.spi.component.Reference;
import org.apache.tuscany.spi.component.Service;
import org.apache.tuscany.spi.component.WorkContext;
+import static org.apache.tuscany.spi.idl.java.JavaIDLUtils.findMethod;
import org.apache.tuscany.spi.model.BindlessServiceDefinition;
import org.apache.tuscany.spi.model.BoundServiceDefinition;
import org.apache.tuscany.spi.model.ComponentDefinition;
import org.apache.tuscany.spi.model.ComponentType;
import org.apache.tuscany.spi.model.CompositeComponentType;
import org.apache.tuscany.spi.model.Implementation;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.ReferenceDefinition;
import org.apache.tuscany.spi.model.ReferenceTarget;
import org.apache.tuscany.spi.model.ServiceContract;
@@ -81,12 +84,31 @@
public void init() {
}
+ private Map<Method, InboundInvocationChain> createInboundMapping(InboundWire<?> wire, Method[] methods)
+ throws NoMethodForOperationException {
+ Map<Method, InboundInvocationChain> chains = new HashMap<Method, InboundInvocationChain>();
+ for (Map.Entry<Operation, InboundInvocationChain> entry : wire.getInvocationChains().entrySet()) {
+ Operation operation = entry.getKey();
+ InboundInvocationChain chain = entry.getValue();
+ Method method = findMethod(operation, methods);
+ if (method == null) {
+ NoMethodForOperationException e = new NoMethodForOperationException();
+ e.setIdentifier(operation.getName());
+ }
+ chains.put(method, chain);
+ }
+ return chains;
+ }
+
+ @SuppressWarnings("unchecked")
public <T> T createProxy(RuntimeWire<T> wire) throws ProxyCreationException {
assert wire != null : "Wire was null";
if (wire instanceof InboundWire) {
InboundWire<T> inbound = (InboundWire<T>) wire;
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(inbound.getInvocationChains());
- Class<?> interfaze = inbound.getServiceContract().getInterfaceClass();
+ Class<?> interfaze = wire.getServiceContract().getInterfaceClass();
+ Method[] methods = interfaze.getMethods();
+ Map<Method, InboundInvocationChain> chains = createInboundMapping(inbound, methods);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains);
ClassLoader cl = interfaze.getClassLoader();
//FIXME
return (T) Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
@@ -103,7 +125,9 @@
}
}
- public <T> T createCallbackProxy(Class<T> interfaze) throws ProxyCreationException {
+ @SuppressWarnings("unchecked")
+ public <T> T createCallbackProxy(ServiceContract<?> contract) throws ProxyCreationException {
+ Class<T> interfaze = (Class<T>) contract.getCallbackClass();
ClassLoader cl = interfaze.getClassLoader();
JDKCallbackInvocationHandler handler = new JDKCallbackInvocationHandler(context);
return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler));
@@ -113,7 +137,9 @@
assert wire != null : "Wire was null";
if (wire instanceof InboundWire) {
InboundWire<T> inbound = (InboundWire<T>) wire;
- return new JDKInboundInvocationHandler(inbound.getInvocationChains());
+ Method[] methods = inbound.getServiceContract().getInterfaceClass().getMethods();
+ Map<Method, InboundInvocationChain> chains = createInboundMapping(inbound, methods);
+ return new JDKInboundInvocationHandler(chains);
} else if (wire instanceof OutboundWire) {
OutboundWire<T> outbound = (OutboundWire<T>) wire;
return new JDKOutboundInvocationHandler(outbound);
@@ -128,19 +154,11 @@
return new JDKCallbackInvocationHandler(context);
}
- public OutboundWire createOutboundWire() {
- return new OutboundWireImpl();
- }
-
- public InboundWire createInboundWire() {
- return new InboundWireImpl();
- }
-
- public OutboundInvocationChain createOutboundChain(Method operation) {
+ public OutboundInvocationChain createOutboundChain(Operation operation) {
return new OutboundInvocationChainImpl(operation);
}
- public InboundInvocationChain createInboundChain(Method operation) {
+ public InboundInvocationChain createInboundChain(Operation operation) {
return new InboundInvocationChainImpl(operation);
}
@@ -169,14 +187,13 @@
}
}
- public <T> void createWires(Reference<T> reference, ServiceContract contract) {
+ public <T> void createWires(Reference<T> reference, ServiceContract<?> contract) {
InboundWire<T> wire = new InboundWireImpl<T>();
- Class<T> interfaze = reference.getInterface();
wire.setServiceContract(contract);
- for (Method method : interfaze.getMethods()) {
- InboundInvocationChain chain = createInboundChain(method);
+ for (Operation operation : contract.getOperations().values()) {
+ InboundInvocationChain chain = createInboundChain(operation);
chain.addInterceptor(new InvokerInterceptor());
- wire.addInvocationChain(method, chain);
+ wire.addInvocationChain(operation, chain);
}
reference.setInboundWire(wire);
}
@@ -189,76 +206,73 @@
createWires(service, def.getTarget().getPath(), def.getServiceContract());
}
- private <T> void createWires(Service<T> service, String targetName, ServiceContract contract) {
- InboundWire<T> inboundWire = new InboundWireImpl<T>();
- OutboundWire<T> outboundWire = new OutboundWireImpl<T>();
- Class<T> interfaze = service.getInterface();
- inboundWire.setServiceContract(contract);
- outboundWire.setServiceContract(contract);
- outboundWire.setTargetName(new QualifiedName(targetName));
- for (Method method : interfaze.getMethods()) {
- InboundInvocationChain inboundChain = createInboundChain(method);
- inboundWire.addInvocationChain(method, inboundChain);
- OutboundInvocationChain outboundChain = createOutboundChain(method);
- outboundWire.addInvocationChain(method, outboundChain);
- }
- service.setInboundWire(inboundWire);
- service.setOutboundWire(outboundWire);
- }
-
-
@SuppressWarnings("unchecked")
public OutboundWire createWire(ReferenceTarget reference, ReferenceDefinition def) {
//TODO multiplicity
if (reference.getTargets().size() != 1) {
throw new UnsupportedOperationException();
}
- ServiceContract contract = def.getServiceContract();
- Class<?> interfaze = def.getServiceContract().getInterfaceClass();
- OutboundWire wire = createOutboundWire();
+ ServiceContract<?> contract = def.getServiceContract();
+ OutboundWire wire = new OutboundWireImpl();
QualifiedName qName = new QualifiedName(reference.getTargets().get(0).toString());
wire.setTargetName(qName);
wire.setServiceContract(contract);
wire.setReferenceName(reference.getReferenceName());
- for (Method method : interfaze.getMethods()) {
+ for (Operation operation : contract.getOperations().values()) {
//TODO handle policy
- OutboundInvocationChain chain = createOutboundChain(method);
- wire.addInvocationChain(method, chain);
+ OutboundInvocationChain chain = createOutboundChain(operation);
+ wire.addInvocationChain(operation, chain);
+
}
Class<?> callbackInterface = contract.getCallbackClass();
if (callbackInterface != null) {
wire.setCallbackInterface(callbackInterface);
- for (Method callbackMethod : callbackInterface.getMethods()) {
- InboundInvocationChain callbackTargetChain = createInboundChain(callbackMethod);
- OutboundInvocationChain callbackSourceChain = createOutboundChain(callbackMethod);
+ for (Operation operation : contract.getCallbacksOperations().values()) {
+ InboundInvocationChain callbackTargetChain = createInboundChain(operation);
+ OutboundInvocationChain callbackSourceChain = createOutboundChain(operation);
// TODO handle policy
//TODO statement below could be cleaner
callbackTargetChain.addInterceptor(new InvokerInterceptor());
- wire.addTargetCallbackInvocationChain(callbackMethod, callbackTargetChain);
- wire.addSourceCallbackInvocationChain(callbackMethod, callbackSourceChain);
+ wire.addTargetCallbackInvocationChain(operation, callbackTargetChain);
+ wire.addSourceCallbackInvocationChain(operation, callbackSourceChain);
}
}
return wire;
}
public InboundWire createWire(ServiceDefinition service) {
- Class<?> interfaze = service.getServiceContract().getInterfaceClass();
- InboundWire wire = createInboundWire();
- wire.setServiceContract(service.getServiceContract());
+ InboundWire wire = new InboundWireImpl();
+ ServiceContract<?> contract = service.getServiceContract();
+ wire.setServiceContract(contract);
wire.setServiceName(service.getName());
- for (Method method : interfaze.getMethods()) {
- InboundInvocationChain chain = createInboundChain(method);
+ for (Operation operation : contract.getOperations().values()) {
+ InboundInvocationChain chain = createInboundChain(operation);
// TODO handle policy
//TODO statement below could be cleaner
chain.addInterceptor(new InvokerInterceptor());
- wire.addInvocationChain(method, chain);
+ wire.addInvocationChain(operation, chain);
}
- ServiceContract contract = service.getServiceContract();
Class<?> callbackInterface = contract.getCallbackClass();
if (callbackInterface != null) {
wire.setCallbackReferenceName(service.getCallbackReferenceName());
}
return wire;
+ }
+
+ private <T> void createWires(Service<T> service, String targetName, ServiceContract<?> contract) {
+ InboundWire<T> inboundWire = new InboundWireImpl<T>();
+ OutboundWire<T> outboundWire = new OutboundWireImpl<T>();
+ inboundWire.setServiceContract(contract);
+ outboundWire.setServiceContract(contract);
+ outboundWire.setTargetName(new QualifiedName(targetName));
+ for (Operation operation : contract.getOperations().values()) {
+ InboundInvocationChain inboundChain = createInboundChain(operation);
+ inboundWire.addInvocationChain(operation, inboundChain);
+ OutboundInvocationChain outboundChain = createOutboundChain(operation);
+ outboundWire.addInvocationChain(operation, outboundChain);
+ }
+ service.setInboundWire(inboundWire);
+ service.setOutboundWire(outboundWire);
}
}
Added: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java?rev=438785&view=auto
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java (added)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java Wed Aug 30 21:31:11 2006
@@ -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.core.wire.jdk;
+
+import org.apache.tuscany.spi.wire.ProxyCreationException;
+
+/**
+ * Thrown when an {@link org.apache.tuscany.spi.model.Operation} cannot be mapped to a method on an interface
+ * @version $Rev$ $Date$
+ */
+public class NoMethodForOperationException extends ProxyCreationException {
+ public NoMethodForOperationException() {
+ }
+
+ public NoMethodForOperationException(String message) {
+ super(message);
+ }
+
+ public NoMethodForOperationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public NoMethodForOperationException(Throwable cause) {
+ super(cause);
+ }
+}
Propchange: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/wire/jdk/NoMethodForOperationException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java Wed Aug 30 21:31:11 2006
@@ -18,10 +18,13 @@
*/
package org.apache.tuscany.core.builder;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.Interceptor;
import org.apache.tuscany.spi.wire.Message;
@@ -30,6 +33,7 @@
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
import org.apache.tuscany.core.mock.component.SimpleTarget;
import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
@@ -45,6 +49,7 @@
* @version $$Rev$$ $$Date$$
*/
public class InboundtoOutboundConnectTestCase extends MockObjectTestCase {
+ private Operation operation;
@SuppressWarnings("unchecked")
public void testNoInterceptorsNoHandlers() throws Exception {
@@ -146,13 +151,7 @@
List<MessageHandler> requestHandlers,
List<MessageHandler> responseHandlers) {
- Method echo;
- try {
- echo = SimpleTarget.class.getMethod("echo", String.class);
- } catch (NoSuchMethodException e) {
- throw new AssertionError();
- }
- InboundInvocationChainImpl chain = new InboundInvocationChainImpl(echo);
+ InboundInvocationChainImpl chain = new InboundInvocationChainImpl(operation);
if (interceptors != null) {
for (Interceptor interceptor : interceptors) {
chain.addInterceptor(interceptor);
@@ -175,13 +174,7 @@
List<MessageHandler> requestHandlers,
List<MessageHandler> responseHandlers) {
- Method echo;
- try {
- echo = SimpleTarget.class.getMethod("echo", String.class);
- } catch (NoSuchMethodException e) {
- throw new AssertionError();
- }
- OutboundInvocationChainImpl chain = new OutboundInvocationChainImpl(echo);
+ OutboundInvocationChainImpl chain = new OutboundInvocationChainImpl(operation);
if (interceptors != null) {
for (Interceptor interceptor : interceptors) {
chain.addInterceptor(interceptor);
@@ -201,4 +194,15 @@
return chain;
}
+ protected void setUp() throws Exception {
+ super.setUp();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
+ try {
+ contract = registry.introspect(SimpleTarget.class);
+ } catch (InvalidServiceContractException e) {
+ throw new AssertionError();
+ }
+ operation = contract.getOperations().get("echo");
+ }
}
Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/builder/OutboundToInboundConnectTestCase.java Wed Aug 30 21:31:11 2006
@@ -18,10 +18,13 @@
*/
package org.apache.tuscany.core.builder;
-import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.Interceptor;
import org.apache.tuscany.spi.wire.Message;
@@ -30,6 +33,7 @@
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
import org.apache.tuscany.spi.wire.TargetInvoker;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
import org.apache.tuscany.core.mock.component.SimpleTarget;
import org.apache.tuscany.core.mock.wire.MockHandler;
import org.apache.tuscany.core.mock.wire.MockSyncInterceptor;
@@ -463,13 +467,15 @@
List<MessageHandler> requestHandlers,
List<MessageHandler> responseHandlers) {
- Method echo;
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
try {
- echo = SimpleTarget.class.getMethod("echo", String.class);
- } catch (NoSuchMethodException e) {
+ contract = registry.introspect(SimpleTarget.class);
+ } catch (InvalidServiceContractException e) {
throw new AssertionError();
}
- InboundInvocationChainImpl chain = new InboundInvocationChainImpl(echo);
+ Operation operation = contract.getOperations().get("echo");
+ InboundInvocationChainImpl chain = new InboundInvocationChainImpl(operation);
if (interceptors != null) {
for (Interceptor interceptor : interceptors) {
chain.addInterceptor(interceptor);
@@ -493,13 +499,15 @@
List<MessageHandler> requestHandlers,
List<MessageHandler> responseHandlers) {
- Method echo;
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract;
try {
- echo = SimpleTarget.class.getMethod("echo", String.class);
- } catch (NoSuchMethodException e) {
+ contract = registry.introspect(SimpleTarget.class);
+ } catch (InvalidServiceContractException e) {
throw new AssertionError();
}
- OutboundInvocationChainImpl chain = new OutboundInvocationChainImpl(echo);
+ Operation operation = contract.getOperations().get("echo");
+ OutboundInvocationChainImpl chain = new OutboundInvocationChainImpl(operation);
if (interceptors != null) {
for (Interceptor interceptor : interceptors) {
chain.addInterceptor(interceptor);
Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeBuilderTestCase.java Wed Aug 30 21:31:11 2006
@@ -20,23 +20,14 @@
import java.net.URI;
-import org.apache.tuscany.core.builder.BuilderRegistryImpl;
-import org.apache.tuscany.core.deployer.RootDeploymentContext;
-import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.component.CompositeComponent;
+import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
import org.apache.tuscany.spi.implementation.java.JavaMappedService;
import org.apache.tuscany.spi.implementation.java.PojoComponentType;
-import org.apache.tuscany.core.implementation.java.JavaComponentBuilder;
-import org.apache.tuscany.core.implementation.java.JavaImplementation;
-import org.apache.tuscany.core.implementation.java.mock.components.Source;
-import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
-import org.apache.tuscany.core.implementation.java.mock.components.Target;
-import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
-import org.apache.tuscany.core.wire.jdk.JDKWireService;
-import org.apache.tuscany.spi.component.CompositeComponent;
-import org.apache.tuscany.spi.component.ScopeContainer;
-import org.apache.tuscany.spi.deployer.DeploymentContext;
import org.apache.tuscany.spi.model.BindlessServiceDefinition;
import org.apache.tuscany.spi.model.ComponentDefinition;
import org.apache.tuscany.spi.model.CompositeComponentType;
@@ -48,6 +39,16 @@
import org.apache.tuscany.spi.model.ServiceDefinition;
import org.apache.tuscany.spi.wire.WireService;
+import org.apache.tuscany.core.builder.BuilderRegistryImpl;
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
+import org.apache.tuscany.core.implementation.java.JavaComponentBuilder;
+import org.apache.tuscany.core.implementation.java.JavaImplementation;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
+import org.apache.tuscany.core.implementation.java.mock.components.SourceImpl;
+import org.apache.tuscany.core.implementation.java.mock.components.Target;
+import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
+import org.apache.tuscany.core.wire.jdk.JDKWireService;
import org.jmock.Mock;
import org.jmock.MockObjectTestCase;
@@ -66,7 +67,7 @@
@SuppressWarnings("unchecked")
public void testBuild() throws Exception {
CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);
-
+
CompositeBuilder builder = new CompositeBuilder();
WireService wireService = new JDKWireService();
builder.setWireService(wireService);
@@ -79,71 +80,74 @@
builderRegistry.register(bindlessBuilder);
builder.setBuilderRegistry(builderRegistry);
CompositeComponent component =
- (CompositeComponent)builder.build(parent, createTopComponentDef(), deploymentContext);
+ (CompositeComponent) builder.build(parent, createTopComponentDef(), deploymentContext);
deploymentContext.getModuleScope().start();
component.start();
- CompositeComponent sourceComponent = (CompositeComponent)component.getChild("SourceComponent");
- Source source = (Source)sourceComponent.getServiceInstance("InnerSourceService");
+ CompositeComponent sourceComponent = (CompositeComponent) component.getChild("SourceComponent");
+ Source source = (Source) sourceComponent.getServiceInstance("InnerSourceService");
assertNotNull(source);
component.stop();
}
-
+
private ComponentDefinition createTopComponentDef() throws Exception {
-
+
CompositeComponentType outerType = new CompositeComponentType();
outerType.add(createSourceComponentDef());
outerType.add(createTargetComponentDef());
-
+
CompositeImplementation outerImpl = new CompositeImplementation();
outerImpl.setComponentType(outerType);
-
+
ComponentDefinition<CompositeImplementation> topComponentDefinition =
new ComponentDefinition<CompositeImplementation>(outerImpl);
-
+
return topComponentDefinition;
}
-
+
private ComponentDefinition createSourceComponentDef() throws Exception {
-
+
CompositeComponentType innerType = new CompositeComponentType();
innerType.add(createInnerSourceComponentDef());
ReferenceDefinition reference = new ReferenceDefinition();
reference.setName("targetComponentRef");
- ServiceContract targetContract = new JavaServiceContract(Target.class);
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> targetContract = registry.introspect(Target.class);
reference.setServiceContract(targetContract);
innerType.add(reference);
BindlessServiceDefinition service = new BindlessServiceDefinition();
service.setName("InnerSourceService");
- ServiceContract sourceContract = new JavaServiceContract(Source.class);
+ ServiceContract<?> sourceContract = registry.introspect(Source.class);
service.setServiceContract(sourceContract);
service.setTarget(new URI("InnerSourceComponent"));
innerType.add(service);
-
+
CompositeImplementation innerImpl = new CompositeImplementation();
innerImpl.setComponentType(innerType);
-
+
ComponentDefinition<CompositeImplementation> sourceComponentDefinition =
new ComponentDefinition<CompositeImplementation>("SourceComponent", innerImpl);
ReferenceTarget refTarget = new ReferenceTarget();
refTarget.setReferenceName("targetComponentRef");
refTarget.addTarget(new URI("TargetComponent"));
sourceComponentDefinition.add(refTarget);
-
+
return sourceComponentDefinition;
}
-
+
private ComponentDefinition createInnerSourceComponentDef() throws Exception {
PojoComponentType sourceType = new PojoComponentType();
sourceType.setImplementationScope(Scope.MODULE);
JavaMappedReference reference = new JavaMappedReference();
reference.setName("targetReference");
- ServiceContract targetContract = new JavaServiceContract(Target.class);
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> targetContract = registry.introspect(Target.class);
reference.setServiceContract(targetContract);
reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
sourceType.add(reference);
- ServiceContract sourceContract = new JavaServiceContract(Source.class);
+ ServiceContract<?> sourceContract = registry.introspect(Source.class);
+
ServiceDefinition sourceServiceDefinition = new JavaMappedService();
sourceServiceDefinition.setName("Source");
sourceServiceDefinition.setServiceContract(sourceContract);
@@ -159,16 +163,18 @@
refTarget.setReferenceName("targetReference");
refTarget.addTarget(new URI("TargetComponentRef"));
innerSourceComponentDefinition.add(refTarget);
-
+
return innerSourceComponentDefinition;
}
-
+
private ComponentDefinition createTargetComponentDef() throws Exception {
-
+
PojoComponentType targetType = new PojoComponentType();
targetType.setImplementationScope(Scope.MODULE);
- ServiceContract targetContract = new JavaServiceContract(Target.class);
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> targetContract = registry.introspect(Target.class);
+
ServiceDefinition targetServiceDefinition = new JavaMappedService();
targetServiceDefinition.setName("Target");
targetServiceDefinition.setServiceContract(targetContract);
@@ -180,7 +186,7 @@
targetImpl.setImplementationClass(TargetImpl.class);
ComponentDefinition<JavaImplementation> targetComponentDefinition =
new ComponentDefinition<JavaImplementation>("TargetComponent", targetImpl);
-
+
return targetComponentDefinition;
}
Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/CallbackInvocationTestCase.java Wed Aug 30 21:31:11 2006
@@ -28,29 +28,31 @@
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.component.ScopeContainer;
import org.apache.tuscany.spi.deployer.DeploymentContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
+import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
+import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
+import org.apache.tuscany.spi.implementation.java.JavaMappedService;
+import org.apache.tuscany.spi.implementation.java.PojoComponentType;
import org.apache.tuscany.spi.model.ComponentDefinition;
import org.apache.tuscany.spi.model.ReferenceTarget;
import org.apache.tuscany.spi.model.Scope;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.services.work.WorkScheduler;
import org.apache.tuscany.spi.wire.WireService;
-import org.apache.tuscany.spi.implementation.java.JavaMappedService;
import junit.framework.TestCase;
import org.apache.tuscany.core.builder.ConnectorImpl;
import org.apache.tuscany.core.component.WorkContextImpl;
import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
-import org.apache.tuscany.spi.implementation.java.ConstructorDefinition;
-import org.apache.tuscany.spi.implementation.java.JavaMappedProperty;
-import org.apache.tuscany.spi.implementation.java.JavaMappedReference;
-import org.apache.tuscany.spi.implementation.java.PojoComponentType;
-import org.apache.tuscany.spi.idl.java.JavaServiceContract;
-
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
import org.apache.tuscany.core.implementation.java.JavaComponentBuilder;
import org.apache.tuscany.core.implementation.java.JavaImplementation;
+import org.apache.tuscany.core.implementation.java.mock.components.Source;
import org.apache.tuscany.core.wire.jdk.JDKWireService;
-
import static org.easymock.EasyMock.createMock;
import static org.easymock.EasyMock.expectLastCall;
import static org.easymock.EasyMock.getCurrentArguments;
@@ -137,14 +139,16 @@
}
- private ComponentDefinition<JavaImplementation> createTarget() throws NoSuchMethodException {
+ private ComponentDefinition<JavaImplementation> createTarget() throws NoSuchMethodException,
+ InvalidServiceContractException {
ConstructorDefinition<FooImpl> ctorDef = new ConstructorDefinition<FooImpl>(FooImpl.class.getConstructor());
PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
type.setConstructorDefinition(ctorDef);
type.setImplementationScope(Scope.MODULE);
Method method = FooImpl.class.getMethod("setCallback", FooCallback.class);
- ServiceContract contract = new JavaServiceContract(Foo.class);
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(Foo.class);
contract.setCallbackClass(FooCallback.class);
contract.setCallbackName("callback");
JavaMappedService mappedService = new JavaMappedService("Foo", contract, false, "callback", method);
@@ -157,7 +161,7 @@
}
private ComponentDefinition<JavaImplementation> createSource(String name)
- throws NoSuchMethodException, URISyntaxException {
+ throws NoSuchMethodException, URISyntaxException, InvalidServiceContractException {
ConstructorDefinition<FooClient> ctorDef =
new ConstructorDefinition<FooClient>(FooClient.class.getConstructor());
PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type =
@@ -165,7 +169,8 @@
type.setConstructorDefinition(ctorDef);
type.setImplementationScope(Scope.MODULE);
Method method = FooClient.class.getMethod("setFoo", Foo.class);
- ServiceContract contract = new JavaServiceContract(Foo.class);
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(Foo.class);
contract.setCallbackClass(FooCallback.class);
contract.setCallbackName("callback");
JavaMappedReference mappedReference = new JavaMappedReference("foo", contract, method);
Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OneWayWireInvocationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OneWayWireInvocationTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OneWayWireInvocationTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OneWayWireInvocationTestCase.java Wed Aug 30 21:31:11 2006
@@ -19,6 +19,7 @@
package org.apache.tuscany.core.implementation.java.integration.component;
import java.lang.reflect.Method;
+import java.util.Map;
import org.apache.tuscany.spi.component.WorkContext;
import org.apache.tuscany.spi.services.work.WorkScheduler;
@@ -26,6 +27,7 @@
import org.apache.tuscany.spi.wire.InboundWire;
import org.apache.tuscany.spi.wire.MessageImpl;
import org.apache.tuscany.spi.wire.WireService;
+import org.apache.tuscany.spi.model.Operation;
import junit.framework.TestCase;
import org.apache.tuscany.core.implementation.java.AsyncJavaTargetInvoker;
@@ -73,7 +75,8 @@
AsyncJavaTargetInvoker invoker = new AsyncJavaTargetInvoker(method, null, component, scheduler, null, context);
InboundWire<AsyncTarget> wire =
createServiceWire("foo", AsyncTarget.class, null, null, null);
- InboundInvocationChain chain = wire.getInvocationChains().get(method);
+ Map<Operation, InboundInvocationChain> chains = wire.getInvocationChains();
+ InboundInvocationChain chain = chains.get(wire.getServiceContract().getOperations().get("invoke"));
chain.setTargetInvoker(invoker);
chain.prepare();
MessageImpl msg = new MessageImpl();
Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/integration/component/OutboundWireToJavaTestCase.java Wed Aug 30 21:31:11 2006
@@ -18,16 +18,20 @@
*/
package org.apache.tuscany.core.implementation.java.integration.component;
-import java.lang.reflect.Method;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import org.apache.tuscany.spi.QualifiedName;
-import org.apache.tuscany.spi.idl.java.JavaServiceContract;
import org.apache.tuscany.spi.component.ScopeContainer;
import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.spi.model.Operation;
+import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundWire;
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
import org.apache.tuscany.spi.wire.OutboundWire;
@@ -46,13 +50,13 @@
import org.apache.tuscany.core.component.scope.ModuleScopeContainer;
import org.apache.tuscany.core.component.scope.RequestScopeContainer;
import org.apache.tuscany.core.component.scope.StatelessScopeContainer;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
import org.apache.tuscany.core.implementation.PojoConfiguration;
import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
import org.apache.tuscany.core.implementation.java.mock.MockFactory;
import org.apache.tuscany.core.implementation.java.mock.components.Target;
import org.apache.tuscany.core.implementation.java.mock.components.TargetImpl;
import org.apache.tuscany.core.injection.PojoObjectFactory;
-import org.apache.tuscany.core.util.MethodHashMap;
import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
import org.apache.tuscany.core.wire.OutboundWireImpl;
import org.apache.tuscany.core.wire.jdk.JDKWireService;
@@ -168,7 +172,8 @@
}
@SuppressWarnings("unchecked")
- private OutboundWire<Target> getWire(ScopeContainer scope) throws NoSuchMethodException {
+ private OutboundWire<Target> getWire(ScopeContainer scope) throws NoSuchMethodException,
+ InvalidServiceContractException {
ConnectorImpl connector = new ConnectorImpl();
OutboundWire<Target> wire = createOutboundWire(new QualifiedName("target/Target"), Target.class);
@@ -184,7 +189,8 @@
return wire;
}
- public static <T> OutboundWire<T> createOutboundWire(QualifiedName targetName, Class<T> interfaze) {
+ public static <T> OutboundWire<T> createOutboundWire(QualifiedName targetName, Class<T> interfaze)
+ throws InvalidServiceContractException {
OutboundWire<T> wire = new OutboundWireImpl<T>();
JavaServiceContract contract = new JavaServiceContract(interfaze);
wire.setServiceContract(contract);
@@ -193,12 +199,14 @@
return wire;
}
- private static Map<Method, OutboundInvocationChain> createInvocationChains(Class<?> interfaze) {
- Map<Method, OutboundInvocationChain> invocations = new MethodHashMap<OutboundInvocationChain>();
- Method[] methods = interfaze.getMethods();
- for (Method method : methods) {
- OutboundInvocationChain chain = new OutboundInvocationChainImpl(method);
- invocations.put(method, chain);
+ private static Map<Operation<?>, OutboundInvocationChain> createInvocationChains(Class<?> interfaze)
+ throws InvalidServiceContractException {
+ Map<Operation<?>, OutboundInvocationChain> invocations = new HashMap<Operation<?>, OutboundInvocationChain>();
+ JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
+ ServiceContract<?> contract = registry.introspect(interfaze);
+ for (Operation operation : contract.getOperations().values()) {
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
+ invocations.put(operation, chain);
}
return invocations;
}
Modified: incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/MockFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/MockFactory.java?rev=438785&r1=438784&r2=438785&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/MockFactory.java (original)
+++ incubator/tuscany/java/sca/core/src/test/java/org/apache/tuscany/core/implementation/java/mock/MockFactory.java Wed Aug 30 21:31:11 2006
@@ -28,8 +28,12 @@
import org.apache.tuscany.spi.builder.BuilderConfigException;
import org.apache.tuscany.spi.component.AtomicComponent;
import org.apache.tuscany.spi.component.ScopeContainer;
+import org.apache.tuscany.spi.idl.InvalidServiceContractException;
+import org.apache.tuscany.spi.idl.java.JavaIDLUtils;
+import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
+import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.model.Scope;
-import org.apache.tuscany.spi.services.work.WorkScheduler;
+import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
import org.apache.tuscany.spi.wire.Interceptor;
@@ -38,13 +42,12 @@
import org.apache.tuscany.spi.wire.OutboundWire;
import org.apache.tuscany.spi.wire.TargetInvoker;
import org.apache.tuscany.spi.wire.WireService;
-import org.apache.tuscany.spi.idl.java.JavaServiceContract;
+import org.apache.tuscany.core.idl.java.JavaInterfaceProcessorRegistryImpl;
import org.apache.tuscany.core.implementation.PojoConfiguration;
import org.apache.tuscany.core.implementation.java.JavaAtomicComponent;
import org.apache.tuscany.core.implementation.java.JavaTargetInvoker;
import org.apache.tuscany.core.injection.PojoObjectFactory;
-import org.apache.tuscany.core.util.MethodHashMap;
import org.apache.tuscany.core.wire.InboundInvocationChainImpl;
import org.apache.tuscany.core.wire.InboundWireImpl;
import org.apache.tuscany.core.wire.InvokerInterceptor;
@@ -63,6 +66,7 @@
public final class MockFactory {
private static final WireService WIRE_SERVICE = new JDKWireService();
+ private static final JavaInterfaceProcessorRegistry REGISTRY = new JavaInterfaceProcessorRegistryImpl();
private MockFactory() {
}
@@ -102,21 +106,6 @@
}
- @SuppressWarnings("unchecked")
- public static <T> JavaAtomicComponent<T> createJavaComponent(String name,
- ScopeContainer scope,
- Class<T> clazz,
- WorkScheduler scheduler)
- throws NoSuchMethodException {
- PojoConfiguration configuration = new PojoConfiguration();
- configuration.setScopeContainer(scope);
- configuration.setInstanceFactory(new PojoObjectFactory(clazz.getConstructor()));
- configuration.addServiceInterface(clazz);
- configuration.setWireService(WIRE_SERVICE);
- return new JavaAtomicComponent(name, configuration, null);
-
- }
-
/**
* Wires two contexts together where the reference interface is the same as target service
*
@@ -255,7 +244,8 @@
return contexts;
}
- public static <T> InboundWire<T> createTargetWire(String serviceName, Class<T> interfaze) {
+ public static <T> InboundWire<T> createTargetWire(String serviceName, Class<T> interfaze)
+ throws InvalidServiceContractException {
return createServiceWire(serviceName, interfaze, null, null, null);
}
@@ -263,9 +253,10 @@
public static <T> InboundWire<T> createServiceWire(String serviceName, Class<T> interfaze,
Interceptor headInterceptor,
MessageHandler headRequestHandler,
- MessageHandler headResponseHandler) {
+ MessageHandler headResponseHandler)
+ throws InvalidServiceContractException {
InboundWire<T> wire = new InboundWireImpl<T>();
- JavaServiceContract contract = new JavaServiceContract(interfaze);
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
wire.setServiceContract(contract);
wire.setServiceName(serviceName);
wire.addInvocationChains(
@@ -276,22 +267,25 @@
public static <T> OutboundWire<T> createReferenceWire(String refName, Class<T> interfaze,
Interceptor headInterceptor,
MessageHandler headRequestHandler,
- MessageHandler headResponseHandler) {
+ MessageHandler headResponseHandler)
+ throws InvalidServiceContractException {
OutboundWire<T> wire = new OutboundWireImpl<T>();
wire.setReferenceName(refName);
- wire.addInvocationChains(
- createOutboundChains(interfaze, headInterceptor, headRequestHandler, headResponseHandler));
- JavaServiceContract contract = new JavaServiceContract(interfaze);
+ Map<Operation<?>, OutboundInvocationChain> outboundChains =
+ createOutboundChains(interfaze, headInterceptor, headRequestHandler, headResponseHandler);
+ wire.addInvocationChains(outboundChains);
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
wire.setServiceContract(contract);
return wire;
}
- public static <T> OutboundWire<T> createReferenceWire(String refName, Class<T> interfaze) {
+ public static <T> OutboundWire<T> createReferenceWire(String refName, Class<T> interfaze)
+ throws InvalidServiceContractException {
OutboundWire<T> wire = new OutboundWireImpl<T>();
wire.setReferenceName(refName);
wire.addInvocationChains(createOutboundChains(interfaze));
- JavaServiceContract contract = new JavaServiceContract(interfaze);
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
wire.setServiceContract(contract);
return wire;
}
@@ -310,11 +304,11 @@
boolean cacheable) throws Exception {
if (inboundWire != null) {
// if null, the target side has no interceptors or handlers
- Map<Method, InboundInvocationChain> targetInvocationConfigs = inboundWire.getInvocationChains();
+ Map<Operation, InboundInvocationChain> targetInvocationConfigs = inboundWire.getInvocationChains();
for (OutboundInvocationChain outboundInvocationConfig : outboundWire.getInvocationChains().values()) {
// match wire chains
InboundInvocationChain inboundInvocationConfig =
- targetInvocationConfigs.get(outboundInvocationConfig.getMethod());
+ targetInvocationConfigs.get(outboundInvocationConfig.getOperation());
if (inboundInvocationConfig == null) {
BuilderConfigException e =
new BuilderConfigException("Incompatible source and target interface types for reference");
@@ -332,7 +326,7 @@
if (inboundInvocationConfig.getHeadInterceptor() == null) {
BuilderConfigException e =
new BuilderConfigException("No target handler or interceptor for operation");
- e.setIdentifier(inboundInvocationConfig.getMethod().getName());
+ e.setIdentifier(inboundInvocationConfig.getOperation().getName());
throw e;
}
if (!(outboundInvocationConfig.getTailInterceptor() instanceof InvokerInterceptor
@@ -344,28 +338,31 @@
}
}
- for (OutboundInvocationChain outboundInvocationConfig : outboundWire.getInvocationChains()
- .values()) {
+ for (OutboundInvocationChain chain : outboundWire.getInvocationChains().values()) {
//FIXME should use target method, not outboundInvocationConfig.getMethod()
- TargetInvoker invoker = new JavaTargetInvoker(outboundInvocationConfig.getMethod(), targetContext);
+ Method[] methods = outboundWire.getServiceContract().getInterfaceClass().getMethods();
+ Method m = JavaIDLUtils.findMethod(chain.getOperation(), methods);
+ TargetInvoker invoker = new JavaTargetInvoker(m, targetContext);
invoker.setCacheable(cacheable);
- outboundInvocationConfig.setTargetInvoker(invoker);
+ chain.setTargetInvoker(invoker);
}
}
}
- private static Map<Method, OutboundInvocationChain> createOutboundChains(Class<?> interfaze) {
+ private static Map<Operation<?>, OutboundInvocationChain> createOutboundChains(Class<?> interfaze)
+ throws InvalidServiceContractException {
return createOutboundChains(interfaze, null, null, null);
}
- private static Map<Method, OutboundInvocationChain> createOutboundChains(Class<?> interfaze,
- Interceptor headInterceptor,
- MessageHandler headRequestHandler,
- MessageHandler headResponseHandler) {
- Map<Method, OutboundInvocationChain> invocations = new HashMap<Method, OutboundInvocationChain>();
- Method[] methods = interfaze.getMethods();
- for (Method method : methods) {
- OutboundInvocationChain chain = new OutboundInvocationChainImpl(method);
+ private static Map<Operation<?>, OutboundInvocationChain> createOutboundChains(Class<?> interfaze,
+ Interceptor headInterceptor,
+ MessageHandler headRequestHandler,
+ MessageHandler headResponseHandler)
+ throws InvalidServiceContractException {
+ Map<Operation<?>, OutboundInvocationChain> invocations = new HashMap<Operation<?>, OutboundInvocationChain>();
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
+ for (Operation operation : contract.getOperations().values()) {
+ OutboundInvocationChain chain = new OutboundInvocationChainImpl(operation);
if (headInterceptor != null) {
chain.addInterceptor(headInterceptor);
}
@@ -375,18 +372,20 @@
if (headResponseHandler != null) {
chain.addRequestHandler(headResponseHandler);
}
- invocations.put(method, chain);
+ invocations.put(operation, chain);
}
return invocations;
}
- private static Map<Method, InboundInvocationChain> createInboundChains(Class<?> interfaze,
- Interceptor headInterceptor,
- MessageHandler headRequestHandler,
- MessageHandler headResponseHandler) {
- Map<Method, InboundInvocationChain> invocations = new MethodHashMap<InboundInvocationChain>();
- Method[] methods = interfaze.getMethods();
- for (Method method : methods) {
+ private static Map<Operation, InboundInvocationChain> createInboundChains(Class<?> interfaze,
+ Interceptor headInterceptor,
+ MessageHandler headRequestHandler,
+ MessageHandler headResponseHandler)
+ throws InvalidServiceContractException {
+
+ Map<Operation, InboundInvocationChain> invocations = new HashMap<Operation, InboundInvocationChain>();
+ ServiceContract<?> contract = REGISTRY.introspect(interfaze);
+ for (Operation method : contract.getOperations().values()) {
InboundInvocationChain chain = new InboundInvocationChainImpl(method);
if (headInterceptor != null) {
chain.addInterceptor(headInterceptor);
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org