List of usage examples for org.springframework.jndi JndiObjectFactoryBean afterPropertiesSet
@Override public void afterPropertiesSet() throws IllegalArgumentException, NamingException
From source file:com.zekke.webapp.config.DataSourceConfig.java
/** * Creates a new DataSource./*from w ww . j ava2 s.c o m*/ * * @param jndiName the JNDI resource. * @return a DataSource. * @throws NamingException if the given JNDI resource doesn't exist. */ @Bean public DataSource dataSource(@Value("${jndi.name}") String jndiName) throws NamingException { JndiObjectFactoryBean jndiFactoryBean = new JndiObjectFactoryBean(); jndiFactoryBean.setJndiName(jndiName); jndiFactoryBean.afterPropertiesSet(); return (DataSource) jndiFactoryBean.getObject(); }
From source file:net.sourceforge.vulcan.jabber.JdbcScreenNameMapper.java
protected DataSource findDataSource() throws IllegalArgumentException, NamingException { final JndiObjectFactoryBean dsFactory = new JndiObjectFactoryBean(); dsFactory.setJndiName(config.getJndiName()); dsFactory.afterPropertiesSet(); return (DataSource) dsFactory.getObject(); }
From source file:com.evolveum.midpoint.repo.sql.DataSourceFactory.java
private DataSource createJNDIDataSource() throws IllegalArgumentException, NamingException { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(configuration.getDataSource()); factory.afterPropertiesSet(); return (DataSource) factory.getObject(); }
From source file:com.edgenius.core.service.impl.JavaMailSenderImpl.java
/** * MailSession JDNI name changed, reload JNDI object. * /* w w w . ja va 2s. c o m*/ */ public void resetMailSessionByJNDI(String jndiName) throws IllegalArgumentException, NamingException { //always reset session to null, so make "reset" meaningful. This is also a trick, as setSession() doesn't allow null //however, this.setJavaMailProperties(prop) will reset Session to null internally... this.setJavaMailProperties(new Properties()); JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName(jndiName); factory.afterPropertiesSet(); if (factory.getObject() instanceof Session) this.setSession((Session) factory.getObject()); else throw new IllegalArgumentException("JNDI object is not mail session instance"); }
From source file:sample.tomcat.jndi.Application.java
@Bean(destroyMethod = "") public DataSource jndiDataSource() throws IllegalArgumentException, NamingException { System.out.println("\n\n\nIn jndiDataSource\n\n\n"); JndiObjectFactoryBean bean = new JndiObjectFactoryBean(); bean.setJndiName("jdbc/MYDataSource"); bean.setProxyInterface(DataSource.class); bean.setLookupOnStartup(false);//from www. j a v a 2s. c o m bean.afterPropertiesSet(); return (DataSource) bean.getObject(); }
From source file:sample.tomcat.jndi.SampleTomcatJndiApplication.java
@Bean(destroyMethod = "") public DataSource jndiDataSource() throws IllegalArgumentException, NamingException { JndiObjectFactoryBean bean = new JndiObjectFactoryBean(); bean.setJndiName("java:comp/env/jdbc/myDataSource"); bean.setProxyInterface(DataSource.class); bean.setLookupOnStartup(false);/* w ww .ja va 2 s . c om*/ bean.afterPropertiesSet(); return (DataSource) bean.getObject(); }
From source file:com.redhat.rhtracking.config.JPAConfig.java
@Bean public DataSource jndiDataSource() throws NamingException { JndiObjectFactoryBean factory = new JndiObjectFactoryBean(); factory.setJndiName("java:/jdbc/rhtracking"); factory.setLookupOnStartup(true);/*from w w w . j a va 2s . c o m*/ factory.setProxyInterface(DataSource.class); factory.afterPropertiesSet(); return (DataSource) factory.getObject(); }
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(); 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 ww w .j av a2 s .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.github.dbourdette.glass.SpringConfig.java
@Bean public DataSource dataSource() throws Exception { if (configuration().isInMemory()) { return null; }// w w w. j a v a 2 s. c om JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean(); factoryBean.setJndiName("java:comp/env/jdbc/glassDb"); factoryBean.afterPropertiesSet(); return (DataSource) factoryBean.getObject(); }