Search in sources :

Example 1 with JMSConnectionFactory

use of io.micronaut.jms.annotations.JMSConnectionFactory in project micronaut-jms by micronaut-projects.

the class JMSConnectionFactoryBeanProcessor method process.

@Override
public void process(BeanDefinition<?> beanDefinition, BeanContext context) {
    final Object candidate = context.getBean(beanDefinition);
    Assert.isTrue(candidate instanceof ConnectionFactory, () -> "@JMSConnectionFactory can only be applied to a bean of type javax.jms.ConnectionFactory. " + "Provided class was " + candidate.getClass().getName());
    final ConnectionFactory connectionFactory = (ConnectionFactory) candidate;
    final String name = beanDefinition.stringValue(JMSConnectionFactory.class).orElseThrow(() -> new ConfigurationException("@JMSConnectionFactory must specify a name for the bean."));
    context.registerSingleton(JMSConnectionPool.class, new JMSConnectionPool(connectionFactory, properties.getInitialPoolSize(), properties.getMaxPoolSize()), Qualifiers.byName(name));
    logger.debug("created JMSConnectionPool bean '{}' for ConnectionFactory {}", name, connectionFactory.getClass().getName());
}
Also used : JMSConnectionFactory(io.micronaut.jms.annotations.JMSConnectionFactory) ConnectionFactory(javax.jms.ConnectionFactory) JMSConnectionPool(io.micronaut.jms.pool.JMSConnectionPool) ConfigurationException(io.micronaut.context.exceptions.ConfigurationException) JMSConnectionFactory(io.micronaut.jms.annotations.JMSConnectionFactory)

Aggregations

ConfigurationException (io.micronaut.context.exceptions.ConfigurationException)1 JMSConnectionFactory (io.micronaut.jms.annotations.JMSConnectionFactory)1 JMSConnectionPool (io.micronaut.jms.pool.JMSConnectionPool)1 ConnectionFactory (javax.jms.ConnectionFactory)1