Search in sources :

Example 6 with ConfiguredBeanLocator

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

the class MetricsFeature method createDefaultProvidersIfNeeded.

private void createDefaultProvidersIfNeeded(Bus bus) {
    if (providers == null) {
        ConfiguredBeanLocator b = bus.getExtension(ConfiguredBeanLocator.class);
        if (b != null) {
            Collection<?> coll = b.getBeansOfType(MetricsProvider.class);
            if (coll != null) {
                providers = coll.toArray(new MetricsProvider[] {});
            }
        }
    }
    if (providers == null) {
        try {
            Class<?> cls = ClassLoaderUtils.loadClass("org.apache.cxf.metrics.codahale.CodahaleMetricsProvider", MetricsFeature.class);
            Constructor<?> c = cls.getConstructor(Bus.class);
            providers = new MetricsProvider[] { (MetricsProvider) c.newInstance(bus) };
        } catch (Throwable t) {
        // ignore;
        }
    }
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator)

Example 7 with ConfiguredBeanLocator

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

the class AssertionBuilderRegistryImpl method loadDynamic.

protected synchronized void loadDynamic() {
    if (!dynamicLoaded && bus != null) {
        dynamicLoaded = true;
        ConfiguredBeanLocator c = bus.getExtension(ConfiguredBeanLocator.class);
        if (c != null) {
            c.getBeansOfType(AssertionBuilderLoader.class);
            for (AssertionBuilder<?> b : c.getBeansOfType(AssertionBuilder.class)) {
                registerBuilder(b);
            }
        }
    }
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator)

Example 8 with ConfiguredBeanLocator

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

the class DomainExpressionBuilderRegistry method loadDynamic.

protected synchronized void loadDynamic() {
    if (!dynamicLoaded && bus != null) {
        dynamicLoaded = true;
        ConfiguredBeanLocator c = bus.getExtension(ConfiguredBeanLocator.class);
        if (c != null) {
            for (DomainExpressionBuilder b : c.getBeansOfType(DomainExpressionBuilder.class)) {
                for (QName q : b.getDomainExpressionTypes()) {
                    register(q, b);
                }
            }
        }
    }
}
Also used : ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) QName(javax.xml.namespace.QName)

Example 9 with ConfiguredBeanLocator

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

the class JMSConfigFactory method createFromEndpoint.

/**
 * @param bus
 * @param endpointInfo
 * @return
 */
public static JMSConfiguration createFromEndpoint(Bus bus, JMSEndpoint endpoint) {
    JMSConfiguration jmsConfig = new JMSConfiguration();
    int deliveryMode = endpoint.getDeliveryMode() == org.apache.cxf.transport.jms.uri.JMSEndpoint.DeliveryModeType.PERSISTENT ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
    jmsConfig.setDeliveryMode(deliveryMode);
    jmsConfig.setPriority(endpoint.getPriority());
    jmsConfig.setExplicitQosEnabled(true);
    jmsConfig.setMessageType(endpoint.getMessageType().value());
    boolean pubSubDomain = endpoint.getJmsVariant().contains(JMSEndpoint.TOPIC);
    jmsConfig.setPubSubDomain(pubSubDomain);
    jmsConfig.setDurableSubscriptionName(endpoint.getDurableSubscriptionName());
    jmsConfig.setDurableSubscriptionClientId(endpoint.getDurableSubscriptionClientId());
    jmsConfig.setReceiveTimeout(endpoint.getReceiveTimeout());
    jmsConfig.setTimeToLive(endpoint.getTimeToLive());
    jmsConfig.setSessionTransacted(endpoint.isSessionTransacted());
    if (!endpoint.isUseConduitIdSelector()) {
        jmsConfig.setUseConduitIdSelector(endpoint.isUseConduitIdSelector());
    }
    jmsConfig.setConduitSelectorPrefix(endpoint.getConduitIdSelectorPrefix());
    jmsConfig.setUserName(endpoint.getUsername());
    jmsConfig.setPassword(endpoint.getPassword());
    jmsConfig.setConcurrentConsumers(endpoint.getConcurrentConsumers());
    jmsConfig.setOneSessionPerConnection(endpoint.isOneSessionPerConnection());
    jmsConfig.setMessageSelector(endpoint.getMessageSelector());
    TransactionManager tm = getTransactionManager(bus, endpoint);
    jmsConfig.setTransactionManager(tm);
    if (endpoint.getJndiURL() != null) {
        // Configure Connection Factory using jndi
        jmsConfig.setJndiEnvironment(JMSConfigFactory.getInitialContextEnv(endpoint));
        jmsConfig.setConnectionFactoryName(endpoint.getJndiConnectionFactoryName());
    } else {
        ConfiguredBeanLocator locator = bus.getExtension(ConfiguredBeanLocator.class);
        if (endpoint.getConnectionFactory() != null) {
            jmsConfig.setConnectionFactory(endpoint.getConnectionFactory());
        } else if (locator != null) {
            // Configure ConnectionFactory using locator
            // Lookup connectionFactory in context like blueprint
            ConnectionFactory cf = locator.getBeanOfType(endpoint.getJndiConnectionFactoryName(), ConnectionFactory.class);
            if (cf != null) {
                jmsConfig.setConnectionFactory(cf);
            }
        }
    }
    boolean resolveUsingJndi = endpoint.getJmsVariant().contains(JMSEndpoint.JNDI);
    if (resolveUsingJndi) {
        // Setup Destination jndi destination resolver
        JndiHelper jt = new JndiHelper(JMSConfigFactory.getInitialContextEnv(endpoint));
        final JMSDestinationResolver jndiDestinationResolver = new JMSDestinationResolver();
        jndiDestinationResolver.setJndiTemplate(jt);
        jmsConfig.setDestinationResolver(jndiDestinationResolver);
        jmsConfig.setTargetDestination(endpoint.getDestinationName());
        setReplyDestination(jmsConfig, endpoint);
    } else {
        // Use the default dynamic destination resolver
        jmsConfig.setTargetDestination(endpoint.getDestinationName());
        setReplyDestination(jmsConfig, endpoint);
    }
    String requestURI = endpoint.getRequestURI();
    jmsConfig.setRequestURI(requestURI);
    String targetService = endpoint.getTargetService();
    jmsConfig.setTargetService(targetService);
    jmsConfig.setMessageSelector(endpoint.getMessageSelector());
    int retryInterval = endpoint.getRetryInterval();
    jmsConfig.setRetryInterval(retryInterval);
    return jmsConfig;
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) JndiHelper(org.apache.cxf.transport.jms.util.JndiHelper) ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) TransactionManager(javax.transaction.TransactionManager) JMSDestinationResolver(org.apache.cxf.transport.jms.util.JMSDestinationResolver) JMSEndpoint(org.apache.cxf.transport.jms.uri.JMSEndpoint)

Example 10 with ConfiguredBeanLocator

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

the class JMSConfigFactoryTest method testTransactionManagerFromBus.

@Test
public void testTransactionManagerFromBus() throws XAException, NamingException {
    Bus bus = BusFactory.newInstance().createBus();
    ConfiguredBeanLocator cbl = bus.getExtension(ConfiguredBeanLocator.class);
    MyBeanLocator mybl = new MyBeanLocator(cbl);
    bus.setExtension(mybl, ConfiguredBeanLocator.class);
    TransactionManager tmExpected = new GeronimoTransactionManager();
    mybl.register("tm", tmExpected);
    tmByName(bus, tmExpected);
    tmByClass(bus, tmExpected);
}
Also used : Bus(org.apache.cxf.Bus) ConfiguredBeanLocator(org.apache.cxf.configuration.ConfiguredBeanLocator) GeronimoTransactionManager(org.apache.geronimo.transaction.manager.GeronimoTransactionManager) TransactionManager(javax.transaction.TransactionManager) MyBeanLocator(org.apache.cxf.transport.jms.uri.MyBeanLocator) GeronimoTransactionManager(org.apache.geronimo.transaction.manager.GeronimoTransactionManager) Test(org.junit.Test)

Aggregations

ConfiguredBeanLocator (org.apache.cxf.configuration.ConfiguredBeanLocator)17 TransactionManager (javax.transaction.TransactionManager)4 Resource (javax.annotation.Resource)3 ConnectionFactory (javax.jms.ConnectionFactory)1 JMException (javax.management.JMException)1 SystemException (javax.transaction.SystemException)1 QName (javax.xml.namespace.QName)1 Bus (org.apache.cxf.Bus)1 BusException (org.apache.cxf.BusException)1 AbstractBindingFactory (org.apache.cxf.binding.AbstractBindingFactory)1 BindingFactory (org.apache.cxf.binding.BindingFactory)1 BusLifeCycleManager (org.apache.cxf.buslifecycle.BusLifeCycleManager)1 ConfigurerImpl (org.apache.cxf.configuration.spring.ConfigurerImpl)1 InstrumentationManager (org.apache.cxf.management.InstrumentationManager)1 ResourceManager (org.apache.cxf.resource.ResourceManager)1 JMSEndpoint (org.apache.cxf.transport.jms.uri.JMSEndpoint)1 MyBeanLocator (org.apache.cxf.transport.jms.uri.MyBeanLocator)1 JMSDestinationResolver (org.apache.cxf.transport.jms.util.JMSDestinationResolver)1 JndiHelper (org.apache.cxf.transport.jms.util.JndiHelper)1 AutomaticWorkQueue (org.apache.cxf.workqueue.AutomaticWorkQueue)1