List of usage examples for org.springframework.jndi JndiObjectFactoryBean setExpectedType
public void setExpectedType(@Nullable Class<?> expectedType)
From source file:com.javaetmoi.sample.config.DataSourceConfig.java
@Bean @Profile("javaee") public JndiObjectFactoryBean dataSource() throws IllegalArgumentException { JndiObjectFactoryBean dataSource = new JndiObjectFactoryBean(); dataSource.setExpectedType(DataSource.class); dataSource.setJndiName(env.getProperty("jdbc.jndiDataSource")); return dataSource; }
From source file:dk.nsi.haiba.minipasconverter.config.MinipasConverterConfiguration.java
@Bean public DataSource minipasDataSource() throws Exception { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(minipasJNDIName); factory.setExpectedType(DataSource.class); factory.afterPropertiesSet();/*from w w w. ja v a2 s .c o m*/ return (DataSource) factory.getObject(); }
From source file:dk.nsi.haiba.minipasconverter.config.MinipasConverterConfiguration.java
@Bean public DataSource haibaDataSource() throws Exception { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(haibaJNDIName);/*from w w w.j a v a2s . co m*/ factory.setExpectedType(DataSource.class); factory.afterPropertiesSet(); DataSource dataSource = (DataSource) factory.getObject(); // requires manual transaction handling dataSource.getConnection().setAutoCommit(false); return dataSource; }
From source file:com.mycompany.projetsportmanager.spring.configuration.DefaultProfileConfiguration.java
/** * Builds a JNDI datasource./*from w w w . j av a2 s.c o m*/ * @return the datasource. */ @Bean(destroyMethod = "") public DataSource dataSource() { JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean(); jndiObjectFactoryBean.setJndiName("jdbc/ProjetSportManager"); jndiObjectFactoryBean.setResourceRef(true); jndiObjectFactoryBean.setExpectedType(DataSource.class); try { jndiObjectFactoryBean.afterPropertiesSet(); } catch (NamingException e) { throw new RuntimeException(e); } return (DataSource) jndiObjectFactoryBean.getObject(); }
From source file:dk.nsi.haiba.epimibaimporter.config.EPIMIBAConfiguration.java
@Bean @Qualifier("haibaDataSource") public DataSource haibaDataSource() throws Exception { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(haibaJdbcJNDIName); factory.setExpectedType(DataSource.class); factory.afterPropertiesSet();/*from w w w . j a v a 2 s. c o m*/ return (DataSource) factory.getObject(); }
From source file:dk.nsi.haiba.epimibaimporter.config.EPIMIBAConfiguration.java
@Bean @Qualifier("classificationDataSource") public DataSource classificationDataSource() throws Exception { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(classificationJdbcJNDIName); factory.setExpectedType(DataSource.class); factory.afterPropertiesSet();//from w w w .ja va 2s. c om return (DataSource) factory.getObject(); }
From source file:dk.nsi.haiba.lprimporter.config.LPRConfiguration.java
@Bean public DataSource lprDataSource() throws Exception { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(lprJdbcJNDIName); factory.setExpectedType(DataSource.class); factory.afterPropertiesSet();//from ww w. j a v a2 s. c o m return (DataSource) factory.getObject(); }
From source file:dk.nsi.haiba.lprimporter.config.LPRConfiguration.java
@Bean public DataSource haibaDataSource() throws Exception { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(haibaJdbcJNDIName); factory.setExpectedType(DataSource.class); factory.afterPropertiesSet();// www.j a va 2s .com return (DataSource) factory.getObject(); }
From source file:dk.nsi.haiba.lprimporter.config.LPRConfiguration.java
@Bean public DataSource lprDataSourceMinipas() throws Exception { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(lprJdbcJNDIName_minipas); factory.setExpectedType(DataSource.class); factory.afterPropertiesSet();/*from w w w. ja v a 2s . com*/ return (DataSource) factory.getObject(); }
From source file:org.nema.medical.mint.server.ServerConfig.java
@Bean(destroyMethod = "close") public SessionFactory sessionFactory() throws Exception { if (sessionFactory == null) { final AnnotationSessionFactoryBean annotationSessionFactoryBean = new AnnotationSessionFactoryBean(); if (StringUtils.isBlank(getConfigString("hibernate.connection.datasource"))) { // Not using JNDI data source final BasicDataSource dataSource = new BasicDataSource(); dataSource.setDriverClassName(getConfigString("hibernate.connection.driver_class")); String url = getConfigString("hibernate.connection.url"); url = url.replace("$MINT_HOME", mintHome().getPath()); dataSource.setUrl(url);/* ww w . j a v a2 s . c om*/ dataSource.setUsername(getConfigString("hibernate.connection.username")); dataSource.setPassword(getConfigString("hibernate.connection.password")); annotationSessionFactoryBean.setDataSource(dataSource); } else { // Using a JNDI dataSource final JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean(); jndiObjectFactoryBean.setExpectedType(DataSource.class); jndiObjectFactoryBean.setJndiName(getConfigString("hibernate.connection.datasource")); jndiObjectFactoryBean.afterPropertiesSet(); annotationSessionFactoryBean.setDataSource((DataSource) jndiObjectFactoryBean.getObject()); } final Properties hibernateProperties = new Properties(); hibernateProperties.put("hibernate.connection.autocommit", Boolean.TRUE); final String dialect = getConfigString("hibernate.dialect"); if (StringUtils.isNotBlank(dialect)) { hibernateProperties.put("hibernate.dialect", dialect); } final String hbm2dll = getConfigString("hibernate.hbm2ddl.auto"); hibernateProperties.put("hibernate.hbm2ddl.auto", hbm2dll == null ? "verify" : hbm2dll); hibernateProperties.put("hibernate.show_sql", "true".equalsIgnoreCase(getConfigString("hibernate.show_sql"))); hibernateProperties.put("hibernate.c3p0.max_statement", 50); hibernateProperties.put("hibernate.c3p0.maxPoolSize", 20); hibernateProperties.put("hibernate.c3p0.minPoolSize", 5); hibernateProperties.put("hibernate.c3p0.testConnectionOnCheckout", Boolean.FALSE); hibernateProperties.put("hibernate.c3p0.timeout", 600); annotationSessionFactoryBean.setHibernateProperties(hibernateProperties); annotationSessionFactoryBean.setPackagesToScan(getPackagesToScan()); annotationSessionFactoryBean.afterPropertiesSet(); sessionFactory = annotationSessionFactoryBean.getObject(); } return sessionFactory; }