Search in sources :

Example 16 with BusFactory

use of org.apache.cxf.BusFactory in project cxf by apache.

the class BusServer method run.

protected void run() {
    // 
    // Just instantiate the Bus; services will be instantiated
    // and published automatically through Spring
    // 
    final BusFactory factory = BusFactory.newInstance();
    Bus bus = factory.createBus();
    setBus(bus);
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
}
Also used : Bus(org.apache.cxf.Bus) BusFactory(org.apache.cxf.BusFactory)

Example 17 with BusFactory

use of org.apache.cxf.BusFactory in project cxf by apache.

the class BusServer method run.

protected void run() {
    // 
    // Just instantiate the Bus; services will be instantiated
    // and published automatically through Spring
    // 
    final BusFactory factory = BusFactory.newInstance();
    Bus bus = factory.createBus();
    setBus(bus);
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
}
Also used : Bus(org.apache.cxf.Bus) BusFactory(org.apache.cxf.BusFactory)

Example 18 with BusFactory

use of org.apache.cxf.BusFactory in project cxf by apache.

the class JCABusFactory method init.

protected synchronized void init() throws ResourceException {
    LOG.info("Initializing the CXF Bus ...");
    new UriHandlerInit();
    ClassLoader original = Thread.currentThread().getContextClassLoader();
    try {
        ClassLoader cl = this.getClass().getClassLoader();
        // ensure resourceadapter: url handler can be found by URLFactory
        Thread.currentThread().setContextClassLoader(cl);
        // TODO Check for the managed connection factory properties
        // TODO We may need get the configuration file from properties
        BusFactory bf = BusFactory.newInstance();
        bus = bf.createBus();
        initializeServants();
    } catch (Exception ex) {
        if (ex instanceof ResourceAdapterInternalException) {
            throw (ResourceException) ex;
        }
        throw new ResourceAdapterInternalException(new Message("FAIL_TO_INITIALIZE_JCABUSFACTORY", BUNDLE).toString(), ex);
    } finally {
        Thread.currentThread().setContextClassLoader(original);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) BusFactory(org.apache.cxf.BusFactory) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) UriHandlerInit(org.apache.cxf.jca.core.resourceadapter.UriHandlerInit) ResourceException(javax.resource.ResourceException) ResourceAdapterInternalException(org.apache.cxf.jca.core.resourceadapter.ResourceAdapterInternalException) IOException(java.io.IOException)

Example 19 with BusFactory

use of org.apache.cxf.BusFactory in project cxf by apache.

the class MessageIdAsCorrelationIdJMSConduitTest method sendAndReceive.

public void sendAndReceive(boolean synchronous, String replyDestination) throws Exception {
    BusFactory bf = BusFactory.newInstance();
    Bus bus = bf.createBus();
    BusFactory.setDefaultBus(bus);
    EndpointReferenceType target = new EndpointReferenceType();
    connectionFactory = new PooledConnectionFactory(BROKER_URI);
    TestReceiver receiver = new TestReceiver(connectionFactory, SERVICE_QUEUE, true);
    receiver.runAsync();
    JMSConfiguration jmsConfig = new JMSConfiguration();
    jmsConfig.setTargetDestination(SERVICE_QUEUE);
    jmsConfig.setConnectionFactory(connectionFactory);
    jmsConfig.setUseConduitIdSelector(false);
    jmsConfig.setReplyDestination(replyDestination);
    JMSConduit conduit = new JMSConduit(target, jmsConfig, bus);
    Exchange exchange = new ExchangeImpl();
    exchange.setSynchronous(synchronous);
    Message message = new MessageImpl();
    exchange.setOutMessage(message);
    conduit.sendExchange(exchange, "Request");
    waitForAsyncReply(exchange);
    receiver.close();
    if (exchange.getInMessage() == null) {
        throw new RuntimeException("No reply received within 2 seconds");
    }
    JMSMessageHeadersType inHeaders = (JMSMessageHeadersType) exchange.getInMessage().get(JMSConstants.JMS_CLIENT_RESPONSE_HEADERS);
    Assert.assertEquals(receiver.getRequestMessageId(), inHeaders.getJMSCorrelationID());
    conduit.close();
    bus.shutdown(true);
}
Also used : Bus(org.apache.cxf.Bus) EndpointReferenceType(org.apache.cxf.ws.addressing.EndpointReferenceType) Message(org.apache.cxf.message.Message) BusFactory(org.apache.cxf.BusFactory) TestReceiver(org.apache.cxf.transport.jms.util.TestReceiver) Exchange(org.apache.cxf.message.Exchange) PooledConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) MessageImpl(org.apache.cxf.message.MessageImpl) ExchangeImpl(org.apache.cxf.message.ExchangeImpl)

Example 20 with BusFactory

use of org.apache.cxf.BusFactory in project jbossws-cxf by jbossws.

the class Helper method verifyCXF.

public static void verifyCXF() {
    // check BusFactory customization; this is required by the JBWS-CXF Configurer integration (HTTPConduit customization, JAXBIntros, ...)
    BusFactory factory = BusFactory.newInstance();
    if (!(factory instanceof JBossWSBusFactory))
        throw new RuntimeException("Expected " + JBossWSBusFactory.class + " but got " + (factory == null ? null : factory.getClass()));
    // check the Apache CXF JAXWS implementation is actually used
    Object obj = getImplementationObject();
    if (!obj.getClass().getName().contains("cxf"))
        throw new RuntimeException("JAXWS implementation is not properly selected or endorsed!");
}
Also used : JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory) BusFactory(org.apache.cxf.BusFactory) JBossWSBusFactory(org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory)

Aggregations

BusFactory (org.apache.cxf.BusFactory)20 Bus (org.apache.cxf.Bus)14 Test (org.junit.Test)5 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)4 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)4 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)4 JaxWsDynamicClientFactory (org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory)4 CXFBusFactory (org.apache.cxf.bus.CXFBusFactory)3 JBossWSBusFactory (org.jboss.wsf.stack.cxf.client.configuration.JBossWSBusFactory)3 Subject (javax.security.auth.Subject)2 ExtensionManagerBus (org.apache.cxf.bus.extension.ExtensionManagerBus)2 Before (org.junit.Before)2 IOException (java.io.IOException)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ResourceException (javax.resource.ResourceException)1 ManagedConnection (javax.resource.spi.ManagedConnection)1 QName (javax.xml.namespace.QName)1 PooledConnectionFactory (org.apache.activemq.pool.PooledConnectionFactory)1