Java Code Examples for org.springframework.context.support.LiveBeansView

The following examples show how to use org.springframework.context.support.LiveBeansView. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-cloud-formula   Source File: LauncherApplication.java    License: Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) {
    originalMBeanDomain = System.getProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME);
    originalAdminEnabled = System.getProperty("spring.application.admin.enabled");

    System.clearProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME);
    System.clearProperty("spring.application.admin.enabled");
    SpringApplication.run(LauncherApplication.class, args);
}
 
Example 2
Source Project: spring-cloud-formula   Source File: LauncherApplication.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public CommandLineRunner commandLineRunner(DependencyProcessor dependencyProcessor, ResourceLoader resourceLoader) {
    return args -> {
        if (launcherProperties.getApplicationPath() == null) {
            throw new LaunchingException("application path can not be null");
        }

        if (originalMBeanDomain != null) {
            System.setProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME, originalMBeanDomain);
        }
        if (originalAdminEnabled != null) {
            System.setProperty("spring.application.admin.enabled", originalAdminEnabled);
        }

        Resource gitResource = resourceLoader.getResource("classpath:/git.properties");

        try (InputStream in = gitResource.getInputStream()) {
            Properties props = new Properties();
            props.load(in);

            props.forEach((key, value) -> {
                System.setProperty("formula.launcher." + key, (String) value);
            });
        } catch (FileNotFoundException e) {
            // do nothing
        }

        new FormulaLauncher(launcherProperties, dependencyProcessor).launch(args);
    };
}
 
Example 3
@Override
public void setApplicationContext(ApplicationContext context) throws BeansException {
    // 复制 BeansEndpoint#setApplicationContext(ApplicationContext) 方法实现
    if (context.getEnvironment()
            .getProperty(LiveBeansView.MBEAN_DOMAIN_PROPERTY_NAME) == null) {
        this.liveBeansView.setApplicationContext(context);
    }
}
 
Example 4
@Test
public void testRestartTwice() throws Exception {

	this.context = SpringApplication.run(TestConfiguration.class,
			"--management.endpoint.restart.enabled=true", "--server.port=0",
			"--management.endpoints.web.exposure.include=restart",
			"--spring.liveBeansView.mbeanDomain=livebeans");

	RestartEndpoint endpoint = this.context.getBean(RestartEndpoint.class);
	then(this.context.getParent()).isNotNull();
	then(this.context.getParent().getParent()).isNull();
	this.context = endpoint.doRestart();

	then(this.context).isNotNull();
	then(this.context.getParent()).isNotNull();
	then(this.context.getParent().getParent()).isNull();

	RestartEndpoint next = this.context.getBean(RestartEndpoint.class);
	then(next).isSameAs(endpoint);
	this.context = next.doRestart();

	then(this.context).isNotNull();
	then(this.context.getParent()).isNotNull();
	then(this.context.getParent().getParent()).isNull();

	LiveBeansView beans = new LiveBeansView();
	String json = beans.getSnapshotAsJson();
	then(json).containsOnlyOnce("parent\": \"bootstrap");
	then(json).containsOnlyOnce("parent\": null");
}
 
Example 5
Source Project: spring-analysis-note   Source File: LiveBeansViewServlet.java    License: MIT License 4 votes vote down vote up
protected LiveBeansView buildLiveBeansView() {
	return new ServletContextLiveBeansView(getServletContext());
}
 
Example 6
Source Project: java-technology-stack   Source File: LiveBeansViewServlet.java    License: MIT License 4 votes vote down vote up
protected LiveBeansView buildLiveBeansView() {
	return new ServletContextLiveBeansView(getServletContext());
}
 
Example 7
Source Project: lams   Source File: LiveBeansViewServlet.java    License: GNU General Public License v2.0 4 votes vote down vote up
protected LiveBeansView buildLiveBeansView() {
	return new ServletContextLiveBeansView(getServletContext());
}
 
Example 8
protected LiveBeansView buildLiveBeansView() {
	return new ServletContextLiveBeansView(getServletContext());
}