Search in sources :

Example 16 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class AtmosphereWebSocketServletDestinationTest method testUseCustomAtmoosphereInterceptors.

@Test
public void testUseCustomAtmoosphereInterceptors() throws Exception {
    Bus bus = new ExtensionManagerBus();
    bus.setProperty("atmosphere.interceptors", Arrays.asList(new CustomInterceptor1(), new CustomInterceptor2()));
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);
    AtmosphereWebSocketServletDestination dest = new AtmosphereWebSocketServletDestination(bus, registry, endpoint, ENDPOINT_ADDRESS);
    List<AtmosphereInterceptor> ais = dest.getAtmosphereFramework().interceptors();
    int added = 0;
    for (AtmosphereInterceptor a : ais) {
        if (CustomInterceptor1.class.equals(a.getClass())) {
            added++;
        } else if (CustomInterceptor2.class.equals(a.getClass())) {
            added++;
            break;
        }
    }
    assertEquals(2, added);
}
Also used : AtmosphereInterceptor(org.atmosphere.cpr.AtmosphereInterceptor) Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DestinationRegistry(org.apache.cxf.transport.http.DestinationRegistry) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 17 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class JettyWebSocketDestinationTest method testRegisteration.

@Test
public void testRegisteration() throws Exception {
    Bus bus = new ExtensionManagerBus();
    DestinationRegistry registry = new HTTPTransportFactory().getRegistry();
    EndpointInfo endpoint = new EndpointInfo();
    endpoint.setAddress(ENDPOINT_ADDRESS);
    endpoint.setName(ENDPOINT_NAME);
    JettyHTTPServerEngine engine = EasyMock.createMock(JettyHTTPServerEngine.class);
    control.replay();
    TestJettyWebSocketDestination dest = new TestJettyWebSocketDestination(bus, registry, endpoint, null, engine);
    dest.activate();
    assertNotNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
    dest.deactivate();
    assertNull(registry.getDestinationForPath(ENDPOINT_ADDRESS));
}
Also used : Bus(org.apache.cxf.Bus) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) DestinationRegistry(org.apache.cxf.transport.http.DestinationRegistry) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) ExtensionManagerBus(org.apache.cxf.bus.extension.ExtensionManagerBus) Test(org.junit.Test)

Example 18 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class CXFNonSpringServlet method getDestinationRegistryFromBusOrDefault.

protected DestinationRegistry getDestinationRegistryFromBusOrDefault(final String transportId) {
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    try {
        String peferredTransportId = transportId;
        // extension or customization).
        if (StringUtils.isEmpty(peferredTransportId) && getBus() != null) {
            peferredTransportId = (String) getBus().getProperty(AbstractTransportFactory.PREFERRED_TRANSPORT_ID);
        }
        if (StringUtils.isEmpty(peferredTransportId)) {
            final Set<String> candidates = dfm.getRegisteredDestinationFactoryNames();
            // consider other candidates
            if (!candidates.contains(DEFAULT_TRANSPORT_ID)) {
                peferredTransportId = candidates.stream().filter(name -> name.endsWith("/configuration")).findAny().orElse(DEFAULT_TRANSPORT_ID);
            }
        }
        DestinationFactory df = StringUtils.isEmpty(peferredTransportId) ? dfm.getDestinationFactory(DEFAULT_TRANSPORT_ID) : dfm.getDestinationFactory(peferredTransportId);
        if (df instanceof HTTPTransportFactory) {
            HTTPTransportFactory transportFactory = (HTTPTransportFactory) df;
            return transportFactory.getRegistry();
        }
    } catch (BusException e) {
    // why are we throwing a busexception if the DF isn't found?
    }
    return null;
}
Also used : Bus(org.apache.cxf.Bus) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) FilterChain(javax.servlet.FilterChain) ServletException(javax.servlet.ServletException) StringUtils(org.apache.cxf.common.util.StringUtils) HttpServletRequestWrapper(javax.servlet.http.HttpServletRequestWrapper) AbstractHTTPDestination(org.apache.cxf.transport.http.AbstractHTTPDestination) ResourceManager(org.apache.cxf.resource.ResourceManager) HttpServletRequest(javax.servlet.http.HttpServletRequest) ClassLoaderHolder(org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder) Method(java.lang.reflect.Method) ServletRequest(javax.servlet.ServletRequest) ServiceListGeneratorServlet(org.apache.cxf.transport.servlet.servicelist.ServiceListGeneratorServlet) ServletConfig(javax.servlet.ServletConfig) HttpServlet(javax.servlet.http.HttpServlet) CastUtils(org.apache.cxf.helpers.CastUtils) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Collection(java.util.Collection) BusException(org.apache.cxf.BusException) HttpServletResponse(javax.servlet.http.HttpServletResponse) Set(java.util.Set) IOException(java.io.IOException) AbstractTransportFactory(org.apache.cxf.transport.AbstractTransportFactory) ClassLoaderUtils(org.apache.cxf.common.classloader.ClassLoaderUtils) ServletResponse(javax.servlet.ServletResponse) BusFactory(org.apache.cxf.BusFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ServletContext(javax.servlet.ServletContext) DestinationRegistry(org.apache.cxf.transport.http.DestinationRegistry) DestinationFactory(org.apache.cxf.transport.DestinationFactory) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) BusException(org.apache.cxf.BusException)

Example 19 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class HttpConduitConfigurationTest method testConduitBean.

@Test
public void testConduitBean() throws Exception {
    SpringBusFactory factory = new SpringBusFactory();
    bus = factory.createBus("org/apache/cxf/transport/http/spring/conduit-bean.xml");
    HTTPTransportFactory atf = new HTTPTransportFactory();
    HTTPConduit conduit = (HTTPConduit) atf.getConduit(ei, bus);
    verifyConduit(conduit);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) Test(org.junit.Test)

Example 20 with HTTPTransportFactory

use of org.apache.cxf.transport.http.HTTPTransportFactory in project cxf by apache.

the class HttpConduitConfigurationTest method testConduitBeanWithTLSReferences.

@Test
public void testConduitBeanWithTLSReferences() throws Exception {
    SpringBusFactory factory = new SpringBusFactory();
    bus = factory.createBus("org/apache/cxf/transport/http/spring/conduit-tlsrefs-bean.xml");
    HTTPTransportFactory atf = new HTTPTransportFactory();
    HTTPConduit conduit = (HTTPConduit) atf.getConduit(ei, bus);
    verifyConduit(conduit);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) HTTPTransportFactory(org.apache.cxf.transport.http.HTTPTransportFactory) Test(org.junit.Test)

Aggregations

HTTPTransportFactory (org.apache.cxf.transport.http.HTTPTransportFactory)28 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)23 Test (org.junit.Test)22 QName (javax.xml.namespace.QName)15 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)15 Bus (org.apache.cxf.Bus)14 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)14 DestinationRegistry (org.apache.cxf.transport.http.DestinationRegistry)10 AbstractHTTPDestination (org.apache.cxf.transport.http.AbstractHTTPDestination)7 URL (java.net.URL)6 Message (org.apache.cxf.message.Message)6 Destination (org.apache.cxf.transport.Destination)6 AtmosphereInterceptor (org.atmosphere.cpr.AtmosphereInterceptor)6 HTTPServerPolicy (org.apache.cxf.transports.http.configuration.HTTPServerPolicy)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HashSet (java.util.HashSet)3 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)3 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)3 MessageObserver (org.apache.cxf.transport.MessageObserver)3 EndpointReferenceType (org.apache.cxf.ws.addressing.EndpointReferenceType)3