Search in sources :

Example 1 with ConfigurerImpl

use of org.apache.cxf.configuration.spring.ConfigurerImpl in project cxf by apache.

the class SpringBus method setApplicationContext.

/**
 * {@inheritDoc}
 */
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
    ctx = (AbstractApplicationContext) applicationContext;
    @SuppressWarnings("rawtypes") ApplicationListener listener = new ApplicationListener() {

        public void onApplicationEvent(ApplicationEvent event) {
            SpringBus.this.onApplicationEvent(event);
        }
    };
    ctx.addApplicationListener(listener);
    ApplicationContext ac = applicationContext.getParent();
    while (ac != null) {
        if (ac instanceof AbstractApplicationContext) {
            ((AbstractApplicationContext) ac).addApplicationListener(listener);
        }
        ac = ac.getParent();
    }
    // set the classLoader extension with the application context classLoader
    setExtension(applicationContext.getClassLoader(), ClassLoader.class);
    setExtension(new ConfigurerImpl(applicationContext), Configurer.class);
    ResourceManager m = getExtension(ResourceManager.class);
    m.addResourceResolver(new BusApplicationContextResourceResolver(applicationContext));
    setExtension(applicationContext, ApplicationContext.class);
    ConfiguredBeanLocator loc = getExtension(ConfiguredBeanLocator.class);
    if (!(loc instanceof SpringBeanLocator)) {
        setExtension(new SpringBeanLocator(applicationContext, this), ConfiguredBeanLocator.class);
    }
    if (getState() != BusState.RUNNING) {
        initialize();
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) AbstractApplicationContext(org.springframework.context.support.AbstractApplicationContext) AbstractApplicationContext(org.springframework.context.support.AbstractApplicationContext) ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) ApplicationListener(org.springframework.context.ApplicationListener) ApplicationEvent(org.springframework.context.ApplicationEvent) ResourceManager(org.apache.cxf.resource.ResourceManager)

Example 2 with ConfigurerImpl

use of org.apache.cxf.configuration.spring.ConfigurerImpl in project cxf by apache.

the class JettyHTTPServerEngineTest method setUp.

@Before
public void setUp() throws Exception {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    Configurer configurer = new ConfigurerImpl();
    bus.getExtension(Configurer.class);
    EasyMock.expectLastCall().andReturn(configurer).anyTimes();
    InstrumentationManager iManager = control.createMock(InstrumentationManager.class);
    iManager.getMBeanServer();
    EasyMock.expectLastCall().andReturn(ManagementFactory.getPlatformMBeanServer()).anyTimes();
    bus.getExtension(InstrumentationManager.class);
    EasyMock.expectLastCall().andReturn(iManager).anyTimes();
    control.replay();
    factory = new JettyHTTPServerEngineFactory();
    factory.setBus(bus);
}
Also used : Bus(org.apache.cxf.Bus) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) Configurer(org.apache.cxf.configuration.Configurer) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) Before(org.junit.Before)

Example 3 with ConfigurerImpl

use of org.apache.cxf.configuration.spring.ConfigurerImpl in project cxf by apache.

the class UndertowHTTPServerEngineTest method setUp.

@Before
public void setUp() throws Exception {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    Configurer configurer = new ConfigurerImpl();
    bus.getExtension(Configurer.class);
    EasyMock.expectLastCall().andReturn(configurer).anyTimes();
    InstrumentationManager iManager = control.createMock(InstrumentationManager.class);
    iManager.getMBeanServer();
    EasyMock.expectLastCall().andReturn(ManagementFactory.getPlatformMBeanServer()).anyTimes();
    bus.getExtension(InstrumentationManager.class);
    EasyMock.expectLastCall().andReturn(iManager).anyTimes();
    control.replay();
    factory = new UndertowHTTPServerEngineFactory();
    factory.setBus(bus);
}
Also used : Bus(org.apache.cxf.Bus) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) Configurer(org.apache.cxf.configuration.Configurer) InstrumentationManager(org.apache.cxf.management.InstrumentationManager) Before(org.junit.Before)

Example 4 with ConfigurerImpl

use of org.apache.cxf.configuration.spring.ConfigurerImpl in project cxf by apache.

the class ApplicationContextTest method checkContext.

private void checkContext(TestApplicationContext ctx) throws Exception {
    ConfigurerImpl cfg = new ConfigurerImpl(ctx);
    EndpointInfo info = getEndpointInfo("bla", "Foo", "http://localhost:9000");
    Bus bus = (Bus) ctx.getBean(Bus.DEFAULT_BUS_ID);
    bus.setExtension(cfg, Configurer.class);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    DestinationFactory factory = dfm.getDestinationFactory("http://cxf.apache.org/transports/http");
    Destination d = factory.getDestination(info, bus);
    assertTrue(d instanceof UndertowHTTPDestination);
    UndertowHTTPDestination jd = (UndertowHTTPDestination) d;
    assertEquals("foobar", jd.getServer().getContentEncoding());
    UndertowHTTPServerEngine engine = (UndertowHTTPServerEngine) jd.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
    ConduitInitiator ci = cim.getConduitInitiator("http://cxf.apache.org/transports/http");
    HTTPConduit conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(97, conduit.getClient().getConnectionTimeout());
    info.setName(new QName("urn:test:ns", "Bar"));
    conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(79, conduit.getClient().getConnectionTimeout());
    UndertowHTTPDestination jd2 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
    engine = (UndertowHTTPServerEngine) jd2.getEngine();
    assertEquals(40000, engine.getMaxIdleTime());
    assertEquals(99, engine.getThreadingParameters().getMinThreads());
    assertEquals(777, engine.getThreadingParameters().getMaxThreads());
    assertNotNull("The handlers should not be null", engine.getHandlers());
    assertEquals(1, engine.getHandlers().size());
    UndertowHTTPDestination jd3 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
    engine = (UndertowHTTPServerEngine) jd3.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), true);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), true);
    UndertowHTTPDestination jd4 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
    engine = (UndertowHTTPServerEngine) jd4.getEngine();
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), false);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), false);
    UndertowHTTPDestination jd5 = (UndertowHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "http://localhost:9100"), bus);
    engine = (UndertowHTTPServerEngine) jd5.getEngine();
    String r = "expected fallback thread parameters configured for port 0";
    assertNotNull(r, engine.getThreadingParameters());
    assertEquals(r, 21, engine.getThreadingParameters().getMinThreads());
    assertEquals(r, 389, engine.getThreadingParameters().getMaxThreads());
}
Also used : UndertowHTTPServerEngine(org.apache.cxf.transport.http_undertow.UndertowHTTPServerEngine) Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) UndertowHTTPDestination(org.apache.cxf.transport.http_undertow.UndertowHTTPDestination) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) UndertowHTTPDestination(org.apache.cxf.transport.http_undertow.UndertowHTTPDestination) QName(javax.xml.namespace.QName) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator)

Example 5 with ConfigurerImpl

use of org.apache.cxf.configuration.spring.ConfigurerImpl in project cxf by apache.

the class ApplicationContextTest method checkContext.

private void checkContext(TestApplicationContext ctx) throws Exception {
    ConfigurerImpl cfg = new ConfigurerImpl(ctx);
    EndpointInfo info = getEndpointInfo("bla", "Foo", "http://localhost:9000");
    Bus bus = (Bus) ctx.getBean(Bus.DEFAULT_BUS_ID);
    bus.setExtension(cfg, Configurer.class);
    DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class);
    DestinationFactory factory = dfm.getDestinationFactory("http://cxf.apache.org/transports/http");
    Destination d = factory.getDestination(info, bus);
    assertTrue(d instanceof JettyHTTPDestination);
    JettyHTTPDestination jd = (JettyHTTPDestination) d;
    assertEquals("foobar", jd.getServer().getContentEncoding());
    JettyHTTPServerEngine engine = (JettyHTTPServerEngine) jd.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    assertEquals("TestPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    ConduitInitiatorManager cim = bus.getExtension(ConduitInitiatorManager.class);
    ConduitInitiator ci = cim.getConduitInitiator("http://cxf.apache.org/transports/http");
    HTTPConduit conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(97, conduit.getClient().getConnectionTimeout());
    info.setName(new QName("urn:test:ns", "Bar"));
    conduit = (HTTPConduit) ci.getConduit(info, bus);
    assertEquals(79, conduit.getClient().getConnectionTimeout());
    JettyHTTPDestination jd2 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("foo", "bar", "http://localhost:9001"), bus);
    engine = (JettyHTTPServerEngine) jd2.getEngine();
    assertEquals(40000, engine.getMaxIdleTime());
    assertFalse(engine.getSendServerVersion());
    assertEquals(99, engine.getThreadingParameters().getMinThreads());
    assertEquals(777, engine.getThreadingParameters().getMaxThreads());
    assertEquals("AnotherPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    assertTrue("The engine should support session manager", engine.isSessionSupport());
    assertNotNull("The handlers should not be null", engine.getHandlers());
    assertEquals(1, engine.getHandlers().size());
    JettyHTTPDestination jd3 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "https://localhost:9002"), bus);
    engine = (JettyHTTPServerEngine) jd3.getEngine();
    assertEquals(111, engine.getThreadingParameters().getMinThreads());
    assertEquals(120, engine.getThreadingParameters().getMaxThreads());
    assertEquals("TestPrefix", engine.getThreadingParameters().getThreadNamePrefix());
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), true);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), true);
    JettyHTTPDestination jd4 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo2", "https://localhost:9003"), bus);
    engine = (JettyHTTPServerEngine) jd4.getEngine();
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(), false);
    assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(), false);
    JettyHTTPDestination jd5 = (JettyHTTPDestination) factory.getDestination(getEndpointInfo("sna", "foo", "http://localhost:9100"), bus);
    engine = (JettyHTTPServerEngine) jd5.getEngine();
    String r = "expected fallback thread parameters configured for port 0";
    assertNotNull(r, engine.getThreadingParameters());
    assertEquals(r, 21, engine.getThreadingParameters().getMinThreads());
    assertEquals(r, 389, engine.getThreadingParameters().getMaxThreads());
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactory(org.apache.cxf.transport.DestinationFactory) Destination(org.apache.cxf.transport.Destination) JettyHTTPDestination(org.apache.cxf.transport.http_jetty.JettyHTTPDestination) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) ConfigurerImpl(org.apache.cxf.configuration.spring.ConfigurerImpl) QName(javax.xml.namespace.QName) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) EndpointInfo(org.apache.cxf.service.model.EndpointInfo) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) JettyHTTPServerEngine(org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine) ConduitInitiator(org.apache.cxf.transport.ConduitInitiator) JettyHTTPDestination(org.apache.cxf.transport.http_jetty.JettyHTTPDestination)

Aggregations

ConfigurerImpl (org.apache.cxf.configuration.spring.ConfigurerImpl)6 Bus (org.apache.cxf.Bus)5 QName (javax.xml.namespace.QName)3 EndpointInfo (org.apache.cxf.service.model.EndpointInfo)3 ConduitInitiator (org.apache.cxf.transport.ConduitInitiator)3 ConduitInitiatorManager (org.apache.cxf.transport.ConduitInitiatorManager)3 Destination (org.apache.cxf.transport.Destination)3 DestinationFactory (org.apache.cxf.transport.DestinationFactory)3 DestinationFactoryManager (org.apache.cxf.transport.DestinationFactoryManager)3 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)3 Configurer (org.apache.cxf.configuration.Configurer)2 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)2 Before (org.junit.Before)2 ConfiguredBeanLocator (org.apache.cxf.configuration.ConfiguredBeanLocator)1 ResourceManager (org.apache.cxf.resource.ResourceManager)1 NettyHttpDestination (org.apache.cxf.transport.http.netty.server.NettyHttpDestination)1 NettyHttpServerEngine (org.apache.cxf.transport.http.netty.server.NettyHttpServerEngine)1 JettyHTTPDestination (org.apache.cxf.transport.http_jetty.JettyHTTPDestination)1 JettyHTTPServerEngine (org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine)1 UndertowHTTPDestination (org.apache.cxf.transport.http_undertow.UndertowHTTPDestination)1