Java Code Examples for org.apache.cxf.transport.http.HTTPTransportFactory#getRegistry()

The following examples show how to use org.apache.cxf.transport.http.HTTPTransportFactory#getRegistry() . 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: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testServerPolicyInServiceModel()
    throws Exception {
    policy = new HTTPServerPolicy();
    address = getEPR("bar/foo");
    bus = BusFactory.getDefaultBus(true);

    transportFactory = new HTTPTransportFactory();

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    endpointInfo = new EndpointInfo(serviceInfo, "");
    endpointInfo.setName(new QName("bla", "Port"));
    endpointInfo.addExtensor(policy);

    engine = EasyMock.createMock(JettyHTTPServerEngine.class);
    EasyMock.replay();
    endpointInfo.setAddress(NOWHERE + "bar/foo");

    JettyHTTPDestination dest =
        new EasyMockJettyHTTPDestination(
                bus, transportFactory.getRegistry(), endpointInfo, null, engine);
    assertEquals(policy, dest.getServer());
}
 
Example 2
Source File: UndertowHTTPDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testServerPolicyInServiceModel()
    throws Exception {
    policy = new HTTPServerPolicy();
    address = getEPR("bar/foo");
    bus = BusFactory.getDefaultBus(true);

    transportFactory = new HTTPTransportFactory();

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    endpointInfo = new EndpointInfo(serviceInfo, "");
    endpointInfo.setName(new QName("bla", "Port"));
    endpointInfo.addExtensor(policy);

    engine = EasyMock.createMock(UndertowHTTPServerEngine.class);
    EasyMock.replay();
    endpointInfo.setAddress(NOWHERE + "bar/foo");

    UndertowHTTPDestination dest =
        new EasyMockUndertowHTTPDestination(
                bus, transportFactory.getRegistry(), endpointInfo, null, engine);
    assertEquals(policy, dest.getServer());
}
 
Example 3
Source File: NettyHttpDestinationTest.java    From cxf with Apache License 2.0 6 votes vote down vote up
@Test
public void testServerPolicyInServiceModel()
    throws Exception {
    policy = new HTTPServerPolicy();
    address = getEPR("bar/foo");
    bus = new ExtensionManagerBus();

    transportFactory = new HTTPTransportFactory();

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    endpointInfo = new EndpointInfo(serviceInfo, "");
    endpointInfo.setName(new QName("bla", "Port"));
    endpointInfo.addExtensor(policy);

    engine = EasyMock.createMock(NettyHttpServerEngine.class);
    EasyMock.replay();
    endpointInfo.setAddress(NOWHERE + "bar/foo");

    NettyHttpDestination dest =
        new EasyMockJettyHTTPDestination(
                bus, transportFactory.getRegistry(), endpointInfo, null, engine);
    assertEquals(policy, dest.getServer());
}
 
Example 4
Source File: CxfExtractor.java    From component-runtime with Apache License 2.0 5 votes vote down vote up
public DestinationRegistry getRegistry() {
    try {
        final HTTPTransportFactory transportFactory = HTTPTransportFactory.class
                .cast(bus
                        .getExtension(DestinationFactoryManager.class)
                        .getDestinationFactory("http://cxf.apache.org/transports/http" + "/configuration"));
        return transportFactory.getRegistry();
    } catch (final BusException e) {
        throw new IllegalStateException(e);
    }
}
 
Example 5
Source File: SyncopeServiceImpl.java    From syncope with Apache License 2.0 5 votes vote down vote up
private DestinationRegistry getDestinationRegistryFromBusOrDefault() {
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    try {
        HTTPTransportFactory df = (HTTPTransportFactory) dfm.
                getDestinationFactory("http://cxf.apache.org/transports/http/configuration");
        return df.getRegistry();
    } catch (Exception e) {
        throw new InternalServerErrorException("Could not find CXF's DestinationRegistry", e);
    }
}
 
Example 6
Source File: KSBDispatcherServlet.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@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 7
Source File: WebSocketDestinationFactory.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static DestinationRegistry getDestinationRegistry(Bus bus) {
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    try {
        DestinationFactory df = dfm
            .getDestinationFactory("http://cxf.apache.org/transports/http/configuration");
        if (df instanceof HTTPTransportFactory) {
            HTTPTransportFactory transportFactory = (HTTPTransportFactory)df;
            return transportFactory.getRegistry();
        }
    } catch (Exception e) {
        // why are we throwing a busexception if the DF isn't found?
    }
    return null;
}
 
Example 8
Source File: CXFNonSpringServlet.java    From cxf with Apache License 2.0 5 votes vote down vote up
protected DestinationRegistry getDestinationRegistryFromBusOrDefault(final String transportId) {
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    try {
        String peferredTransportId = transportId;

        // Check if the preferred transport is set on a bus level (f.e., from any
        // 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();

            // If the default transport is present, fall back to it and don't even
            // 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;
}
 
Example 9
Source File: JettyHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContinuationsIgnored() throws Exception {

    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));

    final JettyHTTPServerEngine httpEngine = new JettyHTTPServerEngine();
    httpEngine.setContinuationsEnabled(false);
    JettyHTTPServerEngineFactory factory = new JettyHTTPServerEngineFactory() {
        @Override
        public JettyHTTPServerEngine retrieveJettyHTTPServerEngine(int port) {
            return httpEngine;
        }
    };
    Bus b2 = new ExtensionManagerBus();
    transportFactory = new HTTPTransportFactory();
    b2.setExtension(factory, JettyHTTPServerEngineFactory.class);

    TestJettyDestination testDestination =
        new TestJettyDestination(b2,
                                 transportFactory.getRegistry(),
                                 ei,
                                 factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
 
Example 10
Source File: UndertowHTTPDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContinuationsIgnored() throws Exception {

    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));

    final UndertowHTTPServerEngine httpEngine = new UndertowHTTPServerEngine();
    httpEngine.setContinuationsEnabled(false);
    UndertowHTTPServerEngineFactory factory = new UndertowHTTPServerEngineFactory() {
        @Override
        public UndertowHTTPServerEngine retrieveUndertowHTTPServerEngine(int port) {
            return httpEngine;
        }
    };
    Bus b2 = new ExtensionManagerBus();
    transportFactory = new HTTPTransportFactory();
    b2.setExtension(factory, UndertowHTTPServerEngineFactory.class);

    TestUndertowDestination testDestination =
        new TestUndertowDestination(b2,
                                 transportFactory.getRegistry(),
                                 ei,
                                 factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
 
Example 11
Source File: NettyHttpDestinationTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testContinuationsIgnored() throws Exception {

    HttpServletRequest httpRequest = EasyMock.createMock(HttpServletRequest.class);

    ServiceInfo serviceInfo = new ServiceInfo();
    serviceInfo.setName(new QName("bla", "Service"));
    EndpointInfo ei = new EndpointInfo(serviceInfo, "");
    ei.setName(new QName("bla", "Port"));

    // Just create a fake engine
    final NettyHttpServerEngine httpEngine = new NettyHttpServerEngine("localhost", 8080);
    //httpEngine.setContinuationsEnabled(false);
    NettyHttpServerEngineFactory factory = new NettyHttpServerEngineFactory() {
        @Override
        public NettyHttpServerEngine retrieveNettyHttpServerEngine(int port) {
            return httpEngine;
        }
    };
    transportFactory = new HTTPTransportFactory();
    bus = BusFactory.getDefaultBus();
    bus.setExtension(factory, NettyHttpServerEngineFactory.class);

    TestJettyDestination testDestination =
        new TestJettyDestination(bus,
                                 transportFactory.getRegistry(),
                                 ei,
                                 factory);
    testDestination.finalizeConfig();
    Message mi = testDestination.retrieveFromContinuation(httpRequest);
    assertNull("Continuations must be ignored", mi);
}
 
Example 12
Source File: GenericWebServiceServlet.java    From BIMserver with GNU Affero General Public License v3.0 5 votes vote down vote up
private static DestinationRegistry getDestinationRegistryFromBus(Bus bus) {
	DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
	try {
		DestinationFactory df = dfm.getDestinationFactory("http://cxf.apache.org/transports/http/configuration");
		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;
}