Package org.springframework.beans.factory.config

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


   * @see #refreshBeanFactory()
   * @see #getBeanFactory()
   */
  protected ConfigurableListableBeanFactory obtainFreshBeanFactory() {
    refreshBeanFactory();
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (logger.isDebugEnabled()) {
      logger.debug("Bean factory for " + getDisplayName() + ": " + beanFactory);
    }
    return beanFactory;
  }
View Full Code Here


  /**
   * Initialize the MessageSource.
   * Use parent's if none defined in this context.
   */
  protected void initMessageSource() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(MESSAGE_SOURCE_BEAN_NAME)) {
      this.messageSource = beanFactory.getBean(MESSAGE_SOURCE_BEAN_NAME, MessageSource.class);
      // Make MessageSource aware of parent MessageSource.
      if (this.parent != null && this.messageSource instanceof HierarchicalMessageSource) {
        HierarchicalMessageSource hms = (HierarchicalMessageSource) this.messageSource;
        if (hms.getParentMessageSource() == null) {
          // Only set parent context as parent MessageSource if no parent MessageSource
          // registered already.
          hms.setParentMessageSource(getInternalParentMessageSource());
        }
      }
      if (logger.isDebugEnabled()) {
        logger.debug("Using MessageSource [" + this.messageSource + "]");
      }
    }
    else {
      // Use empty MessageSource to be able to accept getMessage calls.
      DelegatingMessageSource dms = new DelegatingMessageSource();
      dms.setParentMessageSource(getInternalParentMessageSource());
      this.messageSource = dms;
      beanFactory.registerSingleton(MESSAGE_SOURCE_BEAN_NAME, this.messageSource);
      if (logger.isDebugEnabled()) {
        logger.debug("Unable to locate MessageSource with name '" + MESSAGE_SOURCE_BEAN_NAME +
            "': using default [" + this.messageSource + "]");
      }
    }
View Full Code Here

   * Initialize the ApplicationEventMulticaster.
   * Uses SimpleApplicationEventMulticaster if none defined in the context.
   * @see org.springframework.context.event.SimpleApplicationEventMulticaster
   */
  protected void initApplicationEventMulticaster() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
      this.applicationEventMulticaster =
          beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
      if (logger.isDebugEnabled()) {
        logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
      }
    }
    else {
      this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
      beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
      if (logger.isDebugEnabled()) {
        logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
            APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
            "': using default [" + this.applicationEventMulticaster + "]");
      }
View Full Code Here

   * Initialize the LifecycleProcessor.
   * Uses DefaultLifecycleProcessor if none defined in the context.
   * @see org.springframework.context.support.DefaultLifecycleProcessor
   */
  protected void initLifecycleProcessor() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(LIFECYCLE_PROCESSOR_BEAN_NAME)) {
      this.lifecycleProcessor =
          beanFactory.getBean(LIFECYCLE_PROCESSOR_BEAN_NAME, LifecycleProcessor.class);
      if (logger.isDebugEnabled()) {
        logger.debug("Using LifecycleProcessor [" + this.lifecycleProcessor + "]");
      }
    }
    else {
      DefaultLifecycleProcessor defaultProcessor = new DefaultLifecycleProcessor();
      defaultProcessor.setBeanFactory(beanFactory);
      this.lifecycleProcessor = defaultProcessor;
      beanFactory.registerSingleton(LIFECYCLE_PROCESSOR_BEAN_NAME, this.lifecycleProcessor);
      if (logger.isDebugEnabled()) {
        logger.debug("Unable to locate LifecycleProcessor with name '" +
            LIFECYCLE_PROCESSOR_BEAN_NAME +
            "': using default [" + this.lifecycleProcessor + "]");
      }
View Full Code Here

      }
      else {
        result.append("\"parent\": null,\n");
      }
      result.append("\"beans\": [\n");
      ConfigurableListableBeanFactory bf = context.getBeanFactory();
      String[] beanNames = bf.getBeanDefinitionNames();
      for (int i = 0; i < beanNames.length; i++) {
        String beanName = beanNames[i];
        BeanDefinition bd = bf.getBeanDefinition(beanName);
        if (bd.getRole() != BeanDefinition.ROLE_INFRASTRUCTURE &&
            (!bd.isLazyInit() || bf.containsSingleton(beanName))) {
          result.append("{\n\"bean\": \"").append(beanName).append("\",\n");
          String scope = bd.getScope();
          if (!StringUtils.hasText(scope)) {
            scope = BeanDefinition.SCOPE_SINGLETON;
          }
          result.append("\"scope\": \"").append(scope).append("\",\n");
          Class<?> beanType = bf.getType(beanName);
          if (beanType != null) {
            result.append("\"type\": \"").append(beanType.getName()).append("\",\n");
          }
          else {
            result.append("\"type\": null,\n");
          }
          String resource = StringUtils.replace(bd.getResourceDescription(), "\\", "/");
          result.append("\"resource\": \"").append(resource).append("\",\n");
          result.append("\"dependencies\": [");
          String[] dependencies = bf.getDependenciesForBean(beanName);
          if (dependencies.length > 0) {
            result.append("\"");
          }
          result.append(StringUtils.arrayToDelimitedString(dependencies, "\", \""));
          if (dependencies.length > 0) {
View Full Code Here

   
    /* *************** package level methods ************** */

    void processBeanFactory(final BeanFactoryCallback callback) {
       
        ConfigurableListableBeanFactory listableBeanFactory = ObjectUtils.cast(beanFactory, ConfigurableListableBeanFactory.class);
          
        // gets list of all bean definitions in this context
        final String[] beanNames = listableBeanFactory.getBeanDefinitionNames();
        for (String beanName : beanNames) {

            final BeanDefinition beanDefinition = listableBeanFactory.getBeanDefinition(beanName);
            if (!beanDefinition.isAbstract()) {

                final Object bean = beanFactory.getBean(beanName);
                callback.doWithBean(beanName, bean);
            }
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 {
View Full Code Here

   * @see #refreshBeanFactory()
   * @see #getBeanFactory()
   */
  protected ConfigurableListableBeanFactory obtainFreshBeanFactory() {
    refreshBeanFactory();
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (logger.isDebugEnabled()) {
      logger.debug("Bean factory for " + getDisplayName() + ": " + beanFactory);
    }
    return beanFactory;
  }
View Full Code Here

  /**
   * Initialize the MessageSource.
   * Use parent's if none defined in this context.
   */
  protected void initMessageSource() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(MESSAGE_SOURCE_BEAN_NAME)) {
      this.messageSource = beanFactory.getBean(MESSAGE_SOURCE_BEAN_NAME, MessageSource.class);
      // Make MessageSource aware of parent MessageSource.
      if (this.parent != null && this.messageSource instanceof HierarchicalMessageSource) {
        HierarchicalMessageSource hms = (HierarchicalMessageSource) this.messageSource;
        if (hms.getParentMessageSource() == null) {
          // Only set parent context as parent MessageSource if no parent MessageSource
          // registered already.
          hms.setParentMessageSource(getInternalParentMessageSource());
        }
      }
      if (logger.isDebugEnabled()) {
        logger.debug("Using MessageSource [" + this.messageSource + "]");
      }
    }
    else {
      // Use empty MessageSource to be able to accept getMessage calls.
      DelegatingMessageSource dms = new DelegatingMessageSource();
      dms.setParentMessageSource(getInternalParentMessageSource());
      this.messageSource = dms;
      beanFactory.registerSingleton(MESSAGE_SOURCE_BEAN_NAME, this.messageSource);
      if (logger.isDebugEnabled()) {
        logger.debug("Unable to locate MessageSource with name '" + MESSAGE_SOURCE_BEAN_NAME +
            "': using default [" + this.messageSource + "]");
      }
    }
View Full Code Here

   * Initialize the ApplicationEventMulticaster.
   * Uses SimpleApplicationEventMulticaster if none defined in the context.
   * @see org.springframework.context.event.SimpleApplicationEventMulticaster
   */
  protected void initApplicationEventMulticaster() {
    ConfigurableListableBeanFactory beanFactory = getBeanFactory();
    if (beanFactory.containsLocalBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME)) {
      this.applicationEventMulticaster =
          beanFactory.getBean(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, ApplicationEventMulticaster.class);
      if (logger.isDebugEnabled()) {
        logger.debug("Using ApplicationEventMulticaster [" + this.applicationEventMulticaster + "]");
      }
    }
    else {
      this.applicationEventMulticaster = new SimpleApplicationEventMulticaster(beanFactory);
      beanFactory.registerSingleton(APPLICATION_EVENT_MULTICASTER_BEAN_NAME, this.applicationEventMulticaster);
      if (logger.isDebugEnabled()) {
        logger.debug("Unable to locate ApplicationEventMulticaster with name '" +
            APPLICATION_EVENT_MULTICASTER_BEAN_NAME +
            "': using default [" + this.applicationEventMulticaster + "]");
      }
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.