Package org.apache.tuscany.spi.wire

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


                        args[i] = is.readObject();
                    }
                    Map<Operation<?>, InboundInvocationChain> chains = getInboundWire().getInvocationChains();
                    for (InboundInvocationChain chain : chains.values()) {
                        if (chain.getOperation().getName().equals(operation)) {
                            Message message = new MessageImpl();
                            message.setTargetInvoker(chain.getTargetInvoker());
                            message.setBody(args);
                            message = chain.getHeadInterceptor().invoke(message);
                            os = new ObjectOutputStream(clientSocket.getOutputStream());
                            os.writeObject(message.getBody());
                            os.flush();
                        }
                    }
                } catch (IOException e) {
                    throw new TestBindingRuntimeException(e);
View Full Code Here


                return null;
            }
        });
        replay(scheduler);
        WorkContext context = createMock(WorkContext.class);
        Message msg = new MessageImpl();
        Interceptor next = EasyMock.createMock(Interceptor.class);
        EasyMock.expect(next.invoke(EasyMock.eq(msg))).andReturn(msg);
        EasyMock.replay(next);
        Interceptor interceptor = new NonBlockingBridgingInterceptor(scheduler, context, next);
        interceptor.invoke(msg);
View Full Code Here

        source.prepare();
        target.prepare();
        MockStaticInvoker invoker = new MockStaticInvoker(hello, new SimpleTargetImpl());
        source.setTargetInvoker(invoker);

        Message msg = new MessageImpl();
        msg.setTargetInvoker(invoker);
        Message response = source.getHeadInterceptor().invoke(msg);
        assertTrue(response.isFault());
        assertTrue(response.getBody() instanceof IllegalArgumentException);
        assertEquals(1, sourceInterceptor.getCount());
        assertEquals(1, targetInterceptor.getCount());

    }
View Full Code Here

            Object messageId = workContext.getCurrentMessageId();
            workContext.setCurrentMessageId(null);
            Object correlationId = workContext.getCurrentCorrelationId();
            workContext.setCurrentCorrelationId(null);

            Message msg = new MessageImpl();
            msg.setTargetInvoker(chain.getTargetInvoker());
            msg.setFromAddress(getFromAddress());
            if (messageId == null) {
                messageId = new MessageId();
            }
            msg.setMessageId(messageId);
            msg.setCorrelationId(correlationId);
            msg.setBody(args);
            Message resp;
            // dispatch the wire down the chain and get the response
            // TODO http://issues.apache.org/jira/browse/TUSCANY-777
            ClassLoader oldtccl = Thread.currentThread().getContextClassLoader();
            try {
                Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
                resp = headInterceptor.invoke(msg);
            } finally {
                Thread.currentThread().setContextClassLoader(oldtccl);
            }
            Object body = resp.getBody();
            if (resp.isFault()) {
                throw new InvocationTargetException((Throwable)body);
            }
            return body;
        }
    }
View Full Code Here

* @version $Rev: 451655 $ $Date: 2006-09-30 13:06:53 -0700 (Sat, 30 Sep 2006) $
*/
public class SynchronousBridgingInterceptorTestCase extends TestCase {

    public void testInvoke() throws Exception {
        Message msg = new MessageImpl();
        Interceptor next = EasyMock.createMock(Interceptor.class);
        EasyMock.expect(next.invoke(EasyMock.eq(msg))).andReturn(msg);
        EasyMock.replay(next);
        Interceptor interceptor = new SynchronousBridgingInterceptor(next);
        interceptor.invoke(msg);
View Full Code Here

        WorkContext context = createMock(WorkContext.class);
        Method method = AsyncTarget.class.getMethod("invoke");
        method.setAccessible(true);
        InboundWire wire = createMock(InboundWire.class);
        AsyncGroovyInvoker invoker = new AsyncGroovyInvoker("invoke", wire, component, monitor, context);
        Message msg = new MessageImpl();
        invoker.invoke(msg);
        verify(instance);
    }
View Full Code Here

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

        reportMatcher(new IArgumentMatcher() {
            public boolean matches(Object object) {
                if (!(object instanceof Message)) {
                    return false;
                }
                final Message msg = (Message) object;
                Object[] body = (Object[]) msg.getBody();
                return "foo".equals(body[0]);
            }

            public void appendTo(StringBuffer stringBuffer) {
            }
View Full Code Here

     * @see org.apache.tuscany.spi.wire.Interceptor#invoke(org.apache.tuscany.spi.wire.Message)
     */
    public Message invoke(Message msg) {
        Object input = transform(msg.getBody(), sourceOperation.getInputType(), targetOperation.getInputType());
        msg.setBody(input);
        Message resultMsg = next.invoke(msg);
        Object result = resultMsg.getBody();
        // FIXME: How to deal with faults?
        if (resultMsg.isFault()) {
            // We need to figure out what fault type it is and then transform it back the source fault type
            throw new InvocationRuntimeException((Throwable) result);
        } else if (result != null) {
            // FIXME: Should we fix the Operation model so that getOutputType returns DataType<DataType<T>>?
            DataType<DataType> targetType =
                    new DataType<DataType>("idl:output", Object.class, targetOperation.getOutputType());
           
            targetType.setMetadata(Operation.class.getName(), targetOperation.getOutputType().getMetadata(
                    Operation.class.getName()));
            DataType<DataType> sourceType =
                    new DataType<DataType>("idl:output", Object.class, sourceOperation.getOutputType());
            sourceType.setMetadata(Operation.class.getName(), sourceOperation.getOutputType().getMetadata(
                    Operation.class.getName()));

            result = transform(result, targetType, sourceType);
            resultMsg.setBody(result);
        }
        return resultMsg;
    }
View Full Code Here

        reportMatcher(new IArgumentMatcher() {
            public boolean matches(Object object) {
                if (!(object instanceof Message)) {
                    return false;
                }
                final Message msg = (Message) object;
                Object[] body = (Object[]) msg.getBody();
                return "foo".equals(body[0]);
            }

            public void appendTo(StringBuffer stringBuffer) {
            }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.wire.Message

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.