Java 类org.springframework.beans.factory.access.BeanFactoryReference 实例源码

项目:lams    文件:ContextJndiBeanFactoryLocator.java   
/**
 * 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);
    }
}
项目:spring4-understanding    文件:ContextJndiBeanFactoryLocator.java   
/**
 * 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);
    }
}
项目:spring4-understanding    文件:ContextSingletonBeanFactoryLocatorTests.java   
@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);
}
项目:my-spring-cache-redis    文件:ContextJndiBeanFactoryLocator.java   
/**
 * 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);
    }
}
项目:spring    文件:ContextJndiBeanFactoryLocator.java   
/**
 * 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);
    }
}
项目:jspresso-ce    文件:AbstractStartup.java   
/**
 * 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;
  }
}
项目:class-guard    文件:ContextJndiBeanFactoryLocator.java   
/**
 * 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);
    }
}
项目:class-guard    文件:ContextSingletonBeanFactoryLocatorTests.java   
@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);
}
项目:opennmszh    文件:InsAbstractSession.java   
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;
    }
项目:OpenNMS    文件:InsAbstractSession.java   
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;
    }
项目:lams    文件:SpringBeanAutowiringInterceptor.java   
/**
 * 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();
    }
}
项目:spring4-understanding    文件:SpringBeanAutowiringInterceptor.java   
/**
 * 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();
    }
}
项目:my-spring-cache-redis    文件:SpringBeanAutowiringInterceptor.java   
/**
 * 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();
    }
}
项目:spring    文件:SpringBeanAutowiringInterceptor.java   
/**
 * 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();
    }
}
项目:zstack    文件:ComponentLoaderImpl.java   
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();
}
项目:jspresso-ce    文件:AbstractBeanFactoryAwareContextListener.java   
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;
}
项目:community-edition-old    文件:JBPMSpringActionHandler.java   
/**
 * 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());
}
项目:community-edition-old    文件:NodeConverter.java   
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;
}
项目:community-edition-old    文件:WorkflowTaskInstance.java   
/**
 * 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;
}
项目:community-edition-old    文件:NodeListConverter.java   
/**
 * @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;
}
项目:community-edition-old    文件:AlfrescoJobExecutor.java   
/**
 * 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");
}
项目:community-edition-old    文件:JBPMSpringAssignmentHandler.java   
/**
 * 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());
}
项目:scriptella-etl    文件:EtlExecutorBean.java   
/**
 * 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);
}
项目:class-guard    文件:SpringBeanAutowiringInterceptor.java   
/**
 * 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();
    }
}
项目:opennmszh    文件:InsSession.java   
private void getEventsByCriteria() {
    LogUtils.debugf(this, "clearing events");

    clearEvents();
    final BeanFactoryReference bf = BeanUtils.getBeanFactory("daoContext");
    final EventDao eventDao = BeanUtils.getBean(bf,"eventDao", EventDao.class);
    final TransactionTemplate transTemplate = BeanUtils.getBean(bf, "transactionTemplate",TransactionTemplate.class);
    try {
            transTemplate.execute(new TransactionCallback<Object>() {
            public Object doInTransaction(final TransactionStatus status) {
                LogUtils.debugf(this, "Entering transaction call back: selection with criteria: %s", criteriaRestriction);
                final OnmsCriteria criteria = new OnmsCriteria(OnmsEvent.class);
                criteria.add(Restrictions.sqlRestriction(criteriaRestriction));

                final List<OnmsEvent> events = eventDao.findMatching(criteria);
                LogUtils.infof(this, "Found %d event(s) with criteria: %s", events.size(), criteriaRestriction);

                for (final OnmsEvent onmsEvent : events) {
                    final Event xmlEvent = getXMLEvent(onmsEvent);
                    if (xmlEvent != null) addEvent(xmlEvent);
                }
                return new Object();
            }

        });

    } catch (final RuntimeException e) {
        LogUtils.errorf(this, e, "Error while getting events.");
    }

}
项目:OpenNMS    文件:InsSession.java   
private void getEventsByCriteria() {
    LogUtils.debugf(this, "clearing events");

    clearEvents();
    final BeanFactoryReference bf = BeanUtils.getBeanFactory("daoContext");
    final EventDao eventDao = BeanUtils.getBean(bf,"eventDao", EventDao.class);
    final TransactionTemplate transTemplate = BeanUtils.getBean(bf, "transactionTemplate",TransactionTemplate.class);
    try {
            transTemplate.execute(new TransactionCallback<Object>() {
            public Object doInTransaction(final TransactionStatus status) {
                LogUtils.debugf(this, "Entering transaction call back: selection with criteria: %s", criteriaRestriction);
                final OnmsCriteria criteria = new OnmsCriteria(OnmsEvent.class);
                criteria.add(Restrictions.sqlRestriction(criteriaRestriction));

                final List<OnmsEvent> events = eventDao.findMatching(criteria);
                LogUtils.infof(this, "Found %d event(s) with criteria: %s", events.size(), criteriaRestriction);

                for (final OnmsEvent onmsEvent : events) {
                    final Event xmlEvent = getXMLEvent(onmsEvent);
                    if (xmlEvent != null) addEvent(xmlEvent);
                }
                return new Object();
            }

        });

    } catch (final RuntimeException e) {
        LogUtils.errorf(this, e, "Error while getting events.");
    }

}
项目:jspresso-ce    文件:ViewTester.java   
private ApplicationContext getApplicationContext() {
  BeanFactoryLocator bfl = SingletonBeanFactoryLocator
      .getInstance(beanFactorySelector);
  BeanFactoryReference bf = bfl.useBeanFactory(applicationContextKey);
  return (ApplicationContext) bf.getFactory();
}
项目:jspresso-ce    文件:EntityGenerator.java   
private BeanFactoryReference getBeanFactoryReference() {
  BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance(beanFactorySelector);
  BeanFactoryReference bf = bfl.useBeanFactory(applicationContextKey);
  return bf;
}
项目:sakuli    文件:BeanLoader.java   
private static BeanFactoryReference getBeanFactoryReference() {
    BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance(CONTEXT_PATH);
    return bfl.useBeanFactory("org.sakuli.app.root");
}
项目:class-guard    文件:AbstractEnterpriseBean.java   
public BeanFactoryReferenceReleaseListener(BeanFactoryReference beanFactoryReference) {
    this.beanFactoryReference = beanFactoryReference;
}
项目:opennmszh    文件:QoSD.java   
/**
     * <p>onStart</p>
     */
    protected void onStart() {


//TODO REMOVE EXAMPLE IMPORTER CODE
//      ThreadCategory.setPrefix(ImporterService.NAME);
//      m_status = Fiber.STARTING;
//      ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

//      BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
//      BeanFactoryReference bf = bfl.useBeanFactory("daoContext");
//      ApplicationContext daoContext = (ApplicationContext) bf.getFactory();

//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/opennms/netmgt/importer/importer-context.xml" }, daoContext);
//      ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());
//      m_status = Fiber.RUNNING;

        ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

        // finds the already instantiated OpenNMS daoContext
        BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
        BeanFactoryReference bf = bfl.useBeanFactory("daoContext");
        ApplicationContext daoContext = (ApplicationContext) bf.getFactory();


        // this chooses if we expect AlarmMonitor to run in seperate j2ee container ( Jboss ) or in local
        // OpenNMS spring container
        String qosdj2ee=System.getProperty("qosd.usej2ee");
        ThreadCategory.getInstance().info("QoSD System Property qosd.usej2ee=" + qosdj2ee );
        if ("true".equals(qosdj2ee)){
            ThreadCategory.getInstance().debug("QoSD using /org/openoss/opennms/spring/qosd/qosd-j2ee-context.xml");
            m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosd/qosd-j2ee-context.xml" },daoContext);
        }
        else {
            ThreadCategory.getInstance().debug("QoSD using /org/openoss/opennms/spring/qosd/qosd-spring-context.xml");
            m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosd/qosd-spring-context.xml" },daoContext);
        }

        ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());

        getQoSD().init();
        getQoSD().start();


//      TODO remove original code       
//      ThreadCategory.setPrefix(QoSD.NAME);
//      m_status = Fiber.STARTING;
//      ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

//      // this chooses if we expect AlarmMonitor to run in seperate j2ee container ( Jboss ) or in local
//      // OpenNMS spring container
//      String qosdj2ee=System.getProperty("qosd.usej2ee");
//      ThreadCategory.getInstance().info("QoSD System Property qosd.usej2ee=" + qosdj2ee );
//      if ("true".equals(qosdj2ee)){
//      ThreadCategory.getInstance().debug("QoSD using /org/openoss/opennms/spring/qosd/qosd-j2ee-context.xml");
//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosd/qosd-j2ee-context.xml" });
//      }
//      else {
//      ThreadCategory.getInstance().debug("QoSD using /org/openoss/opennms/spring/qosd/qosd-spring-context.xml");
//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosd/qosd-spring-context.xml" });
//      }

//      ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());

//      getQoSD().init();
//      getQoSD().start();


//      m_status = Fiber.RUNNING;
    }
项目:opennmszh    文件:QoSDrx.java   
/**
     * <p>onStart</p>
     */
    protected void onStart() {
//      TODO REMOVE EXAMPLE IMPORTER CODE
//      ThreadCategory.setPrefix(ImporterService.NAME);
//      m_status = Fiber.STARTING;
//      ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

//      BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
//      BeanFactoryReference bf = bfl.useBeanFactory("daoContext");
//      ApplicationContext daoContext = (ApplicationContext) bf.getFactory();

//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/opennms/netmgt/importer/importer-context.xml" }, daoContext);
//      ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());
//      m_status = Fiber.RUNNING;



        ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

        // finds the already instantiated OpenNMS daoContext
        BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
        BeanFactoryReference bf = bfl.useBeanFactory("daoContext");
        ApplicationContext daoContext = (ApplicationContext) bf.getFactory();

        ThreadCategory.getInstance().debug("QoSDrx using /org/openoss/opennms/spring/qosdrx/qosdrx-spring-context.xml");
        m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosdrx/qosdrx-spring-context.xml" }, daoContext);
        ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());

        getQoSDrx().init();
        getQoSDrx().start();

//TODO remove old code      
//      ThreadCategory.setPrefix(QoSDrx.NAME);
//      m_status = Fiber.STARTING;
//      ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());
//
//      ThreadCategory.getInstance().debug("QoSDrx using /org/openoss/opennms/spring/qosdrx/qosdrx-spring-context.xml");
//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosdrx/qosdrx-spring-context.xml" });
//      ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());
//
//      getQoSDrx().init();
//      getQoSDrx().start();
//
//
//      m_status = Fiber.RUNNING;
    }
项目:opennmszh    文件:ImporterServiceJmxTest.java   
@Before
public void setUp() throws Exception {

    MockDatabase db = new MockDatabase();
    DataSourceFactory.setInstance(db);

    MockLogAppender.setupLogging();
    DaoTestConfigBean bean = new DaoTestConfigBean();
    bean.afterPropertiesSet();


    BeanFactoryReference ref = BeanUtils.getBeanFactory("daemonContext");
    ApplicationContext daemonContext = (ApplicationContext) ref.getFactory();

    new ClassPathXmlApplicationContext(new String[] { "classpath:META-INF/opennms/mockEventIpcManager.xml" }, daemonContext);


}
项目:opennmszh    文件:Correlator.java   
/**
 * Initialization.
 * 
 * Retrieves the Spring context for the correlator.
 */
public void init() {
    final BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
    final BeanFactoryReference bf = bfl.useBeanFactory("correlatorContext");
    m_correlator = (org.opennms.netmgt.correlation.Correlator) bf.getFactory().getBean("correlator");
}
项目:opennmszh    文件:DbHelper.java   
public static String getNodeLabel(Integer nodeid) {
    BeanFactoryReference bf = BeanUtils.getBeanFactory("daoContext");
       return BeanUtils.getBean(bf,"nodeDao", NodeDao.class)
        .get(nodeid).getLabel();
}
项目:OpenNMS    文件:QoSD.java   
/**
     * <p>onStart</p>
     */
    protected void onStart() {


//TODO REMOVE EXAMPLE IMPORTER CODE
//      ThreadCategory.setPrefix(ImporterService.NAME);
//      m_status = Fiber.STARTING;
//      ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

//      BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
//      BeanFactoryReference bf = bfl.useBeanFactory("daoContext");
//      ApplicationContext daoContext = (ApplicationContext) bf.getFactory();

//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/opennms/netmgt/importer/importer-context.xml" }, daoContext);
//      ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());
//      m_status = Fiber.RUNNING;

        ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

        // finds the already instantiated OpenNMS daoContext
        BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
        BeanFactoryReference bf = bfl.useBeanFactory("daoContext");
        ApplicationContext daoContext = (ApplicationContext) bf.getFactory();


        // this chooses if we expect AlarmMonitor to run in seperate j2ee container ( Jboss ) or in local
        // OpenNMS spring container
        String qosdj2ee=System.getProperty("qosd.usej2ee");
        ThreadCategory.getInstance().info("QoSD System Property qosd.usej2ee=" + qosdj2ee );
        if ("true".equals(qosdj2ee)){
            ThreadCategory.getInstance().debug("QoSD using /org/openoss/opennms/spring/qosd/qosd-j2ee-context.xml");
            m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosd/qosd-j2ee-context.xml" },daoContext);
        }
        else {
            ThreadCategory.getInstance().debug("QoSD using /org/openoss/opennms/spring/qosd/qosd-spring-context.xml");
            m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosd/qosd-spring-context.xml" },daoContext);
        }

        ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());

        getQoSD().init();
        getQoSD().start();


//      TODO remove original code       
//      ThreadCategory.setPrefix(QoSD.NAME);
//      m_status = Fiber.STARTING;
//      ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

//      // this chooses if we expect AlarmMonitor to run in seperate j2ee container ( Jboss ) or in local
//      // OpenNMS spring container
//      String qosdj2ee=System.getProperty("qosd.usej2ee");
//      ThreadCategory.getInstance().info("QoSD System Property qosd.usej2ee=" + qosdj2ee );
//      if ("true".equals(qosdj2ee)){
//      ThreadCategory.getInstance().debug("QoSD using /org/openoss/opennms/spring/qosd/qosd-j2ee-context.xml");
//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosd/qosd-j2ee-context.xml" });
//      }
//      else {
//      ThreadCategory.getInstance().debug("QoSD using /org/openoss/opennms/spring/qosd/qosd-spring-context.xml");
//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosd/qosd-spring-context.xml" });
//      }

//      ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());

//      getQoSD().init();
//      getQoSD().start();


//      m_status = Fiber.RUNNING;
    }
项目:OpenNMS    文件:QoSDrx.java   
/**
     * <p>onStart</p>
     */
    protected void onStart() {
//      TODO REMOVE EXAMPLE IMPORTER CODE
//      ThreadCategory.setPrefix(ImporterService.NAME);
//      m_status = Fiber.STARTING;
//      ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

//      BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
//      BeanFactoryReference bf = bfl.useBeanFactory("daoContext");
//      ApplicationContext daoContext = (ApplicationContext) bf.getFactory();

//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/opennms/netmgt/importer/importer-context.xml" }, daoContext);
//      ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());
//      m_status = Fiber.RUNNING;



        ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());

        // finds the already instantiated OpenNMS daoContext
        BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
        BeanFactoryReference bf = bfl.useBeanFactory("daoContext");
        ApplicationContext daoContext = (ApplicationContext) bf.getFactory();

        ThreadCategory.getInstance().debug("QoSDrx using /org/openoss/opennms/spring/qosdrx/qosdrx-spring-context.xml");
        m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosdrx/qosdrx-spring-context.xml" }, daoContext);
        ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());

        getQoSDrx().init();
        getQoSDrx().start();

//TODO remove old code      
//      ThreadCategory.setPrefix(QoSDrx.NAME);
//      m_status = Fiber.STARTING;
//      ThreadCategory.getInstance().debug("SPRING: thread.classLoader="+Thread.currentThread().getContextClassLoader());
//
//      ThreadCategory.getInstance().debug("QoSDrx using /org/openoss/opennms/spring/qosdrx/qosdrx-spring-context.xml");
//      m_context = new ClassPathXmlApplicationContext(new String[] { "/org/openoss/opennms/spring/qosdrx/qosdrx-spring-context.xml" });
//      ThreadCategory.getInstance().debug("SPRING: context.classLoader="+m_context.getClassLoader());
//
//      getQoSDrx().init();
//      getQoSDrx().start();
//
//
//      m_status = Fiber.RUNNING;
    }
项目:OpenNMS    文件:ImporterServiceJmxTest.java   
@Before
public void setUp() throws Exception {

    MockDatabase db = new MockDatabase();
    DataSourceFactory.setInstance(db);

    MockLogAppender.setupLogging();
    DaoTestConfigBean bean = new DaoTestConfigBean();
    bean.afterPropertiesSet();


    BeanFactoryReference ref = BeanUtils.getBeanFactory("daemonContext");
    ApplicationContext daemonContext = (ApplicationContext) ref.getFactory();

    new ClassPathXmlApplicationContext(new String[] { "classpath:META-INF/opennms/mockEventIpcManager.xml" }, daemonContext);


}
项目:OpenNMS    文件:Correlator.java   
/**
 * <p>init</p>
 */
public void init() {
    final BeanFactoryLocator bfl = DefaultLocatorFactory.getInstance();
       final BeanFactoryReference bf = bfl.useBeanFactory("correlatorContext");
       m_correlator = (org.opennms.netmgt.correlation.Correlator) bf.getFactory().getBean("correlator");
   }
项目:OpenNMS    文件:DbHelper.java   
public static String getNodeLabel(Integer nodeid) {
    BeanFactoryReference bf = BeanUtils.getBeanFactory("daoContext");
       return BeanUtils.getBean(bf,"nodeDao", NodeDao.class)
        .get(nodeid).getLabel();
}