Package org.camunda.bpm.engine.impl.juel
Class ExpressionFactoryImpl
- java.lang.Object
-
- org.camunda.bpm.engine.impl.javax.el.ExpressionFactory
-
- org.camunda.bpm.engine.impl.juel.ExpressionFactoryImpl
-
public class ExpressionFactoryImpl extends ExpressionFactory
Expression factory implementation. This class is also used as an EL "service provider". The JUEL jar file specifies this class as el expression factory implementation inMETA-INF/services/javax.el.ExpressionFactory
. CallingExpressionFactory.newInstance()
will then return an instance of this class, configured as described below. If no properties are specified at construction time, properties are read from-
If the file
JAVA_HOME/lib/el.properties
exists and if it contains propertyjavax.el.ExpressionFactory
whose value is the name of this class, these properties are taken as default properties. - Otherwise, if system property
javax.el.ExpressionFactory
is set to the name of this class, the system propertiesSystem.getProperties()
are taken as default properties. -
el.properties
on your classpath. These properties override the properties fromJAVA_HOME/lib/el.properties
orSystem.getProperties()
.
Properties
. Having this, the following properties are read:-
javax.el.cacheSize
- cache size (int, default is 1000) -
javax.el.methodInvocations
- allow method invocations as in${foo.bar(baz)}
(boolean, default isfalse
). -
javax.el.nullProperties
- resolvenull
properties as in${foo[null]}
(boolean, default isfalse
). -
javax.el.varArgs
- support function/method calls using varargs (boolean, default isfalse
).
- Author:
- Christoph Beck
-
If the file
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ExpressionFactoryImpl.Profile
A profile provides a default set of language features that will define the builder's behavior.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PROP_CACHE_SIZE
javax.el.cacheSize
static java.lang.String
PROP_METHOD_INVOCATIONS
javax.el.methodInvocations
static java.lang.String
PROP_NULL_PROPERTIES
javax.el.nullProperties
static java.lang.String
PROP_VAR_ARGS
javax.el.varArgs
-
Constructor Summary
Constructors Constructor Description ExpressionFactoryImpl()
Create a new expression factory using the default builder and cache implementations.ExpressionFactoryImpl(java.util.Properties properties)
Create a new expression factory using the default builder and cache implementations.ExpressionFactoryImpl(java.util.Properties properties, TypeConverter converter)
Create a new expression factory using the default builder and cache implementations.ExpressionFactoryImpl(ExpressionFactoryImpl.Profile profile)
Create a new expression factory using the default builder and cache implementations.ExpressionFactoryImpl(ExpressionFactoryImpl.Profile profile, java.util.Properties properties)
Create a new expression factory using the default builder and cache implementations.ExpressionFactoryImpl(ExpressionFactoryImpl.Profile profile, java.util.Properties properties, TypeConverter converter)
Create a new expression factory using the default builder and cache implementations.ExpressionFactoryImpl(TreeStore store)
Create a new expression factory.ExpressionFactoryImpl(TreeStore store, TypeConverter converter)
Create a new expression factory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
coerceToType(java.lang.Object obj, java.lang.Class<?> targetType)
Coerces an object to a specific type according to the EL type conversion rules.TreeMethodExpression
createMethodExpression(ELContext context, java.lang.String expression, java.lang.Class<?> expectedReturnType, java.lang.Class<?>[] expectedParamTypes)
Parses an expression into aMethodExpression
for later evaluation.protected TreeBuilder
createTreeBuilder(java.util.Properties properties, Builder.Feature... features)
Create the factory's builder.protected TreeStore
createTreeStore(int defaultCacheSize, ExpressionFactoryImpl.Profile profile, java.util.Properties properties)
Create the factory's tree store.protected TypeConverter
createTypeConverter(java.util.Properties properties)
Create the factory's type converter.ObjectValueExpression
createValueExpression(java.lang.Object instance, java.lang.Class<?> expectedType)
Creates a ValueExpression that wraps an object instance.TreeValueExpression
createValueExpression(ELContext context, java.lang.String expression, java.lang.Class<?> expectedType)
Parses an expression into aValueExpression
for later evaluation.-
Methods inherited from class org.camunda.bpm.engine.impl.javax.el.ExpressionFactory
newInstance, newInstance
-
-
-
-
Field Detail
-
PROP_METHOD_INVOCATIONS
public static final java.lang.String PROP_METHOD_INVOCATIONS
javax.el.methodInvocations
- See Also:
- Constant Field Values
-
PROP_VAR_ARGS
public static final java.lang.String PROP_VAR_ARGS
javax.el.varArgs
- See Also:
- Constant Field Values
-
PROP_NULL_PROPERTIES
public static final java.lang.String PROP_NULL_PROPERTIES
javax.el.nullProperties
- See Also:
- Constant Field Values
-
PROP_CACHE_SIZE
public static final java.lang.String PROP_CACHE_SIZE
javax.el.cacheSize
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ExpressionFactoryImpl
public ExpressionFactoryImpl()
Create a new expression factory using the default builder and cache implementations. The builder and cache are configured fromel.properties
(see above). The maximum cache size will be 1000 unless overridden inel.properties
. The builder profile isExpressionFactoryImpl.Profile.JEE6
(features may be overridden inel.properties
).
-
ExpressionFactoryImpl
public ExpressionFactoryImpl(ExpressionFactoryImpl.Profile profile)
Create a new expression factory using the default builder and cache implementations. The builder and cache are configured from the specified profile andel.properties
(see above). The maximum cache size will be 1000 unless overridden inel.properties
.- Parameters:
profile
- builder profile (features may be overridden inel.properties
)- Since:
- 2.2
-
ExpressionFactoryImpl
public ExpressionFactoryImpl(java.util.Properties properties)
Create a new expression factory using the default builder and cache implementations. The builder and cache are configured using the specified properties. The maximum cache size will be 1000 unless overridden by propertyjavax.el.cacheSize
. The builder profile isExpressionFactoryImpl.Profile.JEE6
(features may be overridden inproperties
).- Parameters:
properties
- used to initialize this factory (may benull
)
-
ExpressionFactoryImpl
public ExpressionFactoryImpl(ExpressionFactoryImpl.Profile profile, java.util.Properties properties)
Create a new expression factory using the default builder and cache implementations. The builder and cache are configured using the specified profile and properties. The maximum cache size will be 1000 unless overridden by propertyjavax.el.cacheSize
.- Parameters:
profile
- builder profile (individual features may be overridden in properties)properties
- used to initialize this factory (may benull
)- Since:
- 2.2
-
ExpressionFactoryImpl
public ExpressionFactoryImpl(java.util.Properties properties, TypeConverter converter)
Create a new expression factory using the default builder and cache implementations. The builder and cache are configured using the specified properties. The maximum cache size will be 1000 unless overridden by propertyjavax.el.cacheSize
. The builder profile isExpressionFactoryImpl.Profile.JEE6
(individual features may be overridden inproperties
).- Parameters:
properties
- used to initialize this factory (may benull
)converter
- custom type converter
-
ExpressionFactoryImpl
public ExpressionFactoryImpl(ExpressionFactoryImpl.Profile profile, java.util.Properties properties, TypeConverter converter)
Create a new expression factory using the default builder and cache implementations. The builder and cache are configured using the specified profile and properties. The maximum cache size will be 1000 unless overridden by propertyjavax.el.cacheSize
.- Parameters:
profile
- builder profile (individual features may be overridden in properties)properties
- used to initialize this factory (may benull
)converter
- custom type converter- Since:
- 2.2
-
ExpressionFactoryImpl
public ExpressionFactoryImpl(TreeStore store)
Create a new expression factory.- Parameters:
store
- the tree store used to parse and cache parse trees.
-
ExpressionFactoryImpl
public ExpressionFactoryImpl(TreeStore store, TypeConverter converter)
Create a new expression factory.- Parameters:
store
- the tree store used to parse and cache parse trees.converter
- custom type converter
-
-
Method Detail
-
createTreeStore
protected TreeStore createTreeStore(int defaultCacheSize, ExpressionFactoryImpl.Profile profile, java.util.Properties properties)
Create the factory's tree store. This implementation creates a new tree store using the default builder and cache implementations. The builder and cache are configured using the specified properties. The maximum cache size will be as specified unless overridden by propertyjavax.el.cacheSize
.
-
createTypeConverter
protected TypeConverter createTypeConverter(java.util.Properties properties)
Create the factory's type converter. This implementation takes thede.odysseus.el.misc.TypeConverter
property as the name of a class implementing thede.odysseus.el.misc.TypeConverter
interface. If the property is not set, the default converter (TypeConverter.DEFAULT
) is used.
-
createTreeBuilder
protected TreeBuilder createTreeBuilder(java.util.Properties properties, Builder.Feature... features)
Create the factory's builder. This implementation takes thede.odysseus.el.tree.TreeBuilder
property as a name of a class implementing thede.odysseus.el.tree.TreeBuilder
interface. If the property is not set, a plainde.odysseus.el.tree.impl.Builder
is used. If the configured class is a subclass ofde.odysseus.el.tree.impl.Builder
and which provides a constructor taking an array ofBuilder.Feature
, this constructor will be invoked. Otherwise, the default constructor will be used.
-
coerceToType
public final java.lang.Object coerceToType(java.lang.Object obj, java.lang.Class<?> targetType)
Description copied from class:ExpressionFactory
Coerces an object to a specific type according to the EL type conversion rules. AnELException
is thrown if an error results from applying the conversion rules.- Specified by:
coerceToType
in classExpressionFactory
- Parameters:
obj
- The object to coerce.targetType
- The target type for the coercion.- Returns:
- the coerced object
-
createValueExpression
public final ObjectValueExpression createValueExpression(java.lang.Object instance, java.lang.Class<?> expectedType)
Description copied from class:ExpressionFactory
Creates a ValueExpression that wraps an object instance. This method can be used to pass any object as a ValueExpression. The wrapper ValueExpression is read only, and returns the wrapped object via its getValue() method, optionally coerced.- Specified by:
createValueExpression
in classExpressionFactory
- Parameters:
instance
- The object instance to be wrapped.expectedType
- The type the result of the expression will be coerced to after evaluation. There will be no coercion if it is Object.class,- Returns:
- a ValueExpression that wraps the given object instance.
-
createValueExpression
public final TreeValueExpression createValueExpression(ELContext context, java.lang.String expression, java.lang.Class<?> expectedType)
Description copied from class:ExpressionFactory
Parses an expression into aValueExpression
for later evaluation. Use this method for expressions that refer to values. This method should perform syntactic validation of the expression. If in doing so it detects errors, it should raise an ELException.- Specified by:
createValueExpression
in classExpressionFactory
- Parameters:
context
- The EL context used to parse the expression. The FunctionMapper and VariableMapper stored in the ELContext are used to resolve functions and variables found in the expression. They can be null, in which case functions or variables are not supported for this expression. The object returned must invoke the same functions and access the same variable mappings regardless of whether the mappings in the provided FunctionMapper and VariableMapper instances change between calling ExpressionFactory.createValueExpression() and any method on ValueExpression. Note that within the EL, the ${} and #{} syntaxes are treated identically. This includes the use of VariableMapper and FunctionMapper at expression creation time. Each is invoked if not null, independent of whether the #{} or ${} syntax is used for the expression.expression
- The expression to parseexpectedType
- The type the result of the expression will be coerced to after evaluation.- Returns:
- The parsed expression
-
createMethodExpression
public final TreeMethodExpression createMethodExpression(ELContext context, java.lang.String expression, java.lang.Class<?> expectedReturnType, java.lang.Class<?>[] expectedParamTypes)
Description copied from class:ExpressionFactory
Parses an expression into aMethodExpression
for later evaluation. Use this method for expressions that refer to methods. If the expression is a String literal, a MethodExpression is created, which when invoked, returns the String literal, coerced to expectedReturnType. An ELException is thrown if expectedReturnType is void or if the coercion of the String literal to the expectedReturnType yields an error (see Section "1.16 Type Conversion"). This method should perform syntactic validation of the expression. If in doing so it detects errors, it should raise an ELException.- Specified by:
createMethodExpression
in classExpressionFactory
- Parameters:
context
- The EL context used to parse the expression. The FunctionMapper and VariableMapper stored in the ELContext are used to resolve functions and variables found in the expression. They can be null, in which case functions or variables are not supported for this expression. The object returned must invoke the same functions and access the same variable mappings regardless of whether the mappings in the provided FunctionMapper and VariableMapper instances change between calling ExpressionFactory.createMethodExpression() and any method on MethodExpression. Note that within the EL, the ${} and #{} syntaxes are treated identically. This includes the use of VariableMapper and FunctionMapper at expression creation time. Each is invoked if not null, independent of whether the #{} or ${} syntax is used for the expression.expression
- The expression to parseexpectedReturnType
- The expected return type for the method to be found. After evaluating the expression, the MethodExpression must check that the return type of the actual method matches this type. Passing in a value of null indicates the caller does not care what the return type is, and the check is disabled.expectedParamTypes
- The expected parameter types for the method to be found. Must be an array with no elements if there are no parameters expected. It is illegal to pass null.- Returns:
- The parsed expression
-
-