javax.el.FunctionMapper Java Examples
The following examples show how to use
javax.el.FunctionMapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AstFunction.java From Tomcat8-Source-Read with MIT License | 6 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { FunctionMapper fnMapper = ctx.getFunctionMapper(); // quickly validate again for this request if (fnMapper == null) { throw new ELException(MessageFactory.get("error.fnMapper.null")); } Method m = fnMapper.resolveFunction(this.prefix, this.localName); if (m == null) { throw new ELException(MessageFactory.get("error.fnMapper.method", this.getOutputName())); } return m.getReturnType(); }
Example #2
Source File: TestRandomTestChooser.java From proctor with Apache License 2.0 | 6 votes |
static RandomTestChooser initializeRandomTestChooser(final List<Range> ranges, final List<TestBucket> buckets) { final ExpressionFactory expressionFactory = new ExpressionFactoryImpl(); final FunctionMapper functionMapper = RuleEvaluator.FUNCTION_MAPPER; final ConsumableTestDefinition testDefinition = new ConsumableTestDefinition(); testDefinition.setConstants(Collections.emptyMap()); testDefinition.setBuckets(buckets); final List<Allocation> allocations = Lists.newArrayList(); allocations.add(new Allocation("${}", ranges, "#A1")); testDefinition.setAllocations(allocations); final RandomTestChooser rtc = new RandomTestChooser(expressionFactory, functionMapper, "testName", testDefinition); return rtc; }
Example #3
Source File: AstFunction.java From tomcatsrc with Apache License 2.0 | 6 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { FunctionMapper fnMapper = ctx.getFunctionMapper(); // quickly validate again for this request if (fnMapper == null) { throw new ELException(MessageFactory.get("error.fnMapper.null")); } Method m = fnMapper.resolveFunction(this.prefix, this.localName); if (m == null) { throw new ELException(MessageFactory.get("error.fnMapper.method", this.getOutputName())); } return m.getReturnType(); }
Example #4
Source File: AstFunction.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@Override public Class<?> getType(EvaluationContext ctx) throws ELException { FunctionMapper fnMapper = ctx.getFunctionMapper(); // quickly validate again for this request if (fnMapper == null) { throw new ELException(MessageFactory.get("error.fnMapper.null")); } Method m = fnMapper.resolveFunction(this.prefix, this.localName); if (m == null) { throw new ELException(MessageFactory.get("error.fnMapper.method", this.getOutputName())); } return m.getReturnType(); }
Example #5
Source File: CdiResolver.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public CdiResolver() { context = new javax.el.ELContext() { @Override public VariableMapper getVariableMapper() { return null; } @Override public FunctionMapper getFunctionMapper() { return null; } @Override public javax.el.ELResolver getELResolver() { return getWrappedResolver(); } }; }
Example #6
Source File: RuleEvaluator.java From proctor with Apache License 2.0 | 6 votes |
@Nonnull ELContext createELContext(@Nonnull final VariableMapper variableMapper) { return new ELContext() { @Nonnull @Override public ELResolver getELResolver() { return elResolver; } @Nonnull @Override public FunctionMapper getFunctionMapper() { return functionMapper; } @Nonnull @Override public VariableMapper getVariableMapper() { return variableMapper; } }; }
Example #7
Source File: ElMetricName.java From metrics-cdi with Apache License 2.0 | 6 votes |
private ELContext createELContext(final ELResolver resolver, final FunctionMapper functionMapper, final VariableMapper variableMapper) { return new ELContext() { @Override public ELResolver getELResolver() { return resolver; } @Override public FunctionMapper getFunctionMapper() { return functionMapper; } @Override public VariableMapper getVariableMapper() { return variableMapper; } }; }
Example #8
Source File: CdiResolver.java From flowable-engine with Apache License 2.0 | 6 votes |
public CdiResolver() { context = new javax.el.ELContext() { @Override public VariableMapper getVariableMapper() { return null; } @Override public FunctionMapper getFunctionMapper() { return null; } @Override public javax.el.ELResolver getELResolver() { return getWrappedResolver(); } }; }
Example #9
Source File: ProctorUtils.java From proctor with Apache License 2.0 | 6 votes |
/** * Verifies that the TestMatrix is compatible with all the required tests. * Removes non-required tests from the TestMatrix * Replaces invalid or missing tests (buckets are not compatible) with * default implementation returning the fallback value see defaultFor * * @param testMatrix the {@link TestMatrixArtifact} to be verified. * @param matrixSource a {@link String} of the source of proctor artifact. For example a path of proctor artifact file. * @param requiredTests a {@link Map} of required test. The {@link TestSpecification} would be verified * @param functionMapper a given el {@link FunctionMapper} * @return a {@link ProctorLoadResult} to describe the result of verification. It contains errors of verification and a list of missing test. */ public static ProctorLoadResult verifyAndConsolidate( @Nonnull final TestMatrixArtifact testMatrix, final String matrixSource, @Nonnull final Map<String, TestSpecification> requiredTests, @Nonnull final FunctionMapper functionMapper ) { return verifyAndConsolidate( testMatrix, matrixSource, requiredTests, functionMapper, ProvidedContext.nonEvaluableContext(), Collections.emptySet() ); }
Example #10
Source File: ProctorUtils.java From proctor with Apache License 2.0 | 6 votes |
public static ProctorLoadResult verifyAndConsolidate( @Nonnull final TestMatrixArtifact testMatrix, final String matrixSource, @Nonnull final Map<String, TestSpecification> requiredTests, @Nonnull final FunctionMapper functionMapper, final ProvidedContext providedContext ) { return verifyAndConsolidate( testMatrix, matrixSource, requiredTests, functionMapper, providedContext, Collections.emptySet() ); }
Example #11
Source File: ProctorUtils.java From proctor with Apache License 2.0 | 6 votes |
/** * Verifies that a single dynamic test is valid against {@link FunctionMapper} and {@link ProvidedContext}. * * @param testName the name of the test * @param testDefinition {@link ConsumableTestDefinition} of the test * @param matrixSource a {@link String} of the source of proctor artifact. For example a path of proctor artifact file. * @param functionMapper a given el {@link FunctionMapper} * @param providedContext a {@link Map} containing variables describing the context in which the request is executing. * These will be supplied to verifying all rules. * @throws IncompatibleTestMatrixException if validation is failed. */ private static void verifyDynamicTest( @Nonnull final String testName, @Nonnull final ConsumableTestDefinition testDefinition, @Nonnull final String matrixSource, @Nonnull final FunctionMapper functionMapper, final ProvidedContext providedContext ) throws IncompatibleTestMatrixException { verifyTest( testName, testDefinition, // hack: use empty test spec to not verify buckets and payloads new TestSpecification(), // this parameter is ignored Collections.emptySet(), matrixSource, functionMapper, providedContext ); }
Example #12
Source File: ProctorUtils.java From proctor with Apache License 2.0 | 6 votes |
/** * verify with default function mapper and no dynamic tests */ public static ProctorLoadResult verify( @Nonnull final TestMatrixArtifact testMatrix, final String matrixSource, @Nonnull final Map<String, TestSpecification> requiredTests, @Nonnull final FunctionMapper functionMapper, final ProvidedContext providedContext ) { return verify( testMatrix, matrixSource, requiredTests, functionMapper, providedContext, Collections.emptySet() ); }
Example #13
Source File: MethodExpressionImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * @param expr * @param node * @param fnMapper * @param expectedType * @param paramTypes */ public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType, Class<?>[] paramTypes) { super(); this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; this.paramTypes = paramTypes; }
Example #14
Source File: RuleAnalyzer.java From proctor with Apache License 2.0 | 5 votes |
/** * @return variables contained in the expression */ public static Set<String> getReferencedVariables(final String elString) { final NameGatheringVariableMapper variableMapper = new NameGatheringVariableMapper(); // instances are not thread-safe, so creating new ones on every call. final ELResolver elResolver = new CompositeELResolver(); final FunctionMapper functionMapper = RuleEvaluator.defaultFunctionMapperBuilder().build(); ExpressionFactory.newInstance().createValueExpression( new ELContext() { @Override public ELResolver getELResolver() { return elResolver; } @Override public FunctionMapper getFunctionMapper() { return functionMapper; } @Override public VariableMapper getVariableMapper() { return variableMapper; } }, elString, Void.class ); return variableMapper.getGatheredVariables(); }
Example #15
Source File: ValueExpressionImpl.java From Tomcat8-Source-Read with MIT License | 5 votes |
public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType) { this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; }
Example #16
Source File: ProctorUtils.java From proctor with Apache License 2.0 | 5 votes |
@Nonnull private static RuleEvaluator makeRuleEvaluator(final ExpressionFactory expressionFactory, final FunctionMapper functionMapper) { // Make the expression evaluation context. final Map<String, Object> testConstants = Collections.emptyMap(); return new RuleEvaluator(expressionFactory, functionMapper, testConstants); }
Example #17
Source File: MethodExpressionImpl.java From Tomcat8-Source-Read with MIT License | 5 votes |
public MethodExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType, Class<?>[] paramTypes) { super(); this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; this.paramTypes = paramTypes; }
Example #18
Source File: AbstractProctorLoader.java From proctor with Apache License 2.0 | 5 votes |
/** * @param cls name will be used as namespace for timer * @param specification provides tests, context, dynamic filters * @param functionMapper evaluates functions in allocation rules */ public AbstractProctorLoader( @Nonnull final Class<?> cls, @Nonnull final ProctorSpecification specification, @Nonnull final FunctionMapper functionMapper ) { super(cls.getSimpleName()); this.requiredTests = specification.getTests(); this.providedContext = createProvidedContext(specification); if (!this.providedContext.shouldEvaluate()) { LOGGER.debug("providedContext Objects missing necessary functions for validation, rules will not be tested."); } this.functionMapper = functionMapper; this.dynamicFilters = specification.getDynamicFilters(); }
Example #19
Source File: ValueExpressionImpl.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
/** * */ public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType) { this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; }
Example #20
Source File: ValueExpressionImpl.java From Tomcat7.0.67 with Apache License 2.0 | 5 votes |
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.expr = in.readUTF(); String type = in.readUTF(); if (!"".equals(type)) { this.expectedType = ReflectionUtil.forName(type); } this.fnMapper = (FunctionMapper) in.readObject(); this.varMapper = (VariableMapper) in.readObject(); }
Example #21
Source File: ProctorUtils.java From proctor with Apache License 2.0 | 5 votes |
/** * Verifies that a single required test is valid against {@link TestSpecification} * and {@link FunctionMapper} and {@link ProvidedContext}. * * @param testName the name of the test * @param testDefinition {@link ConsumableTestDefinition} of the test * @param testSpecification {@link TestSpecification} defined in an application for the test * @param matrixSource a {@link String} of the source of proctor artifact. For example a path of proctor artifact file. * @param functionMapper a given el {@link FunctionMapper} * @param providedContext a {@link Map} containing variables describing the context in which the request is executing. * These will be supplied to verifying all rules. * @throws IncompatibleTestMatrixException if validation is failed. */ private static void verifyRequiredTest( @Nonnull final String testName, @Nonnull final ConsumableTestDefinition testDefinition, @Nonnull final TestSpecification testSpecification, @Nonnull final String matrixSource, @Nonnull final FunctionMapper functionMapper, final ProvidedContext providedContext ) throws IncompatibleTestMatrixException { final Set<Integer> knownBucketValues = new HashSet<>(); for (final Integer bucketValue : testSpecification.getBuckets().values()) { if (bucketValue == null) { throw new IncompatibleTestMatrixException("Test specification of " + testName + " has null in buckets"); } if (!knownBucketValues.add(bucketValue)) { throw new IncompatibleTestMatrixException( "Test specification of " + testName + " has duplicated buckets for value " + bucketValue ); } } verifyTest( testName, testDefinition, testSpecification, knownBucketValues, matrixSource, functionMapper, providedContext ); }
Example #22
Source File: RuleEvaluator.java From proctor with Apache License 2.0 | 5 votes |
RuleEvaluator( @Nonnull final ExpressionFactory expressionFactory, @Nonnull final FunctionMapper functionMapper, @Nonnull final Map<String, Object> testConstantsMap ) { this.expressionFactory = expressionFactory; this.functionMapper = functionMapper; elResolver = constructStandardElResolver(); testConstants = ProctorUtils.convertToValueExpressionMap(expressionFactory, testConstantsMap); }
Example #23
Source File: MethodExpressionImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.expr = in.readUTF(); String type = in.readUTF(); if (!"".equals(type)) { this.expectedType = ReflectionUtil.forName(type); } this.paramTypes = ReflectionUtil.toTypeArray(((String[]) in .readObject())); this.fnMapper = (FunctionMapper) in.readObject(); this.varMapper = (VariableMapper) in.readObject(); }
Example #24
Source File: ExpressionBuilder.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * */ public ExpressionBuilder(String expression, ELContext ctx) throws ELException { this.expression = expression; FunctionMapper ctxFn = ctx.getFunctionMapper(); VariableMapper ctxVar = ctx.getVariableMapper(); if (ctxFn != null) { this.fnMapper = new FunctionMapperFactory(ctxFn); } if (ctxVar != null) { this.varMapper = new VariableMapperFactory(ctxVar); } }
Example #25
Source File: ProctorUtils.java From proctor with Apache License 2.0 | 5 votes |
public static ProctorLoadResult verifyAndConsolidate( @Nonnull final TestMatrixArtifact testMatrix, final String matrixSource, @Nonnull final Map<String, TestSpecification> requiredTests, @Nonnull final FunctionMapper functionMapper, final ProvidedContext providedContext, @Nonnull final Set<String> dynamicTests ) { final ProctorLoadResult result = verify(testMatrix, matrixSource, requiredTests, functionMapper, providedContext, dynamicTests); final Map<String, ConsumableTestDefinition> definedTests = testMatrix.getTests(); // Remove any invalid tests so that any required ones will be replaced with default values during the // consolidation below (just like missing tests). Any non-required tests can safely be ignored. for (final String invalidTest : result.getTestsWithErrors()) { // TODO - mjs - gross that this depends on the mutability of the returned map, but then so does the // consolidate method below. definedTests.remove(invalidTest); } // Remove any invalid dynamic tests. This ones won't be replaced with default values // because they are not required tests. for (final String invalidDynamicTest : result.getDynamicTestWithErrors()) { definedTests.remove(invalidDynamicTest); } consolidate(testMatrix, requiredTests, dynamicTests); return result; }
Example #26
Source File: ValueExpressionImpl.java From tomcatsrc with Apache License 2.0 | 5 votes |
/** * */ public ValueExpressionImpl(String expr, Node node, FunctionMapper fnMapper, VariableMapper varMapper, Class<?> expectedType) { this.expr = expr; this.node = node; this.fnMapper = fnMapper; this.varMapper = varMapper; this.expectedType = expectedType; }
Example #27
Source File: StandardTestChooser.java From proctor with Apache License 2.0 | 5 votes |
public StandardTestChooser( @Nonnull final ExpressionFactory expressionFactory, @Nonnull final FunctionMapper functionMapper, @Nonnull final String testName, @Nonnull final ConsumableTestDefinition testDefinition ) { this(new TestRangeSelector(expressionFactory, functionMapper, testName, testDefinition)); }
Example #28
Source File: PageContextImpl.java From packagedrone with Eclipse Public License 1.0 | 5 votes |
public static ValueExpression getValueExpression(String expression, PageContext pageContext, Class expectedType, FunctionMapper functionMap) { // ELResolvers are not used in createValueExpression ELContextImpl elctxt = (ELContextImpl)pageContext.getELContext(); elctxt.setFunctionMapper(functionMap); ExpressionFactory expFactory = getExpressionFactory(pageContext); return expFactory.createValueExpression(elctxt, expression, expectedType); }
Example #29
Source File: FeelElContextFactory.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
public ELContext createContext(ExpressionFactory expressionFactory, VariableContext variableContext) { ELResolver elResolver = createElResolver(); FunctionMapper functionMapper = createFunctionMapper(); VariableMapper variableMapper = createVariableMapper(expressionFactory, variableContext); return new FeelElContext(elResolver, functionMapper, variableMapper); }
Example #30
Source File: CompositeFunctionMapper.java From camunda-engine-dmn with Apache License 2.0 | 5 votes |
public Method resolveFunction(String prefix, String localName) { for (FunctionMapper functionMapper : functionMappers) { Method method = functionMapper.resolveFunction(prefix, localName); if (method != null) { return method; } } throw LOG.unknownFunction(prefix, localName); }