Java Code Examples for org.apache.cxf.Bus#getInInterceptors()

The following examples show how to use org.apache.cxf.Bus#getInInterceptors() . These examples are extracted from open source projects. 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 Project: cxf   File: BusDefinitionParserTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
@SuppressWarnings("deprecation")
public void testFeatures() {
    String cfgFile = "org/apache/cxf/bus/spring/bus.xml";
    Bus bus = new SpringBusFactory().createBus(cfgFile, true);

    List<Interceptor<? extends Message>> in = bus.getInInterceptors();
    assertTrue("could not find logging interceptor.",
            in.stream().anyMatch(i -> i.getClass() == org.apache.cxf.interceptor.LoggingInInterceptor.class));

    Collection<Feature> features = bus.getFeatures();
    TestFeature tf = null;
    for (Feature f : features) {
        if (f instanceof TestFeature) {
            tf = (TestFeature)f;
            break;
        }
    }

    assertNotNull(tf);
    assertTrue("test feature  has not been initialised", tf.initialised);
    assertNotNull("test feature has not been injected", tf.testBean);
    assertTrue("bean injected into test feature has not been initialised", tf.testBean.initialised);
}
 
Example 2
Source Project: cxf   File: SpringBusFactoryTest.java    License: Apache License 2.0 6 votes vote down vote up
private void checkCustomerConfiguration(Bus bus) {
    assertNotNull(bus);
    List<Interceptor<? extends Message>> interceptors = bus.getInInterceptors();
    assertEquals("Unexpected number of interceptors", 2, interceptors.size());
    assertEquals("Unexpected interceptor", "in-a", interceptors.get(0).toString());
    assertEquals("Unexpected interceptor", "in-b", interceptors.get(1).toString());
    interceptors = bus.getInFaultInterceptors();
    assertEquals("Unexpected number of interceptors", 1, interceptors.size());
    assertEquals("Unexpected interceptor", "in-fault", interceptors.get(0).toString());
    interceptors = bus.getOutFaultInterceptors();
    assertEquals("Unexpected number of interceptors", 1, interceptors.size());
    assertEquals("Unexpected interceptor", "out-fault", interceptors.get(0).toString());
    interceptors = bus.getOutInterceptors();
    assertEquals("Unexpected number of interceptors", 1, interceptors.size());
    assertEquals("Unexpected interceptor", "out", interceptors.get(0).toString());
}
 
Example 3
@Override
protected void initFrameworkServlet() throws ServletException, BeansException {
	this.httpInvokerHandler = new KSBHttpInvokerHandler();
	
       Bus bus = KSBServiceLocator.getCXFBus();

       List<Interceptor<? extends Message>> inInterceptors = KSBServiceLocator.getInInterceptors();
       if(inInterceptors != null) {
       	List<Interceptor<? extends Message>> busInInterceptors = bus.getInInterceptors();
       	busInInterceptors.addAll(inInterceptors);
       }
      
       List<Interceptor<? extends Message>> outInterceptors = KSBServiceLocator.getOutInterceptors();
       if(outInterceptors != null) {
       	List<Interceptor<? extends Message>> busOutInterceptors = bus.getOutInterceptors();
       	busOutInterceptors.addAll(outInterceptors);
       }


	HTTPTransportFactory transportFactory = bus.getExtension(HTTPTransportFactory.class);
       if (transportFactory == null) {
           throw new IllegalStateException("Failed to locate HTTPTransportFactory extension on Apache CXF Bus");
       }

       DestinationRegistry destinationRegistry = transportFactory.getRegistry();


	this.cxfServletController = new ServletController(destinationRegistry, getCXFServletConfig(
               this.getServletConfig()), new ServiceListGeneratorServlet(destinationRegistry, bus));

	this.setPublishEvents(false);
}
 
Example 4
Source Project: cxf   File: RedeliveryQueueImpl.java    License: Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
Source Project: cxf   File: ColocUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static InterceptorChain getInInterceptorChain(Exchange ex, SortedSet<Phase> phases) {
    Bus bus = ex.getBus();
    PhaseInterceptorChain chain = new PhaseInterceptorChain(phases);

    Endpoint ep = ex.getEndpoint();
    List<Interceptor<? extends Message>> 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));
    modifyChain(chain, ex, true);
    return chain;
}
 
Example 6
Source Project: cxf   File: BusDefinitionParserTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("deprecation")
public void testLazyInit() {
    String cfgFile = "org/apache/cxf/bus/spring/lazyInitBus.xml";
    Bus bus = new SpringBusFactory().createBus(cfgFile, true);

    List<Interceptor<? extends Message>> in = bus.getInInterceptors();
    assertTrue("could not find logging interceptor.",
            in.stream().anyMatch(i -> i.getClass() == org.apache.cxf.interceptor.LoggingInInterceptor.class));
}