/** * Code borrowed from the DefaultCamelController: https://github.com/apache/camel/blob/master/platforms/commands/commands-jolokia/src/main/java/org/apache/camel/commands/jolokia/DefaultJolokiaCamelController.java * Slight modifications have been applied. * Credits to: Claus & Tomo */ private ObjectName lookupCamelContext(String camelContextName) throws Exception { ObjectName on = cache.get(camelContextName); if (on == null) { ObjectName found = null; J4pSearchResponse sr = jolokia.execute(new J4pSearchRequest("org.apache.camel:type=context,*")); if (sr != null) { for (ObjectName name : sr.getObjectNames()) { String id = name.getKeyProperty("name"); id = removeLeadingAndEndingQuotes(id); if (camelContextName.equals(id)) { found = name; break; } } } if (found != null) { on = found; cache.put(camelContextName, on); } } return on; }