|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mule.expression.DefaultExpressionManager
public class DefaultExpressionManager
Provides universal access for evaluating expressions embedded in Mule configurations, such as Xml, Java, scripting and annotations.
Users can register or unregisterExpressionEvaluator
through this interface.
Field Summary | |
---|---|
protected static Log |
logger
logger used by this class |
Fields inherited from interface org.mule.api.expression.ExpressionManager |
---|
DEFAULT_EXPRESSION_POSTFIX, DEFAULT_EXPRESSION_PREFIX |
Fields inherited from interface org.mule.api.lifecycle.Initialisable |
---|
PHASE_NAME |
Constructor Summary | |
---|---|
DefaultExpressionManager()
|
Method Summary | |
---|---|
void |
clearEnrichers()
Clears all registered enrichers from the manager. |
void |
clearEvaluators()
Clears all registered evaluators from the manager. |
protected String |
createEnrichmentExpression(String expression)
|
void |
enrich(String expression,
MuleEvent event,
Object object)
|
void |
enrich(String expression,
MuleMessage message,
Object object)
Enriches the current message using |
void |
enrich(String expression,
String enricherName,
MuleMessage message,
Object object)
Enriches the current message |
Object |
evaluate(String expression,
MuleEvent event)
|
Object |
evaluate(String expression,
MuleEvent event,
boolean failIfNull)
Evaluates the given expression. |
Object |
evaluate(String expression,
MuleMessage message)
Evaluates the given expression. |
Object |
evaluate(String expression,
MuleMessage message,
boolean failIfNull)
Evaluates the given expression. |
Object |
evaluate(String expression,
String evaluator,
MuleMessage message,
boolean failIfNull)
Evaluates the given expression. |
boolean |
evaluateBoolean(String expression,
MuleEvent event)
|
boolean |
evaluateBoolean(String expression,
MuleEvent event,
boolean nullReturnsTrue,
boolean nonBooleanReturnsTrue)
|
boolean |
evaluateBoolean(String expression,
MuleMessage message)
Evaluates the given expression resolving the result of the evaluation to a boolean. |
boolean |
evaluateBoolean(String expression,
MuleMessage message,
boolean nullReturnsTrue,
boolean nonBooleanReturnsTrue)
Evaluates the given expression resolving the result of the evaluation to a boolean. |
boolean |
evaluateBoolean(String expression,
String evaluator,
MuleMessage message)
Evaluates the given expression resolving the result of the evaluation to a boolean. |
boolean |
evaluateBoolean(String expression,
String evaluator,
MuleMessage message,
boolean nullReturnsTrue,
boolean nonBooleanReturnsTrue)
Evaluates the given expression resolving the result of the evaluation to a boolean. |
ExpressionLanguage |
getExpressionLanguage()
|
void |
initialise()
Method used to perform any initialisation work. |
protected boolean |
isEnricherExpression(String expression)
|
boolean |
isEnricherRegistered(String name)
Checks whether an enricher is registered with the manager |
protected boolean |
isEvaluatorExpression(String expression)
|
boolean |
isEvaluatorRegistered(String name)
Checks whether an evaluator is registered with the manager |
boolean |
isExpression(String string)
Determines if the string is an expression. |
boolean |
isValidExpression(String expression)
Determines if the expression is valid or not. |
String |
parse(String expression,
MuleEvent event)
|
String |
parse(String expression,
MuleEvent event,
boolean failIfNull)
|
String |
parse(String expression,
MuleMessage message)
Evaluates expressions in a given string. |
String |
parse(String expression,
MuleMessage message,
boolean failIfNull)
Evaluates expressions in a given string. |
protected String |
preProcessExpression(String expression)
|
void |
registerEnricher(ExpressionEnricher enricher)
|
void |
registerEvaluator(ExpressionEvaluator evaluator)
|
protected boolean |
resolveBoolean(Object result,
boolean nullReturnsTrue,
boolean nonBooleanReturnsTrue,
String expression)
|
void |
setExpressionLanguage(ExpressionLanguage expressionLanguage)
|
void |
setMuleContext(MuleContext context)
|
ExpressionEnricher |
unregisterEnricher(String name)
Removes the evaluator with the given name |
ExpressionEvaluator |
unregisterEvaluator(String name)
Removes the evaluator with the given name |
void |
validateExpression(String expression)
Determines if the expression is valid or not. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final transient Log logger
Constructor Detail |
---|
public DefaultExpressionManager()
Method Detail |
---|
public void setMuleContext(MuleContext context)
setMuleContext
in interface MuleContextAware
public void registerEvaluator(ExpressionEvaluator evaluator)
registerEvaluator
in interface ExpressionManager
public void registerEnricher(ExpressionEnricher enricher)
registerEnricher
in interface ExpressionManager
public boolean isEvaluatorRegistered(String name)
isEvaluatorRegistered
in interface ExpressionManager
name
- the name of the expression evaluator
public boolean isEnricherRegistered(String name)
isEnricherRegistered
in interface ExpressionManager
name
- the name of the expression enricher
public ExpressionEvaluator unregisterEvaluator(String name)
unregisterEvaluator
in interface ExpressionManager
name
- the name of the evaluator to remove
public ExpressionEnricher unregisterEnricher(String name)
unregisterEnricher
in interface ExpressionManager
name
- the name of the evaluator to remove
public Object evaluate(String expression, MuleMessage message) throws ExpressionRuntimeException
ExpressionManager.parse(String,org.mule.api.MuleMessage,boolean)
method
should be used since it will iterate through all expressions in a string.
evaluate
in interface ExpressionManager
expression
- a single expression i.e. xpath://foomessage
- the current message to process. The expression will evaluata on the message.
ExpressionRuntimeException
- if the expression is invalid, or a null is found for the expression
and 'failIfNull is set to true.public Object evaluate(String expression, MuleEvent event) throws ExpressionRuntimeException
evaluate
in interface ExpressionManager
ExpressionRuntimeException
public Object evaluate(String expression, MuleEvent event, boolean failIfNull) throws ExpressionRuntimeException
ExpressionManager.parse(String,org.mule.api.MuleMessage,boolean)
method
should be used since it will iterate through all expressions in a string.
evaluate
in interface ExpressionManager
expression
- a single expression i.e. xpath://foomessage
- the current message to process. The expression will evaluata on the message.failIfNull
- determines if an exception should be thrown if expression could not be evaluated or
returns null.
ExpressionRuntimeException
- if the expression is invalid, or a null is found for the expression
and 'failIfNull is set to true.public Object evaluate(String expression, MuleMessage message, boolean failIfNull)
ExpressionManager
ExpressionManager.parse(String,org.mule.api.MuleMessage,boolean)
method should be used since it will iterate
through all expressions in a string.
evaluate
in interface ExpressionManager
expression
- a single expression i.e. xpath://foomessage
- The current message being processedfailIfNull
- determines if an exception should be thrown if expression could not be evaluated or
returns null. @return the result of the evaluation
public void enrich(String expression, MuleMessage message, Object object) throws ExpressionRuntimeException
ExpressionManager
enrich
in interface ExpressionManager
expression
- a single expression i.e. header://foo that defines how the message shoud be enrichedmessage
- The current message being processed that will be enrichedobject
- The object that will be used to enrich the message
ExpressionRuntimeException
public void enrich(String expression, MuleEvent event, Object object)
enrich
in interface ExpressionManager
public void enrich(String expression, String enricherName, MuleMessage message, Object object)
ExpressionManager
enrich
in interface ExpressionManager
expression
- a single expression i.e. header://foo that defines how the message shoud be enrichedenricherName
- the enricher to use when executing the expressionmessage
- The current message being processed that will be enrichedobject
- The object that will be used to enrich the messagepublic Object evaluate(String expression, String evaluator, MuleMessage message, boolean failIfNull) throws ExpressionRuntimeException
ExpressionManager.parse(String,org.mule.api.MuleMessage,boolean)
method
should be used since it will iterate through all expressions in a string.
evaluate
in interface ExpressionManager
expression
- a single expression i.e. xpath://fooevaluator
- the evaluator to use when executing the expressionmessage
- the current message to process. The expression will evaluata on the message.failIfNull
- determines if an exception should be thrown if expression could not be evaluated or
returns null or if an exception should be thrown if an empty collection is returned.
ExpressionRuntimeException
- if the expression is invalid, or a null is found for the expression
and 'failIfNull is set to true.public boolean evaluateBoolean(String expression, String evaluator, MuleMessage message) throws ExpressionRuntimeException
ExpressionManager
evaluateBoolean
in interface ExpressionManager
expression
- a single expression i.e. header:foo=barevaluator
- the evaluator to use when executing the expressionmessage
- The current message being processed
ExpressionRuntimeException
public boolean evaluateBoolean(String expression, MuleMessage message) throws ExpressionRuntimeException
ExpressionManager
evaluateBoolean
in interface ExpressionManager
expression
- a single expression i.e. header:foo=barmessage
- The current message being processed
ExpressionRuntimeException
public boolean evaluateBoolean(String expression, String evaluator, MuleMessage message, boolean nullReturnsTrue, boolean nonBooleanReturnsTrue) throws ExpressionRuntimeException
ExpressionManager
evaluateBoolean
in interface ExpressionManager
expression
- a single expression i.e. header:foo=barevaluator
- the evaluator to use when executing the expressionmessage
- The current message being processednullReturnsTrue
- determines if true should be returned if the result of the evaluation is nullnonBooleanReturnsTrue
- determines if true should returned if the result is not null but isn't
recognised as a boolean
ExpressionRuntimeException
public boolean evaluateBoolean(String expression, MuleMessage message, boolean nullReturnsTrue, boolean nonBooleanReturnsTrue) throws ExpressionRuntimeException
ExpressionManager
evaluateBoolean
in interface ExpressionManager
expression
- a single expression i.e. header:foo=barmessage
- The current message being processednullReturnsTrue
- determines if true should be returned if the result of the evaluation is nullnonBooleanReturnsTrue
- determines if true should returned if the result is not null but isn't
recognised as a boolean
ExpressionRuntimeException
public boolean evaluateBoolean(String expression, MuleEvent event, boolean nullReturnsTrue, boolean nonBooleanReturnsTrue) throws ExpressionRuntimeException
evaluateBoolean
in interface ExpressionManager
ExpressionRuntimeException
protected boolean resolveBoolean(Object result, boolean nullReturnsTrue, boolean nonBooleanReturnsTrue, String expression)
public String parse(String expression, MuleMessage message) throws ExpressionRuntimeException
ExpressionManager.evaluate(String,org.mule.api.MuleMessage,boolean)
.
parse
in interface ExpressionManager
expression
- a single expression i.e. xpath://foomessage
- the current message to process. The expression will evaluata on the message.
ExpressionRuntimeException
- if the expression is invalid, or a null is
found for the expression and 'failIfNull is set to true.public String parse(String expression, MuleEvent event) throws ExpressionRuntimeException
parse
in interface ExpressionManager
ExpressionRuntimeException
public String parse(String expression, MuleMessage message, boolean failIfNull) throws ExpressionRuntimeException
ExpressionManager.evaluate(String,org.mule.api.MuleMessage,boolean)
.
parse
in interface ExpressionManager
expression
- a single expression i.e. xpath://foomessage
- the current message to process. The expression will evaluata on the message.failIfNull
- determines if an exception should be thrown if expression could not be evaluated or
returns null.
ExpressionRuntimeException
- if the expression is invalid, or a null is found for the expression
and 'failIfNull is set to true.public String parse(String expression, MuleEvent event, boolean failIfNull) throws ExpressionRuntimeException
parse
in interface ExpressionManager
ExpressionRuntimeException
public void clearEvaluators()
clearEvaluators
in interface ExpressionManager
public void clearEnrichers()
ExpressionManager
clearEnrichers
in interface ExpressionManager
public boolean isExpression(String string)
ExpressionManager
isExpression
in interface ExpressionManager
string
- is this string an expression string
public boolean isValidExpression(String expression)
isValidExpression
in interface ExpressionManager
expression
- the expression to validate
public void validateExpression(String expression) throws InvalidExpressionException
ExpressionManager
validateExpression
in interface ExpressionManager
expression
- the expression to validate
InvalidExpressionException
- if the expression is invalid, including information about the
position and faultpublic void initialise() throws InitialisationException
Initialisable
InitialisationException
should be thrown,
causing the Mule instance to shutdown. If the error is recoverable, say by
retrying to connect, a RecoverableException
should be thrown.
There is no guarantee that by throwing a Recoverable exception that the Mule
instance will not shut down.
initialise
in interface Initialisable
InitialisationException
- if a fatal error occurs causing the Mule instance to shutdown
RecoverableException
- if an error occurs that can be recovered frompublic boolean evaluateBoolean(String expression, MuleEvent event) throws ExpressionRuntimeException
evaluateBoolean
in interface ExpressionManager
ExpressionRuntimeException
protected String preProcessExpression(String expression)
protected boolean isEvaluatorExpression(String expression)
protected boolean isEnricherExpression(String expression)
protected String createEnrichmentExpression(String expression)
public void setExpressionLanguage(ExpressionLanguage expressionLanguage)
public ExpressionLanguage getExpressionLanguage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |