org.apache.camel.model
Class PolicyDefinition

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<PolicyDefinition>
              extended by org.apache.camel.model.PolicyDefinition
All Implemented Interfaces:
Block, NamedNode

public class PolicyDefinition
extends OutputDefinition<PolicyDefinition>

Represents an XML <policy/> element

Version:

Field Summary
protected  String ref
           
protected  Class<? extends Policy> type
           
 
Fields inherited from class org.apache.camel.model.OutputDefinition
outputs
 
Fields inherited from class org.apache.camel.model.ProcessorDefinition
inheritErrorHandler, log
 
Constructor Summary
PolicyDefinition()
           
PolicyDefinition(Policy policy)
           
 
Method Summary
 Processor createProcessor(RouteContext routeContext)
          Override this in definition class and implement logic to create the processor based on the definition model.
protected  String description()
           
 String getLabel()
          Returns a label to describe this node such as the expression if some kind of expression node
 String getRef()
           
 String getShortName()
          Returns a short name for this node which can be useful for ID generation or referring to related resources like images
 boolean isAbstract()
          Whether this model is abstract or not.
 PolicyDefinition ref(String ref)
          Sets a reference to use for lookup the policy in the registry.
protected  Policy resolvePolicy(RouteContext routeContext)
           
 void setRef(String ref)
           
 void setType(Class<? extends Policy> type)
          Sets a policy type that this definition should scope within.
 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, 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
 

Field Detail

type

protected Class<? extends Policy> type

ref

protected String ref
Constructor Detail

PolicyDefinition

public PolicyDefinition()

PolicyDefinition

public PolicyDefinition(Policy policy)
Method Detail

toString

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

description

protected String description()

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<PolicyDefinition>
Returns:
defaults to "node" but derived nodes should overload this to provide a unique name

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<PolicyDefinition>

isAbstract

public boolean isAbstract()
Description copied from class: ProcessorDefinition
Whether this model is abstract or not.

An abstract model is something that is used for configuring cross cutting concerns such as error handling, transaction policies, interceptors etc.

Regular definitions is what is part of the route, such as ToDefinition, WireTapDefinition and the likes.

Will by default return false to indicate regular definition, so all the abstract definitions must override this method and return true instead.

This information is used in camel-spring to let Camel work a bit on the model provided by JAXB from the Spring XML file. This is needed to handle those cross cutting concerns properly. The Java DSL does not have this issue as it can work this out directly using the fluent builder methods.

Overrides:
isAbstract in class ProcessorDefinition<PolicyDefinition>
Returns:
true for abstract, otherwise false for regular.

getRef

public String getRef()

setRef

public void setRef(String ref)

setType

public void setType(Class<? extends Policy> type)
Sets a policy type that this definition should scope within.

Is used for convention over configuration situations where the policy should be automatic looked up in the registry and it should be based on this type. For instance a TransactedPolicy can be set as type for easy transaction configuration.

Will by default scope to the wide Policy

Parameters:
type - the policy type

ref

public PolicyDefinition ref(String ref)
Sets a reference to use for lookup the policy in the registry.

Parameters:
ref - the reference
Returns:
the builder

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<PolicyDefinition>
Throws:
Exception

resolvePolicy

protected Policy resolvePolicy(RouteContext routeContext)


Apache CAMEL