org.apache.camel.model
Class LoadBalancerDefinition

java.lang.Object
  extended by org.apache.camel.model.IdentifiedType
      extended by org.apache.camel.model.LoadBalancerDefinition
All Implemented Interfaces:
AsyncProcessor, Processor, LoadBalancer
Direct Known Subclasses:
CustomLoadBalancerDefinition, FailoverLoadBalancerDefinition, RandomLoadBalancerDefinition, RoundRobinLoadBalancerDefinition, StickyLoadBalancerDefinition, TopicLoadBalancerDefinition, WeightedLoadBalancerDefinition

public class LoadBalancerDefinition
extends IdentifiedType
implements LoadBalancer

Represents an XML <loadBalancer/> element


Constructor Summary
  LoadBalancerDefinition()
           
  LoadBalancerDefinition(LoadBalancer loadBalancer)
           
protected LoadBalancerDefinition(String loadBalancerTypeName)
           
 
Method Summary
 void addProcessor(Processor processor)
          Adds a new processor to the load balancer
protected  void configureLoadBalancer(LoadBalancer loadBalancer)
          Allows derived classes to customize the load balancer
protected  LoadBalancer createLoadBalancer(RouteContext routeContext)
          Factory method to create the load balancer instance
 LoadBalancer getLoadBalancer(RouteContext routeContext)
           
static LoadBalancer getLoadBalancer(RouteContext routeContext, LoadBalancerDefinition type, String ref)
           
 List<Processor> getProcessors()
          Returns the current processors available to this load balancer
 void process(Exchange exchange)
          Processes the message exchange
 boolean process(Exchange exchange, AsyncCallback callback)
          Processes the message exchange.
 void removeProcessor(Processor processor)
          Removes the given processor from the load balancer
protected  void setProperty(Object bean, String name, Object value)
          Sets a named property on the data format instance using introspection
 String toString()
           
 
Methods inherited from class org.apache.camel.model.IdentifiedType
getId, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LoadBalancerDefinition

public LoadBalancerDefinition()

LoadBalancerDefinition

public LoadBalancerDefinition(LoadBalancer loadBalancer)

LoadBalancerDefinition

protected LoadBalancerDefinition(String loadBalancerTypeName)
Method Detail

getLoadBalancer

public static LoadBalancer getLoadBalancer(RouteContext routeContext,
                                           LoadBalancerDefinition type,
                                           String ref)

setProperty

protected void setProperty(Object bean,
                           String name,
                           Object value)
Sets a named property on the data format instance using introspection


configureLoadBalancer

protected void configureLoadBalancer(LoadBalancer loadBalancer)
Allows derived classes to customize the load balancer


getLoadBalancer

public LoadBalancer getLoadBalancer(RouteContext routeContext)

createLoadBalancer

protected LoadBalancer createLoadBalancer(RouteContext routeContext)
Factory method to create the load balancer instance


addProcessor

public void addProcessor(Processor processor)
Description copied from interface: LoadBalancer
Adds a new processor to the load balancer

Specified by:
addProcessor in interface LoadBalancer
Parameters:
processor - the processor to be added to the load balancer

getProcessors

public List<Processor> getProcessors()
Description copied from interface: LoadBalancer
Returns the current processors available to this load balancer

Specified by:
getProcessors in interface LoadBalancer
Returns:
the processors available

removeProcessor

public void removeProcessor(Processor processor)
Description copied from interface: LoadBalancer
Removes the given processor from the load balancer

Specified by:
removeProcessor in interface LoadBalancer
Parameters:
processor - the processor to be removed from the load balancer

process

public void process(Exchange exchange)
             throws Exception
Description copied from interface: Processor
Processes the message exchange

Specified by:
process in interface Processor
Parameters:
exchange - the message exchange
Throws:
Exception - if an internal processing error has occurred.

process

public boolean process(Exchange exchange,
                       AsyncCallback callback)
Description copied from interface: AsyncProcessor
Processes the message exchange. Similar to Processor.process(org.apache.camel.Exchange), but the caller supports having the exchange asynchronously processed.

If there was a failure processing then the caused Exception would be set on the Exchange.

Specified by:
process in interface AsyncProcessor
Parameters:
exchange - the message exchange
callback - the AsyncCallback will be invoked when the processing of the exchange is completed. If the exchange is completed synchronously, then the callback is also invoked synchronously. The callback should therefore be careful of starting recursive loop.
Returns:
(doneSync) true to continue execute synchronously, false to continue being executed asynchronously
See Also:
AsyncProcessorHelper.process(AsyncProcessor, Exchange, AsyncCallback)

toString

public String toString()
Overrides:
toString in class Object


Apache CAMEL