當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。