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 2007/01/03 15:36:09 UTC
svn commit: r492163 - in /incubator/tuscany/java/sca/kernel/core/src:
main/java/org/apache/tuscany/core/binding/local/
main/java/org/apache/tuscany/core/builder/
main/java/org/apache/tuscany/core/launcher/
main/java/org/apache/tuscany/core/wire/ test/j...
Author: jmarino
Date: Wed Jan 3 06:36:06 2007
New Revision: 492163
URL: http://svn.apache.org/viewvc?view=rev&rev=492163
Log:
enable callbacks over local binding; start to refactor for wire and proxy optimizations
Added:
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java (with props)
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java
incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalServiceBinding.java Wed Jan 3 06:36:06 2007
@@ -42,4 +42,9 @@
return new LocalTargetInvoker(operation, outboundWire);
}
+
+ public TargetInvoker createCallbackTargetInvoker(ServiceContract contract, Operation operation)
+ throws TargetInvokerCreationException {
+ return new LocalCallbackTargetInvoker(operation, getInboundWire());
+ }
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/binding/local/LocalTargetInvoker.java Wed Jan 3 06:36:06 2007
@@ -63,4 +63,9 @@
return faultMsg;
}
}
+
+
+ public boolean isOptimizable() {
+ return true;
+ }
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/builder/ConnectorImpl.java Wed Jan 3 06:36:06 2007
@@ -99,21 +99,17 @@
throws WiringException {
Map<Operation<?>, OutboundInvocationChain> targetChains = targetWire.getInvocationChains();
// perform optimization, if possible
- if (optimizable && sourceWire.getInvocationChains().isEmpty() && targetChains.isEmpty()) {
+ if (sourceWire.getContainer() != null && sourceWire.getContainer().isSystem()) {
sourceWire.setTargetWire(targetWire);
+ return;
+ } else if (optimizable && sourceWire.isOptimizable() && targetWire.isOptimizable()) {
if (postProcessorRegistry != null) {
// run wire post-processors
postProcessorRegistry.process(sourceWire, targetWire);
}
- return;
- } else if (optimizable && sourceWire.getContainer() != null
- && sourceWire.getContainer().isSystem()
- && targetWire.getContainer() != null
- && targetWire.getContainer().isSystem()) {
- // system services are directly wired withut invocation chains
- // JFM FIXME test this
- sourceWire.setTargetWire(targetWire);
- return;
+ if (sourceWire.isOptimizable() && targetWire.isOptimizable()) {
+ sourceWire.setTargetWire(targetWire);
+ }
}
for (InboundInvocationChain inboundChain : sourceWire.getInvocationChains().values()) {
// match invocation chains
@@ -123,6 +119,7 @@
}
connect(inboundChain, outboundChain);
}
+
if (postProcessorRegistry != null) {
// run wire post-processors
postProcessorRegistry.process(sourceWire, targetWire);
@@ -146,23 +143,18 @@
ServiceContract contract = sourceWire.getServiceContract();
Map<Operation<?>, InboundInvocationChain> targetChains = targetWire.getInvocationChains();
// perform optimization, if possible
- // REVIEW: (kentaminator@gmail.com) shouldn't this check whether the interceptors in the
- // source & target chains are marked as optimizable? (and if so, optimize them away?)
- if (optimizable && sourceWire.getInvocationChains().isEmpty() && targetChains.isEmpty()) {
+ if (sourceWire.getContainer() != null && sourceWire.getContainer().isSystem()) {
sourceWire.setTargetWire(targetWire);
+ return;
+ } else if (optimizable && sourceWire.isOptimizable() && targetWire.isOptimizable()) {
if (postProcessorRegistry != null) {
// run wire post-processors
postProcessorRegistry.process(sourceWire, targetWire);
}
- return;
- } else if (optimizable
- && sourceWire.getContainer() != null
- && sourceWire.getContainer().isSystem()
- && targetWire.getContainer() != null
- && targetWire.getContainer().isSystem()) {
- // JFM FIXME test this
- sourceWire.setTargetWire(targetWire);
- return;
+ if (sourceWire.isOptimizable() && targetWire.isOptimizable()) {
+ // JFM FIXME test this
+ sourceWire.setTargetWire(targetWire);
+ }
}
// match outbound to inbound chains
for (OutboundInvocationChain outboundChain : sourceWire.getInvocationChains().values()) {
@@ -263,42 +255,38 @@
e);
}
connect(outboundChain, inboundChain, invoker, false);
- } else if (source instanceof Reference) {
- Reference reference = (Reference) source;
+ } else if (source instanceof ReferenceBinding) {
+ //Reference reference = (Reference) source;
+ ReferenceBinding binding = (ReferenceBinding) source;
ServiceContract sourceContract = sourceWire.getServiceContract();
- for (ReferenceBinding binding : reference.getReferenceBindings()) {
- // FIXME JFM why is this only specific to local bindings and not generalized to all bindings?
- if (binding instanceof LocalReferenceBinding) {
- TargetInvoker invoker;
- try {
- invoker = binding.createCallbackTargetInvoker(sourceContract, operation);
- } catch (TargetInvokerCreationException e) {
- throw new WireConnectException("Error connecting source and target",
- sourceWire,
- targetWire,
- e);
- }
- connect(outboundChain, inboundChain, invoker, false);
- }
+ TargetInvoker invoker;
+ try {
+ invoker = binding.createCallbackTargetInvoker(sourceContract, operation);
+ } catch (TargetInvokerCreationException e) {
+ throw new WireConnectException("Error connecting source and target",
+ sourceWire,
+ targetWire,
+ e);
}
- } else if (source instanceof Service) {
- Service service = (Service) source;
+ connect(outboundChain, inboundChain, invoker, false);
+ } else if (source instanceof ServiceBinding) {
+ ServiceBinding binding = (ServiceBinding) source;
ServiceContract sourceContract = sourceWire.getServiceContract();
- for (ServiceBinding binding : service.getServiceBindings()) {
- TargetInvoker invoker;
- try {
- invoker = binding.createCallbackTargetInvoker(sourceContract, operation);
- } catch (TargetInvokerCreationException e) {
- String targetName = sourceWire.getContainer().getName();
- throw new WireConnectException("Error processing callback wire",
- null,
- null,
- targetName,
- null,
- e);
- }
- connect(outboundChain, inboundChain, invoker, false);
+ TargetInvoker invoker;
+ try {
+ invoker = binding.createCallbackTargetInvoker(sourceContract, operation);
+ } catch (TargetInvokerCreationException e) {
+ String targetName = sourceWire.getContainer().getName();
+ throw new WireConnectException("Error processing callback wire",
+ null,
+ null,
+ targetName,
+ null,
+ e);
}
+ connect(outboundChain, inboundChain, invoker, false);
+ } else {
+ throw new AssertionError();
}
}
if (postProcessorRegistry != null) {
@@ -427,7 +415,7 @@
targetName,
serviceName);
}
- connect(reference, outboundWire, target);
+ connect(binding, outboundWire, target);
}
}
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/launcher/CompositeContextImpl.java Wed Jan 3 06:36:06 2007
@@ -81,6 +81,14 @@
} else {
wire = getInboundWire(child, name, qName.getPortName());
}
+ // TODO JFM enable
+// if (wire.isOptimizable()) {
+// try {
+// return serviceInterface.cast(wire.getTargetService());
+// } catch (TargetResolutionException e) {
+// throw new ServiceRuntimeException(e);
+// }
+// }
return wireService.createProxy(serviceInterface, wire);
}
@@ -103,7 +111,7 @@
public ServiceReference newSession(String arg0, Object arg1) {
throw new UnsupportedOperationException();
}
-
+
private InboundWire getInboundWire(SCAObject child, String name, String serviceName) {
InboundWire wire = null;
if (child instanceof AtomicComponent) {
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptor.java Wed Jan 3 06:36:06 2007
@@ -101,7 +101,7 @@
}
public boolean isOptimizable() {
- return true;
+ return false;
}
private static class ContextBinder extends SCA {
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/OutboundWireImpl.java Wed Jan 3 06:36:06 2007
@@ -20,7 +20,6 @@
import java.util.HashMap;
import java.util.Map;
-
import javax.xml.namespace.QName;
import org.apache.tuscany.spi.QualifiedName;
@@ -150,21 +149,9 @@
for (OutboundInvocationChain chain : chains.values()) {
if (chain.getHeadInterceptor() != null) {
Interceptor current = chain.getHeadInterceptor();
- while (current != null && current != chain.getTargetInterceptor()) {
- if (!current.isOptimizable()) {
- return false;
- }
- current = current.getNext();
+ if (current == null) {
+ break;
}
- }
- }
-
- for (InboundInvocationChain chain : callbackTargetChains.values()) {
- if (chain.getTargetInvoker() != null && !chain.getTargetInvoker().isOptimizable()) {
- return false;
- }
- if (chain.getHeadInterceptor() != null) {
- Interceptor current = chain.getHeadInterceptor();
while (current != null) {
if (!current.isOptimizable()) {
return false;
@@ -173,8 +160,8 @@
}
}
}
-
- return true;
+ // if there is a callback, the wire is never optimizable since the callback target needs to be disambiguated
+ return callbackTargetChains.isEmpty();
}
public SCAObject getContainer() {
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireObjectFactory.java Wed Jan 3 06:36:06 2007
@@ -39,6 +39,7 @@
private WireService wireService;
// the cache of proxy interface method to operation mappings
private Map<Method, OutboundChainHolder> mappings;
+ //private boolean optimizable;
/**
* Constructor.
@@ -57,6 +58,15 @@
}
public T getInstance() throws ObjectCreationException {
+// JFM TODO enable
+// if (optimizable || wire.isOptimizable()) {
+// optimizable = true;
+// try {
+// return interfaze.cast(wire.getTargetService());
+// } catch (TargetResolutionException e) {
+// throw new ObjectCreationException(e);
+// }
+// }
// clone the cached mappings
Map<Method, OutboundChainHolder> newChains = new HashMap<Method, OutboundChainHolder>(mappings.size());
for (Map.Entry<Method, OutboundChainHolder> entry : mappings.entrySet()) {
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/wire/WireServiceExtension.java Wed Jan 3 06:36:06 2007
@@ -133,12 +133,16 @@
}
outboundWire.addInvocationChain(operation, chain);
}
-
- // Notice that we skip inboundWire.setCallbackReferenceName
- // First, an inbound wire's callbackReferenceName is only retrieved by JavaAtomicComponent
- // to create a callback injector based on the callback reference member; a composite reference
- // should not need to do that. Second, a reference definition does not have a callback reference name
- // like a service definition does
+ // Add target callback chain to outbound wire
+ if (contract.getCallbackName() != null) {
+ outboundWire.setCallbackInterface(contract.getCallbackClass());
+ for (Operation<?> operation : contract.getCallbackOperations().values()) {
+ InboundInvocationChain callbackTargetChain = createInboundChain(operation);
+ // TODO handle policy
+ callbackTargetChain.addInterceptor(new InvokerInterceptor());
+ outboundWire.addTargetCallbackInvocationChain(operation, callbackTargetChain);
+ }
+ }
referenceBinding.setInboundWire(inboundWire);
referenceBinding.setOutboundWire(outboundWire);
}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/binding/local/AbstractLocalTargetInvokerTestCase.java Wed Jan 3 06:36:06 2007
@@ -19,13 +19,13 @@
package org.apache.tuscany.core.binding.local;
import org.apache.tuscany.spi.wire.Interceptor;
-import org.apache.tuscany.spi.wire.InvocationRuntimeException;
import org.apache.tuscany.spi.wire.Message;
import org.apache.tuscany.spi.wire.MessageImpl;
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
import org.apache.tuscany.spi.wire.TargetInvoker;
import junit.framework.TestCase;
+import org.apache.tuscany.core.mock.wire.MockTargetInvoker;
import org.easymock.EasyMock;
import org.easymock.IAnswer;
@@ -69,9 +69,4 @@
EasyMock.verify(targetInvoker);
}
- private class MockTargetInvoker extends AbstractLocalTargetInvoker {
- public Message invoke(Message msg) throws InvocationRuntimeException {
- return null;
- }
- }
}
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ConnectorImplTestCase.java Wed Jan 3 06:36:06 2007
@@ -18,8 +18,6 @@
*/
package org.apache.tuscany.core.builder;
-import java.util.Collections;
-
import org.apache.tuscany.spi.component.AtomicComponent;
import org.apache.tuscany.spi.component.CompositeComponent;
import org.apache.tuscany.spi.wire.InboundInvocationChain;
@@ -60,14 +58,14 @@
public void testOutboundToInboundOptimization() throws Exception {
AtomicComponent container = EasyMock.createNiceMock(AtomicComponent.class);
+ EasyMock.expect(container.isSystem()).andReturn(true);
+ EasyMock.replay(container);
InboundWire inboundWire = new InboundWireImpl();
inboundWire.setContainer(container);
OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
- outboundWire.getInvocationChains();
- EasyMock.expectLastCall().andReturn(Collections.emptyMap());
- outboundWire.setTargetWire(inboundWire);
+ outboundWire.setTargetWire(EasyMock.eq(inboundWire));
EasyMock.expect(outboundWire.getServiceContract()).andReturn(null);
- EasyMock.expect(outboundWire.getContainer()).andReturn(container);
+ EasyMock.expect(outboundWire.getContainer()).andReturn(container).atLeastOnce();
EasyMock.replay(outboundWire);
connector.connect(outboundWire, inboundWire, true);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/InboundtoOutboundConnectTestCase.java Wed Jan 3 06:36:06 2007
@@ -18,17 +18,11 @@
*/
package org.apache.tuscany.core.builder;
-import static org.apache.tuscany.spi.wire.TargetInvoker.NONE;
-
-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;
import org.apache.tuscany.spi.wire.MessageImpl;
import org.apache.tuscany.spi.wire.OutboundInvocationChain;
@@ -42,10 +36,6 @@
import org.apache.tuscany.core.wire.InvokerInterceptor;
import org.apache.tuscany.core.wire.OutboundInvocationChainImpl;
import org.easymock.EasyMock;
-import static org.easymock.EasyMock.createNiceMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
/**
* Verifies connection strategies between {@link org.apache.tuscany.spi.wire.OutboundInvocationChain}s and {@link
@@ -55,20 +45,22 @@
*/
public class InboundtoOutboundConnectTestCase extends TestCase {
private Operation operation;
+ private ConnectorImpl connector;
- public void testNoInterceptorsNoHandlers() throws Exception {
- ConnectorImpl connector = new ConnectorImpl();
- InboundInvocationChain inboundChain = setupInbound(null);
- OutboundInvocationChain outboundChain = setupOutbound(null);
- String[] val = new String[]{"foo"};
- TargetInvoker invoker = createNiceMock(TargetInvoker.class);
- expect(invoker.invokeTarget(EasyMock.eq(val), EasyMock.eq(NONE))).andReturn(val);
- replay(invoker);
+ public void testNoInterceptors() throws Exception {
+ InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+ OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+ outboundChain.addInterceptor(new InvokerInterceptor());
+ TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class);
+ EasyMock.expect(invoker.invoke(EasyMock.isA(Message.class))).andReturn(new MessageImpl());
+ EasyMock.replay(invoker);
connector.connect(inboundChain, outboundChain);
inboundChain.setTargetInvoker(invoker);
inboundChain.prepare();
- inboundChain.getTargetInvoker().invokeTarget(val, NONE);
- verify(invoker);
+ Message msg = new MessageImpl();
+ msg.setTargetInvoker(invoker);
+ inboundChain.getHeadInterceptor().invoke(msg);
+ EasyMock.verify(invoker);
}
@@ -76,17 +68,15 @@
* Verifies an invocation with a single source interceptor
*/
public void testSourceInterceptor() throws Exception {
- ConnectorImpl connector = new ConnectorImpl();
MockSyncInterceptor interceptor = new MockSyncInterceptor();
- List<Interceptor> interceptors = new ArrayList<Interceptor>();
- interceptors.add(interceptor);
-
- InboundInvocationChain inboundChain = setupInbound(interceptors);
- OutboundInvocationChain outboundChain = setupOutbound(null);
+ InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+ inboundChain.addInterceptor(interceptor);
+ OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+ outboundChain.addInterceptor(new InvokerInterceptor());
Message msg = new MessageImpl();
- TargetInvoker invoker = createNiceMock(TargetInvoker.class);
- expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
- replay(invoker);
+ TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class);
+ EasyMock.expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ EasyMock.replay(invoker);
assertEquals(0, interceptor.getCount());
connector.connect(inboundChain, outboundChain);
inboundChain.setTargetInvoker(invoker);
@@ -94,24 +84,22 @@
msg.setTargetInvoker(inboundChain.getTargetInvoker());
assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
assertEquals(1, interceptor.getCount());
- verify(invoker);
+ EasyMock.verify(invoker);
}
/**
* Verifies an invocation with a single target interceptor
*/
public void testTargetInterceptor() throws Exception {
- ConnectorImpl connector = new ConnectorImpl();
MockSyncInterceptor interceptor = new MockSyncInterceptor();
- List<Interceptor> interceptors = new ArrayList<Interceptor>();
- interceptors.add(interceptor);
-
- InboundInvocationChain inboundChain = setupInbound(interceptors);
- OutboundInvocationChain outboundChain = setupOutbound(null);
+ InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+ inboundChain.addInterceptor(interceptor);
+ OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+ outboundChain.addInterceptor(new InvokerInterceptor());
Message msg = new MessageImpl();
- TargetInvoker invoker = createNiceMock(TargetInvoker.class);
- expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
- replay(invoker);
+ TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class);
+ EasyMock.expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ EasyMock.replay(invoker);
assertEquals(0, interceptor.getCount());
connector.connect(inboundChain, outboundChain);
inboundChain.setTargetInvoker(invoker);
@@ -119,27 +107,24 @@
msg.setTargetInvoker(inboundChain.getTargetInvoker());
assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
assertEquals(1, interceptor.getCount());
- verify(invoker);
+ EasyMock.verify(invoker);
}
/**
* Verifies an invocation with a source and target interceptor
*/
public void testSourceTargetInterceptor() throws Exception {
- ConnectorImpl connector = new ConnectorImpl();
MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
- List<Interceptor> sourceInterceptors = new ArrayList<Interceptor>();
- sourceInterceptors.add(sourceInterceptor);
MockSyncInterceptor targetInterceptor = new MockSyncInterceptor();
- List<Interceptor> targetInterceptors = new ArrayList<Interceptor>();
- targetInterceptors.add(targetInterceptor);
-
- OutboundInvocationChain outboundChain = setupOutbound(sourceInterceptors);
- InboundInvocationChain inboundChain = setupInbound(targetInterceptors);
+ OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+ outboundChain.addInterceptor(sourceInterceptor);
+ outboundChain.addInterceptor(new InvokerInterceptor());
+ InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+ inboundChain.addInterceptor(targetInterceptor);
Message msg = new MessageImpl();
- TargetInvoker invoker = createNiceMock(TargetInvoker.class);
- expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
- replay(invoker);
+ TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class);
+ EasyMock.expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ EasyMock.replay(invoker);
assertEquals(0, sourceInterceptor.getCount());
assertEquals(0, targetInterceptor.getCount());
connector.connect(inboundChain, outboundChain);
@@ -149,34 +134,28 @@
assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
assertEquals(1, sourceInterceptor.getCount());
assertEquals(1, targetInterceptor.getCount());
- verify(invoker);
- }
-
- public InboundInvocationChain setupInbound(List<Interceptor> interceptors) {
-
- InboundInvocationChainImpl chain = new InboundInvocationChainImpl(operation);
- if (interceptors != null) {
- for (Interceptor interceptor : interceptors) {
- chain.addInterceptor(interceptor);
- }
- }
- return chain;
+ EasyMock.verify(invoker);
}
- public OutboundInvocationChain setupOutbound(List<Interceptor> interceptors) {
-
- OutboundInvocationChainImpl chain = new OutboundInvocationChainImpl(operation);
- if (interceptors != null) {
- for (Interceptor interceptor : interceptors) {
- chain.addInterceptor(interceptor);
- }
- }
- chain.addInterceptor(new InvokerInterceptor()); // add tail interceptor
- return chain;
+ public void testOptimizeSet() throws Exception {
+ OutboundInvocationChain outboundChain = new OutboundInvocationChainImpl(operation);
+ outboundChain.addInterceptor(new InvokerInterceptor());
+ InboundInvocationChain inboundChain = new InboundInvocationChainImpl(operation);
+ Message msg = new MessageImpl();
+ TargetInvoker invoker = EasyMock.createNiceMock(TargetInvoker.class);
+ EasyMock.expect(invoker.invoke(EasyMock.eq(msg))).andReturn(msg);
+ EasyMock.replay(invoker);
+ connector.connect(inboundChain, outboundChain);
+ inboundChain.setTargetInvoker(invoker);
+ inboundChain.prepare();
+ msg.setTargetInvoker(inboundChain.getTargetInvoker());
+ assertEquals(msg, inboundChain.getHeadInterceptor().invoke(msg));
+ EasyMock.verify(invoker);
}
protected void setUp() throws Exception {
super.setUp();
+ connector = new ConnectorImpl();
JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
ServiceContract<?> contract;
try {
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/builder/ReferenceConnectorTestCase.java Wed Jan 3 06:36:06 2007
@@ -66,7 +66,7 @@
EasyMock.expect(referenceBinding.createTargetInvoker(contract, operation)).andReturn(null);
EasyMock.expect(referenceBinding.getInboundWire()).andReturn(inboundWire);
EasyMock.expect(referenceBinding.getOutboundWire()).andReturn(outboundWire);
- EasyMock.expect(referenceBinding.isSystem()).andReturn(false);
+ EasyMock.expect(referenceBinding.isSystem()).andReturn(false).atLeastOnce();
EasyMock.replay(referenceBinding);
inboundWire.setContainer(referenceBinding);
outboundWire.setContainer(referenceBinding);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/implementation/composite/CompositeComponentImplSystemWireTestCase.java Wed Jan 3 06:36:06 2007
@@ -44,8 +44,7 @@
public class CompositeComponentImplSystemWireTestCase extends TestCase {
/**
- * Verifies system serviceBindings in a CompositeComponentImpl are wired during the parent composite's prepare
- * callback
+ * Verifies system services in a CompositeComponentImpl are wired during the parent composite's prepare callback
*/
public void testSystemServiceWire() throws Exception {
InboundWire inbound = EasyMock.createMock(InboundWire.class);
@@ -58,8 +57,6 @@
EasyMock.expect(outbound.getTargetName()).andReturn(qName).atLeastOnce();
EasyMock.expect(outbound.isAutowire()).andReturn(false);
- outbound.getInvocationChains();
- EasyMock.expectLastCall().andReturn(Collections.emptyMap()).atLeastOnce();
outbound.setTargetWire(EasyMock.eq(inbound));
EasyMock.expect(outbound.getServiceContract()).andReturn(new JavaServiceContract(Foo.class)).atLeastOnce();
List<OutboundWire> wires = new ArrayList<OutboundWire>();
@@ -79,7 +76,7 @@
source.prepare();
EasyMock.replay(source);
- EasyMock.expect(outbound.getContainer()).andReturn(source);
+ EasyMock.expect(outbound.getContainer()).andReturn(source).atLeastOnce();
EasyMock.replay(outbound);
parent.register(source);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationIdleExpireTestCase.java Wed Jan 3 06:36:06 2007
@@ -86,6 +86,7 @@
// create source component mock
JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class);
EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce();
EasyMock.replay(source);
owire = MockFactory.createOutboundWire("foo", Foo.class);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationMaxAgeExpireTestCase.java Wed Jan 3 06:36:06 2007
@@ -86,6 +86,7 @@
// create source component mock
JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class);
EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce();
EasyMock.replay(source);
owire = MockFactory.createOutboundWire("foo", Foo.class);
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/integration/conversation/ConversationStartStopEndTestCase.java Wed Jan 3 06:36:06 2007
@@ -86,6 +86,7 @@
// create source component mock
JavaAtomicComponent source = EasyMock.createMock(JavaAtomicComponent.class);
EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
+ EasyMock.expect(source.isSystem()).andReturn(false).atLeastOnce();
EasyMock.replay(source);
owire = MockFactory.createOutboundWire("foo", Foo.class);
Added: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java?view=auto&rev=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java Wed Jan 3 06:36:06 2007
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.core.mock.wire;
+
+import org.apache.tuscany.spi.wire.InvocationRuntimeException;
+import org.apache.tuscany.spi.wire.Message;
+
+import org.apache.tuscany.core.binding.local.AbstractLocalTargetInvoker;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class MockTargetInvoker extends AbstractLocalTargetInvoker {
+ public Message invoke(Message msg) throws InvocationRuntimeException {
+ return null;
+ }
+}
\ No newline at end of file
Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/mock/wire/MockTargetInvoker.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java?view=diff&rev=492163&r1=492162&r2=492163
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/wire/NonBlockingBridgingInterceptorTestCase.java Wed Jan 3 06:36:06 2007
@@ -19,11 +19,11 @@
package org.apache.tuscany.core.wire;
import org.apache.tuscany.spi.component.WorkContext;
+import org.apache.tuscany.spi.model.Scope;
import org.apache.tuscany.spi.services.work.WorkScheduler;
import org.apache.tuscany.spi.wire.Interceptor;
import org.apache.tuscany.spi.wire.Message;
import org.apache.tuscany.spi.wire.MessageImpl;
-import org.apache.tuscany.spi.model.Scope;
import junit.framework.TestCase;
import org.easymock.EasyMock;
@@ -65,6 +65,11 @@
interceptor.invoke(msg);
verify(context);
verify(next);
+ }
+
+ public void testOptimizable() {
+ NonBlockingBridgingInterceptor interceptor = new NonBlockingBridgingInterceptor(null, null);
+ assertFalse(interceptor.isOptimizable());
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org