当前位置: 首页>>代码示例>>Java>>正文


Java MBeanServerFactory.findMBeanServer方法代码示例

本文整理汇总了Java中javax.management.MBeanServerFactory.findMBeanServer方法的典型用法代码示例。如果您正苦于以下问题:Java MBeanServerFactory.findMBeanServer方法的具体用法?Java MBeanServerFactory.findMBeanServer怎么用?Java MBeanServerFactory.findMBeanServer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.MBeanServerFactory的用法示例。


在下文中一共展示了MBeanServerFactory.findMBeanServer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findServer

import javax.management.MBeanServerFactory; //导入方法依赖的package包/类
/**
 * Locate the MBean server to use based on user input from startup.
 *
 * @return The MBean server to use.
 */
private MBeanServer findServer() {
	if ( usePlatformServer ) {
		// they specified to use the platform (vm) server
		return ManagementFactory.getPlatformMBeanServer();
	}

	// otherwise lookup all servers by (optional) agentId.
	// IMPL NOTE : the findMBeanServer call treats a null agentId to mean match all...
	ArrayList<MBeanServer> mbeanServers = MBeanServerFactory.findMBeanServer( agentId );

	if ( defaultDomain == null ) {
		// they did not specify a domain by which to locate a particular MBeanServer to use, so chose the first
		return mbeanServers.get( 0 );
	}

	for ( MBeanServer mbeanServer : mbeanServers ) {
		// they did specify a domain, so attempt to locate an MBEanServer with a matching default domain, returning it
		// if we find it.
		if ( defaultDomain.equals( mbeanServer.getDefaultDomain() ) ) {
			return mbeanServer;
		}
	}

	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:31,代码来源:JmxServiceImpl.java

示例2: load

import javax.management.MBeanServerFactory; //导入方法依赖的package包/类
private static Class<?> load(ClassLoader without, String className)
        throws ClassNotFoundException {
    final List<MBeanServer> mbsList = MBeanServerFactory.findMBeanServer(null);

    for (MBeanServer mbs : mbsList) {
        ClassLoaderRepository clr = mbs.getClassLoaderRepository();
        try {
            return clr.loadClassWithout(without, className);
        } catch (ClassNotFoundException e) {
            // OK : Try with next one...
        }
    }
    throw new ClassNotFoundException(className);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:DefaultLoaderRepository.java

示例3: locateMBeanServer

import javax.management.MBeanServerFactory; //导入方法依赖的package包/类
/**
 * Attempt to find a locally running {@code MBeanServer}. Fails if no
 * {@code MBeanServer} can be found. Logs a warning if more than one
 * {@code MBeanServer} found, returning the first one from the list.
 * @param agentId the agent identifier of the MBeanServer to retrieve.
 * If this parameter is {@code null}, all registered MBeanServers are considered.
 * If the empty String is given, the platform MBeanServer will be returned.
 * @return the {@code MBeanServer} if found
 * @throws org.springframework.jmx.MBeanServerNotFoundException
 * if no {@code MBeanServer} could be found
 * @see javax.management.MBeanServerFactory#findMBeanServer(String)
 */
public static MBeanServer locateMBeanServer(String agentId) throws MBeanServerNotFoundException {
	MBeanServer server = null;

	// null means any registered server, but "" specifically means the platform server
	if (!"".equals(agentId)) {
		List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(agentId);
		if (servers != null && servers.size() > 0) {
			// Check to see if an MBeanServer is registered.
			if (servers.size() > 1 && logger.isWarnEnabled()) {
				logger.warn("Found more than one MBeanServer instance" +
						(agentId != null ? " with agent id [" + agentId + "]" : "") +
						". Returning first from list.");
			}
			server = servers.get(0);
		}
	}

	if (server == null && !StringUtils.hasLength(agentId)) {
		// Attempt to load the PlatformMBeanServer.
		try {
			server = ManagementFactory.getPlatformMBeanServer();
		}
		catch (SecurityException ex) {
			throw new MBeanServerNotFoundException("No specific MBeanServer found, " +
					"and not allowed to obtain the Java platform MBeanServer", ex);
		}
	}

	if (server == null) {
		throw new MBeanServerNotFoundException(
				"Unable to locate an MBeanServer instance" +
				(agentId != null ? " with agent id [" + agentId + "]" : ""));
	}

	if (logger.isDebugEnabled()) {
		logger.debug("Found MBeanServer: " + server);
	}
	return server;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:52,代码来源:JmxUtils.java


注:本文中的javax.management.MBeanServerFactory.findMBeanServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。