Java Code Examples for org.springframework.jndi.JndiObjectFactoryBean#setJndiName()
The following examples show how to use
org.springframework.jndi.JndiObjectFactoryBean#setJndiName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShardingSpringBootConfiguration.java From seata-samples with Apache License 2.0 | 6 votes |
private DataSource getJndiDataSource(final String jndiName) throws NamingException { JndiObjectFactoryBean bean = new JndiObjectFactoryBean(); bean.setResourceRef(true); bean.setJndiName(jndiName); bean.setProxyInterface(DataSource.class); bean.afterPropertiesSet(); return (DataSource) bean.getObject(); }
Example 2
Source File: DataSourceConfig.java From Project with Apache License 2.0 | 5 votes |
/** * <p>描述:jndi数据源;生产环境</p> * @return * @author LZC * @date 2019-02-14 17:38 */ @Bean @Profile("prod") public DataSource jndiDataSource() { JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean(); jndiObjectFactoryBean.setJndiName("jdbc/myDS"); jndiObjectFactoryBean.setResourceRef(true); jndiObjectFactoryBean.setProxyInterface(DataSource.class); return (DataSource) jndiObjectFactoryBean.getObject(); }
Example 3
Source File: DataSourceMapSetter.java From shardingsphere with Apache License 2.0 | 5 votes |
private static DataSource getJNDIDataSource(final String jndiName) throws NamingException { JndiObjectFactoryBean bean = new JndiObjectFactoryBean(); bean.setResourceRef(true); bean.setJndiName(jndiName); bean.setProxyInterface(DataSource.class); bean.afterPropertiesSet(); return (DataSource) bean.getObject(); }
Example 4
Source File: MQJndiHierachy.java From Thunder with Apache License 2.0 | 5 votes |
@Override public void initialize() throws Exception { super.initialize(); String jndiInitialContextFactoryClass = mqPropertyEntity.getMQEntity().getJndiInitialContextFactoryClass(); String url = mqPropertyEntity.getString(ThunderConstant.MQ_URL_ATTRIBUTE_NAME); String userName = mqPropertyEntity.getString(ThunderConstant.MQ_USER_NAME_ATTRIBUTE_NAME); String password = mqPropertyEntity.getString(ThunderConstant.MQ_PASSWORD_ATTRIBUTE_NAME); String jndiName = mqPropertyEntity.getString(ThunderConstant.MQ_JNDI_NAME_ATTRIBUTE_NAME); Properties environment = new Properties(); environment.put("java.naming.factory.initial", jndiInitialContextFactoryClass); environment.put("java.naming.provider.url", url); environment.put("java.naming.security.principal", userName); environment.put("java.naming.security.credentials", password); JndiTemplate jndiTemplate = new JndiTemplate(); jndiTemplate.setEnvironment(environment); JndiObjectFactoryBean targetConnectionFactory = new JndiObjectFactoryBean(); targetConnectionFactory.setJndiTemplate(jndiTemplate); targetConnectionFactory.setJndiName(jndiName); targetConnectionFactory.setLookupOnStartup(true); targetConnectionFactory.afterPropertiesSet(); setTargetConnectionFactory((ConnectionFactory) targetConnectionFactory.getObject()); afterPropertiesSet(); }
Example 5
Source File: SpringConfig.java From quartz-glass with Apache License 2.0 | 5 votes |
@Bean public DataSource dataSource() throws Exception { if (configuration().isInMemory()) return null; JndiObjectFactoryBean factoryBean = new JndiObjectFactoryBean(); factoryBean.setJndiName("java:comp/env/jdbc/glassDb"); factoryBean.afterPropertiesSet(); return (DataSource) factoryBean.getObject(); }
Example 6
Source File: CerberusConfiguration.java From cerberus-source with GNU General Public License v3.0 | 5 votes |
@Bean public JndiObjectFactoryBean dataSource() { JndiObjectFactoryBean jpfb = new JndiObjectFactoryBean(); jpfb.setJndiName("jdbc/cerberus"+ System.getProperty(Property.ENVIRONMENT)); jpfb.setResourceRef(true); return jpfb; }