Package javax.jbi.messaging

Examples of javax.jbi.messaging.MessageExchange$Role


        message.setContent(Source.class, new StreamSource(new StringReader("<hello/>")));
        message.getTransportHeaders().put("Content-Type", "text/xml");
       
        interceptor.handleMessage(message);
       
        MessageExchange me = message.getContent(MessageExchange.class);
        assertNotNull(me);
        assertTrue(me instanceof InOnly);
        NormalizedMessage nm = me.getMessage("in");
        assertNotNull(nm);
        assertNotNull(nm.getContent());
        Map headers = (Map) nm.getProperty(JbiConstants.PROTOCOL_HEADERS);
        assertNotNull(headers);
        assertEquals("text/xml", headers.get("Content-Type"));
View Full Code Here


        String str = pattern.toString();
        if (str.startsWith("http://www.w3.org/2006/01/wsdl/")) {
            str = str.replace("http://www.w3.org/2006/01/wsdl/", "http://www.w3.org/2004/08/wsdl/");
            pattern = URI.create(str);
        }
        MessageExchange me;
        if (JbiConstants.IN_ONLY.equals(pattern)) {
            me = createInOnlyExchange();
        } else if (JbiConstants.IN_OUT.equals(pattern)) {
            me = createInOutExchange();
        } else if (JbiConstants.IN_OPTIONAL_OUT.equals(pattern)) {
View Full Code Here

        super(Phase.RECEIVE);
    }
   
    public void handleMessage(Message message) {
        List<Attachment> attachmentList = new ArrayList<Attachment>();
        MessageExchange exchange = message.get(MessageExchange.class);
        NormalizedMessageImpl norMessage =
            (NormalizedMessageImpl) exchange.getMessage("in");
        Iterator<String> iter = norMessage.listAttachments();
        while (iter.hasNext()) {
            String id = iter.next();
            DataHandler dh = norMessage.getAttachment(id);
            attachmentList.add(new AttachmentImpl(id, dh));
View Full Code Here

        }
    }
    */

    public void route(String uri) throws MessagingException {
        MessageExchange me = this.exchange.getInternalExchange();
        NormalizedMessage in = me.getMessage("in");
        MessageExchange newMe = getChannel().createExchangeFactory().createExchange(me.getPattern());
        URIResolver.configureExchange(newMe, getContext(), uri);
        MessageUtil.transferToIn(in, newMe);
        getChannel().sendSync(newMe);
        if (newMe.getStatus() == ExchangeStatus.DONE) {
            me.setStatus(ExchangeStatus.DONE);
            getChannel().send(me);
        } else if (newMe.getStatus() == ExchangeStatus.ERROR) {
            me.setStatus(ExchangeStatus.ERROR);
            me.setError(newMe.getError());
            getChannel().send(me);
        } else {
            if (newMe.getFault() != null) {
                MessageUtil.transferFaultToFault(newMe, me);
            } else {
                MessageUtil.transferOutToOut(newMe, me);
            }
            getChannel().sendSync(me);
View Full Code Here

        }
        update();
    }

    public void fault(String content) throws Exception {
        MessageExchange me = this.exchange.getInternalExchange();
        if (me instanceof InOnly) {
            me.setError(new Exception(content));
            getChannel().send(me);
        } else {
            Fault fault = me.createFault();
            fault.setContent(new StringSource(content));
            me.setFault(fault);
            getChannel().sendSync(me);
        }
        update();
    }
View Full Code Here

public class SerializedMarshaler extends DefaultHttpConsumerMarshaler {

    private static Log log = LogFactory.getLog(SerializedMarshaler.class);

    public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
        MessageExchange me = context.getDeliveryChannel().createExchangeFactory().createExchange(getDefaultMep());
        NormalizedMessage in = me.createMessage();
        in.setContent(marshal(request.getInputStream()));
        me.setMessage(in, "in");
        return me;
    }
View Full Code Here

        }
        update();
    }

    public void answer(String content) throws Exception {
        MessageExchange me = this.exchange.getInternalExchange();
        NormalizedMessage out = me.createMessage();
        out.setContent(new StringSource(content));
        me.setMessage(out, "out");
        getChannel().sendSync(me);
        update();
    }
View Full Code Here

                } else if (context.getExchange().getOperation().getFaults().size() > 0) {
                    mep = MessageExchangeSupport.ROBUST_IN_ONLY;
                } else {
                    mep = MessageExchangeSupport.IN_ONLY;
                }
                MessageExchange me = factory.createExchange(mep);
                me.setInterfaceName((QName) context.getService().getProperty(JBI_INTERFACE_NAME));
                me.setOperation(context.getExchange().getOperation().getQName());
                me.setService((QName) context.getService().getProperty(JBI_SERVICE_NAME));
                me.setEndpoint((ServiceEndpoint) context.getService().getProperty(JBI_ENDPOINT));
                NormalizedMessage msg = me.createMessage();
                me.setMessage(msg, "in");
                if (Boolean.TRUE.equals(context.getService().getProperty(JBI_SECURITY_PROPAGATATION))) {
                    MessageExchange oldMe = JBIContext.getMessageExchange();
                    NormalizedMessage oldMsg = (oldMe != null) ? oldMe.getMessage("in") : null;
                    if (oldMsg != null) {
                        msg.setSecuritySubject(oldMsg.getSecuritySubject());
                    }
                }
                msg.setContent(getContent(context, message));
View Full Code Here

    private DeliveryChannel channel;

    public void onMessageExchange(MessageExchange exchange) throws MessagingException {
        if (exchange.getRole() == MessageExchange.Role.CONSUMER) {
            if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                MessageExchange io = (MessageExchange) exchange.getProperty("exchange");
                MessageUtil.transferOutToOut(exchange, io);
                io.setProperty("exchange", exchange);
                channel.send(io);
            } else if (exchange.getStatus() == ExchangeStatus.DONE) {
                MessageExchange io = (MessageExchange) exchange.getProperty("exchange");
                io.setStatus(ExchangeStatus.DONE);
                channel.send(io);
            }
        } else {
            if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                MessageExchangeFactory factory = channel.createExchangeFactory();
                InOut io = factory.createInOutExchange();
                MessageUtil.transferInToIn(exchange, io);
                io.setService(new QName("echo"));
                io.setProperty("exchange", exchange);
                channel.send(io);
            } else if (exchange.getStatus() == ExchangeStatus.DONE) {
                // Do nothing
            }
        }
View Full Code Here

        client.sendSync(exchange);

        assertExchangeWorked(exchange);

        PlainBean bean = (PlainBean) getBean("plainBean");
        MessageExchange answer = bean.getFoo();

        log.info("Bean's foo() method has been invoked: " + answer);

        assertNotNull("Bean's foo() method should bave been invoked", answer);
    }
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.MessageExchange$Role

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.