public class LiveBeansView extends java.lang.Object implements LiveBeansViewMBean, ApplicationContextAware
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.
getSnapshotAsJson()
,
LiveBeansViewServlet
Modifier and Type | Field and Description |
---|---|
private ConfigurableApplicationContext |
applicationContext |
private static java.util.Set<ConfigurableApplicationContext> |
applicationContexts |
static java.lang.String |
MBEAN_APPLICATION_KEY |
static java.lang.String |
MBEAN_DOMAIN_PROPERTY_NAME |
Constructor and Description |
---|
LiveBeansView() |
Modifier and Type | Method and Description |
---|---|
protected java.util.Set<ConfigurableApplicationContext> |
findApplicationContexts()
Find all applicable ApplicationContexts for the current application.
|
protected java.lang.String |
generateJson(java.util.Set<ConfigurableApplicationContext> contexts)
Actually generate a JSON snapshot of the beans in the given ApplicationContexts.
|
java.lang.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) . |
(package private) static void |
registerApplicationContext(ConfigurableApplicationContext applicationContext) |
void |
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
|
(package private) static void |
unregisterApplicationContext(ConfigurableApplicationContext applicationContext) |
public static final java.lang.String MBEAN_DOMAIN_PROPERTY_NAME
public static final java.lang.String MBEAN_APPLICATION_KEY
private static final java.util.Set<ConfigurableApplicationContext> applicationContexts
private ConfigurableApplicationContext applicationContext
static void registerApplicationContext(ConfigurableApplicationContext applicationContext)
static void unregisterApplicationContext(ConfigurableApplicationContext applicationContext)
public void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAware
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
in interface ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectBeanInitializationException
public java.lang.String getSnapshotAsJson()
findApplicationContexts()
,
then delegating to generateJson(java.util.Set)
.getSnapshotAsJson
in interface LiveBeansViewMBean
protected java.lang.String generateJson(java.util.Set<ConfigurableApplicationContext> contexts)
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 ApplicationContextsprotected java.util.Set<ConfigurableApplicationContext> findApplicationContexts()
Called if no specific ApplicationContext has been set for this LiveBeansView.