Java 类org.apache.camel.api.management.mbean.ManagedCamelContextMBean 实例源码

项目:Camel    文件:ManagedCamelContextTest.java   
public void testManagedCamelContextClient() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }

    ManagedCamelContextMBean client = context.getManagedCamelContext();
    assertNotNull(client);

    assertEquals("camel-1", client.getCamelId());
    assertEquals("Started", client.getState());

    List<String> names = client.findComponentNames();
    assertNotNull(names);
    assertTrue(names.contains("mock"));
}
项目:Camel    文件:DefaultCamelContext.java   
public ManagedCamelContextMBean getManagedCamelContext() {
    // jmx must be enabled
    if (getManagementStrategy().getManagementAgent() == null) {
        return null;
    }

    try {
        ObjectName on = getManagementStrategy().getManagementNamingStrategy().getObjectNameForCamelContext(this);
        return getManagementStrategy().getManagementAgent().newProxyClient(on, ManagedCamelContextMBean.class);
    } catch (MalformedObjectNameException e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:ManagedCamelContextNewProxyTest.java   
public void testNewProxy() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }

    MBeanServer mbeanServer = getMBeanServer();

    ObjectName on = ObjectName.getInstance("org.apache.camel:context=camel-1,type=context,name=\"camel-1\"");

    ManagedCamelContextMBean proxy = JMX.newMBeanProxy(mbeanServer, on, ManagedCamelContextMBean.class);
    assertNotNull(proxy);
}
项目:camelinaction2    文件:JmxCamelClient2.java   
public void connect(String serviceUrl) throws Exception {
    JMXServiceURL url = new JMXServiceURL(serviceUrl);
    connector = JMXConnectorFactory.connect(url, null);
    connection = connector.getMBeanServerConnection();

    // create a mbean proxy so we can use the type safe api
    ObjectName on = new ObjectName("org.apache.camel:context=camel-1,type=context,name=\"camel-1\"");
    proxy = JMX.newMBeanProxy(connection, on, ManagedCamelContextMBean.class);
}
项目:Camel    文件:CamelTestSupport.java   
@After
public void tearDown() throws Exception {
    long time = watch.stop();

    log.info("********************************************************************************");
    log.info("Testing done: " + getTestMethodName() + "(" + getClass().getName() + ")");
    log.info("Took: " + TimeUtils.printDuration(time) + " (" + time + " millis)");

    // if we should dump route stats, then write that to a file
    if (isDumpRouteCoverage()) {
        String className = this.getClass().getSimpleName();
        String dir = "target/camel-route-coverage";
        String name = className + "-" + getTestMethodName() + ".xml";

        ManagedCamelContextMBean managedCamelContext = context.getManagedCamelContext();
        if (managedCamelContext == null) {
            log.warn("Cannot dump route coverage to file as JMX is not enabled. Override useJmx() method to enable JMX in the unit test classes.");
        } else {
            String xml = managedCamelContext.dumpRoutesCoverageAsXml();
            String combined = "<camelRouteCoverage>\n" + gatherTestDetailsAsXml() + xml + "\n</camelRouteCoverage>";

            File file = new File(dir);
            // ensure dir exists
            file.mkdirs();
            file = new File(dir, name);

            log.info("Dumping route coverage to file: " + file);
            InputStream is = new ByteArrayInputStream(combined.getBytes());
            OutputStream os = new FileOutputStream(file, false);
            IOHelper.copyAndCloseInput(is, os);
            IOHelper.close(os);
        }
    }
    log.info("********************************************************************************");

    if (isCreateCamelContextPerClass()) {
        // we tear down in after class
        return;
    }

    LOG.debug("tearDown test");
    doStopTemplates(consumer, template);
    doStopCamelContext(context, camelContextService);
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public ManagedCamelContextMBean getManagedCamelContext() {
  return context.getManagedCamelContext();
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public ManagedCamelContextMBean getManagedCamelContext() {
    return context.getManagedCamelContext();
}
项目:Camel    文件:CamelContext.java   
/**
 * Gets the managed Camel context client api
 */
ManagedCamelContextMBean getManagedCamelContext();