Java Code Examples for org.apache.cxf.message.Message#getDestination()

The following examples show how to use org.apache.cxf.message.Message#getDestination() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OutgoingChainInterceptor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static void modifyChain(PhaseInterceptorChain chain, Message m) {
    if (m == null) {
        return;
    }
    Collection<InterceptorProvider> providers
        = CastUtils.cast((Collection<?>)m.get(Message.INTERCEPTOR_PROVIDERS));
    if (providers != null) {
        for (InterceptorProvider p : providers) {
            chain.add(p.getOutInterceptors());
        }
    }
    Collection<Interceptor<? extends Message>> is
        = CastUtils.cast((Collection<?>)m.get(Message.OUT_INTERCEPTORS));
    if (is != null) {
        chain.add(is);
    }
    if (m.getDestination() instanceof InterceptorProvider) {
        chain.add(((InterceptorProvider)m.getDestination()).getOutInterceptors());
    }
}
 
Example 2
Source File: OutFaultChainInitiatorObserver.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addToChain(PhaseInterceptorChain chain, Message m) {
    Collection<InterceptorProvider> providers
        = CastUtils.cast((Collection<?>)m.get(Message.INTERCEPTOR_PROVIDERS));
    if (providers != null) {
        for (InterceptorProvider p : providers) {
            chain.add(p.getOutFaultInterceptors());
        }
    }
    Collection<Interceptor<? extends Message>> is
        = CastUtils.cast((Collection<?>)m.get(Message.FAULT_OUT_INTERCEPTORS));
    if (is != null) {
        chain.add(is);
    }
    if (m.getDestination() instanceof InterceptorProvider) {
        chain.add(((InterceptorProvider)m.getDestination()).getOutFaultInterceptors());
    }
}
 
Example 3
Source File: ChainInitiationObserver.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addToChain(InterceptorChain chain, Message m) {
    Collection<InterceptorProvider> providers
        = CastUtils.cast((Collection<?>)m.get(Message.INTERCEPTOR_PROVIDERS));
    if (providers != null) {
        for (InterceptorProvider p : providers) {
            chain.add(p.getInInterceptors());
        }
    }
    Collection<Interceptor<? extends Message>> is
        = CastUtils.cast((Collection<?>)m.get(Message.IN_INTERCEPTORS));
    if (is != null) {
        chain.add(is);
    }
    if (m.getDestination() instanceof InterceptorProvider) {
        chain.add(((InterceptorProvider)m.getDestination()).getInInterceptors());
    }
}
 
Example 4
Source File: HttpUtils.java    From cxf with Apache License 2.0 4 votes vote down vote up
public static String getOriginalAddress(Message m) {
    Destination d = m.getDestination();
    return d == null ? "/" : d.getAddress().getAddress().getValue();
}
 
Example 5
Source File: InternalContextUtils.java    From cxf with Apache License 2.0 4 votes vote down vote up
/**
 * Rebase response on replyTo
 *
 * @param reference the replyTo reference
 * @param inMAPs the inbound MAPs
 * @param inMessage the current message
 */
//CHECKSTYLE:OFF Max executable statement count limitation
public static void rebaseResponse(EndpointReferenceType reference,
                                  AddressingProperties inMAPs,
                                  final Message inMessage) {

    String namespaceURI = inMAPs.getNamespaceURI();
    if (!ContextUtils.retrievePartialResponseSent(inMessage)) {
        ContextUtils.storePartialResponseSent(inMessage);
        Exchange exchange = inMessage.getExchange();
        Message fullResponse = exchange.getOutMessage();
        Message partialResponse = ContextUtils.createMessage(exchange);
        ensurePartialResponseMAPs(partialResponse, namespaceURI);

        // ensure the inbound MAPs are available in the partial response
        // message (used to determine relatesTo etc.)
        ContextUtils.propogateReceivedMAPs(inMAPs, partialResponse);
        Destination target = inMessage.getDestination();
        if (target == null) {
            return;
        }

        try {
            if (reference == null) {
                reference = ContextUtils.getNoneEndpointReference();
            }
            Conduit backChannel = target.getBackChannel(inMessage);
            if (backChannel != null) {
                partialResponse.put(Message.PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
                partialResponse.put(Message.EMPTY_PARTIAL_RESPONSE_MESSAGE, Boolean.TRUE);
                boolean robust = MessageUtils.getContextualBoolean(inMessage, Message.ROBUST_ONEWAY, false);

                if (robust) {
                    BindingOperationInfo boi = exchange.getBindingOperationInfo();
                    // insert the executor in the exchange to fool the OneWayProcessorInterceptor
                    exchange.put(Executor.class, getExecutor(inMessage));
                    // pause dispatch on current thread and resume...
                    inMessage.getInterceptorChain().pause();
                    inMessage.getInterceptorChain().resume();
                    // restore the BOI for the partial response handling
                    exchange.put(BindingOperationInfo.class, boi);
                }


                // set up interceptor chains and send message
                InterceptorChain chain =
                    fullResponse != null
                    ? fullResponse.getInterceptorChain()
                    : OutgoingChainInterceptor.getOutInterceptorChain(exchange);
                exchange.setOutMessage(partialResponse);
                partialResponse.setInterceptorChain(chain);
                exchange.put(ConduitSelector.class,
                             new PreexistingConduitSelector(backChannel,
                                                            exchange.getEndpoint()));

                if (chain != null && !chain.doIntercept(partialResponse)
                    && partialResponse.getContent(Exception.class) != null) {
                    if (partialResponse.getContent(Exception.class) instanceof Fault) {
                        throw (Fault)partialResponse.getContent(Exception.class);
                    }
                    throw new Fault(partialResponse.getContent(Exception.class));
                }
                if (chain != null) {
                    chain.reset();
                }
                exchange.put(ConduitSelector.class, new NullConduitSelector());

                if (fullResponse == null) {
                    fullResponse = ContextUtils.createMessage(exchange);
                }
                exchange.setOutMessage(fullResponse);

                Destination destination = createDecoupledDestination(
                    exchange,
                    reference);
                exchange.setDestination(destination);

            }
        } catch (Exception e) {
            LOG.log(Level.WARNING, "SERVER_TRANSPORT_REBASE_FAILURE_MSG", e);
        }
    }
}
 
Example 6
Source File: CorbaStreamInInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void handleReply(Message msg) {
    ORB orb;
    ServiceInfo service;
    CorbaDestination destination;
    if (msg.getDestination() != null) {
        destination = (CorbaDestination)msg.getDestination();
    } else {
        destination = (CorbaDestination)msg.getExchange().getDestination();
    }
    service = destination.getBindingInfo().getService();

    CorbaMessage message = (CorbaMessage)msg;
    if (message.getStreamableException() != null || message.getSystemException() != null) {
        message.setContent(Exception.class,
                           message.getExchange().getOutMessage().getContent(Exception.class));

        Endpoint ep = message.getExchange().getEndpoint();
        message.getInterceptorChain().abort();
        if (ep.getInFaultObserver() != null) {
            ep.getInFaultObserver().onMessage(message);
            return;
        }
    }

    CorbaMessage outMessage = (CorbaMessage)message.getExchange().getOutMessage();
    orb = message.getExchange().get(ORB.class);
    HandlerIterator paramIterator = new HandlerIterator(outMessage, false);

    CorbaTypeEventProducer eventProducer = null;
    Exchange exchange = message.getExchange();
    BindingOperationInfo bindingOpInfo = exchange.getBindingOperationInfo();
    BindingMessageInfo msgInfo = bindingOpInfo.getOutput();

    boolean wrap = false;
    if (bindingOpInfo.isUnwrappedCapable()) {
        wrap = true;
    }

    if (wrap) {
        // wrapper element around our args
        // REVISIT, bravi, message name same as the element name
        QName wrapperElementQName = msgInfo.getMessageInfo().getName();
        eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName,
                                                                  paramIterator,
                                                                  service,
                                                                  orb);
    } else {
        eventProducer = new ParameterEventProducer(paramIterator,
                                                   service,
                                                   orb);
    }
    CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
    message.setContent(XMLStreamReader.class, reader);
}
 
Example 7
Source File: CorbaStreamInInterceptor.java    From cxf with Apache License 2.0 4 votes vote down vote up
private void handleRequest(Message msg) {
    ORB orb;
    ServiceInfo service;
    CorbaDestination destination;
    if (msg.getDestination() != null) {
        destination = (CorbaDestination)msg.getDestination();
    } else {
        destination = (CorbaDestination)msg.getExchange().getDestination();
    }
    service = destination.getBindingInfo().getService();

    CorbaMessage message = (CorbaMessage) msg;

    Exchange exchange = message.getExchange();

    CorbaTypeMap typeMap = message.getCorbaTypeMap();

    BindingInfo bInfo = destination.getBindingInfo();
    InterfaceInfo info = bInfo.getInterface();
    String opName = exchange.get(String.class);
    Iterator<BindingOperationInfo> i = bInfo.getOperations().iterator();
    OperationType opType = null;
    BindingOperationInfo bopInfo = null;
    QName opQName = null;
    while (i.hasNext()) {
        bopInfo = i.next();
        if (bopInfo.getName().getLocalPart().equals(opName)) {
            opType = bopInfo.getExtensor(OperationType.class);
            opQName = bopInfo.getName();
            break;
        }
    }

    if (opType == null) {
        throw new RuntimeException("Couldn't find the binding operation for " + opName);
    }

    orb = exchange.get(ORB.class);

    ServerRequest request = exchange.get(ServerRequest.class);
    NVList list = prepareArguments(message, info, opType,
                                   opQName, typeMap,
                                   destination, service);
    request.arguments(list);
    message.setList(list);

    HandlerIterator paramIterator = new HandlerIterator(message, true);

    CorbaTypeEventProducer eventProducer = null;
    BindingMessageInfo msgInfo = bopInfo.getInput();
    boolean wrap = false;
    if (bopInfo.isUnwrappedCapable()) {
        wrap = true;
    }

    if (wrap) {
        // wrapper element around our args
        QName wrapperElementQName = msgInfo.getMessageInfo().getName();
        eventProducer = new WrappedParameterSequenceEventProducer(wrapperElementQName,
                                                                  paramIterator,
                                                                  service,
                                                                  orb);
    } else {
        eventProducer = new ParameterEventProducer(paramIterator,
                                                   service,
                                                   orb);
    }
    CorbaStreamReader reader = new CorbaStreamReader(eventProducer);
    message.setContent(XMLStreamReader.class, reader);
}