org.springframework.context.support

Class LiveBeansView

  • java.lang.Object
    • org.springframework.context.support.LiveBeansView
    • Field Detail

      • MBEAN_DOMAIN_PROPERTY_NAME

        public static final java.lang.String MBEAN_DOMAIN_PROPERTY_NAME
        The "MBean Domain" property name.
        See Also:
        Constant Field Values
      • MBEAN_APPLICATION_KEY

        public static final java.lang.String MBEAN_APPLICATION_KEY
        The MBean application key.
        See Also:
        Constant Field Values
    • Constructor Detail

      • LiveBeansView

        public LiveBeansView()
    • Method Detail

      • findApplicationContexts

        protected java.util.Set<ConfigurableApplicationContext> findApplicationContexts()
        Find all applicable ApplicationContexts for the current application.

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

        Returns:
        the set of ApplicationContexts
      • generateJson

        protected java.lang.String generateJson(java.util.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.

        Parameters:
        contexts - the set of ApplicationContexts
        Returns:
        the JSON document
      • isBeanEligible

        protected boolean isBeanEligible(java.lang.String beanName,
                                         BeanDefinition bd,
                                         ConfigurableBeanFactory bf)
        Determine whether the specified bean is eligible for inclusion in the LiveBeansView JSON snapshot.
        Parameters:
        beanName - the name of the bean
        bd - the corresponding bean definition
        bf - the containing bean factory
        Returns:
        true if the bean is to be included; false otherwise
      • getEscapedResourceDescription

        @Nullable
        protected java.lang.String getEscapedResourceDescription(BeanDefinition bd)
        Determine a resource description for the given bean definition and apply basic JSON escaping (backslashes, double quotes) to it.
        Parameters:
        bd - the bean definition to build the resource description for
        Returns:
        the JSON-escaped resource description