Package org.springframework.beans.factory.config

Examples of org.springframework.beans.factory.config.ConfigurableListableBeanFactory


   * Return a Map of all singleton beans that implement the
   * Lifecycle interface in this context.
   * @return Map of Lifecycle beans with bean name as key
   */
  private Map getLifecycleBeans() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    String[] beanNames = beanFactory.getSingletonNames();
    Map beans = new LinkedHashMap();
    for (int i = 0; i < beanNames.length; i++) {
      Object bean = beanFactory.getSingleton(beanNames[i]);
      if (bean instanceof Lifecycle) {
        beans.put(beanNames[i], bean);
      }
    }
    return beans;
View Full Code Here


  }


  protected final void refreshBeanFactory() throws BeansException {
    // Shut down previous bean factory, if any.
    ConfigurableListableBeanFactory oldBeanFactory = null;
    synchronized (this.beanFactoryMonitor) {
      oldBeanFactory = this.beanFactory;
    }
    if (oldBeanFactory != null) {
      oldBeanFactory.destroySingletons();
      synchronized (this.beanFactoryMonitor) {
        this.beanFactory = null;
      }
    }
View Full Code Here

    if (!(getApplicationContext() instanceof ConfigurableApplicationContext)) {
      throw new IllegalStateException(
          "[" + getClass().getName() + "] needs to run in a ConfigurableApplicationContext");
    }
    ConfigurableListableBeanFactory beanFactory =
        ((ConfigurableApplicationContext) getApplicationContext()).getBeanFactory();
    detectAndCreateHandlers(beanFactory);
  }
View Full Code Here

    synchronized (this.startupShutdownMonitor) {
      // Prepare this context for refreshing.
      prepareRefresh();

      // Tell the subclass to refresh the internal bean factory.
      ConfigurableListableBeanFactory beanFactory = obtainFreshBeanFactory();

      // Prepare the bean factory for use in this context.
      prepareBeanFactory(beanFactory);

      try {
        // Allows post-processing of the bean factory in context subclasses.
        postProcessBeanFactory(beanFactory);

        // Invoke factory processors registered as beans in the context.
        invokeBeanFactoryPostProcessors(beanFactory);

        // Register bean processors that intercept bean creation.
        registerBeanPostProcessors(beanFactory);

        // Initialize message source for this context.
        initMessageSource();

        // Initialize event multicaster for this context.
        initApplicationEventMulticaster();

        // Initialize other special beans in specific context subclasses.
        onRefresh();

        // Check for listener beans and register them.
        registerListeners();

        // Instantiate all remaining (non-lazy-init) singletons.
        beanFactory.preInstantiateSingletons();

        // Last step: publish corresponding event.
        finishRefresh();
      }

      catch (BeansException ex) {
        // Destroy already created singletons to avoid dangling resources.
        beanFactory.destroySingletons();

        // Reset 'active' flag.
        cancelRefresh(ex);

        // Propagate exception to caller.
View Full Code Here

   * @see #refreshBeanFactory()
   * @see #getBeanFactory()
   */
  protected ConfigurableListableBeanFactory obtainFreshBeanFactory() {
    refreshBeanFactory();
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();

    if (logger.isInfoEnabled()) {
      logger.info("Bean factory for application context [" + ObjectUtils.identityToString(this) +
          "]: " + ObjectUtils.identityToString(beanFactory));
    }
    if (logger.isDebugEnabled()) {
      logger.debug(beanFactory.getBeanDefinitionCount() + " beans defined in " + this);
    }

    return beanFactory;
  }
View Full Code Here

   * Return a Collection of all singleton beans that implement the
   * Lifecycle interface in this context.
   * @return Collection of Lifecycle beans
   */
  protected Collection getLifecycleBeans() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    String[] beanNames = beanFactory.getBeanNamesForType(Lifecycle.class, false, false);
    Collection beans = new ArrayList(beanNames.length);
    for (int i = 0; i < beanNames.length; i++) {
      Object bean = beanFactory.getSingleton(beanNames[i]);
      if (bean != null) {
        beans.add(bean);
      }
    }
    return beans;
View Full Code Here

    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));

      //Spring Security xml config depends on this Bean
      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
      ClassPathXmlApplicationContext springAppContext = new
View Full Code Here

    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));
      //Spring Security xml config depends on this Bean

      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
      ClassPathXmlApplicationContext springAppContext = new
View Full Code Here

        }

        execution.setStatus(ReportExecStatus.RUNNING);
        execution = reportExecDAO.save(execution);

        ConfigurableListableBeanFactory beanFactory =
                ApplicationContextProvider.getApplicationContext().getBeanFactory();

        // 3. actual report execution
        StringBuilder reportExecutionMessage = new StringBuilder();
        StringWriter exceptionWriter = new StringWriter();
        try {
            // report header
            handler.startDocument();
            AttributesImpl atts = new AttributesImpl();
            atts.addAttribute("", "", ATTR_NAME, XSD_STRING, report.getName());
            handler.startElement("", "", ELEMENT_REPORT, atts);

            // iterate over reportlet instances defined for this report
            for (ReportletConf reportletConf : report.getReportletConfs()) {
                Class<Reportlet> reportletClass =
                        dataBinder.findReportletClassHavingConfClass(reportletConf.getClass());
                if (reportletClass != null) {
                    Reportlet autowired = (Reportlet) beanFactory.createBean(reportletClass,
                            AbstractBeanDefinition.AUTOWIRE_BY_TYPE, false);
                    autowired.setConf(reportletConf);

                    // invoke reportlet
                    try {
View Full Code Here

    try {
      ClassPathXmlApplicationContext parentSpringAppContext =
          new ClassPathXmlApplicationContext();
      parentSpringAppContext.refresh();
      ConfigurableListableBeanFactory factory = parentSpringAppContext.
          getBeanFactory();
      factory.registerSingleton("guiceInjector",
          injector);
      factory.registerSingleton("passwordEncoder",
          injector.getInstance(PasswordEncoder.class));
      factory.registerSingleton("ambariLocalUserService",
          injector.getInstance(AmbariLocalUserDetailsService.class));
      factory.registerSingleton("ambariLdapAuthenticationProvider",
          injector.getInstance(AmbariLdapAuthenticationProvider.class));
      //Spring Security xml config depends on this Bean

      String[] contextLocations = {SPRING_CONTEXT_LOCATION};
      ClassPathXmlApplicationContext springAppContext = new
View Full Code Here

TOP

Related Classes of org.springframework.beans.factory.config.ConfigurableListableBeanFactory

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.