Examples of OutboundWire


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

        InboundWire wire = createMock(InboundWire.class);
        wire.getInvocationChains();
        Map<Operation, InvocationChain> chains = new HashMap<Operation, InvocationChain>();
        chains.put(operation, chain);
        expectLastCall().andReturn(chains);
        OutboundWire outboundWire = createMock(OutboundWire.class);
        outboundWire.getTargetName();
        expectLastCall().andReturn(new QualifiedName("foo/bar"));
        replay(chain);
        replay(wire);
        replay(outboundWire);
        TestReference<Object> ref = new TestReference<Object>(Object.class);
View Full Code Here

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

     * @param refName   the reference name the wire is associated with on the client
     * @param interfaze the interface associated with the wire
     */
    public static <T> OutboundWire createOutboundWire(String refName, Class<T> interfaze)
        throws InvalidServiceContractException {
        OutboundWire wire = new OutboundWireImpl();
        wire.setReferenceName(refName);
        wire.addInvocationChains(createOutboundChains(interfaze));
        JavaInterfaceProcessorRegistry registry = new JavaInterfaceProcessorRegistryImpl();
        ServiceContract<?> contract = registry.introspect(interfaze);
        wire.setServiceContract(contract);
        return wire;
    }
View Full Code Here

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

        configuration.addReferenceSite("setTarget", SourceImpl.class.getMethod("setTarget", Target.class));
        configuration.addServiceInterface(Source.class);
        configuration.setInstanceFactory(new PojoObjectFactory<SourceImpl>(SourceImpl.class.getConstructor()));
        SystemAtomicComponent sourceContext = new SystemAtomicComponentImpl("source", configuration);
        QualifiedName qName = new QualifiedName("service");
        OutboundWire outboundWire = new SystemOutboundWireImpl("setTarget", qName, Target.class);
        outboundWire.setTargetWire(inboundWire);
        sourceContext.addOutboundWire(outboundWire);
        sourceContext.start();
        assertSame(((Source) sourceContext.getServiceInstance()).getTarget(), target);
        // wires should pass back direct ref
        EasyMock.verify(inboundWire);
View Full Code Here

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

        assertNotNull(checkedMethod);
        assertNotNull(runtimeMethod);
    }

    public void testCheckedException() throws Exception {
        OutboundWire wire = new OutboundWireImpl();
        ServiceContract<?> contract = registry.introspect(TestBean.class);
        wire.setServiceContract(contract);
        Operation operation = contract.getOperations().get("checkedException");
        wire.addInvocationChain(operation, createChain(checkedMethod, operation));
        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
        try {
            TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                new Class[]{TestBean.class}, handler);
            proxy.checkedException();
View Full Code Here

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

        }
        fail(TestException.class.getName() + " should have been thrown");
    }

    public void testRuntimeException() throws Exception {
        OutboundWire wire = new OutboundWireImpl();
        ServiceContract<?> contract = registry.introspect(TestBean.class);
        wire.setServiceContract(contract);
        Operation operation = contract.getOperations().get("runtimeException");
        OutboundInvocationChain chain = createChain(runtimeMethod, operation);
        wire.addInvocationChain(operation, chain);
        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
        try {
            TestBean proxy = (TestBean) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
                new Class[]{TestBean.class}, handler);
            proxy.runtimeException();
View Full Code Here

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

        processReferences(definition, componentType.getReferences(), parent, component);
        // FIXME we need a way to build configuration references from autowires in the loader to eliminate this eval
        for (ReferenceDefinition reference : componentType.getReferences().values()) {
            if (reference.isAutowire()) {
                Class interfaze = reference.getServiceContract().getInterfaceClass();
                OutboundWire wire =
                    new SystemOutboundAutowire(reference.getName(), interfaze, parent, reference.isRequired());
                component.addOutboundWire(wire);
            }
        }
        return component;
View Full Code Here

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

        // no proxies needed for system components
        for (ReferenceTarget target : definition.getReferenceTargets().values()) {
            String referenceName = target.getReferenceName();
            JavaMappedReference referenceDefiniton = references.get(referenceName);
            Class interfaze = referenceDefiniton.getServiceContract().getInterfaceClass();
            OutboundWire wire;
            if (referenceDefiniton.isAutowire()) {
                boolean required = referenceDefiniton.isRequired();
                wire = new SystemOutboundAutowire(referenceName, interfaze, parent, required);
            } else {
                //FIXME support multiplicity!
View Full Code Here

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

        chain.addInterceptor(interceptor);
        chain.setTargetInterceptor(new InvokerInterceptor());
        chain.setTargetInvoker(invoker);
        chain.prepare();
        //chains.put(echo, chain);
        OutboundWire wire = new OutboundWireImpl();
        wire.addInvocationChain(operation, chain);
        wire.setServiceContract(contract);
        JDKOutboundInvocationHandler handler = new JDKOutboundInvocationHandler(wire, new WorkContextImpl());
        assertEquals("foo", handler.invoke(null, echo, new String[]{"foo"}));
        assertEquals(1, interceptor.getCount());
    }
View Full Code Here

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

                Operation operation = chain.getOperation();
                TargetInvoker invoker = reference.createTargetInvoker(contract, operation);
                chain.setTargetInvoker(invoker);
                chain.prepare();
            }
            OutboundWire outboundWire = reference.getOutboundWire();
            // connect the reference's inbound and outbound wires
            connect(inboundWire, outboundWire, true);
           
            if (reference instanceof CompositeReference) {
                // For a composite reference only, since its outbound wire comes
                // from its parent composite,
                // the corresponding target would not lie in its parent but
                // rather in its parent's parent
                parent = parent.getParent();
                assert parent != null : "Parent of parent was null";
                SCAObject target = parent.getChild(outboundWire.getTargetName().getPartName());
                connect((Component)parent, outboundWire, target);
            }           
        } else if (source instanceof Service) {
            Service service = (Service) source;
            InboundWire inboundWire = service.getInboundWire();
            OutboundWire outboundWire = service.getOutboundWire();
            // For a composite reference only, since its outbound wire comes from its parent composite,
            // the corresponding target would not lie in its parent but rather in its parent's parent
            if (source instanceof CompositeReference) {
                parent = parent.getParent();
                assert parent != null : "Parent of parent was null";
            }
            SCAObject target;
            if (service.isSystem()) {
                target = parent.getSystemChild(outboundWire.getTargetName().getPartName());
            } else {
                target = parent.getChild(outboundWire.getTargetName().getPartName());
            }
            // connect the outbound service wire to the target
            connect(service, outboundWire, target);
            // NB: this connect must be done after the outbound service chain is connected to its target above
            if (!(source instanceof CompositeService)) {
View Full Code Here

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

        contract = registry.introspect(SimpleTarget.class);
        hello = SimpleTarget.class.getMethod("hello", String.class);
    }

    public void testBasicInvoke() 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());
        assertEquals("foo", handler.invoke(hello, new Object[]{"foo"}));
    }
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.