use of org.apache.camel.management.mbean.ManagedComponent in project camel by apache.
the class DefaultManagementObjectStrategy method getManagedObjectForComponent.
@SuppressWarnings({ "deprecation", "unchecked" })
public Object getManagedObjectForComponent(CamelContext context, Component component, String name) {
if (component instanceof org.apache.camel.spi.ManagementAware) {
return ((org.apache.camel.spi.ManagementAware<Component>) component).getManagedObject(component);
} else {
ManagedComponent mc = new ManagedComponent(name, component);
mc.init(context.getManagementStrategy());
return mc;
}
}
use of org.apache.camel.management.mbean.ManagedComponent in project camel by apache.
the class ManagedManagementStrategy method getManagedObjectName.
public <T> T getManagedObjectName(Object managedObject, String customName, Class<T> nameType) throws Exception {
if (managedObject == null) {
return null;
}
ObjectName objectName = null;
if (managedObject instanceof ManagedCamelContext) {
ManagedCamelContext mcc = (ManagedCamelContext) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForCamelContext(mcc.getContext());
} else if (managedObject instanceof ManagedComponent) {
ManagedComponent mc = (ManagedComponent) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForComponent(mc.getComponent(), mc.getComponentName());
} else if (managedObject instanceof ManagedDataFormat) {
ManagedDataFormat md = (ManagedDataFormat) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForDataFormat(md.getContext(), md.getDataFormat());
} else if (managedObject instanceof ManagedEndpoint) {
ManagedEndpoint me = (ManagedEndpoint) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForEndpoint(me.getEndpoint());
} else if (managedObject instanceof Endpoint) {
objectName = getManagementNamingStrategy().getObjectNameForEndpoint((Endpoint) managedObject);
} else if (managedObject instanceof ManagedRoute) {
ManagedRoute mr = (ManagedRoute) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForRoute(mr.getRoute());
} else if (managedObject instanceof ManagedErrorHandler) {
ManagedErrorHandler meh = (ManagedErrorHandler) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForErrorHandler(meh.getRouteContext(), meh.getErrorHandler(), meh.getErrorHandlerBuilder());
} else if (managedObject instanceof ManagedProcessor) {
ManagedProcessor mp = (ManagedProcessor) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForProcessor(mp.getContext(), mp.getProcessor(), mp.getDefinition());
} else if (managedObject instanceof ManagedConsumer) {
ManagedConsumer ms = (ManagedConsumer) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForConsumer(ms.getContext(), ms.getConsumer());
} else if (managedObject instanceof ManagedProducer) {
ManagedProducer ms = (ManagedProducer) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForProducer(ms.getContext(), ms.getProducer());
} else if (managedObject instanceof ManagedTracer) {
ManagedTracer mt = (ManagedTracer) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForTracer(mt.getContext(), mt.getTracer());
} else if (managedObject instanceof ManagedBacklogTracer) {
ManagedBacklogTracer mt = (ManagedBacklogTracer) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForTracer(mt.getContext(), mt.getBacklogTracer());
} else if (managedObject instanceof ManagedBacklogDebugger) {
ManagedBacklogDebugger md = (ManagedBacklogDebugger) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForTracer(md.getContext(), md.getBacklogDebugger());
} else if (managedObject instanceof ManagedEventNotifier) {
ManagedEventNotifier men = (ManagedEventNotifier) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForEventNotifier(men.getContext(), men.getEventNotifier());
} else if (managedObject instanceof ManagedThreadPool) {
ManagedThreadPool mes = (ManagedThreadPool) managedObject;
objectName = getManagementNamingStrategy().getObjectNameForThreadPool(mes.getContext(), mes.getThreadPool(), mes.getId(), mes.getSourceId());
} else if (managedObject instanceof ManagedService) {
// check for managed service should be last
ManagedService ms = (ManagedService) managedObject;
// skip endpoints as they are already managed
if (ms.getService() instanceof Endpoint) {
return null;
}
objectName = getManagementNamingStrategy().getObjectNameForService(ms.getContext(), ms.getService());
}
return nameType.cast(objectName);
}
Aggregations