예제 #1
0
  public static InterceptorChain getInInterceptorChain(Exchange ex, SortedSet<Phase> phases) {
    Bus bus = ex.get(Bus.class);
    PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);

    Endpoint ep = ex.get(Endpoint.class);
    List<Interceptor> il = ep.getInInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("Interceptors contributed by endpoint: " + il);
    }
    chain.add(il);
    il = ep.getService().getInInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("Interceptors contributed by service: " + il);
    }
    chain.add(il);
    il = bus.getInInterceptors();
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("Interceptors contributed by bus: " + il);
    }
    chain.add(il);

    if (ep.getService().getDataBinding() instanceof InterceptorProvider) {
      il = ((InterceptorProvider) ep.getService().getDataBinding()).getInInterceptors();
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("Interceptors contributed by databinding: " + il);
      }
      chain.add(il);
    }
    chain.setFaultObserver(new ColocOutFaultObserver(bus));

    return chain;
  }
예제 #2
0
  protected Message createMessage(
      Object body,
      String httpMethod,
      MultivaluedMap<String, String> headers,
      URI currentURI,
      Exchange exchange,
      Map<String, Object> invocationContext,
      boolean proxy) {
    Message m = cfg.getConduitSelector().getEndpoint().getBinding().createMessage();
    m.put(Message.REQUESTOR_ROLE, Boolean.TRUE);
    m.put(Message.INBOUND_MESSAGE, Boolean.FALSE);

    m.put(Message.HTTP_REQUEST_METHOD, httpMethod);
    m.put(Message.PROTOCOL_HEADERS, headers);
    if (currentURI.isAbsolute() && currentURI.getScheme().startsWith(HTTP_SCHEME)) {
      m.put(Message.ENDPOINT_ADDRESS, currentURI.toString());
    } else {
      m.put(Message.ENDPOINT_ADDRESS, state.getBaseURI().toString());
    }

    Object requestURIProperty = cfg.getRequestContext().get(Message.REQUEST_URI);
    if (requestURIProperty == null) {
      m.put(Message.REQUEST_URI, currentURI.toString());
    } else {
      m.put(Message.REQUEST_URI, requestURIProperty.toString());
    }

    m.put(Message.CONTENT_TYPE, headers.getFirst(HttpHeaders.CONTENT_TYPE));

    body = checkIfBodyEmpty(body);
    setEmptyRequestPropertyIfNeeded(m, body);

    m.setContent(List.class, getContentsList(body));

    m.put(URITemplate.TEMPLATE_PARAMETERS, getState().getTemplates());

    PhaseInterceptorChain chain = setupOutInterceptorChain(cfg);
    chain.setFaultObserver(setupInFaultObserver(cfg));
    m.setInterceptorChain(chain);

    exchange = createExchange(m, exchange);
    exchange.put(Message.REST_MESSAGE, Boolean.TRUE);
    exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST)));
    exchange.put(Retryable.class, new RetryableImpl());

    // context
    setContexts(m, exchange, invocationContext, proxy);

    // setup conduit selector
    prepareConduitSelector(m, currentURI, proxy);

    return m;
  }