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