List of usage examples for javax.management QueryExp QueryExp
QueryExp
From source file:architecture.ee.web.spring.controller.SecureMoSKitoController.java
private List<URL> getClassPathUrlsForTomcat(final String context, final String contextPropertyName) { List<MBeanServer> servers = MBeanServerFactory.findMBeanServer(null); for (MBeanServer s : servers) { Set<ObjectInstance> instances = s.queryMBeans(null, new QueryExp() { public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, BadAttributeValueExpException, InvalidApplicationException { String type = name.getKeyProperty("type"); log.debug(name.getDomain() + " : " + name.getKeyPropertyList()); if (!type.equals("WebappClassLoader")) return false; if (!name.getDomain().equals("Catalina")) return false; if (!name.getKeyProperty(contextPropertyName).equals(context)) return false; return true; }/*from w w w . ja va 2 s. co m*/ public void setMBeanServer(MBeanServer s) { } }); if (instances.size() > 0) { try { URL[] urls = (URL[]) s.getAttribute(instances.iterator().next().getObjectName(), "URLs"); return Arrays.asList(urls); } catch (Exception e) { } } } return null; }