List of usage examples for javax.management MBeanServer getDefaultDomain
public String getDefaultDomain();
From source file:com.flexive.shared.mbeans.MBeanHelper.java
public static MBeanServer locateServer() { final List<MBeanServer> servers = findMBeanServers(); if (LOG.isInfoEnabled()) for (MBeanServer server : servers) { LOG.info("MBeanServer: " + server.getDefaultDomain() + "/" + server.getMBeanCount()); }/*from w w w. j av a 2 s. co m*/ return servers.get(0); }
From source file:com.beginner.core.utils.ProjectUtil.java
/** * ?Web???(???)//w w w .j a v a2 s . co m */ public static String getPort() { String result = ""; try { MBeanServer mBeanServer = null; List<MBeanServer> mBeanServers = MBeanServerFactory.findMBeanServer(null); if (mBeanServers.size() > 0) { for (MBeanServer _mBeanServer : mBeanServers) { mBeanServer = _mBeanServer; break; } } if (mBeanServer == null) { throw new IllegalStateException("?JVM?MBeanServer."); } Set<ObjectName> objectNames = null; objectNames = mBeanServer.queryNames(new ObjectName("Catalina:type=Connector,*"), null); if (objectNames == null || objectNames.size() <= 0) { throw new IllegalStateException("?JVM?MBeanServer : " + mBeanServer.getDefaultDomain() + " ??."); } for (ObjectName objectName : objectNames) { String protocol = (String) mBeanServer.getAttribute(objectName, "protocol"); if (protocol.equals("HTTP/1.1")) { int port = (Integer) mBeanServer.getAttribute(objectName, "port"); result = port + StringUtils.EMPTY; } } } catch (Exception e) { logger.error("?WEB?HTTP/1.1???", e); } return result; }
From source file:chronos.web.listener.ChronosServletListener.java
/** * @return MBeanServer// w w w .jav a 2 s. c o m */ private MBeanServer findOrCreateChronosMBeanServer() { final ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); logger.debug("Got " + servers.size() + " MBean servers"); if (servers.size() == 0) { logger.debug("Creating new MBeanServer for \"chronos\"..."); return MBeanServerFactory.createMBeanServer(CHRONOS); } final MBeanServer server = servers.get(0); logger.debug("Returning MBeanServer domain: " + server.getDefaultDomain()); return server; }
From source file:com.googlecode.psiprobe.beans.JBossResourceResolverBean.java
public MBeanServer getMBeanServer() { for (Iterator it = MBeanServerFactory.findMBeanServer(null).iterator(); it.hasNext();) { MBeanServer server = (MBeanServer) it.next(); if ("jboss".equals(server.getDefaultDomain()) || "DefaultDomain".equals(server.getDefaultDomain())) { return server; }/* w w w. j av a 2 s. co m*/ } return null; }
From source file:net.zcarioca.jmx.services.impl.MBeanObjectServiceImpl.java
private MBeanServer getPlatformMBeanServer() { synchronized (mbeanServer) { if (mbeanServer == null) { // find the JBoss mbean server, if it exists Collection<MBeanServer> mbeanServers = MBeanServerFactory.findMBeanServer(null); if (mbeanServers != null) { if (mbeanServers.size() == 1) { return mbeanServers.iterator().next(); } else if (mbeanServers.size() > 1) { for (MBeanServer mbeanServer : mbeanServers) { String domain = mbeanServer.getDefaultDomain(); if (StringUtils.contains(domain, "jboss")) { return mbeanServer; }// w w w .j a v a 2 s.c om } } } mbeanServer = ManagementFactory.getPlatformMBeanServer(); } return mbeanServer; } }
From source file:it.greenvulcano.jmx.impl.KarafJMXEntryPoint.java
private ObjectName calculateMBeanName(Object mbean, MBeanServer mserver, Map<String, String> properties, String descriptorName) throws Exception { String domain = mserver.getDefaultDomain(); Hashtable<String, String> keyProperties = new Hashtable<String, String>(); if (properties != null) { keyProperties.putAll(properties); }/* ww w. j a v a 2 s . co m*/ if (objectNameBuilders != null) { for (int i = 0; i < objectNameBuilders.size(); i++) { ObjectNameBuilder onb = objectNameBuilders.get(i); keyProperties = onb.resolve(descriptorName, keyProperties, mbean); } } ObjectName oname = new ObjectName(domain, keyProperties); return oname; }
From source file:com.evolveum.midpoint.web.page.PageTemplate.java
protected void clearLessJsCache(AjaxRequestTarget target) { try {// w ww . j ava2 s. com ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); if (servers.size() > 1) { LOGGER.info("Too many mbean servers, cache won't be cleared."); for (MBeanServer server : servers) { LOGGER.info(server.getDefaultDomain()); } return; } MBeanServer server = servers.get(0); ObjectName objectName = ObjectName.getInstance("wro4j-idm:type=WroConfiguration"); server.invoke(objectName, "reloadCache", new Object[] {}, new String[] {}); if (target != null) { target.add(PageTemplate.this); } } catch (Exception ex) { LoggingUtils.logException(LOGGER, "Couldn't clear less/js cache", ex); error("Error occurred, reason: " + ex.getMessage()); if (target != null) { target.add(getFeedbackPanel()); } } }
From source file:it.greenvulcano.jmx.impl.KarafJMXEntryPoint.java
private ObjectName calculateObjectName(Object object, MBeanServer mserver, ManagedBean managed, Map<String, String> properties, String descriptorName) throws Exception { String domain = managed.getDomain(); if (domain == null) { domain = mserver.getDefaultDomain(); }//ww w .j av a2 s .c o m String name = managed.getName(); String className = managed.getClassName(); String group = managed.getGroup(); String type = managed.getType(); Hashtable<String, String> keyProperties = new Hashtable<String, String>(); keyProperties.put("Name", name); keyProperties.put("Class", className); keyProperties.put("Group", group); keyProperties.put("Type", type); if (properties != null) { keyProperties.putAll(properties); } if (objectNameBuilders != null) { for (int i = 0; i < objectNameBuilders.size(); i++) { ObjectNameBuilder onb = objectNameBuilders.get(i); keyProperties = onb.resolve(descriptorName, keyProperties, object); } } ObjectName oname = new ObjectName(domain, keyProperties); return oname; }
From source file:com.evolveum.midpoint.gui.api.page.PageBase.java
protected void clearLessJsCache(AjaxRequestTarget target) { try {/*ww w . j a va 2 s. com*/ ArrayList<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); if (servers.size() > 1) { LOGGER.info("Too many mbean servers, cache won't be cleared."); for (MBeanServer server : servers) { LOGGER.info(server.getDefaultDomain()); } return; } MBeanServer server = servers.get(0); ObjectName objectName = ObjectName.getInstance(Wro4jConfig.WRO_MBEAN_NAME + ":type=WroConfiguration"); server.invoke(objectName, "reloadCache", new Object[] {}, new String[] {}); if (target != null) { target.add(PageBase.this); } } catch (Exception ex) { LoggingUtils.logUnexpectedException(LOGGER, "Couldn't clear less/js cache", ex); error("Error occurred, reason: " + ex.getMessage()); if (target != null) { target.add(getFeedbackPanel()); } } }
From source file:org.apache.camel.management.DefaultManagementAgent.java
protected MBeanServer findOrCreateMBeanServer() { // return platform mbean server if the option is specified. if (usePlatformMBeanServer) { return ManagementFactory.getPlatformMBeanServer(); }/* w w w . j av a 2 s .c om*/ // look for the first mbean server that has match default domain name List<MBeanServer> servers = (List<MBeanServer>) MBeanServerFactory.findMBeanServer(null); for (MBeanServer server : servers) { if (LOG.isDebugEnabled()) { LOG.debug("Found MBeanServer with default domain " + server.getDefaultDomain()); } if (mBeanServerDefaultDomain.equals(server.getDefaultDomain())) { return server; } } // create a mbean server with the given default domain name return MBeanServerFactory.createMBeanServer(mBeanServerDefaultDomain); }