Package org.springframework.beans.factory.access

Examples of org.springframework.beans.factory.access.BeanFactoryReference


  @Test
  public final void testContextLoader() {
    BeanFactoryLocator locator = MyBeanFactoryLocator
        .getInstance("classpath*:/org/company/recordshop/*/beanRefContext.xml");
    BeanFactoryReference reference = locator
        .useBeanFactory("org.company.recordshop.service.Context");
    CustomerServiceModelLocalService service = (CustomerServiceModelLocalService) reference
        .getFactory().getBean("customerServiceModelService");
  }
View Full Code Here


    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);
  }
View Full Code Here

   * @see #getBeanFactoryLocatorKey
   * @see org.springframework.beans.factory.access.BeanFactoryLocator#useBeanFactory(String)
   */
  protected BeanFactoryReference getBeanFactoryReference(Object target) {
    String key = getBeanFactoryLocatorKey(target);
    BeanFactoryReference ref = getBeanFactoryLocator(target).useBeanFactory(key);
    this.beanFactoryReferences.put(target, ref);
    return ref;
  }
View Full Code Here

  /**
   * 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();
    }
  }
View Full Code Here

      log.info("No WEB-INF directory found for "
          + context.getContextPath()
          + ", creating default application.");
      BeanFactoryLocator bfl = ContextSingletonBeanFactoryLocator
          .getInstance("red5.xml");
      BeanFactoryReference bfr = bfl.useBeanFactory("red5.common");

      // Create WebScope dynamically
      WebScope scope = new WebScope();
      IServer server = (IServer) bfr.getFactory().getBean(IServer.ID);
      scope.setServer(server);
      scope.setGlobalScope(server.getGlobal("default"));

      // Get default Red5 context from context loader that is JettyLoader in this case
      ApplicationContext appCtx = JettyLoader.getApplicationContext();
View Full Code Here

      // get the main factory
      parentFactory = (DefaultListableBeanFactory) factory
          .getParentBeanFactory();

      // create a wrapper around our primary context
      BeanFactoryReference beanfactoryRef = new ContextBeanFactoryReference(
          applicationContext);

      // set it in the root servlet context
      servletContext.setAttribute("bean.factory.ref", beanfactoryRef);
View Full Code Here

  public void setUp() {
    StepExecutionCountingDecider.previousStepCount = 0;

    if(jobExplorer == null) {
      BeanFactoryLocator beanFactoryLocactor = ContextSingletonBeanFactoryLocator.getInstance();
      BeanFactoryReference ref = beanFactoryLocactor.useBeanFactory("baseContext");
      baseContext = (ApplicationContext) ref.getFactory();

      baseContext.getAutowireCapableBeanFactory().autowireBeanProperties(this,
          AutowireCapableBeanFactory.AUTOWIRE_BY_NAME, false);
    }
  }
View Full Code Here

   * singleton ApplicationContext if one has not already been created (and will utilize the existing
   * one if it has) to populate itself.
   */
  public JsrJobOperator() {
    BeanFactoryLocator beanFactoryLocactor = ContextSingletonBeanFactoryLocator.getInstance();
    BeanFactoryReference ref = beanFactoryLocactor.useBeanFactory("baseContext");
    baseContext = (ApplicationContext) ref.getFactory();

    baseContext.getAutowireCapableBeanFactory().autowireBeanProperties(this,
        AutowireCapableBeanFactory.AUTOWIRE_BY_TYPE, false);

    if(taskExecutor == null) {
View Full Code Here

    locator2.afterPropertiesSet();
  }

  @After
  public void destroy() {
    BeanFactoryReference ref1;
    try {
      ref1 = locator1.useBeanFactory(INSTANCE_1);
      ref1.release();
      BeanFactoryReference ref2 = locator2.useBeanFactory(INSTANCE_2);
      ref2.release();

    } catch (IllegalArgumentException e) {
      // it's okay
    }
    locator1.destroy();
View Full Code Here

  public void testBeanFactoryRelease() throws Exception {
  }

  @Test
  public void testFactoryLocator() throws Exception {
    BeanFactoryReference reference1 = locator1.useBeanFactory(INSTANCE_1);
    BeanFactoryReference reference2 = locator2.useBeanFactory(INSTANCE_2);
    BeanFactoryReference aliasRef1 = locator1.useBeanFactory("alias1");
    BeanFactoryReference aliasRef2 = locator1.useBeanFactory("alias2");

    // verify the static map
    BeanFactory factory1 = reference1.getFactory();
    BeanFactory factory2 = reference2.getFactory();
    BeanFactory factory3 = reference2.getFactory();
    // get the alias from different factories
    BeanFactory alias1 = aliasRef1.getFactory();
    BeanFactory alias2 = aliasRef2.getFactory();

    assertSame(factory1, factory2);
    assertSame(factory1, factory3);
    // verify it's the same bean factory as the application context
    assertSame(factory1, applicationContext);

    // verify aliases
    assertSame(alias1, alias2);
    assertSame(factory1, alias1);

    aliasRef1.release();
    aliasRef2.release();
    reference1.release();
    reference2.release();
  }
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.access.BeanFactoryReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.