Package javax.jbi.messaging

Examples of javax.jbi.messaging.DeliveryChannel


   
    public final void start() throws JBIException {
       
        try {
            LOG.fine("CeltixServiceEngine starting");
            DeliveryChannel chnl = ctx.getDeliveryChannel();
            configureJBITransportFactory(chnl, suManager);
            LOG.fine("CeltixServiceEngine startup complete");
        } catch (BusException ex) {
            throw new JBIException(ex);
        }
View Full Code Here


            throw new NullPointerException("MEP not found");
        }
        MessageExchangeFactory mef = message.getExchange().get(
                MessageExchangeFactory.class);
        if (mef == null) {
            DeliveryChannel dv = message.getExchange().get(
                    DeliveryChannel.class);
            if (dv == null) {
                ComponentContext cc = message.getExchange().get(
                        ComponentContext.class);
                if (cc == null) {
                    throw new NullPointerException(
                            "MessageExchangeFactory or DeliveryChannel or ComponentContext not found");
                }
                dv = cc.getDeliveryChannel();
            }
            mef = dv.createExchangeFactory();
        }
        MessageExchange me = mef.createExchange(mep);
        me.setOperation(operation.getName());
        return me;
    }
View Full Code Here

        }
    }

    public void process(Exchange exchange) {
        try {
            DeliveryChannel deliveryChannel = componentContext.getDeliveryChannel();
            MessageExchangeFactory exchangeFactory = deliveryChannel.createExchangeFactory();
            MessageExchange messageExchange = binding.makeJbiMessageExchange(exchange, exchangeFactory, mep);

            URIResolver.configureExchange(messageExchange, componentContext, destinationUri);
            deliveryChannel.sendSync(messageExchange);

            if (messageExchange.getStatus() == ExchangeStatus.ERROR) {
                exchange.setException(messageExchange.getError());
            } else if (messageExchange.getStatus() == ExchangeStatus.ACTIVE) {
                if (messageExchange.getFault() != null) {
                    exchange.getFault().setBody(messageExchange.getFault().getContent());
                } else {
                    exchange.getOut().setBody(messageExchange.getMessage("out").getContent());
                }
                messageExchange.setStatus(ExchangeStatus.DONE);
                deliveryChannel.send(messageExchange);
            }

        } catch (MessagingException e) {
            throw new JbiException(e);
        } catch (URISyntaxException e) {
View Full Code Here

     *
     * @param target the bean to be injected
     */
    protected void injectBean(final Object target) {
        final PojoContext ctx = new PojoContext();
        final DeliveryChannel ch = ctx.channel;
        // Inject fields
        ReflectionUtils.doWithFields(target.getClass(), new ReflectionUtils.FieldCallback() {
            public void doWith(Field f) throws IllegalArgumentException, IllegalAccessException {
                ExchangeTarget et = f.getAnnotation(ExchangeTarget.class);
                if (et != null) {
View Full Code Here

        Source inputSource = getSourceFromPayload(payload);
        // Create and send exchange
        try {
            BPEEndpoint endpoint = BPEEndpoint.getCurrent();
            BPEComponent component = (BPEComponent) endpoint.getServiceUnit().getComponent();
            DeliveryChannel channel = ((BPELifeCycle) component.getLifeCycle()).getContext().getDeliveryChannel();
            MessageExchangeFactory factory = channel.createExchangeFactory();
            // TODO: need to configure mep
            MessageExchange me = factory.createExchange(this.mep);
            me.setInterfaceName(interfaceName);
            me.setService(serviceName);
            if (endpointName != null) {
                ServiceEndpoint ep = component.getComponentContext().getEndpoint(serviceName, endpointName);
                me.setEndpoint(ep);
            }
            // TODO: set endpoint
            me.setOperation(operationName);
            NormalizedMessage nm = me.createMessage();
            me.setMessage(nm, "in");
            nm.setContent(inputSource);
            boolean res = channel.sendSync(me);
            if (!res) {
                throw new ActionSystemException("Timeout on sending message");
            }
            if (me.getStatus() == ExchangeStatus.ACTIVE) {
                if (me.getFault() != null) {
                    Document fault;
                    try {
                        fault = transformer.toDOMDocument(me.getFault());
                        me.setStatus(ExchangeStatus.DONE);
                    } catch (Exception e) {
                        me.setError(e);
                        throw new ActionSystemException(e);
                    } finally {
                        channel.send(me);
                    }
                    Element e = fault.getDocumentElement();
                    // Try to determine fault name
                    String faultName = e.getLocalName();
                    String partName = BPEComponent.PART_PAYLOAD;
                    QName elemName = new QName(e.getNamespaceURI(), e.getLocalName());
                    if (wsdlOperation != null) {
                        for (Iterator itFault = wsdlOperation.getFaults().values().iterator(); itFault.hasNext();) {
                            Fault f = (Fault) itFault.next();
                            Part p = (Part) f.getMessage().getParts().values().iterator().next();
                            if (elemName.equals(p.getTypeName())) {
                                faultName = f.getName();
                                partName = p.getName();
                            }
                        }
                    }
                    BPRuntimeException bpre = new BPRuntimeException(faultName, "");
                    bpre.setNameSpace(e.getNamespaceURI());
                    /* We must use a type that implements BPE's IFormattableValue interface
                     * since otherwise the value will get wrapped in a CannedFormattableValue
                     * which has undesireable side effects. 
                     */
                    DocumentFormattableValue documentFormattableValue = new DocumentFormattableValue(fault);
                    bpre.addPartMessage(partName, documentFormattableValue);
                    throw bpre;
                } else {
                    try {
                        nm = me.getMessage("out");
                        if (nm != null) {
                            /* We must use a type that implements BPE's IFormattableValue interface
                             * since otherwise the value will get wrapped in a CannedFormattableValue
                             * which has undesireable side effects. 
                             */
                            Document out = transformer.toDOMDocument(nm);
                            DocumentFormattableValue documentFormattableValue = new DocumentFormattableValue(out);
                            output.put(outputPartName, documentFormattableValue);
                        }
                        me.setStatus(ExchangeStatus.DONE);
                    } catch (Exception e) {
                        me.setError(e);
                        throw new ActionSystemException(e);
                    } finally {
                        channel.send(me);
                    }
                }
            } else if (me.getStatus() == ExchangeStatus.ERROR) {
                // Extract error
                Exception error = me.getError();
View Full Code Here

        if (mep == null) {
            throw new NullPointerException("MEP not found");
        }
        MessageExchangeFactory mef = message.get(MessageExchangeFactory.class);
        if (mef == null) {
            DeliveryChannel dv = message.get(DeliveryChannel.class);
            if (dv == null) {
                ComponentContext cc = message.get(ComponentContext.class);
                if (cc == null) {
                    throw new NullPointerException("MessageExchangeFactory or DeliveryChannel or ComponentContext not found");
                }
                dv = cc.getDeliveryChannel();
            }
            mef = dv.createExchangeFactory();
        }
        return mef.createExchange(mep);
    }
View Full Code Here

        Bus bus = BusFactory.getDefaultBus();
        JBITransportFactory jbiTransportFactory = (JBITransportFactory) bus
                .getExtension(ConduitInitiatorManager.class)
                .getConduitInitiator(CxfSeComponent.JBI_TRANSPORT_ID);
        if (getContext() != null) {
            DeliveryChannel dc = getContext().getDeliveryChannel();
            if (dc != null) {
                jbiTransportFactory.setDeliveryChannel(dc);
            }
        }
        return cf.create();
View Full Code Here

    }

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

                .getExtension(ConduitInitiatorManager.class)
                .getConduitInitiator(CxfSeComponent.JBI_TRANSPORT_ID);
        JBIDestination jbiDestination = jbiTransportFactory
                .getDestination(exchange.getService().toString()
                        + exchange.getInterfaceName().toString());
        DeliveryChannel dc = getContext().getDeliveryChannel();
        jbiTransportFactory.setDeliveryChannel(dc);
        jbiDestination.setDeliveryChannel(dc);
        if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
            jbiDestination.getJBIDispatcherUtil().dispatch(exchange);
        }
View Full Code Here

                }
                return;
            }
        } else {
            try {
                DeliveryChannel channel = ((JbiTransport) getTransport()).getContext().getDeliveryChannel();
                MessageExchangeFactory factory = channel.createExchangeFactory();
                URI mep = null;
                if (context.getExchange().getOperation().getOutputMessage() != null) {
                    mep = MessageExchangeSupport.IN_OUT;
                } 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));
                if (!channel.sendSync(me)) {
                    throw new XFireException("Unable to send jbi exchange: sendSync returned false");
                }
                if (me.getStatus() == ExchangeStatus.ERROR) {
                    if (me.getError() != null) {
                        throw new XFireFault(me.getError(), XFireFault.RECEIVER);
                    } else {
                        throw new XFireFault("Unkown Error", XFireFault.RECEIVER);
                    }
                } else if (me.getStatus() == ExchangeStatus.ACTIVE) {
                    if (me.getFault() != null) {
                        JDOMResult result = new JDOMResult();
                        String str = getTransformer().contentToString(me.getFault());
                        getTransformer().toResult(new StringSource(str), result);
                        Element e = result.getDocument().getRootElement();
                        e = (Element) e.clone();
                        me.setStatus(ExchangeStatus.DONE);
                        channel.send(me);
                        XFireFault xfireFault = new XFireFault(str, XFireFault.RECEIVER);
                        xfireFault.getDetail().addContent(e);
                        throw xfireFault;
                    } else if (me.getMessage("out") != null) {
                        Source outSrc = me.getMessage("out").getContent();
                        InMessage inMessage = new InMessage(getTransformer().toXMLStreamReader(outSrc), getUri());
                        getEndpoint().onReceive(context, inMessage);
                        me.setStatus(ExchangeStatus.DONE);
                        channel.send(me);
                    }
                }
            } catch (XFireException e) {
                throw e;
            } catch (Exception e) {
View Full Code Here

TOP

Related Classes of javax.jbi.messaging.DeliveryChannel

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.