List of usage examples for org.springframework.jndi JndiObjectFactoryBean afterPropertiesSet
@Override public void afterPropertiesSet() throws IllegalArgumentException, NamingException
From source file:com.mycompany.projetsportmanager.spring.configuration.DefaultProfileConfiguration.java
/** * Builds a JNDI datasource./* w ww . j ava2s .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(); 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(); 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(); 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(); 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(); return (DataSource) factory.getObject(); }
From source file:info.jtrac.mail.MailSender.java
private void initMailSenderFromJndi(String mailSessionJndiName) { logger.info("attempting to initialize mail sender from jndi name = '" + mailSessionJndiName + "'"); JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean(); factoryBean.setJndiName(mailSessionJndiName); // "java:comp/env/" will be prefixed if the JNDI name doesn't already have it factoryBean.setResourceRef(true);//w ww . j a v a 2s .c o m try { // this step actually does the JNDI lookup factoryBean.afterPropertiesSet(); } catch (Exception e) { logger.warn("failed to locate mail session : " + e); return; } Session session = (Session) factoryBean.getObject(); sender = new JavaMailSenderImpl(); sender.setSession(session); logger.info("email sender initialized from jndi name = '" + mailSessionJndiName + "'"); }
From source file:MailSender.java
private void initMailSenderFromJndi(String mailSessionJndiName) { logger.info("attempting to initialize mail sender from jndi name = '" + mailSessionJndiName + "'"); JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean(); factoryBean.setJndiName(mailSessionJndiName); // "java:comp/env/" will be prefixed if the JNDI name doesn't already // have it/*from w w w . j a v a 2 s. c o m*/ // major: the above behavoiur is already documented // in the class JndiObjectFactoryBean. Remove it. factoryBean.setResourceRef(true); try { // this step actually does the JNDI lookup factoryBean.afterPropertiesSet(); } catch (Exception e) { logger.warn("failed to locate mail session : " + e); return; } Session session = (Session) factoryBean.getObject(); sender = new JavaMailSenderImpl(); sender.setSession(session); logger.info("email sender initialized from jndi name = '" + mailSessionJndiName + "'"); }
From source file:gr.abiss.calipso.config.DataSourceFactoryBean.java
public Object getObject() throws Exception { if (StringUtils.hasText(dataSourceJndiName)) { logger.info("JNDI datasource requested, looking up datasource from JNDI name: '" + dataSourceJndiName + "'"); JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean(); factoryBean.setJndiName(dataSourceJndiName); // "java:comp/env/" will be prefixed if the JNDI name doesn't already have it factoryBean.setResourceRef(true); // this step actually does the JNDI lookup try {/* w w w . ja v a 2s. c o m*/ factoryBean.afterPropertiesSet(); } catch (Exception e) { logger.error("datasource init from JNDI failed : " + e); logger.error("aborting application startup"); throw new RuntimeException(e); } dataSource = (DataSource) factoryBean.getObject(); } else if (url.startsWith("jdbc:hsqldb:file")) { logger.info("embedded HSQLDB mode detected, switching on spring single connection data source"); SingleConnectionDataSource ds = new SingleConnectionDataSource(); ds.setUrl(url); ds.setDriverClassName(driverClassName); ds.setUsername(username); ds.setPassword(password); ds.setSuppressClose(true); dataSource = ds; } else { logger.info( "Not using embedded HSQLDB or JNDI datasource, switching on Apache DBCP data source connection pooling"); BasicDataSource ds = new BasicDataSource(); ds.setUrl(url); ds.setDriverClassName(driverClassName); ds.setUsername(username); ds.setPassword(password); ds.setValidationQuery(validationQuery); ds.setTestOnBorrow(false); ds.setTestWhileIdle(true); ds.setTimeBetweenEvictionRunsMillis(600000); dataSource = ds; } return dataSource; }