org.springframework.context.support

## 类 LiveBeansView

- java.lang.Object
- - org.springframework.context.support.LiveBeansView

- 所有已实现的接口:
    org.springframework.beans.factory.Aware, ApplicationContextAware, LiveBeansViewMBean

      public class LiveBeansView
      extends Object
      implements LiveBeansViewMBean, ApplicationContextAware

  Adapter for live beans view exposure, building a snapshot of current beans and their dependencies from either a local `ApplicationContext` (with a local `LiveBeansView` bean definition) or all registered ApplicationContexts (driven by the "spring.liveBeansView.mbeanDomain" environment property).

  Note: This feature is still in beta and primarily designed for use with Spring Tool Suite 3.1 and higher.

  从以下版本开始:
    3.2
  作者:
    Juergen Hoeller, Stephane Nicoll
  另请参阅:
    `getSnapshotAsJson()`, `org.springframework.web.context.support.LiveBeansViewServlet`

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static String` | `MBEAN_APPLICATION_KEY`
    `static String` | `MBEAN_DOMAIN_PROPERTY_NAME`

  - ### 构造器概要

    构造器
    构造器和说明
    `LiveBeansView()`

  - ### 方法概要

    所有方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected Set<ConfigurableApplicationContext>` | `findApplicationContexts()` Find all applicable ApplicationContexts for the current application.
    `protected String` | `generateJson(Set<ConfigurableApplicationContext> contexts)` Actually generate a JSON snapshot of the beans in the given ApplicationContexts.
    `protected String` | `getEscapedResourceDescription(org.springframework.beans.factory.config.BeanDefinition bd)` Determine a resource description for the given bean definition and apply basic JSON escaping (backslashes, double quotes) to it.
    `String` | `getSnapshotAsJson()` Generate a JSON snapshot of current beans and their dependencies, finding all active ApplicationContexts through `findApplicationContexts()`, then delegating to `generateJson(java.util.Set)`.
    `protected boolean` | `isBeanEligible(String beanName, org.springframework.beans.factory.config.BeanDefinition bd, org.springframework.beans.factory.config.ConfigurableBeanFactory bf)` Determine whether the specified bean is eligible for inclusion in the LiveBeansView JSON snapshot.
    `void` | `setApplicationContext(ApplicationContext applicationContext)` Set the ApplicationContext that this object runs in.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 字段详细资料

    - #### MBEAN_DOMAIN_PROPERTY_NAME

          public static final String MBEAN_DOMAIN_PROPERTY_NAME

      另请参阅:
        常量字段值

    - #### MBEAN_APPLICATION_KEY

          public static final String MBEAN_APPLICATION_KEY

      另请参阅:
        常量字段值

  - ### 构造器详细资料

    - #### LiveBeansView

          public LiveBeansView()

  - ### 方法详细资料

    - #### setApplicationContext

          public void setApplicationContext(ApplicationContext applicationContext)

      从接口复制的说明: `ApplicationContextAware`
      Set the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.

      Invoked after population of normal bean properties but before an init callback such as `InitializingBean.afterPropertiesSet()` or a custom init-method. Invoked after `ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)`, `ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)` and `MessageSourceAware`, if applicable.

      指定者:
        `setApplicationContext` 在接口中 `ApplicationContextAware`
      参数:
        `applicationContext` - the ApplicationContext object to be used by this object
      另请参阅:
        `BeanInitializationException`

    - #### getSnapshotAsJson

          public String getSnapshotAsJson()

      Generate a JSON snapshot of current beans and their dependencies, finding all active ApplicationContexts through `findApplicationContexts()`, then delegating to `generateJson(java.util.Set)`.
      指定者:
        `getSnapshotAsJson` 在接口中 `LiveBeansViewMBean`

    - #### findApplicationContexts

          protected Set<ConfigurableApplicationContext> findApplicationContexts()

      Find all applicable ApplicationContexts for the current application.

      Called if no specific ApplicationContext has been set for this LiveBeansView.

      返回:
        the set of ApplicationContexts

    - #### generateJson

          protected String generateJson(Set<ConfigurableApplicationContext> contexts)

      Actually generate a JSON snapshot of the beans in the given ApplicationContexts.

      This implementation doesn't use any JSON parsing libraries in order to avoid third-party library dependencies. It produces an array of context description objects, each containing a context and parent attribute as well as a beans attribute with nested bean description objects. Each bean object contains a bean, scope, type and resource attribute, as well as a dependencies attribute with a nested array of bean names that the present bean depends on.

      参数:
        `contexts` - the set of ApplicationContexts
      返回:
        the JSON document

    - #### isBeanEligible

          protected boolean isBeanEligible(String beanName,
                                           org.springframework.beans.factory.config.BeanDefinition bd,
                                           org.springframework.beans.factory.config.ConfigurableBeanFactory bf)

      Determine whether the specified bean is eligible for inclusion in the LiveBeansView JSON snapshot.
      参数:
        `beanName` - the name of the bean
        `bd` - the corresponding bean definition
        `bf` - the containing bean factory
      返回:
        `true` if the bean is to be included; `false` otherwise

    - #### getEscapedResourceDescription

          @Nullable
          protected String getEscapedResourceDescription(org.springframework.beans.factory.config.BeanDefinition bd)

      Determine a resource description for the given bean definition and apply basic JSON escaping (backslashes, double quotes) to it.
      参数:
        `bd` - the bean definition to build the resource description for
      返回:
        the JSON-escaped resource description