Java Code Examples for org.springframework.context.ConfigurableApplicationContext#getApplicationName()

The following examples show how to use org.springframework.context.ConfigurableApplicationContext#getApplicationName() . 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: LiveBeansView.java    From spring-analysis-note with MIT License 6 votes vote down vote up
static void registerApplicationContext(ConfigurableApplicationContext applicationContext) {
	String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME);
	if (mbeanDomain != null) {
		synchronized (applicationContexts) {
			if (applicationContexts.isEmpty()) {
				try {
					MBeanServer server = ManagementFactory.getPlatformMBeanServer();
					applicationName = applicationContext.getApplicationName();
					server.registerMBean(new LiveBeansView(),
							new ObjectName(mbeanDomain, MBEAN_APPLICATION_KEY, applicationName));
				}
				catch (Throwable ex) {
					throw new ApplicationContextException("Failed to register LiveBeansView MBean", ex);
				}
			}
			applicationContexts.add(applicationContext);
		}
	}
}
 
Example 2
Source File: LiveBeansView.java    From java-technology-stack with MIT License 6 votes vote down vote up
static void registerApplicationContext(ConfigurableApplicationContext applicationContext) {
	String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME);
	if (mbeanDomain != null) {
		synchronized (applicationContexts) {
			if (applicationContexts.isEmpty()) {
				try {
					MBeanServer server = ManagementFactory.getPlatformMBeanServer();
					applicationName = applicationContext.getApplicationName();
					server.registerMBean(new LiveBeansView(),
							new ObjectName(mbeanDomain, MBEAN_APPLICATION_KEY, applicationName));
				}
				catch (Throwable ex) {
					throw new ApplicationContextException("Failed to register LiveBeansView MBean", ex);
				}
			}
			applicationContexts.add(applicationContext);
		}
	}
}
 
Example 3
Source File: LiveBeansView.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
static void registerApplicationContext(ConfigurableApplicationContext applicationContext) {
	String mbeanDomain = applicationContext.getEnvironment().getProperty(MBEAN_DOMAIN_PROPERTY_NAME);
	if (mbeanDomain != null) {
		synchronized (applicationContexts) {
			if (applicationContexts.isEmpty()) {
				try {
					MBeanServer server = ManagementFactory.getPlatformMBeanServer();
					applicationName = applicationContext.getApplicationName();
					server.registerMBean(new LiveBeansView(),
							new ObjectName(mbeanDomain, MBEAN_APPLICATION_KEY, applicationName));
				}
				catch (Throwable ex) {
					throw new ApplicationContextException("Failed to register LiveBeansView MBean", ex);
				}
			}
			applicationContexts.add(applicationContext);
		}
	}
}