private ManagedCamelContext getManagedContext(CamelContext camelContext) { ManagementObjectStrategy managementObjectStrategy = camelContext.getManagementStrategy() .getManagementObjectStrategy(); return (ManagedCamelContext) managementObjectStrategy .getManagedObjectForCamelContext(camelContext); }
/** * Callback when an endpoint was intercepted with the given mock endpoint * * @param uri the uri * @param endpoint the endpoint * @param mockEndpoint the mocked endpoint * @param mockProducer the mock producer * @return the mock producer */ protected Producer onInterceptEndpoint(String uri, Endpoint endpoint, MockEndpoint mockEndpoint, Producer mockProducer) { CamelContext context = mockEndpoint.getCamelContext(); // the mock endpoint should be registered in JMX try { Object me = context.getManagementStrategy().getManagementObjectStrategy().getManagedObjectForEndpoint(context, mockEndpoint); if (me != null && !context.getManagementStrategy().isManaged(me, null)) { LOG.info("Registering mock endpoint in JMX: {}", mockEndpoint); context.getManagementStrategy().manageObject(me); } } catch (Exception e) { LOG.warn("Error registering mock endpoint in JMX: " + mockEndpoint + " due " + e.getMessage() + ". This exception is ignored."); } return mockProducer; }
/** * Callback when an endpoint was intercepted with the given mock endpoint * * @param uri the uri * @param endpoint the endpoint * @param mockEndpoint the mocked endpoint * @param mockProducer the mock producer * @return the mock producer */ protected Producer onInterceptEndpoint(String uri, Endpoint endpoint, MockEndpoint mockEndpoint, Producer mockProducer) { CamelContext context = mockEndpoint.getCamelContext(); // the mock endpoint should be registered in JMX try { Object me = context.getManagementStrategy().getManagementObjectStrategy().getManagedObjectForEndpoint(context, mockEndpoint); if (me != null && !context.getManagementStrategy().isManaged(me, null)) { LOG.info("Registering mock endpoint in JMX: {}", mockEndpoint); context.getManagementStrategy().manageObject(me); } } catch (Exception e) { LOG.warn("Error registering mock endpoint in JMX: " + mockEndpoint + " due " + e.getMessage() + ". This exception is ignored."); } return mockProducer; }