001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.management; 018 019import java.util.Iterator; 020import java.util.concurrent.ThreadPoolExecutor; 021 022import org.apache.camel.CamelContext; 023import org.apache.camel.Component; 024import org.apache.camel.Consumer; 025import org.apache.camel.DelegateProcessor; 026import org.apache.camel.Endpoint; 027import org.apache.camel.NamedNode; 028import org.apache.camel.Processor; 029import org.apache.camel.Producer; 030import org.apache.camel.Route; 031import org.apache.camel.Service; 032import org.apache.camel.cluster.CamelClusterService; 033import org.apache.camel.component.bean.BeanProcessor; 034import org.apache.camel.component.log.LogEndpoint; 035import org.apache.camel.health.HealthCheckRegistry; 036import org.apache.camel.management.mbean.ManagedAggregateProcessor; 037import org.apache.camel.management.mbean.ManagedBeanProcessor; 038import org.apache.camel.management.mbean.ManagedBrowsableEndpoint; 039import org.apache.camel.management.mbean.ManagedCamelContext; 040import org.apache.camel.management.mbean.ManagedCamelHealth; 041import org.apache.camel.management.mbean.ManagedChoice; 042import org.apache.camel.management.mbean.ManagedClaimCheck; 043import org.apache.camel.management.mbean.ManagedClusterService; 044import org.apache.camel.management.mbean.ManagedComponent; 045import org.apache.camel.management.mbean.ManagedConsumer; 046import org.apache.camel.management.mbean.ManagedConvertBody; 047import org.apache.camel.management.mbean.ManagedConvertHeader; 048import org.apache.camel.management.mbean.ManagedCustomLoadBalancer; 049import org.apache.camel.management.mbean.ManagedDataFormat; 050import org.apache.camel.management.mbean.ManagedDelayer; 051import org.apache.camel.management.mbean.ManagedDisabled; 052import org.apache.camel.management.mbean.ManagedDoCatch; 053import org.apache.camel.management.mbean.ManagedDoFinally; 054import org.apache.camel.management.mbean.ManagedDoTry; 055import org.apache.camel.management.mbean.ManagedDynamicRouter; 056import org.apache.camel.management.mbean.ManagedEndpoint; 057import org.apache.camel.management.mbean.ManagedEnricher; 058import org.apache.camel.management.mbean.ManagedEventNotifier; 059import org.apache.camel.management.mbean.ManagedFailoverLoadBalancer; 060import org.apache.camel.management.mbean.ManagedFilter; 061import org.apache.camel.management.mbean.ManagedIdempotentConsumer; 062import org.apache.camel.management.mbean.ManagedLog; 063import org.apache.camel.management.mbean.ManagedLoop; 064import org.apache.camel.management.mbean.ManagedMarshal; 065import org.apache.camel.management.mbean.ManagedMulticast; 066import org.apache.camel.management.mbean.ManagedPollEnricher; 067import org.apache.camel.management.mbean.ManagedProcess; 068import org.apache.camel.management.mbean.ManagedProcessor; 069import org.apache.camel.management.mbean.ManagedProducer; 070import org.apache.camel.management.mbean.ManagedRandomLoadBalancer; 071import org.apache.camel.management.mbean.ManagedRecipientList; 072import org.apache.camel.management.mbean.ManagedRemoveHeader; 073import org.apache.camel.management.mbean.ManagedRemoveHeaders; 074import org.apache.camel.management.mbean.ManagedRemoveProperties; 075import org.apache.camel.management.mbean.ManagedRemoveProperty; 076import org.apache.camel.management.mbean.ManagedResequencer; 077import org.apache.camel.management.mbean.ManagedRollback; 078import org.apache.camel.management.mbean.ManagedRoundRobinLoadBalancer; 079import org.apache.camel.management.mbean.ManagedRoute; 080import org.apache.camel.management.mbean.ManagedRouteController; 081import org.apache.camel.management.mbean.ManagedRoutingSlip; 082import org.apache.camel.management.mbean.ManagedSamplingThrottler; 083import org.apache.camel.management.mbean.ManagedScheduledPollConsumer; 084import org.apache.camel.management.mbean.ManagedScript; 085import org.apache.camel.management.mbean.ManagedSendDynamicProcessor; 086import org.apache.camel.management.mbean.ManagedSendProcessor; 087import org.apache.camel.management.mbean.ManagedService; 088import org.apache.camel.management.mbean.ManagedSetBody; 089import org.apache.camel.management.mbean.ManagedSetExchangePattern; 090import org.apache.camel.management.mbean.ManagedSetHeader; 091import org.apache.camel.management.mbean.ManagedSetProperty; 092import org.apache.camel.management.mbean.ManagedSplitter; 093import org.apache.camel.management.mbean.ManagedStep; 094import org.apache.camel.management.mbean.ManagedStickyLoadBalancer; 095import org.apache.camel.management.mbean.ManagedStop; 096import org.apache.camel.management.mbean.ManagedSupervisingRouteController; 097import org.apache.camel.management.mbean.ManagedSuspendableRoute; 098import org.apache.camel.management.mbean.ManagedThreadPool; 099import org.apache.camel.management.mbean.ManagedThreads; 100import org.apache.camel.management.mbean.ManagedThrottler; 101import org.apache.camel.management.mbean.ManagedThroughputLogger; 102import org.apache.camel.management.mbean.ManagedThrowException; 103import org.apache.camel.management.mbean.ManagedTopicLoadBalancer; 104import org.apache.camel.management.mbean.ManagedTransformer; 105import org.apache.camel.management.mbean.ManagedUnmarshal; 106import org.apache.camel.management.mbean.ManagedValidate; 107import org.apache.camel.management.mbean.ManagedWeightedLoadBalancer; 108import org.apache.camel.management.mbean.ManagedWireTapProcessor; 109import org.apache.camel.model.AggregateDefinition; 110import org.apache.camel.model.CatchDefinition; 111import org.apache.camel.model.DynamicRouterDefinition; 112import org.apache.camel.model.EnrichDefinition; 113import org.apache.camel.model.ExpressionNode; 114import org.apache.camel.model.FinallyDefinition; 115import org.apache.camel.model.IdempotentConsumerDefinition; 116import org.apache.camel.model.LoadBalanceDefinition; 117import org.apache.camel.model.LoopDefinition; 118import org.apache.camel.model.MarshalDefinition; 119import org.apache.camel.model.PollEnrichDefinition; 120import org.apache.camel.model.ProcessDefinition; 121import org.apache.camel.model.ProcessorDefinition; 122import org.apache.camel.model.RecipientListDefinition; 123import org.apache.camel.model.RoutingSlipDefinition; 124import org.apache.camel.model.ScriptDefinition; 125import org.apache.camel.model.SetBodyDefinition; 126import org.apache.camel.model.SetHeaderDefinition; 127import org.apache.camel.model.SetPropertyDefinition; 128import org.apache.camel.model.SplitDefinition; 129import org.apache.camel.model.TransformDefinition; 130import org.apache.camel.model.TryDefinition; 131import org.apache.camel.model.UnmarshalDefinition; 132import org.apache.camel.model.ValidateDefinition; 133import org.apache.camel.model.loadbalancer.CustomLoadBalancerDefinition; 134import org.apache.camel.processor.CatchProcessor; 135import org.apache.camel.processor.ChoiceProcessor; 136import org.apache.camel.processor.ClaimCheckProcessor; 137import org.apache.camel.processor.Delayer; 138import org.apache.camel.processor.DisabledProcessor; 139import org.apache.camel.processor.DynamicRouter; 140import org.apache.camel.processor.Enricher; 141import org.apache.camel.processor.ExchangePatternProcessor; 142import org.apache.camel.processor.FilterProcessor; 143import org.apache.camel.processor.FinallyProcessor; 144import org.apache.camel.processor.LogProcessor; 145import org.apache.camel.processor.LoopProcessor; 146import org.apache.camel.processor.MulticastProcessor; 147import org.apache.camel.processor.Pipeline; 148import org.apache.camel.processor.PollEnricher; 149import org.apache.camel.processor.RecipientList; 150import org.apache.camel.processor.RemoveHeaderProcessor; 151import org.apache.camel.processor.RemoveHeadersProcessor; 152import org.apache.camel.processor.RemovePropertiesProcessor; 153import org.apache.camel.processor.RemovePropertyProcessor; 154import org.apache.camel.processor.Resequencer; 155import org.apache.camel.processor.RollbackProcessor; 156import org.apache.camel.processor.RoutingSlip; 157import org.apache.camel.processor.SamplingThrottler; 158import org.apache.camel.processor.ScriptProcessor; 159import org.apache.camel.processor.SendDynamicProcessor; 160import org.apache.camel.processor.SendProcessor; 161import org.apache.camel.processor.SetBodyProcessor; 162import org.apache.camel.processor.SetHeaderProcessor; 163import org.apache.camel.processor.SetPropertyProcessor; 164import org.apache.camel.processor.Splitter; 165import org.apache.camel.processor.StepProcessor; 166import org.apache.camel.processor.StopProcessor; 167import org.apache.camel.processor.StreamResequencer; 168import org.apache.camel.processor.ThreadsProcessor; 169import org.apache.camel.processor.Throttler; 170import org.apache.camel.processor.ThrowExceptionProcessor; 171import org.apache.camel.processor.TransformProcessor; 172import org.apache.camel.processor.TryProcessor; 173import org.apache.camel.processor.WireTapProcessor; 174import org.apache.camel.processor.aggregate.AggregateProcessor; 175import org.apache.camel.processor.idempotent.IdempotentConsumer; 176import org.apache.camel.processor.loadbalancer.FailOverLoadBalancer; 177import org.apache.camel.processor.loadbalancer.LoadBalancer; 178import org.apache.camel.processor.loadbalancer.RandomLoadBalancer; 179import org.apache.camel.processor.loadbalancer.RoundRobinLoadBalancer; 180import org.apache.camel.processor.loadbalancer.StickyLoadBalancer; 181import org.apache.camel.processor.loadbalancer.TopicLoadBalancer; 182import org.apache.camel.processor.loadbalancer.WeightedLoadBalancer; 183import org.apache.camel.processor.transformer.DataTypeProcessor; 184import org.apache.camel.spi.BrowsableEndpoint; 185import org.apache.camel.spi.DataFormat; 186import org.apache.camel.spi.ErrorHandler; 187import org.apache.camel.spi.EventNotifier; 188import org.apache.camel.spi.ManagementObjectStrategy; 189import org.apache.camel.spi.RouteController; 190import org.apache.camel.spi.SupervisingRouteController; 191import org.apache.camel.support.ScheduledPollConsumer; 192import org.apache.camel.support.processor.ConvertBodyProcessor; 193import org.apache.camel.support.processor.ConvertHeaderProcessor; 194import org.apache.camel.support.processor.MarshalProcessor; 195import org.apache.camel.support.processor.PredicateValidatingProcessor; 196import org.apache.camel.support.processor.ThroughputLogger; 197import org.apache.camel.support.processor.UnmarshalProcessor; 198 199/** 200 * Default {@link org.apache.camel.spi.ManagementObjectStrategy}. 201 */ 202public class DefaultManagementObjectStrategy implements ManagementObjectStrategy { 203 204 @Override 205 public Object getManagedObjectForCamelContext(CamelContext context) { 206 ManagedCamelContext mc = new ManagedCamelContext(context); 207 mc.init(context.getManagementStrategy()); 208 return mc; 209 } 210 211 @Override 212 public Object getManagedObjectForCamelHealth(CamelContext context, HealthCheckRegistry healthCheckRegistry) { 213 ManagedCamelHealth mch = new ManagedCamelHealth(context, healthCheckRegistry); 214 mch.init(context.getManagementStrategy()); 215 return mch; 216 } 217 218 @Override 219 @SuppressWarnings({ "deprecation", "unchecked" }) 220 public Object getManagedObjectForComponent(CamelContext context, Component component, String name) { 221 ManagedComponent mc = new ManagedComponent(name, component); 222 mc.init(context.getManagementStrategy()); 223 return mc; 224 } 225 226 @Override 227 @SuppressWarnings({ "deprecation", "unchecked" }) 228 public Object getManagedObjectForDataFormat(CamelContext context, DataFormat dataFormat) { 229 ManagedDataFormat md = new ManagedDataFormat(context, dataFormat); 230 md.init(context.getManagementStrategy()); 231 return md; 232 } 233 234 @Override 235 @SuppressWarnings({ "deprecation", "unchecked" }) 236 public Object getManagedObjectForEndpoint(CamelContext context, Endpoint endpoint) { 237 // we only want to manage singleton endpoints 238 if (!endpoint.isSingleton()) { 239 return null; 240 } 241 242 if (endpoint instanceof BrowsableEndpoint) { 243 ManagedBrowsableEndpoint me = new ManagedBrowsableEndpoint((BrowsableEndpoint) endpoint); 244 me.init(context.getManagementStrategy()); 245 return me; 246 } else { 247 ManagedEndpoint me = new ManagedEndpoint(endpoint); 248 me.init(context.getManagementStrategy()); 249 return me; 250 } 251 } 252 253 @Override 254 public Object getManagedObjectForRouteController(CamelContext context, RouteController routeController) { 255 ManagedService mrc; 256 if (routeController instanceof SupervisingRouteController) { 257 mrc = new ManagedSupervisingRouteController(context, (SupervisingRouteController) routeController); 258 } else { 259 mrc = new ManagedRouteController(context, routeController); 260 } 261 mrc.init(context.getManagementStrategy()); 262 return mrc; 263 } 264 265 @Override 266 public Object getManagedObjectForRoute(CamelContext context, Route route) { 267 ManagedRoute mr; 268 if (route.supportsSuspension()) { 269 mr = new ManagedSuspendableRoute(context, route); 270 } else { 271 mr = new ManagedRoute(context, route); 272 } 273 mr.init(context.getManagementStrategy()); 274 return mr; 275 } 276 277 @Override 278 public Object getManagedObjectForThreadPool( 279 CamelContext context, ThreadPoolExecutor threadPool, 280 String id, String sourceId, String routeId, String threadPoolProfileId) { 281 ManagedThreadPool mtp = new ManagedThreadPool(context, threadPool, id, sourceId, routeId, threadPoolProfileId); 282 mtp.init(context.getManagementStrategy()); 283 return mtp; 284 } 285 286 @Override 287 public Object getManagedObjectForEventNotifier(CamelContext context, EventNotifier eventNotifier) { 288 ManagedEventNotifier men = new ManagedEventNotifier(context, eventNotifier); 289 men.init(context.getManagementStrategy()); 290 return men; 291 } 292 293 @Override 294 public Object getManagedObjectForConsumer(CamelContext context, Consumer consumer) { 295 ManagedConsumer mc; 296 if (consumer instanceof ScheduledPollConsumer) { 297 mc = new ManagedScheduledPollConsumer(context, (ScheduledPollConsumer) consumer); 298 } else { 299 mc = new ManagedConsumer(context, consumer); 300 } 301 mc.init(context.getManagementStrategy()); 302 return mc; 303 } 304 305 @Override 306 public Object getManagedObjectForProducer(CamelContext context, Producer producer) { 307 ManagedProducer mp = new ManagedProducer(context, producer); 308 mp.init(context.getManagementStrategy()); 309 return mp; 310 } 311 312 @Override 313 public Object getManagedObjectForService(CamelContext context, Service service) { 314 ManagedService mc = new ManagedService(context, service); 315 mc.init(context.getManagementStrategy()); 316 return mc; 317 } 318 319 @Override 320 public Object getManagedObjectForClusterService(CamelContext context, CamelClusterService service) { 321 ManagedClusterService mcs = new ManagedClusterService(context, service); 322 mcs.init(context.getManagementStrategy()); 323 return mcs; 324 } 325 326 @Override 327 @SuppressWarnings({ "deprecation", "unchecked" }) 328 public Object getManagedObjectForProcessor( 329 CamelContext context, Processor processor, 330 NamedNode node, Route route) { 331 ManagedProcessor answer = null; 332 333 ProcessorDefinition<?> definition = (ProcessorDefinition<?>) node; 334 335 if (definition instanceof RecipientListDefinition) { 336 // special for RecipientListDefinition, as the processor is wrapped in a pipeline as last 337 Pipeline pipeline = (Pipeline) processor; 338 Iterator<Processor> it = pipeline.next().iterator(); 339 while (it.hasNext()) { 340 processor = it.next(); 341 } 342 } 343 344 // unwrap delegates as we want the real target processor 345 Processor target = processor; 346 while (target != null) { 347 348 // skip error handlers 349 if (target instanceof ErrorHandler) { 350 return false; 351 } 352 353 if (target instanceof ConvertBodyProcessor) { 354 answer = new ManagedConvertBody(context, (ConvertBodyProcessor) target, definition); 355 } else if (target instanceof ConvertHeaderProcessor) { 356 answer = new ManagedConvertHeader(context, (ConvertHeaderProcessor) target, definition); 357 } else if (target instanceof ChoiceProcessor) { 358 answer = new ManagedChoice(context, (ChoiceProcessor) target, definition); 359 } else if (target instanceof ClaimCheckProcessor) { 360 answer = new ManagedClaimCheck(context, (ClaimCheckProcessor) target, definition); 361 } else if (target instanceof Delayer) { 362 answer = new ManagedDelayer(context, (Delayer) target, definition); 363 } else if (target instanceof DisabledProcessor) { 364 answer = new ManagedDisabled(context, (DisabledProcessor) target, definition); 365 } else if (target instanceof TryProcessor) { 366 answer = new ManagedDoTry(context, (TryProcessor) target, (TryDefinition) definition); 367 } else if (target instanceof CatchProcessor) { 368 answer = new ManagedDoCatch(context, (CatchProcessor) target, (CatchDefinition) definition); 369 } else if (target instanceof FinallyProcessor) { 370 answer = new ManagedDoFinally(context, (FinallyProcessor) target, (FinallyDefinition) definition); 371 } else if (target instanceof Throttler) { 372 answer = new ManagedThrottler(context, (Throttler) target, definition); 373 } else if (target instanceof DynamicRouter) { 374 answer = new ManagedDynamicRouter(context, (DynamicRouter) target, (DynamicRouterDefinition) definition); 375 } else if (target instanceof RoutingSlip) { 376 answer = new ManagedRoutingSlip(context, (RoutingSlip) target, (RoutingSlipDefinition) definition); 377 } else if (target instanceof FilterProcessor) { 378 answer = new ManagedFilter(context, (FilterProcessor) target, (ExpressionNode) definition); 379 } else if (target instanceof LogProcessor) { 380 answer = new ManagedLog(context, (LogProcessor) target, definition); 381 } else if (target instanceof LoopProcessor) { 382 answer = new ManagedLoop(context, (LoopProcessor) target, (LoopDefinition) definition); 383 } else if (target instanceof MarshalProcessor) { 384 answer = new ManagedMarshal(context, (MarshalProcessor) target, (MarshalDefinition) definition); 385 } else if (target instanceof UnmarshalProcessor) { 386 answer = new ManagedUnmarshal(context, (UnmarshalProcessor) target, (UnmarshalDefinition) definition); 387 } else if (target instanceof FailOverLoadBalancer) { 388 answer = new ManagedFailoverLoadBalancer( 389 context, (FailOverLoadBalancer) target, (LoadBalanceDefinition) definition); 390 } else if (target instanceof RandomLoadBalancer) { 391 answer = new ManagedRandomLoadBalancer( 392 context, (RandomLoadBalancer) target, (LoadBalanceDefinition) definition); 393 } else if (target instanceof RoundRobinLoadBalancer) { 394 answer = new ManagedRoundRobinLoadBalancer( 395 context, (RoundRobinLoadBalancer) target, (LoadBalanceDefinition) definition); 396 } else if (target instanceof StickyLoadBalancer) { 397 answer = new ManagedStickyLoadBalancer( 398 context, (StickyLoadBalancer) target, (LoadBalanceDefinition) definition); 399 } else if (target instanceof TopicLoadBalancer) { 400 answer = new ManagedTopicLoadBalancer(context, (TopicLoadBalancer) target, (LoadBalanceDefinition) definition); 401 } else if (target instanceof WeightedLoadBalancer) { 402 answer = new ManagedWeightedLoadBalancer( 403 context, (WeightedLoadBalancer) target, (LoadBalanceDefinition) definition); 404 } else if (target instanceof RecipientList) { 405 answer = new ManagedRecipientList(context, (RecipientList) target, (RecipientListDefinition) definition); 406 } else if (target instanceof Splitter) { 407 answer = new ManagedSplitter(context, (Splitter) target, (SplitDefinition) definition); 408 } else if (target instanceof MulticastProcessor) { 409 answer = new ManagedMulticast(context, (MulticastProcessor) target, definition); 410 } else if (target instanceof SamplingThrottler) { 411 answer = new ManagedSamplingThrottler(context, (SamplingThrottler) target, definition); 412 } else if (target instanceof Resequencer) { 413 answer = new ManagedResequencer(context, (Resequencer) target, definition); 414 } else if (target instanceof RollbackProcessor) { 415 answer = new ManagedRollback(context, (RollbackProcessor) target, definition); 416 } else if (target instanceof StreamResequencer) { 417 answer = new ManagedResequencer(context, (StreamResequencer) target, definition); 418 } else if (target instanceof SetBodyProcessor) { 419 answer = new ManagedSetBody(context, (SetBodyProcessor) target, (SetBodyDefinition) definition); 420 } else if (target instanceof RemoveHeaderProcessor) { 421 answer = new ManagedRemoveHeader(context, (RemoveHeaderProcessor) target, definition); 422 } else if (target instanceof RemoveHeadersProcessor) { 423 answer = new ManagedRemoveHeaders(context, (RemoveHeadersProcessor) target, definition); 424 } else if (target instanceof SetHeaderProcessor) { 425 answer = new ManagedSetHeader(context, (SetHeaderProcessor) target, (SetHeaderDefinition) definition); 426 } else if (target instanceof RemovePropertyProcessor) { 427 answer = new ManagedRemoveProperty(context, (RemovePropertyProcessor) target, definition); 428 } else if (target instanceof RemovePropertiesProcessor) { 429 answer = new ManagedRemoveProperties(context, (RemovePropertiesProcessor) target, definition); 430 } else if (target instanceof SetPropertyProcessor) { 431 answer = new ManagedSetProperty(context, (SetPropertyProcessor) target, (SetPropertyDefinition) definition); 432 } else if (target instanceof ExchangePatternProcessor) { 433 answer = new ManagedSetExchangePattern(context, (ExchangePatternProcessor) target, definition); 434 } else if (target instanceof ScriptProcessor) { 435 answer = new ManagedScript(context, (ScriptProcessor) target, (ScriptDefinition) definition); 436 } else if (target instanceof StepProcessor) { 437 answer = new ManagedStep(context, (StepProcessor) target, definition); 438 } else if (target instanceof StopProcessor) { 439 answer = new ManagedStop(context, (StopProcessor) target, definition); 440 } else if (target instanceof ThreadsProcessor) { 441 answer = new ManagedThreads(context, (ThreadsProcessor) target, definition); 442 } else if (target instanceof ThrowExceptionProcessor) { 443 answer = new ManagedThrowException(context, (ThrowExceptionProcessor) target, definition); 444 } else if (target instanceof TransformProcessor) { 445 answer = new ManagedTransformer(context, target, (TransformDefinition) definition); 446 } else if (target instanceof DataTypeProcessor && definition instanceof TransformDefinition) { 447 answer = new ManagedTransformer(context, target, (TransformDefinition) definition); 448 } else if (target instanceof PredicateValidatingProcessor) { 449 answer = new ManagedValidate(context, (PredicateValidatingProcessor) target, (ValidateDefinition) definition); 450 } else if (target instanceof WireTapProcessor) { 451 answer = new ManagedWireTapProcessor(context, (WireTapProcessor) target, definition); 452 } else if (target instanceof SendDynamicProcessor) { 453 answer = new ManagedSendDynamicProcessor(context, (SendDynamicProcessor) target, definition); 454 } else if (target instanceof SendProcessor) { 455 SendProcessor sp = (SendProcessor) target; 456 // special for sending to throughput logger 457 if (sp.getDestination() instanceof LogEndpoint) { 458 LogEndpoint le = (LogEndpoint) sp.getDestination(); 459 if (le.getLogger() instanceof ThroughputLogger) { 460 ThroughputLogger tl = (ThroughputLogger) le.getLogger(); 461 answer = new ManagedThroughputLogger(context, tl, definition); 462 } 463 } 464 // regular send processor 465 if (answer == null) { 466 answer = new ManagedSendProcessor(context, (SendProcessor) target, definition); 467 } 468 } else if (target instanceof BeanProcessor) { 469 answer = new ManagedBeanProcessor(context, (BeanProcessor) target, definition); 470 } else if (target instanceof IdempotentConsumer) { 471 answer = new ManagedIdempotentConsumer( 472 context, (IdempotentConsumer) target, (IdempotentConsumerDefinition) definition); 473 } else if (target instanceof AggregateProcessor) { 474 answer = new ManagedAggregateProcessor(context, (AggregateProcessor) target, (AggregateDefinition) definition); 475 } else if (target instanceof Enricher) { 476 answer = new ManagedEnricher(context, (Enricher) target, (EnrichDefinition) definition); 477 } else if (target instanceof PollEnricher) { 478 answer = new ManagedPollEnricher(context, (PollEnricher) target, (PollEnrichDefinition) definition); 479 } 480 481 // special for custom load balancer 482 if (definition instanceof LoadBalanceDefinition) { 483 LoadBalanceDefinition lb = (LoadBalanceDefinition) definition; 484 if (lb.getLoadBalancerType() instanceof CustomLoadBalancerDefinition) { 485 answer = new ManagedCustomLoadBalancer(context, (LoadBalancer) target, (LoadBalanceDefinition) definition); 486 } 487 } 488 489 if (answer != null) { 490 // break out as we found an answer 491 break; 492 } 493 494 // no answer yet, so unwrap any delegates and try again 495 if (target instanceof DelegateProcessor) { 496 target = ((DelegateProcessor) target).getProcessor(); 497 } else { 498 // no delegate so we dont have any target to try next 499 break; 500 } 501 } 502 503 if (answer == null && definition instanceof ProcessDefinition) { 504 answer = new ManagedProcess(context, target, (ProcessDefinition) definition); 505 } else if (answer == null) { 506 // fallback to a generic processor 507 answer = new ManagedProcessor(context, target, definition); 508 } 509 510 answer.setRoute(route); 511 answer.init(context.getManagementStrategy()); 512 return answer; 513 } 514 515}