Package org.springframework.beans.factory.access

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


  /*
   * Class to test for BeanFactoryLocator getInstance(String)
   */
  public void testGetInstanceString() {
    BeanFactoryLocator bf = DefaultLocatorFactory.getInstance("my-bean-refs.xml");
    BeanFactoryLocator bf2 = DefaultLocatorFactory.getInstance("my-bean-refs.xml");
    assertTrue(bf.equals(bf2));
  }
View Full Code Here


    MockControl mc = MockControl.createControl(SessionContext.class);
    SessionContext sc = (SessionContext) mc.getMock();
    mc.replay();
   
    final BeanFactory bf = new StaticListableBeanFactory();
    BeanFactoryLocator bfl = new BeanFactoryLocator() {
      public BeanFactoryReference useBeanFactory(String factoryKey)
          throws FatalBeanException {
        return new BeanFactoryReference() {
          public BeanFactory getFactory() {
            return bf;
View Full Code Here

    MockControl mc = MockControl.createControl(SessionContext.class);
    SessionContext sc = (SessionContext) mc.getMock();
    mc.replay();
   
    final BeanFactory bf = new StaticListableBeanFactory();
    BeanFactoryLocator bfl = new BeanFactoryLocator() {
      public BeanFactoryReference useBeanFactory(String factoryKey) throws FatalBeanException {
        return new BeanFactoryReference() {
          public BeanFactory getFactory() {
            return bf;
          }
View Full Code Here

    MockControl mc = MockControl.createControl(MessageDrivenContext.class);
    MessageDrivenContext sc = (MessageDrivenContext) mc.getMock();
    mc.replay();
 
    final BeanFactory bf = new StaticListableBeanFactory();
    BeanFactoryLocator bfl = new BeanFactoryLocator() {
      public BeanFactoryReference useBeanFactory(String factoryKey) throws FatalBeanException {
        return new BeanFactoryReference() {
          public BeanFactory getFactory() {
            return bf;
          }
View Full Code Here

  public void testCannotLoadBeanFactory() throws Exception {
    MockControl mc = MockControl.createControl(SessionContext.class);
    SessionContext sc = (SessionContext) mc.getMock();
    mc.replay();
 
    BeanFactoryLocator bfl = new BeanFactoryLocator() {
      public BeanFactoryReference useBeanFactory(String factoryKey) throws FatalBeanException {
        throw new BootstrapException("", null);
    }};

    AbstractStatelessSessionBean slsb = new AbstractStatelessSessionBean() {
View Full Code Here

     *
     * @param contextName The name of the application context {@link BeanFactory} to return.
     * @return The (singleton) {@link BeanFactory} for the application context.
     */
    public static BeanFactory getApplicationContext(final String contextName) {
        final BeanFactoryLocator locator = SingletonBeanFactoryLocator.getInstance(BEAN_REF_FACTORY_PATH);
        final BeanFactoryReference reference = locator.useBeanFactory(contextName);
        return reference.getFactory();
    }
View Full Code Here

  public static String getInitFactoryName() {
    return initFactoryName;
  }

  protected static BeanFactory createBeanFactory(String factoryName) {
    BeanFactoryLocator bfl = ContextSingletonBeanFactoryLocator.getInstance();
    BeanFactoryReference ref = bfl.useBeanFactory(factoryName);
    BeanFactory result = ref.getFactory();
    log.info("ClassFactory has been initialized with beanFactory '" + factoryName + "'");
    return result;
  }
View Full Code Here

        .getUserTransaction());
  }

  @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

    synchronized (instances) {
      if (logger.isTraceEnabled()) {
        logger.trace("ContextSingletonBeanFactoryLocator.getInstance(): instances.hashCode=" +
            instances.hashCode() + ", instances=" + instances);
      }
      BeanFactoryLocator bfl = (BeanFactoryLocator) instances.get(resourceLocation);
      if (bfl == null) {
        bfl = new ContextSingletonBeanFactoryLocator(resourceLocation);
        instances.put(resourceLocation, bfl);
      }
      return bfl;
View Full Code Here

        if (parentContextKey != null)
        {
            // locatorFactorySelector may be null, indicating the default
            // "classpath*:beanRefContext.xml"
            BeanFactoryLocator locator = ContextSingletonBeanFactoryLocator.getInstance(locatorFactorySelector);
            if (logger.isDebugEnabled())
            {
                logger.debug("Getting parent context definition: using parent context key of '" + parentContextKey
                             + "' with BeanFactoryLocator");
            }
            parentContext = (ApplicationContext) locator.useBeanFactory(parentContextKey).getFactory();
        }

        return parentContext;
    }
View Full Code Here

TOP

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

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.