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


Java BeanFactoryReference类代码示例

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


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

示例1: useBeanFactory

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * Load/use a bean factory, as specified by a factory key which is a JNDI
 * address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The
 * contents of this JNDI location must be a string containing one or more
 * classpath resource names (separated by any of the delimiters '{@code ,; \t\n}'
 * if there is more than one. The resulting BeanFactory (or ApplicationContext)
 * will be created from the combined resources.
 * @see #createBeanFactory
 */
@Override
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
	try {
		String beanFactoryPath = lookup(factoryKey, String.class);
		if (logger.isTraceEnabled()) {
			logger.trace("Bean factory path from JNDI environment variable [" + factoryKey +
					"] is: " + beanFactoryPath);
		}
		String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS);
		return createBeanFactory(paths);
	}
	catch (NamingException ex) {
		throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing " +
				"the class path locations of XML bean definition files", ex);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:26,代码来源:ContextJndiBeanFactoryLocator.java

示例2: testBasicFunctionality

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
@Override
@Test
public void testBasicFunctionality() {
	ContextSingletonBeanFactoryLocator facLoc = new ContextSingletonBeanFactoryLocator(
			"classpath*:" + ClassUtils.addResourcePathToPackagePath(CLASS, CONTEXT));

	basicFunctionalityTest(facLoc);

	BeanFactoryReference bfr = facLoc.useBeanFactory("a.qualified.name.of.some.sort");
	BeanFactory fac = bfr.getFactory();
	assertTrue(fac instanceof ApplicationContext);
	assertEquals("a.qualified.name.of.some.sort", ((ApplicationContext) fac).getId());
	assertTrue(((ApplicationContext) fac).getDisplayName().contains("a.qualified.name.of.some.sort"));
	BeanFactoryReference bfr2 = facLoc.useBeanFactory("another.qualified.name");
	BeanFactory fac2 = bfr2.getFactory();
	assertEquals("another.qualified.name", ((ApplicationContext) fac2).getId());
	assertTrue(((ApplicationContext) fac2).getDisplayName().contains("another.qualified.name"));
	assertTrue(fac2 instanceof ApplicationContext);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:20,代码来源:ContextSingletonBeanFactoryLocatorTests.java

示例3: getApplicationContext

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * Gets the applicationContext.
 *
 * @return the applicationContext.
 */
protected BeanFactory getApplicationContext() {
  try {
    if (applicationContext == null) {
      synchronized (LOCK) {
        if (applicationContext == null) {
          BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance(getBeanFactorySelector());
          BeanFactoryReference bf = bfl.useBeanFactory(getApplicationContextKey());
          BeanFactory tempApplicationContext = bf.getFactory();
          if (tempApplicationContext instanceof ConfigurableApplicationContext) {
            ((ConfigurableApplicationContext) tempApplicationContext).registerShutdownHook();
          }
          applicationContext = tempApplicationContext;
        }
      }
    }
    return applicationContext;
  } catch (RuntimeException ex) {
    LOG.error("{} context could not be instantiated.", getApplicationContextKey(), ex);
    throw ex;
  }
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:27,代码来源:AbstractStartup.java

示例4: useBeanFactory

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * Load/use a bean factory, as specified by a factory key which is a JNDI
 * address, of the form {@code java:comp/env/ejb/BeanFactoryPath}. The
 * contents of this JNDI location must be a string containing one or more
 * classpath resource names (separated by any of the delimiters '{@code ,; \t\n}'
 * if there is more than one. The resulting BeanFactory (or ApplicationContext)
 * will be created from the combined resources.
 * @see #createBeanFactory
 */
public BeanFactoryReference useBeanFactory(String factoryKey) throws BeansException {
	try {
		String beanFactoryPath = lookup(factoryKey, String.class);
		if (logger.isTraceEnabled()) {
			logger.trace("Bean factory path from JNDI environment variable [" + factoryKey +
					"] is: " + beanFactoryPath);
		}
		String[] paths = StringUtils.tokenizeToStringArray(beanFactoryPath, BEAN_FACTORY_PATH_DELIMITERS);
		return createBeanFactory(paths);
	}
	catch (NamingException ex) {
		throw new BootstrapException("Define an environment variable [" + factoryKey + "] containing " +
				"the class path locations of XML bean definition files", ex);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:ContextJndiBeanFactoryLocator.java

示例5: getIfAlias

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
protected String getIfAlias(final int nodeid, final int ifindex) {

        LogUtils.debugf(this, "getting ifalias for nodeid: %d and ifindex: %d", nodeid, ifindex);

        setCriteria("nodeid = " + nodeid + " AND snmpifindex = " + ifindex);
        BeanFactoryReference bf = BeanUtils.getBeanFactory("daoContext");
        final SnmpInterfaceDao snmpInterfaceDao = BeanUtils.getBean(bf,"snmpInterfaceDao", SnmpInterfaceDao.class);
        final TransactionTemplate transTemplate = BeanUtils.getBean(bf, "transactionTemplate",TransactionTemplate.class);
        final List<OnmsSnmpInterface> iface = transTemplate.execute(
                   new TransactionCallback<List<OnmsSnmpInterface>>() {
                        public List<OnmsSnmpInterface> doInTransaction(final TransactionStatus status) {
                            final OnmsCriteria onmsCriteria = new OnmsCriteria(OnmsSnmpInterface.class);
                            onmsCriteria.add(Restrictions.sqlRestriction(getCriteria()));
                            return snmpInterfaceDao.findMatching(onmsCriteria);
                        }
                   }
        );
        LogUtils.debugf(this, "interfaces found: %d", iface.size());

        if (iface.size() == 0) return "-1";
        final String ifAlias = iface.get(0).getIfAlias();
        LogUtils.debugf(this, "ifalias found: %s", ifAlias);
        
        return ifAlias;
    }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:26,代码来源:InsAbstractSession.java

示例6: doReleaseBean

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * Actually release the BeanFactoryReference for the given target bean.
 * @param target the target bean to release
 */
protected void doReleaseBean(Object target) {
	BeanFactoryReference ref = this.beanFactoryReferences.remove(target);
	if (ref != null) {
		ref.release();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:SpringBeanAutowiringInterceptor.java

示例7: ComponentLoaderImpl

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
public ComponentLoaderImpl () throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException {
    checkInit();
    BeanFactoryLocator factoryLocator = ContextSingletonBeanFactoryLocator
            .getInstance(String.format("classpath:%s", CoreGlobalProperty.BEAN_REF_CONTEXT_CONF));
    BeanFactoryReference ref = factoryLocator.useBeanFactory("parentContext");
    ioc = ref.getFactory();
}
 
开发者ID:zstackio,项目名称:zstack,代码行数:8,代码来源:ComponentLoaderImpl.java

示例8: getBeanFactory

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
private BeanFactory getBeanFactory(ServletContextEvent event) {
  String beanFactorySelector = getBeanFactorySelector(event);
  String applicationContextKey = getApplicationContextKey(event);
  BeanFactoryLocator bfl = SingletonBeanFactoryLocator
      .getInstance(beanFactorySelector);
  BeanFactoryReference bf = bfl.useBeanFactory(applicationContextKey);
  BeanFactory beanFactory = bf.getFactory();
  if (beanFactory instanceof ConfigurableApplicationContext) {
    ((ConfigurableApplicationContext) beanFactory).registerShutdownHook();
  }
  return beanFactory;
}
 
开发者ID:jspresso,项目名称:jspresso-ce,代码行数:13,代码来源:AbstractBeanFactoryAwareContextListener.java

示例9: JBPMSpringActionHandler

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * Construct
 */
protected JBPMSpringActionHandler()
{
    // The following implementation is derived from Spring Modules v0.4
    BeanFactoryLocator factoryLocator = new JbpmFactoryLocator();
    BeanFactoryReference factory = factoryLocator.useBeanFactory(null);
    initialiseHandler(factory.getFactory());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:11,代码来源:JBPMSpringActionHandler.java

示例10: revert

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
public Object revert(Object o)
{
    Object reverted = null;
    if (o != null)
    {
        BeanFactoryReference factory = jbpmFactoryLocator.useBeanFactory(null);
        ServiceRegistry serviceRegistry = (ServiceRegistry)factory.getFactory().getBean(ServiceRegistry.SERVICE_REGISTRY);
        reverted = new JBPMNode(new NodeRef((String)o), serviceRegistry);
    }
    return reverted;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:12,代码来源:NodeConverter.java

示例11: getJBPMEngine

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * Gets the JBPM Engine instance
 * 
 * @return JBPM Engine
 */
private JBPMEngine getJBPMEngine()
{
    if (jbpmEngine == null)
    {
        BeanFactoryLocator factoryLocator = new JbpmFactoryLocator();
        BeanFactoryReference factory = factoryLocator.useBeanFactory(null);
        if (jbpmEngineName == null) jbpmEngineName = "jbpm_engine";
        jbpmEngine = (JBPMEngine) factory.getFactory().getBean(jbpmEngineName);
        if (jbpmEngine == null) { throw new WorkflowException(
                    "Failed to retrieve JBPMEngine component"); }
    }
    return jbpmEngine;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:19,代码来源:WorkflowTaskInstance.java

示例12: revertNodes

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * @param value Object
 * @return JBPMNodeList
 */
@SuppressWarnings("unchecked")
private JBPMNodeList revertNodes(Object value)
{
    BeanFactoryReference factory = jbpmFactoryLocator.useBeanFactory(null);
    ServiceRegistry serviceRegistry = (ServiceRegistry)factory.getFactory().getBean(ServiceRegistry.SERVICE_REGISTRY);
    
    JBPMNodeList nodes = new JBPMNodeList();
    Collection<NodeRef> nodeRefs = (Collection<NodeRef>) value;
    for (NodeRef nodeRef : nodeRefs)
    {
        nodes.add(new JBPMNode(nodeRef, serviceRegistry));
    }
    return nodes;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:19,代码来源:NodeListConverter.java

示例13: AlfrescoJobExecutor

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * Constructor
 */
public AlfrescoJobExecutor()
{
    BeanFactoryLocator factoryLocator = new JbpmFactoryLocator();
    BeanFactoryReference factory = factoryLocator.useBeanFactory(null);
    
    transactionService = (TransactionService)factory.getFactory().getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
    jobLockService = (JobLockService)factory.getFactory().getBean(ServiceRegistry.JOB_LOCK_SERVICE.getLocalName());
    
    jbpmConfiguration = (JbpmConfiguration)factory.getFactory().getBean("jbpm_configuration");
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:14,代码来源:AlfrescoJobExecutor.java

示例14: JBPMSpringAssignmentHandler

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * Construct
 */
protected JBPMSpringAssignmentHandler()
{
    // The following implementation is derived from Spring Modules v0.4
    BeanFactoryLocator factoryLocator = new JbpmFactoryLocator();
    BeanFactoryReference factory = factoryLocator.useBeanFactory(null);
    initialiseHandler(factory.getFactory());
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:11,代码来源:JBPMSpringAssignmentHandler.java

示例15: getGlobalThreadLocal

import org.springframework.beans.factory.access.BeanFactoryReference; //导入依赖的package包/类
/**
 * This method obtains a global ThreadLocal class independent of the classloader (JVM-scope singleton).
 * The easiest solution is to use System.getProperties().get/put, but this solution violate
 * Properties contract and have other drawbacks.
 * <p>Current solution relies on the idea behind
 * {@link org.springframework.beans.factory.access.SingletonBeanFactoryLocator}. See also bug #4648
 *
 * @return Global ThreadLocal (JVM-scope singleton).
 */
@SuppressWarnings("unchecked")
private static ThreadLocal<BeanFactory> getGlobalThreadLocal() {
    BeanFactoryLocator locator = SingletonBeanFactoryLocator.getInstance(BEAN_FACTORY_XML_PATH);
    BeanFactoryReference ref = locator.useBeanFactory(FACTORY_BEAN_NAME);
    StaticApplicationContext ctx = (StaticApplicationContext) ref.getFactory();
    if (!ctx.containsBean(THREAD_LOCAL_BEAN_NAME)) {
        ctx.registerSingleton(THREAD_LOCAL_BEAN_NAME, ThreadLocal.class);
    }
    return (ThreadLocal) ctx.getBean(THREAD_LOCAL_BEAN_NAME);
}
 
开发者ID:scriptella,项目名称:scriptella-etl,代码行数:20,代码来源:EtlExecutorBean.java


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