use of org.camunda.bpm.engine.impl.javax.el.ELException in project camunda-bpm-platform by camunda.
the class JuelScriptEngine method importFunctions.
public static void importFunctions(ScriptContext ctx, String namespace, Object obj) {
Class<?> clazz = null;
if (obj instanceof Class) {
clazz = (Class<?>) obj;
} else if (obj instanceof String) {
try {
clazz = ReflectUtil.loadClass((String) obj);
} catch (ProcessEngineException ae) {
throw new ELException(ae);
}
} else {
throw new ELException("Class or class name is missing");
}
Method[] methods = clazz.getMethods();
for (Method m : methods) {
int mod = m.getModifiers();
if (Modifier.isStatic(mod) && Modifier.isPublic(mod)) {
String name = namespace + ":" + m.getName();
ctx.setAttribute(name, m, ScriptContext.ENGINE_SCOPE);
}
}
}
use of org.camunda.bpm.engine.impl.javax.el.ELException in project camunda-bpm-platform by camunda.
the class ExpressionFactoryImpl method loadProperties.
private Properties loadProperties(String path) {
Properties properties = new Properties(loadDefaultProperties());
// try to find and load properties
InputStream input = null;
try {
input = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
} catch (SecurityException e) {
input = ClassLoader.getSystemResourceAsStream(path);
}
if (input != null) {
try {
properties.load(input);
} catch (IOException e) {
throw new ELException("Cannot read EL properties", e);
} finally {
try {
input.close();
} catch (IOException e) {
// ignore...
}
}
}
return properties;
}
use of org.camunda.bpm.engine.impl.javax.el.ELException in project camunda-bpm-platform by camunda.
the class ExpressionFactoryImpl method createTreeStore.
/**
* 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
* property <code>javax.el.cacheSize</code>.
*/
protected TreeStore createTreeStore(int defaultCacheSize, Profile profile, Properties properties) {
// create builder
TreeBuilder builder = null;
if (properties == null) {
builder = createTreeBuilder(null, profile.features());
} else {
EnumSet<Builder.Feature> features = EnumSet.noneOf(Builder.Feature.class);
if (getFeatureProperty(profile, properties, Feature.METHOD_INVOCATIONS, PROP_METHOD_INVOCATIONS)) {
features.add(Builder.Feature.METHOD_INVOCATIONS);
}
if (getFeatureProperty(profile, properties, Feature.VARARGS, PROP_VAR_ARGS)) {
features.add(Builder.Feature.VARARGS);
}
if (getFeatureProperty(profile, properties, Feature.NULL_PROPERTIES, PROP_NULL_PROPERTIES)) {
features.add(Builder.Feature.NULL_PROPERTIES);
}
builder = createTreeBuilder(properties, features.toArray(new Builder.Feature[0]));
}
// create cache
int cacheSize = defaultCacheSize;
if (properties != null && properties.containsKey(PROP_CACHE_SIZE)) {
try {
cacheSize = Integer.parseInt(properties.getProperty(PROP_CACHE_SIZE));
} catch (NumberFormatException e) {
throw new ELException("Cannot parse EL property " + PROP_CACHE_SIZE, e);
}
}
Cache cache = cacheSize > 0 ? new Cache(cacheSize) : null;
return new TreeStore(builder, cache);
}
use of org.camunda.bpm.engine.impl.javax.el.ELException in project camunda-bpm-platform by camunda.
the class JuelExpression method getValue.
public Object getValue(VariableScope variableScope, BaseDelegateExecution contextExecution) {
ELContext elContext = expressionManager.getElContext(variableScope);
try {
ExpressionGetInvocation invocation = new ExpressionGetInvocation(valueExpression, elContext, contextExecution);
Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(invocation);
return invocation.getInvocationResult();
} catch (PropertyNotFoundException pnfe) {
throw new ProcessEngineException("Unknown property used in expression: " + expressionText + ". Cause: " + pnfe.getMessage(), pnfe);
} catch (MethodNotFoundException mnfe) {
throw new ProcessEngineException("Unknown method used in expression: " + expressionText + ". Cause: " + mnfe.getMessage(), mnfe);
} catch (ELException ele) {
throw new ProcessEngineException("Error while evaluating expression: " + expressionText + ". Cause: " + ele.getMessage(), ele);
} catch (Exception e) {
throw new ProcessEngineException("Error while evaluating expression: " + expressionText + ". Cause: " + e.getMessage(), e);
}
}
use of org.camunda.bpm.engine.impl.javax.el.ELException in project camunda-bpm-platform by camunda.
the class AstProperty method invoke.
public Object invoke(Bindings bindings, ELContext context, Class<?> returnType, Class<?>[] paramTypes, Object[] paramValues) {
Object base = prefix.eval(bindings, context);
if (base == null) {
throw new PropertyNotFoundException(LocalMessages.get("error.property.base.null", prefix));
}
Object property = getProperty(bindings, context);
if (property == null && strict) {
throw new PropertyNotFoundException(LocalMessages.get("error.property.method.notfound", "null", base));
}
String name = bindings.convert(property, String.class);
Method method = findMethod(name, base.getClass(), returnType, paramTypes);
try {
return method.invoke(base, paramValues);
} catch (IllegalAccessException e) {
throw new ELException(LocalMessages.get("error.property.method.access", name, base.getClass()));
} catch (IllegalArgumentException e) {
throw new ELException(LocalMessages.get("error.property.method.invocation", name, base.getClass()), e);
} catch (InvocationTargetException e) {
throw new ELException(LocalMessages.get("error.property.method.invocation", name, base.getClass()), e.getCause());
}
}
Aggregations