org.apache.camel.model
Class ThreadsDefinition

java.lang.Object
  extended by org.apache.camel.model.OptionalIdentifiedDefinition<Type>
      extended by org.apache.camel.model.ProcessorDefinition<Type>
          extended by org.apache.camel.model.OutputDefinition<ThreadsDefinition>
              extended by org.apache.camel.model.ThreadsDefinition
All Implemented Interfaces:
ExecutorServiceAware, Block, ExecutorServiceAwareDefinition<ThreadsDefinition>, NamedNode

public class ThreadsDefinition
extends OutputDefinition<ThreadsDefinition>
implements ExecutorServiceAwareDefinition<ThreadsDefinition>

Represents an XML <threads/> element

Version:

Field Summary
 
Fields inherited from class org.apache.camel.model.OutputDefinition
outputs
 
Fields inherited from class org.apache.camel.model.ProcessorDefinition
inheritErrorHandler, log
 
Constructor Summary
ThreadsDefinition()
           
 
Method Summary
 ThreadsDefinition callerRunsWhenRejected(boolean callerRunsWhenRejected)
          Whether or not the caller should run the task when it was rejected by the thread pool.
 Processor createProcessor(RouteContext routeContext)
          Override this in definition class and implement logic to create the processor based on the definition model.
 ThreadsDefinition executorService(ExecutorService executorService)
          Setting the executor service for executing
 ThreadsDefinition executorServiceRef(String executorServiceRef)
          Setting the executor service for executing
 Boolean getCallerRunsWhenRejected()
           
 ExecutorService getExecutorService()
          Gets the executor service
 String getExecutorServiceRef()
          Gets the reference to lookup in the Registry for the executor service to be used.
 Long getKeepAliveTime()
           
 String getLabel()
          Returns a label to describe this node such as the expression if some kind of expression node
 Integer getMaxPoolSize()
           
 Integer getMaxQueueSize()
           
 Integer getPoolSize()
           
 ThreadPoolRejectedPolicy getRejectedPolicy()
           
 String getShortName()
          Returns a short name for this node which can be useful for ID generation or referring to related resources like images
 String getThreadName()
           
 TimeUnit getTimeUnit()
           
 ThreadsDefinition keepAliveTime(long keepAliveTime)
          Sets the keep alive time for idle threads
 ThreadsDefinition maxPoolSize(int maxPoolSize)
          Sets the maximum pool size for the underlying ExecutorService.
 ThreadsDefinition maxQueueSize(int maxQueueSize)
          Sets the maximum number of tasks in the work queue.
 ThreadsDefinition poolSize(int poolSize)
          Sets the core pool size for the underlying ExecutorService.
 ThreadsDefinition rejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy)
          Sets the handler for tasks which cannot be executed by the thread pool.
 void setCallerRunsWhenRejected(Boolean callerRunsWhenRejected)
           
 void setExecutorService(ExecutorService executorService)
          Sets the executor service to be used.
 void setExecutorServiceRef(String executorServiceRef)
          Sets a reference to lookup in the Registry for the executor service to be used.
 void setKeepAliveTime(Long keepAliveTime)
           
 void setMaxPoolSize(Integer maxPoolSize)
           
 void setMaxQueueSize(Integer maxQueueSize)
           
 void setPoolSize(Integer poolSize)
           
 void setRejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy)
           
 void setThreadName(String threadName)
           
 void setTimeUnit(TimeUnit timeUnit)
           
 ThreadsDefinition threadName(String threadName)
          Sets the thread name to use.
 ThreadsDefinition timeUnit(TimeUnit keepAliveTimeUnits)
          Sets the keep alive time unit.
 String toString()
           
 
Methods inherited from class org.apache.camel.model.OutputDefinition
getOutputs, isOutputSupported, setOutputs
 
Methods inherited from class org.apache.camel.model.ProcessorDefinition
addInterceptStrategies, addInterceptStrategy, addOutput, addRoutes, aggregate, aggregate, aggregate, aggregate, aop, attribute, bean, bean, bean, bean, beanRef, beanRef, choice, clearOutput, configureChild, convertBodyTo, convertBodyTo, createChannel, createChildProcessor, createCompositeProcessor, createOutputsProcessor, createOutputsProcessor, delay, delay, delay, doTry, dynamicRouter, dynamicRouter, end, endChoice, endDoTry, endParent, enrich, enrich, enrichRef, filter, filter, filter, filter, getInterceptStrategies, getNodeFactory, getOtherAttributes, getParent, id, idempotentConsumer, idempotentConsumer, idempotentConsumer, inheritErrorHandler, inOnly, inOnly, inOnly, inOnly, inOnly, inOnly, inOut, inOut, inOut, inOut, inOut, inOut, isAbstract, isInheritErrorHandler, loadBalance, loadBalance, log, log, log, log, loop, loop, loop, makeProcessor, markRollbackOnly, markRollbackOnlyLast, marshal, marshal, marshal, marshal, multicast, multicast, multicast, onCompletion, onException, onException, pipeline, pipeline, pipeline, pipeline, placeholder, policy, policy, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrich, pollEnrichRef, preCreateProcessor, process, processRef, recipientList, recipientList, recipientList, recipientList, removeFaultHeader, removeHeader, removeHeaders, removeHeaders, removeProperty, resequence, resequence, resolveKnownConstantFields, resolvePropertyPlaceholders, rollback, rollback, routeId, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, routingSlip, sample, sample, sample, setBody, setBody, setExchangePattern, setFaultBody, setFaultHeader, setHeader, setHeader, setInheritErrorHandler, setNodeFactory, setOtherAttributes, setOutHeader, setOutHeader, setParent, setProperty, setProperty, sort, sort, sort, split, split, split, stop, threads, threads, threads, threads, throttle, throttle, throwException, to, to, to, to, to, to, to, to, to, to, toF, transacted, transacted, transform, transform, unmarshal, unmarshal, unmarshal, unmarshal, validate, validate, validate, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wireTap, wrapChannel, wrapInErrorHandler, wrapProcessor
 
Methods inherited from class org.apache.camel.model.OptionalIdentifiedDefinition
description, getDescription, getDescriptionText, getId, hasCustomIdAssigned, idOrCreate, setDescription, setId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadsDefinition

public ThreadsDefinition()
Method Detail

createProcessor

public Processor createProcessor(RouteContext routeContext)
                          throws Exception
Description copied from class: ProcessorDefinition
Override this in definition class and implement logic to create the processor based on the definition model.

Overrides:
createProcessor in class ProcessorDefinition<ThreadsDefinition>
Throws:
Exception

getLabel

public String getLabel()
Description copied from class: ProcessorDefinition
Returns a label to describe this node such as the expression if some kind of expression node

Overrides:
getLabel in class ProcessorDefinition<ThreadsDefinition>

getShortName

public String getShortName()
Description copied from class: OptionalIdentifiedDefinition
Returns a short name for this node which can be useful for ID generation or referring to related resources like images

Specified by:
getShortName in interface NamedNode
Overrides:
getShortName in class OutputDefinition<ThreadsDefinition>
Returns:
defaults to "node" but derived nodes should overload this to provide a unique name

toString

public String toString()
Overrides:
toString in class OutputDefinition<ThreadsDefinition>

executorService

public ThreadsDefinition executorService(ExecutorService executorService)
Description copied from interface: ExecutorServiceAwareDefinition
Setting the executor service for executing

Specified by:
executorService in interface ExecutorServiceAwareDefinition<ThreadsDefinition>
Parameters:
executorService - the executor service
Returns:
the builder

executorServiceRef

public ThreadsDefinition executorServiceRef(String executorServiceRef)
Description copied from interface: ExecutorServiceAwareDefinition
Setting the executor service for executing

Specified by:
executorServiceRef in interface ExecutorServiceAwareDefinition<ThreadsDefinition>
Parameters:
executorServiceRef - reference for a ExecutorService to lookup in the Registry
Returns:
the builder

poolSize

public ThreadsDefinition poolSize(int poolSize)
Sets the core pool size for the underlying ExecutorService.

Parameters:
poolSize - the core pool size to keep minimum in the pool
Returns:
the builder

maxPoolSize

public ThreadsDefinition maxPoolSize(int maxPoolSize)
Sets the maximum pool size for the underlying ExecutorService.

Parameters:
maxPoolSize - the maximum pool size
Returns:
the builder

keepAliveTime

public ThreadsDefinition keepAliveTime(long keepAliveTime)
Sets the keep alive time for idle threads

Parameters:
keepAliveTime - keep alive time
Returns:
the builder

timeUnit

public ThreadsDefinition timeUnit(TimeUnit keepAliveTimeUnits)
Sets the keep alive time unit. By default SECONDS is used.

Parameters:
keepAliveTimeUnits - time unit
Returns:
the builder

maxQueueSize

public ThreadsDefinition maxQueueSize(int maxQueueSize)
Sets the maximum number of tasks in the work queue.

Use -1 or Integer.MAX_VALUE for an unbounded queue

Parameters:
maxQueueSize - the max queue size
Returns:
the builder

rejectedPolicy

public ThreadsDefinition rejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy)
Sets the handler for tasks which cannot be executed by the thread pool.

Parameters:
rejectedPolicy - the policy for the handler
Returns:
the builder

threadName

public ThreadsDefinition threadName(String threadName)
Sets the thread name to use.

Parameters:
threadName - the thread name
Returns:
the builder

callerRunsWhenRejected

public ThreadsDefinition callerRunsWhenRejected(boolean callerRunsWhenRejected)
Whether or not the caller should run the task when it was rejected by the thread pool.

Is by default true

Parameters:
callerRunsWhenRejected - whether or not the caller should run
Returns:
the builder

getExecutorService

public ExecutorService getExecutorService()
Description copied from interface: ExecutorServiceAware
Gets the executor service

Specified by:
getExecutorService in interface ExecutorServiceAware
Returns:
the executor

setExecutorService

public void setExecutorService(ExecutorService executorService)
Description copied from interface: ExecutorServiceAware
Sets the executor service to be used.

Specified by:
setExecutorService in interface ExecutorServiceAware
Parameters:
executorService - the executor

getExecutorServiceRef

public String getExecutorServiceRef()
Description copied from interface: ExecutorServiceAware
Gets the reference to lookup in the Registry for the executor service to be used.

Specified by:
getExecutorServiceRef in interface ExecutorServiceAware
Returns:
the reference, or null if the executor was set directly

setExecutorServiceRef

public void setExecutorServiceRef(String executorServiceRef)
Description copied from interface: ExecutorServiceAware
Sets a reference to lookup in the Registry for the executor service to be used.

Specified by:
setExecutorServiceRef in interface ExecutorServiceAware
Parameters:
executorServiceRef - reference for the executor

getPoolSize

public Integer getPoolSize()

setPoolSize

public void setPoolSize(Integer poolSize)

getMaxPoolSize

public Integer getMaxPoolSize()

setMaxPoolSize

public void setMaxPoolSize(Integer maxPoolSize)

getKeepAliveTime

public Long getKeepAliveTime()

setKeepAliveTime

public void setKeepAliveTime(Long keepAliveTime)

getTimeUnit

public TimeUnit getTimeUnit()

setTimeUnit

public void setTimeUnit(TimeUnit timeUnit)

getMaxQueueSize

public Integer getMaxQueueSize()

setMaxQueueSize

public void setMaxQueueSize(Integer maxQueueSize)

getThreadName

public String getThreadName()

setThreadName

public void setThreadName(String threadName)

getRejectedPolicy

public ThreadPoolRejectedPolicy getRejectedPolicy()

setRejectedPolicy

public void setRejectedPolicy(ThreadPoolRejectedPolicy rejectedPolicy)

getCallerRunsWhenRejected

public Boolean getCallerRunsWhenRejected()

setCallerRunsWhenRejected

public void setCallerRunsWhenRejected(Boolean callerRunsWhenRejected)


Apache CAMEL