当前位置: 首页>>代码示例>>Java>>正文


Java JndiObjectFactoryBean类代码示例

本文整理汇总了Java中org.springframework.jndi.JndiObjectFactoryBean的典型用法代码示例。如果您正苦于以下问题:Java JndiObjectFactoryBean类的具体用法?Java JndiObjectFactoryBean怎么用?Java JndiObjectFactoryBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


JndiObjectFactoryBean类属于org.springframework.jndi包,在下文中一共展示了JndiObjectFactoryBean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: jndiDataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@Bean(destroyMethod="")
public DataSource jndiDataSource() throws IllegalArgumentException, NamingException {
    JndiObjectFactoryBean bean = new JndiObjectFactoryBean();
    String jndiName = "java:comp/env/" + env.getProperty("sta.datasource.name", "jdbc/sensorThings");
    bean.setJndiName(jndiName);
    bean.setProxyInterface(DataSource.class);
    bean.setLookupOnStartup(false);
    bean.afterPropertiesSet();
    return (DataSource)bean.getObject();
}
 
开发者ID:kinota,项目名称:kinota-server,代码行数:11,代码来源:Application.java

示例2: getDataSourceFromBeanOrJndi

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
private DataSource getDataSourceFromBeanOrJndi(StorageProperties storageProperties, String suffix) {
    DataSource result = null;
    String connectionUrl = storageProperties.getConnectionUrl();
    if (StringUtils.startsWithIgnoreCase(connectionUrl, BEAN_PREFIX)) {
        result = beanFactory.getBean(connectionUrl.substring(BEAN_PREFIX.length()) + suffix, DataSource.class);
    } else if (StringUtils.startsWithIgnoreCase(connectionUrl, JNDI_PREFIX)) {
        String jndiName = connectionUrl.substring(JNDI_PREFIX.length());
        JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
        jndiObjectFactoryBean.setJndiName(jndiName + suffix);
        try {
            jndiObjectFactoryBean.afterPropertiesSet();
        } catch (NamingException e) {
            throw new RuntimeException(e);
        }
        result = (DataSource) jndiObjectFactoryBean.getObject();
    }
    return result;
}
 
开发者ID:alancnet,项目名称:artifactory,代码行数:19,代码来源:DbConfigFactory.java

示例3: getBeanClass

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@Override
protected Class<?> getBeanClass(Element element) {
	return JndiObjectFactoryBean.class;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:JndiLookupBeanDefinitionParser.java

示例4: dataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@Bean
public DataSource dataSource() throws SQLException {
	JndiObjectFactoryBean jndiObjectFactoryBean = new JndiObjectFactoryBean();
	log.debug("DataSource JNDI Name: {}", config.getDbJndiName());
	jndiObjectFactoryBean.setJndiName(config.getDbJndiName());
	try {
		jndiObjectFactoryBean.afterPropertiesSet();
	} catch (IllegalArgumentException | NamingException e) {
		throw new SQLException("Datasource not found", e);
	}
	return (DataSource) jndiObjectFactoryBean.getObject();
}
 
开发者ID:xtianus,项目名称:yadaframework,代码行数:13,代码来源:YadaJpaConfig.java

示例5: findServerForSpecialEnvironment

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
static AbstractBeanDefinition findServerForSpecialEnvironment() {
	if (weblogicPresent) {
		RootBeanDefinition bd = new RootBeanDefinition(JndiObjectFactoryBean.class);
		bd.getPropertyValues().add("jndiName", "java:comp/env/jmx/runtime");
		return bd;
	}
	else if (webspherePresent) {
		return new RootBeanDefinition(WebSphereMBeanServerFactoryBean.class);
	}
	else {
		return null;
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:MBeanServerBeanDefinitionParser.java

示例6: testSimpleDefinition

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@Test
public void testSimpleDefinition() throws Exception {
	BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("simple");
	assertEquals(JndiObjectFactoryBean.class.getName(), beanDefinition.getBeanClassName());
	assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource");
	assertPropertyValue(beanDefinition, "resourceRef", "true");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:JeeNamespaceHandlerTests.java

示例7: testComplexDefinition

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@Test
public void testComplexDefinition() throws Exception {
	BeanDefinition beanDefinition = this.beanFactory.getMergedBeanDefinition("complex");
	assertEquals(JndiObjectFactoryBean.class.getName(), beanDefinition.getBeanClassName());
	assertPropertyValue(beanDefinition, "jndiName", "jdbc/MyDataSource");
	assertPropertyValue(beanDefinition, "resourceRef", "true");
	assertPropertyValue(beanDefinition, "cache", "true");
	assertPropertyValue(beanDefinition, "lookupOnStartup", "true");
	assertPropertyValue(beanDefinition, "exposeAccessContext", "true");
	assertPropertyValue(beanDefinition, "expectedType", "com.myapp.DefaultFoo");
	assertPropertyValue(beanDefinition, "proxyInterface", "com.myapp.Foo");
	assertPropertyValue(beanDefinition, "defaultObject", "myValue");
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:JeeNamespaceHandlerTests.java

示例8: createJNDIDataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
private DataSource createJNDIDataSource() throws IllegalArgumentException, NamingException {
    JndiObjectFactoryBean factory = new JndiObjectFactoryBean();
    factory.setJndiName(configuration.getDataSource());
    factory.afterPropertiesSet();

    return (DataSource) factory.getObject();
}
 
开发者ID:Pardus-Engerek,项目名称:engerek,代码行数:8,代码来源:DataSourceFactory.java

示例9: dataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@Bean
public DataSource dataSource() {
	JndiObjectFactoryBean jndi=new JndiObjectFactoryBean();
	jndi.setResourceRef(true);
	jndi.setJndiName("jdbc/hmisdb");
	jndi.setProxyInterface(DataSource.class);
	jndi.setLookupOnStartup(true);
	try {
		jndi.afterPropertiesSet();
	}catch (NamingException e) {
		throw new RuntimeException(e);
	}
	return (DataSource)jndi.getObject();
}
 
开发者ID:hserv,项目名称:coordinated-entry,代码行数:15,代码来源:DatabaseConfig.java

示例10: jndiDataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@Bean(name = "dataSource")
@Description("JNDI DataSource for JEE environments")
@Profile("javaee")
public JndiObjectFactoryBean jndiDataSource()
		throws IllegalArgumentException {
	JndiObjectFactoryBean dataSource = new JndiObjectFactoryBean();
	dataSource.setExpectedType(DataSource.class);
	dataSource.setJndiName(env.getProperty("java:comp/env/jdbc/petclinic"));
	return dataSource;
}
 
开发者ID:YoannBuch,项目名称:DependencyInjectionAgent,代码行数:11,代码来源:DataSourceConfig.java

示例11: haibaDataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@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();
}
 
开发者ID:trifork,项目名称:HAIBA-EPIMIBA-classification,代码行数:10,代码来源:EPIMIBAConfiguration.java

示例12: classificationDataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@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();
}
 
开发者ID:trifork,项目名称:HAIBA-EPIMIBA-classification,代码行数:10,代码来源:EPIMIBAConfiguration.java

示例13: dataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
/**
 * Creates a new DataSource.
 *
 * @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();
}
 
开发者ID:dan-zx,项目名称:zekke-webapp,代码行数:15,代码来源:DataSourceConfig.java

示例14: getJndiNames

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
/**
 * Gets JNDI names for all configured instances of {@link JndiObjectFactoryBean}
 *
 * Note: If this method is invoked before ApplicationContext.refresh() then any bean property
 * values containing property placeholders will not be resolved.
 *
 * @return the unmodifiable list of JNDI binding names
 */
public List<String> getJndiNames() {
    List<String> bindings = new ArrayList<>();
    for(String beanName : applicationContext.getBeanDefinitionNames()) {
        BeanDefinition definition = applicationContext.getBeanDefinition(beanName);
        String beanClassName = definition.getBeanClassName();

        if (beanClassName != null && beanClassName.equals(JndiObjectFactoryBean.class.getName())) {
            MutablePropertyValues propertyValues = definition.getPropertyValues();
            Object jndiPropertyValue = propertyValues.get("jndiName");

            if (jndiPropertyValue == null) {
                LOGGER.debug("Skipping JNDI binding dependency for bean: {}", beanName);
                continue;
            }

            String jndiName = null;
            if (jndiPropertyValue instanceof String) {
                jndiName = (String) jndiPropertyValue;
            } else if (jndiPropertyValue instanceof TypedStringValue) {
                jndiName = ((TypedStringValue) jndiPropertyValue).getValue();
            } else {
                LOGGER.debug("Ignoring unknown JndiObjectFactoryBean property value type {}", jndiPropertyValue.getClass().getSimpleName());
            }

            if (jndiName != null) {
                bindings.add(jndiName);
            }
        }
    }
    return Collections.unmodifiableList(bindings);
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:40,代码来源:SpringCamelContextBootstrap.java

示例15: dataSource

import org.springframework.jndi.JndiObjectFactoryBean; //导入依赖的package包/类
@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();
}
 
开发者ID:bingoohuang,项目名称:quartz-glass,代码行数:11,代码来源:SpringConfig.java


注:本文中的org.springframework.jndi.JndiObjectFactoryBean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。