}
}
@SuppressWarnings("unchecked")
private Object getManagedObjectForService(CamelContext context, Service service, Route route) {
ManagedService answer = null;
if (service instanceof ManagementAware) {
return ((ManagementAware) service).getManagedObject(service);
} else if (service instanceof Tracer) {
// special for tracer
ManagedTracer mt = new ManagedTracer(context, (Tracer) service);
mt.init(getManagementStrategy());
return mt;
} else if (service instanceof EventNotifier) {
// special for event notifier
ManagedEventNotifier men = new ManagedEventNotifier(context, (EventNotifier) service);
men.init(getManagementStrategy());
return men;
} else if (service instanceof Producer) {
answer = new ManagedProducer(context, (Producer) service);
} else if (service instanceof ScheduledPollConsumer) {
answer = new ManagedScheduledPollConsumer(context, (ScheduledPollConsumer) service);
} else if (service instanceof Consumer) {
answer = new ManagedConsumer(context, (Consumer) service);
} else if (service instanceof Processor) {
// special for processors
return getManagedObjectForProcessor(context, (Processor) service, route);
} else if (service instanceof ThrottlingInflightRoutePolicy) {
answer = new ManagedThrottlingInflightRoutePolicy(context, (ThrottlingInflightRoutePolicy) service);
} else if (service instanceof ProducerCache) {
answer = new ManagedProducerCache(context, (ProducerCache) service);
} else if (service != null) {
// fallback as generic service
answer = new ManagedService(context, service);
}
if (answer != null) {
answer.setRoute(route);
answer.init(getManagementStrategy());
return answer;
} else {
// not supported
return null;
}