Search in sources :

Example 1 with Configurer

use of org.apache.cxf.configuration.Configurer in project cxf by apache.

the class WSAFeatureXmlTest method testClientProxyFactory.

@Test
public void testClientProxyFactory() {
    JaxWsProxyFactoryBean cf = new JaxWsProxyFactoryBean();
    cf.setAddress("http://localhost:" + PORT + "/test");
    cf.setServiceClass(Greeter.class);
    cf.setBus(getBus());
    Configurer c = getBus().getExtension(Configurer.class);
    c.configureBean("client.proxyFactory", cf);
    Greeter greeter = (Greeter) cf.create();
    Client client = ClientProxy.getClient(greeter);
    checkAddressInterceptors(client.getInInterceptors());
}
Also used : Greeter(org.apache.hello_world_soap_http.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) Configurer(org.apache.cxf.configuration.Configurer) Client(org.apache.cxf.endpoint.Client) Test(org.junit.Test) AbstractCXFTest(org.apache.cxf.test.AbstractCXFTest)

Example 2 with Configurer

use of org.apache.cxf.configuration.Configurer in project cxf by apache.

the class ExtensionManagerImpl method loadAndRegister.

final void loadAndRegister(Extension e) {
    Class<?> cls = null;
    if (null != e.getInterfaceName() && !"".equals(e.getInterfaceName())) {
        cls = e.loadInterface(loader);
    } else {
        cls = e.getClassObject(loader);
    }
    if (null != activated && null != cls && null != activated.get(cls)) {
        return;
    }
    synchronized (e) {
        Object obj = e.load(loader, bus);
        if (obj == null) {
            return;
        }
        if (null != activated) {
            Configurer configurer = (Configurer) (activated.get(Configurer.class));
            if (null != configurer) {
                configurer.configureBean(obj);
            }
        }
        // let the object know for which namespaces it has been activated
        ResourceResolver namespacesResolver = null;
        if (null != e.getNamespaces()) {
            namespacesResolver = new SinglePropertyResolver(ACTIVATION_NAMESPACES_PROPERTY_NAME, e.getNamespaces());
            resourceManager.addResourceResolver(namespacesResolver);
        }
        // Now we call the setActivationNamespaces method directly here
        if (e.getNamespaces() != null && !e.getNamespaces().isEmpty()) {
            invokeSetterActivationNSMethod(obj, e.getNamespaces());
        }
        ResourceInjector injector = new ResourceInjector(resourceManager);
        try {
            injector.inject(obj);
            injector.construct(obj);
        } finally {
            if (null != namespacesResolver) {
                resourceManager.removeResourceResolver(namespacesResolver);
            }
        }
        if (null != activated) {
            if (cls == null) {
                cls = obj.getClass();
            }
            activated.put(cls, obj);
        }
    }
}
Also used : SinglePropertyResolver(org.apache.cxf.resource.SinglePropertyResolver) ResourceResolver(org.apache.cxf.resource.ResourceResolver) Configurer(org.apache.cxf.configuration.Configurer) ResourceInjector(org.apache.cxf.common.injection.ResourceInjector)

Example 3 with Configurer

use of org.apache.cxf.configuration.Configurer in project cxf by apache.

the class SpringBusFactoryTest method testDefault.

@Test
public void testDefault() {
    Bus bus = new SpringBusFactory().createBus();
    assertNotNull(bus);
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    assertNotNull("No binding factory manager", bfm);
    assertNotNull("No configurer", bus.getExtension(Configurer.class));
    assertNotNull("No resource manager", bus.getExtension(ResourceManager.class));
    assertNotNull("No destination factory manager", bus.getExtension(DestinationFactoryManager.class));
    assertNotNull("No conduit initiator manager", bus.getExtension(ConduitInitiatorManager.class));
    assertNotNull("No phase manager", bus.getExtension(PhaseManager.class));
    assertNotNull("No workqueue manager", bus.getExtension(WorkQueueManager.class));
    assertNotNull("No lifecycle manager", bus.getExtension(BusLifeCycleManager.class));
    assertNotNull("No service registry", bus.getExtension(ServerRegistry.class));
    try {
        bfm.getBindingFactory("http://cxf.apache.org/unknown");
    } catch (BusException ex) {
    // expected
    }
    assertEquals("Unexpected interceptors", 0, bus.getInInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getInFaultInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getOutInterceptors().size());
    assertEquals("Unexpected interceptors", 0, bus.getOutFaultInterceptors().size());
}
Also used : Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) PhaseManager(org.apache.cxf.phase.PhaseManager) ConduitInitiatorManager(org.apache.cxf.transport.ConduitInitiatorManager) ServerRegistry(org.apache.cxf.endpoint.ServerRegistry) BusLifeCycleManager(org.apache.cxf.buslifecycle.BusLifeCycleManager) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) ResourceManager(org.apache.cxf.resource.ResourceManager) Configurer(org.apache.cxf.configuration.Configurer) WorkQueueManager(org.apache.cxf.workqueue.WorkQueueManager) BusException(org.apache.cxf.BusException) Test(org.junit.Test)

Example 4 with Configurer

use of org.apache.cxf.configuration.Configurer 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 5 with Configurer

use of org.apache.cxf.configuration.Configurer in project cxf by apache.

the class NettyHttpServerEngineTest method setUp.

@Before
public void setUp() throws Exception {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    Configurer configurer = control.createMock(Configurer.class);
    bus.getExtension(Configurer.class);
    EasyMock.expectLastCall().andReturn(configurer).anyTimes();
    control.replay();
    factory = new NettyHttpServerEngineFactory();
    factory.setBus(bus);
}
Also used : Bus(org.apache.cxf.Bus) Configurer(org.apache.cxf.configuration.Configurer) Before(org.junit.Before)

Aggregations

Configurer (org.apache.cxf.configuration.Configurer)15 Bus (org.apache.cxf.Bus)7 Before (org.junit.Before)4 Test (org.junit.Test)4 URL (java.net.URL)2 ResourceInjector (org.apache.cxf.common.injection.ResourceInjector)2 ConfigurerImpl (org.apache.cxf.configuration.spring.ConfigurerImpl)2 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)2 ResourceResolver (org.apache.cxf.resource.ResourceResolver)2 SinglePropertyResolver (org.apache.cxf.resource.SinglePropertyResolver)2 AbstractCXFTest (org.apache.cxf.test.AbstractCXFTest)2 BindingCustomization (org.jboss.ws.api.binding.BindingCustomization)2 File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 InvalidPropertyException (javax.resource.spi.InvalidPropertyException)1 QName (javax.xml.namespace.QName)1 BusException (org.apache.cxf.BusException)1 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1 BusLifeCycleManager (org.apache.cxf.buslifecycle.BusLifeCycleManager)1