@Override protected void updateMessageForSuspend() { Message currentMessage = PhaseInterceptorChain.getCurrentMessage(); if (currentMessage.get(WriteListener.class) != null) { // CXF Continuation WriteListener will likely need to be introduced // for NIO supported with non-Servlet specific mechanisms getOutputStream().setWriteListener(currentMessage.get(WriteListener.class)); currentMessage.getInterceptorChain().suspend(); } else { inMessage.getExchange().getInMessage().getInterceptorChain().suspend(); } }
public PhaseInterceptorChain cloneChain() { return new PhaseInterceptorChain(this); }
public synchronized void resume() { if (state == State.PAUSED || state == State.SUSPENDED) { state = State.EXECUTING; Message m = pausedMessage; pausedMessage = null; doIntercept(m); } }
public void run() { org.apache.cxf.message.Message message = inMessage; Exchange exchange = inMessage.getExchange(); Endpoint endpoint = message.getExchange().get( Endpoint.class); if (endpoint == null) { message.getExchange().put(Endpoint.class, endpoint); message = endpoint.getBinding().createMessage(message); PhaseManager pm = bus.getExtension(PhaseManager.class); chain.setFaultObserver(outFaultObserver); chain.doInterceptStartingAfter(message, startingAfterInterceptorID); } else if (startingInterceptorID != null) { chain.doInterceptStartingAt(message, startingInterceptorID); } else { chain.doIntercept(message); .get(RpcCallback.class);
this.exchange.put(InvocationContext.class, context); Message inMessage = this.exchange.getInMessage(); PhaseInterceptorChain chain = new PhaseInterceptorChain(this.bus.getExtension(PhaseManager.class).getInPhases()); chain.setFaultObserver(endpoint.getOutFaultObserver()); chain.add(new ServiceInvokerInterceptor()); chain.add(new OutgoingChainInterceptor()); chain.add(new WrapperClassInInterceptor()); chain.add(new HolderInInterceptor()); chain.add(new MustUnderstandInterceptor()); chain.add(new LogicalHandlerInInterceptor(binding)); chain.add(new SOAPHandlerInterceptor(binding)); copyDataBindingInterceptors(chain, inMessage.getInterceptorChain()); InterceptorChain oldChain = inMessage.getInterceptorChain(); inMessage.setInterceptorChain(chain); try { chain.doIntercept(inMessage); } finally { inMessage.setInterceptorChain(oldChain);
Exchange exchange = message.getExchange(); Exception ex = message.getContent(Exception.class); if (!(ex instanceof Fault)) { ex = new Fault(ex); FaultMode mode = message.get(FaultMode.class); faultMessage.setContent(Exception.class, ex); message.get("javax.xml.ws.addressing.context.inbound")); exchange.setOutMessage(null); exchange.setOutFaultMessage(faultMessage); if (message.get(BindingFaultInfo.class) != null) { PhaseInterceptorChain chain = new PhaseInterceptorChain(getPhases()); initializeInterceptors(faultMessage.getExchange(), chain); faultMessage.setInterceptorChain(chain); try { chain.doIntercept(faultMessage); } catch (RuntimeException exc) { LOG.log(Level.SEVERE, "ERROR_DURING_ERROR_PROCESSING", exc);
protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) { Endpoint e = ex.getEndpoint(); Client c = ex.get(Client.class); chain.add(getBus().getOutFaultInterceptors()); if (c != null) { chain.add(c.getOutFaultInterceptors()); } chain.add(e.getService().getOutFaultInterceptors()); chain.add(e.getOutFaultInterceptors()); chain.add(e.getBinding().getOutFaultInterceptors()); if (e.getService().getDataBinding() instanceof InterceptorProvider) { chain.add(((InterceptorProvider)e.getService().getDataBinding()).getOutFaultInterceptors()); } addToChain(chain, ex.getInMessage()); addToChain(chain, ex.getOutFaultMessage()); } private void addToChain(PhaseInterceptorChain chain, Message m) {
protected void initializeInterceptors(Exchange ex, PhaseInterceptorChain chain) { Endpoint e = ex.getEndpoint(); Client c = ex.get(Client.class); InterceptorProvider ip = ex.get(InterceptorProvider.class); chain.add(getBus().getInFaultInterceptors()); if (c != null) { chain.add(c.getInFaultInterceptors()); } else if (ip != null) { chain.add(ip.getInFaultInterceptors()); } chain.add(e.getService().getInFaultInterceptors()); chain.add(e.getInFaultInterceptors()); chain.add(e.getBinding().getInFaultInterceptors()); if (e.getService().getDataBinding() instanceof InterceptorProvider) { chain.add(((InterceptorProvider)e.getService().getDataBinding()).getInFaultInterceptors()); } addToChain(chain, ex.getInFaultMessage()); addToChain(chain, ex.getOutMessage()); } private void addToChain(PhaseInterceptorChain chain, Message m) {
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)) { chain.setFaultObserver(setupInFaultObserver(cfg)); m.setInterceptorChain(chain); exchange.put(Message.REST_MESSAGE, Boolean.TRUE); exchange.setOneWay("true".equals(headers.getFirst(Message.ONE_WAY_REQUEST))); exchange.put(Retryable.class, this);
public void onMessage(Message m) { Message message = cfg.getConduitSelector().getEndpoint().getBinding().createMessage(m); message.put(Message.REQUESTOR_ROLE, Boolean.TRUE); message.put(Message.INBOUND_MESSAGE, Boolean.TRUE); PhaseInterceptorChain chain = AbstractClient.setupInInterceptorChain(cfg); message.setInterceptorChain(chain); message.getExchange().setInMessage(message); Bus bus = cfg.getBus(); Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus); ClassLoaderHolder origLoader = null; try { if (loader != null) { origLoader = ClassLoaderUtils.setThreadContextClassloader(loader); } // execute chain chain.doIntercept(message); } finally { if (origBus != bus) { BusFactory.setThreadDefaultBus(origBus); } if (origLoader != null) { origLoader.reset(); } synchronized (message.getExchange()) { message.getExchange().notifyAll(); } } }
private static InterceptorChain getRedeliveryInterceptorChain(Message m, String phase) { Exchange exchange = m.getExchange(); Endpoint ep = exchange.getEndpoint(); Bus bus = exchange.getBus(); PhaseManager pm = bus.getExtension(PhaseManager.class); SortedSet<Phase> phases = new TreeSet<>(pm.getInPhases()); for (Iterator<Phase> it = phases.iterator(); it.hasNext();) { Phase p = it.next(); if (phase.equals(p.getName())) { break; } it.remove(); } PhaseInterceptorChain chain = new PhaseInterceptorChain(phases); List<Interceptor<? extends Message>> il = ep.getInInterceptors(); addInterceptors(chain, il); il = ep.getService().getInInterceptors(); addInterceptors(chain, il); il = ep.getBinding().getInInterceptors(); addInterceptors(chain, il); il = bus.getInInterceptors(); addInterceptors(chain, il); if (ep.getService().getDataBinding() instanceof InterceptorProvider) { il = ((InterceptorProvider)ep.getService().getDataBinding()).getInInterceptors(); addInterceptors(chain, il); } return chain; }
public static InterceptorChain getOutInterceptorChain(Exchange ex) { Bus bus = ex.get(Bus.class); Binding binding = ex.get(Binding.class); PhaseManager pm = bus.getExtension(PhaseManager.class); PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases()); chain.add(il); il = ep.getService().getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by service: " + il); chain.add(il); il = bus.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + il); chain.add(il); if (binding != null) { il = binding.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by binding: " + il); chain.add(il); chain.setFaultObserver(ep.getOutFaultObserver()); return chain;
public static InterceptorChain getOutInterceptorChain(Exchange ex) { Bus bus = ex.getBus(); Binding binding = ex.getBinding(); PhaseManager pm = bus.getExtension(PhaseManager.class); PhaseInterceptorChain chain = new PhaseInterceptorChain(pm.getOutPhases()); chain.add(il); il = ep.getService().getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by service: " + il); chain.add(il); il = bus.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + il); chain.add(il); if (binding != null) { il = binding.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by binding: " + il); chain.add(il); chain.setFaultObserver(ep.getOutFaultObserver()); return chain;
private static PhaseInterceptorChain getChain(Exchange ex, PhaseChainCache chainCache) { Bus bus = ex.get(Bus.class); Binding binding = ex.get(Binding.class); Endpoint ep = ex.get(Endpoint.class); List<Interceptor<? extends Message>> i1 = bus.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + i1); List<Interceptor<? extends Message>> i2 = ep.getService().getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by service: " + i2); List<Interceptor<? extends Message>> i3 = ep.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by endpoint: " + i3); i4 = binding.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by binding: " + i4); if (ep.getService().getDataBinding() instanceof InterceptorProvider) { i5 = ((InterceptorProvider)ep.getService().getDataBinding()).getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by databinding: " + i5); chain.setFaultObserver(ep.getOutFaultObserver()); return chain;
private static PhaseInterceptorChain getChain(Exchange ex, PhaseChainCache chainCache) { Bus bus = ex.getBus(); Binding binding = ex.getBinding(); Endpoint ep = ex.getEndpoint(); List<Interceptor<? extends Message>> i1 = bus.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by bus: " + i1); List<Interceptor<? extends Message>> i2 = ep.getService().getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by service: " + i2); List<Interceptor<? extends Message>> i3 = ep.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by endpoint: " + i3); i4 = binding.getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by binding: " + i4); if (ep.getService().getDataBinding() instanceof InterceptorProvider) { i5 = ((InterceptorProvider)ep.getService().getDataBinding()).getOutInterceptors(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Interceptors contributed by databinding: " + i5); chain.setFaultObserver(ep.getOutFaultObserver()); return chain;
public static List<Element> getWSDLs(Server server) { Message message = PhaseInterceptorChain.getCurrentMessage(); message.put(WSDLGetUtils.AUTO_REWRITE_ADDRESS_ALL, true); String base = (String)message.get(Message.REQUEST_URL); String ctxUri = (String)message.get(Message.PATH_INFO); WSDLGetUtils utils = new WSDLGetUtils(); EndpointInfo info = server.getEndpoint().getEndpointInfo(); List<Element> ret = new LinkedList<>(); for (String id : utils.getWSDLIds(message, base, ctxUri, info)) { Map<String, String> params = new HashMap<>(); params.put("wsdl", id); ret.add(utils.getDocument(message, base, params, ctxUri, info).getDocumentElement()); } return ret; }
public static Map<String, String> getSchemaLocations(Server server) { Message message = PhaseInterceptorChain.getCurrentMessage(); String base = (String)message.get(Message.REQUEST_URL); String ctxUri = (String)message.get(Message.PATH_INFO); WSDLGetUtils utils = new WSDLGetUtils(); EndpointInfo info = server.getEndpoint().getEndpointInfo(); return utils.getSchemaLocations(message, base, ctxUri, info); }
public static URL loadResource(Message message, Object o) { Message msg = message; if (msg == null) { msg = PhaseInterceptorChain.getCurrentMessage(); } ResourceManager manager = null; if (msg != null && msg.getExchange() != null && msg.getExchange().getBus() != null) { manager = msg.getExchange().getBus().getExtension(ResourceManager.class); } return loadResource(manager, o); }
protected boolean isAsyncResponse() { return !PhaseInterceptorChain.getCurrentMessage().getExchange().isSynchronous(); }
public ResponseBuilder location(URI loc) { if (!loc.isAbsolute()) { Message currentMessage = PhaseInterceptorChain.getCurrentMessage(); if (currentMessage != null) { UriInfo ui = new UriInfoImpl(currentMessage.getExchange().getInMessage(), null); loc = ui.getBaseUriBuilder() .path(loc.getRawPath()) .replaceQuery(loc.getRawQuery()) .fragment(loc.getRawFragment()).buildFromEncoded(); } } return setHeader(HttpHeaders.LOCATION, loc); }