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/12/26 10:55:31 UTC
svn commit: r490277 - in /incubator/tuscany/java/sca/kernel:
core/src/main/java/org/apache/tuscany/core/wire/jdk/
core/src/test/java/org/apache/tuscany/core/wire/
core/src/test/java/org/apache/tuscany/core/wire/jdk/
spi/src/main/java/org/apache/tuscany...
Author: jmarino
Date: Tue Dec 26 01:55:30 2006
New Revision: 490277
URL: http://svn.apache.org/viewvc?view=rev&rev=490277
Log:
refactor JDKInboundInvocationHandler to allow client specificaton of the proxy type
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java?view=diff&rev=490277&r1=490276&r2=490277
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandler.java Tue Dec 26 01:55:30 2006
@@ -59,6 +59,7 @@
private transient Map<Method, ChainHolder> chains;
private transient WorkContext context;
private String serviceName;
+ private Class<?> interfaze;
/**
* Constructor used for deserialization only
@@ -66,10 +67,11 @@
public JDKInboundInvocationHandler() {
}
- public JDKInboundInvocationHandler(InboundWire wire, WorkContext context) {
+ public JDKInboundInvocationHandler(Class<?> interfaze, InboundWire wire, WorkContext context) {
this.context = context;
this.serviceName = wire.getServiceName();
- init(wire);
+ this.interfaze = interfaze;
+ init(interfaze, wire);
}
public void setWorkContext(WorkContext context) {
@@ -125,10 +127,12 @@
public void writeExternal(ObjectOutput out) throws IOException {
out.writeObject(serviceName);
+ out.writeObject(interfaze);
}
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
serviceName = (String) in.readObject();
+ interfaze = (Class<?>) in.readObject();
}
public void reactivate() throws ReactivationException {
@@ -138,13 +142,11 @@
throw new ReactivationException("Current atomic component not set on work context");
}
InboundWire wire = owner.getInboundWires().get(serviceName);
- init(wire);
+ init(interfaze, wire);
}
- private void init(InboundWire wire) {
+ private void init(Class<?> interfaze, InboundWire wire) {
this.chains = new HashMap<Method, ChainHolder>();
- // FIXME: TUSCANY-862 we cannot assume there is a Java interface class
- Class<?> interfaze = wire.getServiceContract().getInterfaceClass();
Method[] methods = interfaze.getMethods();
Map<Method, InboundInvocationChain> invocationChains = WireUtils.createInboundMapping(wire, methods);
for (Map.Entry<Method, InboundInvocationChain> entry : invocationChains.entrySet()) {
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java?view=diff&rev=490277&r1=490276&r2=490277
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/jdk/JDKWireService.java Tue Dec 26 01:55:30 2006
@@ -58,7 +58,7 @@
assert wire != null : "Wire was null";
if (wire instanceof InboundWire) {
InboundWire inbound = (InboundWire) wire;
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(inbound, context);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(interfaze, inbound, context);
ClassLoader cl = interfaze.getClassLoader();
return interfaze.cast(Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler));
} else if (wire instanceof OutboundWire) {
@@ -81,7 +81,7 @@
assert wire != null;
if (wire instanceof InboundWire) {
InboundWire inbound = (InboundWire) wire;
- return new JDKInboundInvocationHandler(inbound, context);
+ return new JDKInboundInvocationHandler(interfaze, inbound, context);
} else if (wire instanceof OutboundWire) {
OutboundWire outbound = (OutboundWire) wire;
return new JDKOutboundInvocationHandler(interfaze, outbound, context);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java?view=diff&rev=490277&r1=490276&r2=490277
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/InboundInvocationErrorTestCase.java Tue Dec 26 01:55:30 2006
@@ -92,7 +92,7 @@
wire.setServiceContract(new ServiceContract<TestBean>(TestBean.class) {
});
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(wire, workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(TestBean.class, wire, workContext);
try {
ClassLoader ccl = Thread.currentThread().getContextClassLoader();
TestBean proxy = (TestBean) Proxy.newProxyInstance(ccl, new Class[]{TestBean.class}, handler);
@@ -116,7 +116,7 @@
wire.setServiceContract(new ServiceContract<TestBean>(TestBean.class) {
});
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(wire, workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(TestBean.class, wire, workContext);
try {
InboundInvocationErrorTestCase.TestBean proxy = (InboundInvocationErrorTestCase.TestBean) Proxy
.newProxyInstance(Thread.currentThread().getContextClassLoader(),
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java?view=diff&rev=490277&r1=490276&r2=490277
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerSerializationTestCase.java Tue Dec 26 01:55:30 2006
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.core.wire.jdk;
-import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@@ -29,9 +27,8 @@
import org.apache.tuscany.spi.component.AtomicComponent;
import org.apache.tuscany.spi.component.WorkContext;
-import org.apache.tuscany.spi.model.InteractionScope;
import org.apache.tuscany.spi.model.Operation;
-import org.apache.tuscany.spi.model.ServiceContract;
+import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
import org.apache.tuscany.spi.wire.Message;
@@ -53,7 +50,7 @@
private TargetInvoker invoker;
public void testSerializeDeserialize() throws Throwable {
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(wire, workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(Foo.class, wire, workContext);
handler.invoke(Foo.class.getMethod("invoke"), null);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
@@ -72,17 +69,11 @@
protected void setUp() throws Exception {
super.setUp();
- ServiceContract<Foo> contract = new ServiceContract<Foo>() {
- };
- contract.setInterfaceClass(Foo.class);
- contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL);
-
wire = EasyMock.createMock(InboundWire.class);
Map<Operation<?>, InboundInvocationChain> map = new HashMap<Operation<?>, InboundInvocationChain>();
Operation<Object> operation = new Operation<Object>("invoke", null, null, null, false, null, NO_CONVERSATION);
map.put(operation, createChain(operation));
- EasyMock.expect(wire.getServiceContract()).andReturn(contract).atLeastOnce();
EasyMock.expect(wire.getServiceName()).andReturn("foo").atLeastOnce();
EasyMock.expect(wire.getInvocationChains()).andReturn(map).times(2);
EasyMock.replay(wire);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java?view=diff&rev=490277&r1=490276&r2=490277
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKInboundInvocationHandlerTestCase.java Tue Dec 26 01:55:30 2006
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.core.wire.jdk;
-import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION;
-
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
@@ -33,6 +31,7 @@
import org.apache.tuscany.spi.idl.java.JavaInterfaceProcessorRegistry;
import org.apache.tuscany.spi.model.DataType;
import org.apache.tuscany.spi.model.Operation;
+import static org.apache.tuscany.spi.model.Operation.NO_CONVERSATION;
import org.apache.tuscany.spi.model.ServiceContract;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
@@ -70,7 +69,7 @@
WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
EasyMock.replay(workContext);
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(wire, workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext);
assertEquals("foo", handler.invoke(echo, new String[]{"foo"}));
assertEquals(1, interceptor.getCount());
}
@@ -83,7 +82,7 @@
WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
EasyMock.replay(workContext);
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(wire, workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext);
try {
assertEquals("foo", handler.invoke(echo, new Object[]{}));
fail("Expected " + IllegalArgumentException.class.getName());
@@ -100,7 +99,7 @@
WorkContext workContext = EasyMock.createNiceMock(WorkContext.class);
EasyMock.replay(workContext);
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(wire, workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext);
assertEquals("foo", handler.invoke(echo, new Object[]{"foo"}));
}
@@ -110,7 +109,7 @@
InboundWireImpl wire = new InboundWireImpl();
wire.setServiceContract(new ServiceContract<Foo>(Foo.class) {
});
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(wire, workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext);
Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
assertNotNull(foo.toString());
}
@@ -121,7 +120,7 @@
InboundWireImpl wire = new InboundWireImpl();
wire.setServiceContract(new ServiceContract<Foo>(Foo.class) {
});
- JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(wire, workContext);
+ JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(SimpleTarget.class, wire, workContext);
Foo foo = (Foo) Proxy.newProxyInstance(getClass().getClassLoader(), new Class[]{Foo.class}, handler);
assertNotNull(foo.hashCode());
}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java?view=diff&rev=490277&r1=490276&r2=490277
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/jdk/JDKProxyTestCase.java Tue Dec 26 01:55:30 2006
@@ -22,7 +22,6 @@
import java.util.HashMap;
import java.util.Map;
-import org.apache.tuscany.spi.idl.java.JavaServiceContract;
import org.apache.tuscany.spi.model.Operation;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
import org.apache.tuscany.spi.wire.InboundWire;
@@ -35,13 +34,11 @@
*/
public class JDKProxyTestCase extends TestCase {
private JDKWireService wireService;
- private JavaServiceContract serviceContract;
private InboundWire inboundWire;
private Map<Operation<?>, InboundInvocationChain> chains;
public void testCreateProxy() {
EasyMock.expect(inboundWire.getServiceName()).andReturn("service");
- EasyMock.expect(inboundWire.getServiceContract()).andReturn(serviceContract);
EasyMock.expect(inboundWire.getInvocationChains()).andReturn(chains);
EasyMock.replay(inboundWire);
TestInterface intf = wireService.createProxy(TestInterface.class, inboundWire);
@@ -53,7 +50,6 @@
super.setUp();
wireService = new JDKWireService();
inboundWire = EasyMock.createMock(InboundWire.class);
- serviceContract = new JavaServiceContract(TestInterface.class);
chains = new HashMap<Operation<?>, InboundInvocationChain>();
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java?view=diff&rev=490277&r1=490276&r2=490277
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/wire/InboundInvocationChain.java Tue Dec 26 01:55:30 2006
@@ -19,12 +19,7 @@
package org.apache.tuscany.spi.wire;
/**
- * A set of interceptors and handlers (contained in request and response message channels) associated with the inbound
- * side of a wire for an operation. Inbound chains may start with request {@link MessageHandler}s and contain at least
- * one {@link Interceptor} processed after the handlers prior to dipatching to the target instance. Inbound invocation
- * chains may also contain a set of response <code>MessageHandler</code>s which are processed after dispatching to the
- * target instance.
- * <p/>
+ * A set of interceptors associated with the inbound side of a wire for an operation.
*
* @version $$Rev$$ $$Date$$
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org