org.springframework.context.support.LiveBeansView Java Examples

The following examples show how to use org.springframework.context.support.LiveBeansView. 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 File: LauncherApplication.java    From spring-cloud-formula with 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 File: LauncherApplication.java    From spring-cloud-formula with 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
Source File: SpringBoot13ActuatorEndpointsBootstrap.java    From thinking-in-spring-boot-samples with Apache License 2.0 5 votes vote down vote up
@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
Source File: RestartIntegrationTests.java    From spring-cloud-commons with Apache License 2.0 5 votes vote down vote up
@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 File: LiveBeansViewServlet.java    From spring-analysis-note with MIT License 4 votes vote down vote up
protected LiveBeansView buildLiveBeansView() {
	return new ServletContextLiveBeansView(getServletContext());
}
 
Example #6
Source File: LiveBeansViewServlet.java    From java-technology-stack with MIT License 4 votes vote down vote up
protected LiveBeansView buildLiveBeansView() {
	return new ServletContextLiveBeansView(getServletContext());
}
 
Example #7
Source File: LiveBeansViewServlet.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
protected LiveBeansView buildLiveBeansView() {
	return new ServletContextLiveBeansView(getServletContext());
}
 
Example #8
Source File: LiveBeansViewServlet.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
protected LiveBeansView buildLiveBeansView() {
	return new ServletContextLiveBeansView(getServletContext());
}