Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.BeanFactory


    }.runTest();
  }

  public void testRequiresListableBeanFactoryAndChokesOnAnythingElse() throws Exception {
    MockControl mockBeanFactory = MockControl.createControl(BeanFactory.class);
    final BeanFactory beanFactory = (BeanFactory) mockBeanFactory.getMock();
    mockBeanFactory.replay();

    new AssertThrows(FatalBeanException.class) {
      public void test() throws Exception {
        ServiceLocatorFactoryBean factory = new ServiceLocatorFactoryBean();
View Full Code Here


    DependenciesBean rod5 = (DependenciesBean) xbf.getBean("rod5");
    // Should not have been autowired
    assertNull(rod5.getSpouse());

    BeanFactory appCtx = (BeanFactory) xbf.getBean("childAppCtx");
    assertTrue(appCtx.containsBean("rod1"));
    assertTrue(appCtx.containsBean("jenny"));
  }
View Full Code Here

   * So rubbish class names in bean defs must now not be 'resolved' when the
   * bean def is being parsed, 'cos everything on a bean def is now lazy, but
   * must rather only be picked up when the bean is instantiated.
   */
  public void testClassNotFoundWithDefaultBeanClassLoader() {
    BeanFactory factory = new XmlBeanFactory(new ClassPathResource("classNotFound.xml", getClass()));
    // cool, no errors, so the rubbish class name in the bean def was not resolved
    try {
      // let's resolve the bean definition; must blow up
      factory.getBean("classNotFound");
      fail("Must have thrown a CannotLoadBeanClassException");
    }
    catch (CannotLoadBeanClassException ex) {
      assertTrue(ex.getResourceDescription().indexOf("classNotFound.xml") != -1);
      assertTrue(ex.getCause() instanceof ClassNotFoundException);
View Full Code Here

   public void create(DeploymentInfo di) throws DeploymentException
   {
      URL docURL = getDocUrl(di);
      String defaultName = getDefaultName(di);
      BeanFactory beanFactory = null;
      ClassLoader cl = Thread.currentThread().getContextClassLoader();
      try
      {
         Thread.currentThread().setContextClassLoader(di.ucl);
         beanFactory = createBeanFactory(defaultName, new UrlResource(docURL));
View Full Code Here

   {
      try
      {
         URL docURL = getDocUrl(di);
         String name = (String) beanFactoryNamesMap.remove(docURL.toString());
         BeanFactory beanFactory = lookup(name);
         doClose(beanFactory);
         unbind(name);
         log.info("Bean factory [" + name + "] unbinded from local JNDI.");
      }
      catch (Exception e)
View Full Code Here

      }
   }

   public BeanFactory lookup(String name) throws Exception
   {
      BeanFactory beanFactory = (BeanFactory) Util.lookup(name, getExactBeanFactoryClass());
      log.debug("Found Spring bean factory [" + name + "]: " + beanFactory);
      return beanFactory;
   }
View Full Code Here

      return jndiName;
   }

   private Object getObjectFromBeanFactory(Spring spring, String defaultBeanName, Class beanType) throws Exception
   {
      BeanFactory beanFactory = (BeanFactory) Util.lookup(getJndiName(spring.jndiName()), BeanFactory.class);
      String beanName = spring.bean();
      if (beanName != null && beanName.length() > 0)
      {
         return beanFactory.getBean(beanName, beanType);
      }
      else
      {
         // by type injection
         if (beanFactory instanceof ListableBeanFactory)
         {
            ListableBeanFactory lbf = (ListableBeanFactory) beanFactory;
            Map beans = lbf.getBeansOfType(beanType);
            if (beans.size() > 1)
            {
               Object bean = beans.get(defaultBeanName);
               if (bean == null)
               {
                  throw new IllegalArgumentException("More than one bean of type: " + beanType);
               }
               return bean;
            }
            else if (beans.size() == 1)
            {
               return beans.values().iterator().next();
            }
            else
            {
               throw new IllegalArgumentException("No such bean by type: " + beanType);
            }
         }
         else
         {
            // bean factory is not listable - use default bean name
            return beanFactory.getBean(defaultBeanName, beanType);
         }
      }
   }
View Full Code Here

      FlowStateBean flowBean = super
          .getFlowBeanFromContext(executionContext);
      //MessageLogs tmpMl = flowBean.getMLog();

      // Get the Spring bean responsible for loading the decision table
      BeanFactory appContext = super.getSpringContext();
      dtLoader = (SpringDecisionTableLoader) appContext
          .getBean(SPRING_DECISION_TABLE_LOADER_BEAN_NAME);

      //Set the state that we are in on the bean
     
      // Carry out the processing using the Delegate
View Full Code Here

   */
  protected BeanFactory getSpringContext() throws RpException {
     
    log.debug("getting Spring context ");
   
    BeanFactory myFactory = ContextLoader.getHandleToBeanFactory();
   
    log.debug("BeanFactory is Null:"+myFactory);
    return myFactory;
   
   
View Full Code Here

    try{
      //Carry out the processing
      FlowStateBean flowBean=super.getFlowBeanFromContext(executionContext);
     
      // Get the Spring bean responsible for loading the decision table
      BeanFactory appContext = super.getSpringContext();
      MessageDao mDao = (MessageDao) appContext.getBean(DAO_NAME);
     
     
     

        executionContext.leaveNode();
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.BeanFactory

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.