Examples of OutboundWire


Examples of org.apache.tuscany.spi.wire.OutboundWire

        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
        assertEquals("foo", handler.invoke(hello, new Object[]{"foo"}));
    }

    public void testErrorInvoke() throws Throwable {
        OutboundWire wire = new OutboundWireImpl();
        Operation operation = contract.getOperations().get("hello");
        wire.addInvocationChain(operation, createChain(operation));
        wire.setServiceContract(contract);
        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
        try {
            handler.invoke(hello, new Object[]{});
            fail("Expected " + IllegalArgumentException.class.getName());
        } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

        Operation operation = contract.getOperations().get("hello");
        OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
        MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
        source.setTargetInvoker(invoker);

        OutboundWire wire = new OutboundWireImpl();
        wire.setServiceContract(contract);
        wire.addInvocationChain(operation, source);
        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
        try {
            assertEquals("foo", handler.invoke(hello, new Object[]{}));
            fail("Expected " + IllegalArgumentException.class.getName());
        } catch (IllegalArgumentException e) {
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

        Operation operation = contract.getOperations().get("hello");
        OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
        MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
        source.setTargetInvoker(invoker);

        OutboundWire wire = new OutboundWireImpl();
        wire.setServiceContract(contract);
        wire.addInvocationChain(operation, source);
        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
        assertEquals("foo", handler.invoke(hello, new Object[]{"foo"}));
    }
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

        EasyMock.expectLastCall().andReturn(Collections.emptyMap());

        List<Class<?>> services = new ArrayList<Class<?>>();
        services.add(Foo.class);
        QualifiedName qName = new QualifiedName("target/bar");
        OutboundWire outbound = EasyMock.createMock(OutboundWire.class);
        EasyMock.expect(outbound.getTargetName()).andReturn(qName).atLeastOnce();
        outbound.getInvocationChains();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        outbound.setTargetWire(EasyMock.eq(inbound));
        EasyMock.expect(outbound.getServiceContract()).andReturn(new JavaServiceContract(Foo.class)).atLeastOnce();
        List<OutboundWire> wires = new ArrayList<OutboundWire>();
        wires.add(outbound);
        Map<String, List<OutboundWire>> wireMap = new HashMap<String, List<OutboundWire>>();
        wireMap.put("ref", wires);
        CompositeComponent parent = new CompositeComponentImpl("foo", "foo", null, new ConnectorImpl(), null);
        SystemAtomicComponent source = EasyMock.createMock(SystemAtomicComponent.class);
        EasyMock.expect(source.getScope()).andReturn(Scope.MODULE).atLeastOnce();
        EasyMock.expect(source.getName()).andReturn("source").atLeastOnce();
        EasyMock.expect(source.getServiceInterfaces()).andReturn(services);
        EasyMock.expect(source.getOutboundWires()).andReturn(wireMap);
        source.getInboundWires();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        EasyMock.expect(source.isSystem()).andReturn(true).atLeastOnce();
        EasyMock.expect(source.getParent()).andReturn(parent).atLeastOnce();

        source.prepare();
        EasyMock.replay(source);

        EasyMock.expect(outbound.getContainer()).andReturn(source);
        EasyMock.replay(outbound);

        parent.register(source);

        SystemAtomicComponent target = EasyMock.createMock(SystemAtomicComponent.class);
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

        EasyMock.replay(inbound);

        List<Class<?>> services = new ArrayList<Class<?>>();
        services.add(Foo.class);
        QualifiedName qName = new QualifiedName("target/bar");
        OutboundWire outbound = EasyMock.createMock(OutboundWire.class);
        EasyMock.expect(outbound.getReferenceName()).andReturn("foo");
        EasyMock.expect(outbound.getTargetName()).andReturn(qName).atLeastOnce();
        EasyMock.replay(outbound);

        List<OutboundWire> wires = new ArrayList<OutboundWire>();
        wires.add(outbound);
        Map<String, List<OutboundWire>> wireMap = new HashMap<String, List<OutboundWire>>();
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

        configuration.addReferenceSite("target", SourceImpl.class.getMethod("setTarget", Target.class));
        configuration.addServiceInterface(Source.class);
        Constructor<SourceImpl> ctr = SourceImpl.class.getConstructor();
        configuration.setInstanceFactory(new PojoObjectFactory<SourceImpl>(ctr));
        configuration.setScopeContainer(scope);
        OutboundWire wire = EasyMock.createMock(OutboundWire.class);
        wire.getInvocationChains();
        EasyMock.expectLastCall().andReturn(new HashMap<Operation<?>, OutboundInvocationChain>());
        EasyMock.expect(wire.getReferenceName()).andReturn("target").atLeastOnce();
        EasyMock.replay(wire);
        WireService service = EasyMock.createMock(WireService.class);
        EasyMock.expect(service.createProxy(EasyMock.eq(wire))).andAnswer(new IAnswer<Object>() {
            public Object answer() throws Throwable {
                OutboundWire wire = (OutboundWire) EasyMock.getCurrentArguments()[0];
                wire.getInvocationChains();
                return target;
            }

        }).atLeastOnce();
        EasyMock.replay(service);
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

        configuration.setGroovyClass(implClass1);
        configuration.setServices(services);
        configuration.setScopeContainer(scopeContainer);
        configuration.setWireService(createWireService());
        GroovyAtomicComponent component = new GroovyAtomicComponent(configuration, null);
        OutboundWire wire = createOutboundWire("wire", Greeting.class);
        terminateWire(wire);

        TargetInvoker invoker = createMock(TargetInvoker.class);
        expect(invoker.isCacheable()).andReturn(false);
        Message response = new MessageImpl();
        response.setBody("foo");
        expect(invoker.invoke(eqMessage())).andReturn(response);
        replay(invoker);

        for (OutboundInvocationChain chain : wire.getInvocationChains().values()) {
            chain.setTargetInvoker(invoker);
        }
        component.addOutboundWire(wire);
        Greeting greeting = (Greeting) component.getServiceInstance();
        assertEquals("foo", greeting.greet("foo"));
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

            JDKInboundInvocationHandler handler = new JDKInboundInvocationHandler(chains, context);
            ClassLoader cl = interfaze.getClassLoader();
            //FIXME
            return Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
        } else if (wire instanceof OutboundWire) {
            OutboundWire outbound = (OutboundWire) wire;
            JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(outbound, context);
            Class<?> interfaze = outbound.getServiceContract().getInterfaceClass();
            ClassLoader cl = interfaze.getClassLoader();
            return Proxy.newProxyInstance(cl, new Class[]{interfaze}, handler);
        } else {
            ProxyCreationException e = new ProxyCreationException("Invalid wire type");
            e.setIdentifier(wire.getClass().getName());
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

            InboundWire inbound = (InboundWire) wire;
            Method[] methods = inbound.getServiceContract().getInterfaceClass().getMethods();
            Map<Method, InboundInvocationChain> chains = createInboundMapping(inbound, methods);
            return new JDKInboundInvocationHandler(chains, context);
        } else if (wire instanceof OutboundWire) {
            OutboundWire outbound = (OutboundWire) wire;
            return new JDKOutboundInvocationHandler(outbound, context);
        } else {
            ProxyCreationException e = new ProxyCreationException("Invalid wire type");
            e.setIdentifier(wire.getClass().getName());
            throw e;
View Full Code Here

Examples of org.apache.tuscany.spi.wire.OutboundWire

                ReferenceNotFoundException e = new ReferenceNotFoundException(refName);
                e.addContextName(refName);
                e.addContextName(definition.getName());
                throw e;
            }
            OutboundWire wire = createWire(referenceTarget, mappedReference);
            wire.setContainer(component);
            component.addOutboundWire(wire);
            if (componentType instanceof CompositeComponentType<?, ?, ?>) {
                // If this is the case, then it means that component has already been returned
                // by CompositeBuilder and thus its children, in particular composite references,
                // have been registered
                CompositeComponent compositeComponent = (CompositeComponent) component;
                Reference reference = (Reference) compositeComponent.getChild(referenceTarget.getReferenceName());
                assert reference != null;
                if (reference instanceof CompositeReference) {
                    reference.setOutboundWire(wire);
                    // Notice that now the more immediate container of the wire is the composite reference
                    wire.setContainer(reference);
                }
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.