Package org.springframework.beans.factory

Examples of org.springframework.beans.factory.ListableBeanFactory


  /**
   * Test that inner bean for target means that we can use
   * autowire without ambiguity from target and proxy
   */
  public void testTargetAsInnerBean() {
    ListableBeanFactory bf = new XmlBeanFactory(new ClassPathResource("innerBeanTarget.xml", getClass()));
    ITestBean itb = (ITestBean) bf.getBean("testBean");
    assertEquals("innerBeanTarget", itb.getName());
    assertEquals("Only have proxy and interceptor: no target", 3, bf.getBeanDefinitionCount());
    DependsOnITestBean doit = (DependsOnITestBean) bf.getBean("autowireCheck");
    assertSame(itb, doit.tb);
  }
View Full Code Here


        // Snarf the beans from Spring
        if (beanFactory instanceof ListableBeanFactory)
        {
            try
            {
                ListableBeanFactory listable = (ListableBeanFactory) beanFactory;
                names.addAll(Arrays.asList(listable.getBeanDefinitionNames()));
            }
            catch (IllegalStateException ex)
            {
                log.warn("List of beanNames does not include Spring beans since the BeanFactory was closed when we tried to read it.");
            }
View Full Code Here

            throw new IllegalArgumentException(SYNTAX_MSG);

        SpringExtAuth.prepMemoryDatabases(!sa[0].equals("HsqldbSlave"));
        ApplicationContext ctx =
            new ClassPathXmlApplicationContext("beandefs.xml", authSpringFile);
        ListableBeanFactory bf = (ListableBeanFactory) ctx;
        JdbcAppClass appBean = bf.getBean("appBean", JdbcAppClass.class);
        appBean.doJdbcWork();
    }
View Full Code Here

    /**
     * Register all registered sitemap listeners
     */
    protected void registerListeners() {
        final ListableBeanFactory listableFactory = this.itsContainer;
        Map beans = listableFactory.getBeansOfType(EnterSitemapEventListener.class);
        if ( beans != null ) {
            final Iterator i = beans.values().iterator();
            while ( i.hasNext() ) {
                this.enterSitemapEventListeners.add(i.next());
            }
        }
        beans = listableFactory.getBeansOfType(LeaveSitemapEventListener.class);
        if ( beans != null ) {
            final Iterator i = beans.values().iterator();
            while ( i.hasNext() ) {
                this.leaveSitemapEventListeners.add(i.next());
            }
View Full Code Here

  }

  private Collection<String> getBeanIdsForType( String pluginId, Class<?> clazz ) {
    ArrayList<String> ids = new ArrayList<String>();

    ListableBeanFactory fac = beanFactoryMap.get( pluginId ).getBeanFactory();

    String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors( fac, clazz );
    for ( String beanName : names ) {
      ids.add( beanName );
      for ( String beanAlias : fac.getAliases( beanName ) ) {
        ids.add( beanAlias );
      }
    }
    return ids;
  }
View Full Code Here

  protected Map<String, ListableBeanFactory> getPluginBeanFactories() {
    Collection<String> pluginIds = pluginManager.getRegisteredPlugins();
    Map<String, ListableBeanFactory> pluginBeanFactoryMap = new HashMap<String, ListableBeanFactory>();
    for ( String pluginId : pluginIds ) {
      ListableBeanFactory beanFactory = pluginManager.getBeanFactory( pluginId );
      if ( beanFactory != null ) {
        pluginBeanFactoryMap.put( pluginId, beanFactory );
      }
    }
    return pluginBeanFactoryMap;
View Full Code Here

   * @return a Collection of PhaseListener objects
   * @see #getBeanFactory
   * @see org.springframework.beans.factory.ListableBeanFactory#getBeansOfType(Class)
   */
  protected Collection getDelegates(FacesContext facesContext) {
    ListableBeanFactory bf = getBeanFactory(facesContext);
    return BeanFactoryUtils.beansOfTypeIncludingAncestors(bf, PhaseListener.class, true, false).values();
  }
View Full Code Here

            if (!"".equals(nrOfCallsString)) {
                nrOfCalls = Integer.parseInt(nrOfCallsString);
            }

            ListableBeanFactory beanFactory = new FileSystemXmlApplicationContext("clientContext.xml");
            ClientApplication client = new ClientApplication(beanFactory);

            client.invokeContactManager(new UsernamePasswordAuthenticationToken(username, password), nrOfCalls);
            System.exit(0);
        }
View Full Code Here

  public ConfigurationPhase getConfigurationPhase() {
    return ConfigurationPhase.PARSE_CONFIGURATION;
  }

  public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
    ListableBeanFactory factory = context.getBeanFactory();
    String[] names = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(factory, this.beanType, false, false);
    if (ObjectUtils.isEmpty(names)) {
      logger.debug("No bean of type [" + this.beanType + "]. Conditional configuration applies.");
      return true;
    }
View Full Code Here

    if (getEntityManagerFactory() == null) {
      if (!(beanFactory instanceof ListableBeanFactory)) {
        throw new IllegalStateException("Cannot retrieve EntityManagerFactory by persistence unit name " +
            "in a non-listable BeanFactory: " + beanFactory);
      }
      ListableBeanFactory lbf = (ListableBeanFactory) beanFactory;
      setEntityManagerFactory(EntityManagerFactoryUtils.findEntityManagerFactory(lbf, getPersistenceUnitName()));
    }
  }
View Full Code Here

TOP

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

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.