Package org.apache.tuscany.spi.model

Examples of org.apache.tuscany.spi.model.Operation


        assertEquals(0, method.getParameterTypes().length);
    }

    public void testNoParamsFindOperation() throws Exception {
        Method method = Foo.class.getMethod("foo");
        Operation ret = findOperation(method, operations);
        assertEquals("foo", ret.getName());
        assertEquals(0, method.getParameterTypes().length);
    }
View Full Code Here


        assertEquals(String.class, method.getParameterTypes()[0]);
    }

    public void testParamsFindOperation() throws Exception {
        Method method = Foo.class.getMethod("foo", String.class);
        Operation ret = findOperation(method, operations);
        assertEquals("foo", ret.getName());
        assertEquals(String.class, method.getParameterTypes()[0]);
    }
View Full Code Here

    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);
View Full Code Here

    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(),
View Full Code Here

    /**
     * Tests basic wiring of a source to a target, including handlers and interceptors
     */
    public void testInvokeWithInterceptors() throws Exception {
        Operation operation = contract.getOperations().get("hello");
        OutboundInvocationChain source = new OutboundInvocationChainImpl(operation);
        MockSyncInterceptor sourceInterceptor = new MockSyncInterceptor();
        source.addInterceptor(sourceInterceptor);

        InboundInvocationChain target = new InboundInvocationChainImpl(operation);
View Full Code Here

        this.chains = new HashMap<Method, ChainHolder>(invocationChains.size());
        this.fromAddress = (wire.getContainer() == null) ? null : wire.getContainer().getName();
        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()));
        }

        this.context = context;
View Full Code Here

            Map<Operation<?>, InboundInvocationChain> inboundChains = inboundWire.getInvocationChains();
            for (InboundInvocationChain chain : inboundChains.values()) {
                //TODO handle async
                // add target invoker on inbound side
                ServiceContract contract = inboundWire.getServiceContract();
                Operation operation = chain.getOperation();
                TargetInvoker invoker = reference.createTargetInvoker(contract, operation);
                chain.setTargetInvoker(invoker);
                chain.prepare();
            }
            OutboundWire outboundWire = reference.getOutboundWire();
View Full Code Here

                    new BuilderConfigException("Source callback chain should not exist for operation [" + name + "]");
                e.setIdentifier(sourceWire.getReferenceName());
                throw e;
            }
           
            Operation targetOp =
                (Operation)targetWire.getServiceContract().getCallbackOperations().get(operation.getName());
            OutboundInvocationChain outboundChain = wireService.createOutboundChain(targetOp);
            targetWire.addSourceCallbackInvocationChain(source.getName(), targetOp, outboundChain);
            if (source instanceof Component) {
                Component component = (Component) source;
View Full Code Here

            throw new AssertionError("No from address associated with message id [" + correlationId + "]");
        }
        //TODO optimize as this is slow in local invocations
        Map<Operation<?>, OutboundInvocationChain> sourceCallbackInvocationChains =
            inboundWire.getSourceCallbackInvocationChains(targetAddress);
        Operation operation = findOperation(method, sourceCallbackInvocationChains.keySet());
        OutboundInvocationChain chain = sourceCallbackInvocationChains.get(operation);
        TargetInvoker invoker = chain.getTargetInvoker();
        return invoke(chain, invoker, args);
    }
View Full Code Here

        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

Related Classes of org.apache.tuscany.spi.model.Operation

Copyright © 2018 www.massapicom. 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.