Package javax.jbi.messaging

Examples of javax.jbi.messaging.NormalizedMessage


* @author <a href="mailto:gnodet [at] gmail.com">Guillaume Nodet</a>
*/
public class JbiFaultOutInterceptor extends AbstractInterceptor {

    public void handleMessage(Message message) {
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        if (nm instanceof Fault) {
            SoapFault fault = createFault(nm);
            throw fault;
        }
    }
View Full Code Here


    protected void processFile(FTPClient client, FTPFile file) throws Exception {
        String name = file.getName();
        InputStream in = client.retrieveFileStream(getWorkingPath() + name);
        InOnly exchange = getExchangeFactory().createInOnlyExchange();
        NormalizedMessage message = exchange.createMessage();
        exchange.setInMessage(message);
        marshaler.readMessage(exchange, message, in, name);
        getDeliveryChannel().sendSync(exchange);
        in.close();
        client.completePendingCommand();
View Full Code Here

   
    public void handleMessage(Message message) {
        try {
            Operation operation = message.get(Operation.class);
            MessageExchange exchange;
            NormalizedMessage nm;
            // Create message
            if (server) {
                exchange = createExchange(message);
                if (operation != null) {
                    exchange.setOperation(operation.getName());
                }
                nm = exchange.createMessage();
                exchange.setMessage(nm, "in");
                message.setContent(MessageExchange.class, exchange);
            } else {
                exchange = message.getContent(MessageExchange.class);
                if (exchange == null) {
                    throw new IllegalStateException("Content of type " + MessageExchange.class + " not found on message");
                }
                if (message.getContent(Exception.class) == null) {
                    nm = exchange.getMessage("out");
                    if (nm == null) {
                        nm = exchange.createMessage();
                        exchange.setMessage(nm, "out");
                    }
                } else {
                    exchange.setFault(exchange.createFault());
                    nm = exchange.getFault();
                }
            }
            // Put headers
            toNMSHeaders(nm, message);
            // Put attachments
            toNMSAttachments(nm, message);
            // Put subject
            nm.setSecuritySubject(message.get(Subject.class));
            // Put main source
            getContent(nm, message);
            // Register new content
            message.setContent(NormalizedMessage.class, nm);
        } catch (JBIException e) {
View Full Code Here

        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

        InputStream in = content.getInputStream();
        if (in == null) {
            throw new JBIException("No input available for file!");
        }
        RobustInOnly exchange = getExchangeFactory().createRobustInOnlyExchange();
        NormalizedMessage message = exchange.createMessage();
        exchange.setInMessage(message);
        marshaler.readMessage(exchange, message, in, name);
        getDeliveryChannel().sendSync(exchange);
        in.close();
        content.close();
View Full Code Here

    protected void doNotify(final Element content) {
        try {
            DeliveryChannel channel = getContext().getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory(endpoint);
            InOnly inonly = factory.createInOnlyExchange();
            NormalizedMessage msg = inonly.createMessage();
            inonly.setInMessage(msg);
            msg.setContent(new DOMSource(content));
            getLifeCycle().sendConsumerExchange(inonly, processor);
        } catch (JBIException e) {
            log.warn("Could not deliver notification", e);
        }
    }
View Full Code Here

   
    public Exchange(MessageExchange exchange, NamespaceContext namespaceContext) {
        this.exchange = exchange;
        this.namespaceContext = namespaceContext;
        if (in == null) {
            NormalizedMessage msg = exchange.getMessage("in");
            in = msg != null ? new Message(msg, this.namespaceContext) : null;
        }
        if (out == null) {
            NormalizedMessage msg = exchange.getMessage("out");
            out = msg != null ? new Message(msg, this.namespaceContext) : null;
        }
        if (fault == null) {
            javax.jbi.messaging.Fault msg = exchange.getFault();
            fault = msg != null ? new Fault(msg, this.namespaceContext) : null;
View Full Code Here

    public Message getFault() {
        return fault;
    }
   
    protected Message getMessage(String name) {
        NormalizedMessage msg = exchange.getMessage(name);
        return msg != null ? new Message(msg, this.namespaceContext) : null;
    }
View Full Code Here

        // lets send a request to be written to a file
        // which should then be polled
        for (int i = 0; i < NUMBER; i++) {
            InOnly me = client.createInOnlyExchange();
            me.setService(new QName("urn:test", "service"));
            NormalizedMessage message = me.getInMessage();
            message.setProperty(DefaultFileMarshaler.FILE_NAME_PROPERTY, "test" + i + ".xml");
            message.setContent(new StringSource(sb.toString()));
            client.sendSync(me);
        }

        Receiver receiver = (Receiver) getBean("receiver");
        receiver.getMessageList().assertMessagesReceived(NUMBER);
View Full Code Here

    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

TOP

Related Classes of javax.jbi.messaging.NormalizedMessage

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.