Search in sources :

Example 1 with JndiObjectFactoryBean

use of org.springframework.jndi.JndiObjectFactoryBean in project vorto by eclipse.

the class QPidConfiguration method honoConnectionFactory.

@Bean
public JndiObjectFactoryBean honoConnectionFactory() {
    JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
    jndiObjectFactoryBean.setJndiTemplate(jndiTemplate());
    jndiObjectFactoryBean.setJndiName("vorto");
    return jndiObjectFactoryBean;
}
Also used : JndiObjectFactoryBean(org.springframework.jndi.JndiObjectFactoryBean) PropertiesFactoryBean(org.springframework.beans.factory.config.PropertiesFactoryBean) JndiObjectFactoryBean(org.springframework.jndi.JndiObjectFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 2 with JndiObjectFactoryBean

use of org.springframework.jndi.JndiObjectFactoryBean in project midpoint by Evolveum.

the class DataSourceFactory method createJNDIDataSource.

private DataSource createJNDIDataSource() throws IllegalArgumentException, NamingException {
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiName(configuration.getDataSource());
    factory.afterPropertiesSet();
    return (DataSource) factory.getObject();
}
Also used : JndiObjectFactoryBean(org.springframework.jndi.JndiObjectFactoryBean) DataSource(javax.sql.DataSource) ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource)

Example 3 with JndiObjectFactoryBean

use of org.springframework.jndi.JndiObjectFactoryBean in project midpoint by Evolveum.

the class DataSourceFactory method createJndiDataSource.

private DataSource createJndiDataSource() throws IllegalArgumentException, NamingException {
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiName(configuration.getDataSource());
    factory.afterPropertiesSet();
    return (DataSource) factory.getObject();
}
Also used : JndiObjectFactoryBean(org.springframework.jndi.JndiObjectFactoryBean) HikariDataSource(com.zaxxer.hikari.HikariDataSource) DataSource(javax.sql.DataSource)

Example 4 with JndiObjectFactoryBean

use of org.springframework.jndi.JndiObjectFactoryBean in project symmetric-ds by JumpMind.

the class ClientSymmetricEngine method createDatabasePlatform.

public static IDatabasePlatform createDatabasePlatform(ApplicationContext springContext, TypedProperties properties, DataSource dataSource, boolean waitOnAvailableDatabase) {
    if (dataSource == null) {
        String jndiName = properties.getProperty(ParameterConstants.DB_JNDI_NAME);
        if (StringUtils.isNotBlank(jndiName)) {
            try {
                log.info("Looking up datasource in jndi.  The jndi name is {}", jndiName);
                JndiObjectFactoryBean jndiFactory = new JndiObjectFactoryBean();
                jndiFactory.setJndiName(jndiName);
                jndiFactory.afterPropertiesSet();
                dataSource = (DataSource) jndiFactory.getObject();
                if (dataSource == null) {
                    throw new SymmetricException("Could not locate the configured datasource in jndi.  The jndi name is %s", jndiName);
                }
            } catch (IllegalArgumentException e) {
                throw new SymmetricException("Could not locate the configured datasource in jndi.  The jndi name is %s", e, jndiName);
            } catch (NamingException e) {
                throw new SymmetricException("Could not locate the configured datasource in jndi.  The jndi name is %s", e, jndiName);
            }
        }
        String springBeanName = properties.getProperty(ParameterConstants.DB_SPRING_BEAN_NAME);
        if (isNotBlank(springBeanName) && springContext != null) {
            log.info("Using datasource from spring.  The spring bean name is {}", springBeanName);
            dataSource = (DataSource) springContext.getBean(springBeanName);
        }
        if (dataSource == null) {
            dataSource = BasicDataSourceFactory.create(properties, SecurityServiceFactory.create(SecurityServiceType.CLIENT, properties));
        }
    }
    if (waitOnAvailableDatabase) {
        waitForAvailableDatabase(dataSource);
    }
    boolean delimitedIdentifierMode = properties.is(ParameterConstants.DB_DELIMITED_IDENTIFIER_MODE, true);
    return JdbcDatabasePlatformFactory.createNewPlatformInstance(dataSource, createSqlTemplateSettings(properties), delimitedIdentifierMode);
}
Also used : NamingException(javax.naming.NamingException) JndiObjectFactoryBean(org.springframework.jndi.JndiObjectFactoryBean)

Aggregations

JndiObjectFactoryBean (org.springframework.jndi.JndiObjectFactoryBean)4 DataSource (javax.sql.DataSource)2 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)1 HikariDataSource (com.zaxxer.hikari.HikariDataSource)1 NamingException (javax.naming.NamingException)1 PropertiesFactoryBean (org.springframework.beans.factory.config.PropertiesFactoryBean)1 Bean (org.springframework.context.annotation.Bean)1