Package com.tangosol.coherence.rest.util
Class MvelHelper
- java.lang.Object
-
- com.tangosol.coherence.rest.util.MvelHelper
-
public class MvelHelper extends Object
Enable Mvel to be optional by only accessing module via reflection with implementation provided on classpath.org.mvel.mvel2module is removed by default for security reasons, but one can override and have backwards compatible support by adding the mvel module to the path.- Since:
- 12.2.1.3.18
- Author:
- jf 2022/01/19
-
-
Field Summary
Fields Modifier and Type Field Description static MethodHandleHANDLE_COMPILE_EXPRESSIONMethodHandle for method compileExpression(String expr, ParserContext ctx) from org.mvel2.MVEL.static MethodHandleHANDLE_COMPILE_SET_EXPRESSIONMethodHandle for method compileSetExpression(String expr, ParserContext ctx) from org.mvel2.MVEL.static MethodHandleHANDLE_EXECUTE_EXPRESSIONMethodHandle for method executeExpression(Object compiledExpr, Object ctx) from org.mvel2.MVEL.static MethodHandleHANDLE_EXECUTE_SET_EXPRESSIONMethodHandle for method executeSetExpression(Serializable compiledExpr, Object ctx, Object value) from org.mvel2.MVEL.static MethodHandleHANDLE_PARSER_CONFIGURATION_SET_CLASS_LOADERMethodHandle for method setClassLoader() from org.mvel2.ParserConfiguration.static MethodHandleHANDLE_PARSER_CONTEXT_ADD_PACKAGE_IMPORTMethodHandle for method addPackageImport(String) from org.mvel2.ParserContext.static MethodHandleHANDLE_PARSER_CONTEXT_GET_PARSER_CONFIGURATIONMethodHandle for method getParserConfiguration() from org.mvel2.ParserContext.static Class<?>s_clzMVELReflection lookup of class org.mvel2.MVEL.static Class<?>s_clzParserContextReflection lookup of class org.mvel2.ParserContext.static booleans_fEnabledTrue iff mvel2 jar is on classpath and all reflection lookups succeeded.
-
Constructor Summary
Constructors Constructor Description MvelHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static SerializablecompileExpression(String sExpr, Object ctx)CompilesExprwithin ParserContextctx.static SerializablecompileSetExpression(String sExpr, Object ctx)CompilesExprusing ParserContextctx.static ObjectexecuteExpression(Object compiledExpr, Object oTarget)Executes a compiledExpression against target.static voidexecuteSetExpression(Serializable compiledSet, Object oTarget, Object oValue)Set property referenced bycompiledSetexpression inoTargettoOvalue..static ObjectgetMvelParserContext()Return an instance of ParserContext to be used for MVEL compilation.static booleanisEnabled()Return true if optionalorg.mvel.mvel2module is loaded from path.
-
-
-
Field Detail
-
s_fEnabled
public static final boolean s_fEnabled
True iff mvel2 jar is on classpath and all reflection lookups succeeded.
-
s_clzMVEL
public static final Class<?> s_clzMVEL
Reflection lookup of class org.mvel2.MVEL.
-
s_clzParserContext
public static final Class<?> s_clzParserContext
Reflection lookup of class org.mvel2.ParserContext.
-
HANDLE_PARSER_CONTEXT_ADD_PACKAGE_IMPORT
public static final MethodHandle HANDLE_PARSER_CONTEXT_ADD_PACKAGE_IMPORT
MethodHandle for method addPackageImport(String) from org.mvel2.ParserContext.
-
HANDLE_PARSER_CONTEXT_GET_PARSER_CONFIGURATION
public static final MethodHandle HANDLE_PARSER_CONTEXT_GET_PARSER_CONFIGURATION
MethodHandle for method getParserConfiguration() from org.mvel2.ParserContext.
-
HANDLE_PARSER_CONFIGURATION_SET_CLASS_LOADER
public static final MethodHandle HANDLE_PARSER_CONFIGURATION_SET_CLASS_LOADER
MethodHandle for method setClassLoader() from org.mvel2.ParserConfiguration.
-
HANDLE_COMPILE_EXPRESSION
public static final MethodHandle HANDLE_COMPILE_EXPRESSION
MethodHandle for method compileExpression(String expr, ParserContext ctx) from org.mvel2.MVEL.
-
HANDLE_EXECUTE_EXPRESSION
public static final MethodHandle HANDLE_EXECUTE_EXPRESSION
MethodHandle for method executeExpression(Object compiledExpr, Object ctx) from org.mvel2.MVEL.
-
HANDLE_COMPILE_SET_EXPRESSION
public static final MethodHandle HANDLE_COMPILE_SET_EXPRESSION
MethodHandle for method compileSetExpression(String expr, ParserContext ctx) from org.mvel2.MVEL.
-
HANDLE_EXECUTE_SET_EXPRESSION
public static final MethodHandle HANDLE_EXECUTE_SET_EXPRESSION
MethodHandle for method executeSetExpression(Serializable compiledExpr, Object ctx, Object value) from org.mvel2.MVEL.
-
-
Method Detail
-
isEnabled
public static boolean isEnabled()
Return true if optionalorg.mvel.mvel2module is loaded from path. Due to security concerns, Mvel is removed from default implementation and only optionally available for backwards compatibility mode.- Returns:
- true if mvel implementation is available
-
getMvelParserContext
public static Object getMvelParserContext()
Return an instance of ParserContext to be used for MVEL compilation.- Returns:
- an instance of ParserContext to be used for MVEL compilation
-
compileExpression
public static Serializable compileExpression(String sExpr, Object ctx)
CompilesExprwithin ParserContextctx.- Parameters:
sExpr- expressionctx- ParserContext- Returns:
- a
Serializablecompiled expression
-
executeExpression
public static Object executeExpression(Object compiledExpr, Object oTarget)
Executes a compiledExpression against target.- Parameters:
compiledExpr- compiled expression to select data from targetoTarget- target object- Returns:
- the extracted data from
oTarget
-
compileSetExpression
public static Serializable compileSetExpression(String sExpr, Object ctx)
CompilesExprusing ParserContextctx.- Parameters:
sExpr- expressionctx- ParserContext- Returns:
- a
Serializablecompiled expression
-
executeSetExpression
public static void executeSetExpression(Serializable compiledSet, Object oTarget, Object oValue)
Set property referenced bycompiledSetexpression inoTargettoOvalue..- Parameters:
compiledSet- result ofcompileSetExpression(String, Object)oTarget- object to be updatedoValue- value to update the computed property
-
-