本文整理汇总了Java中de.odysseus.el.TreeValueExpression类的典型用法代码示例。如果您正苦于以下问题:Java TreeValueExpression类的具体用法?Java TreeValueExpression怎么用?Java TreeValueExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeValueExpression类属于de.odysseus.el包,在下文中一共展示了TreeValueExpression类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JuelFunction
import de.odysseus.el.TreeValueExpression; //导入依赖的package包/类
public JuelFunction(String juelExpression, Class<T> resultClass, Map<String, Class<?>> arguments) {
// Initialize the JUEL conext.
this.expressionFactory = new de.odysseus.el.ExpressionFactoryImpl();
this.initializeContext(this.context = new SimpleContext());
// Index the arguments.
Class<?>[] argumentTypeClasses = new Class[arguments.size()];
int argIndex = 0;
for (Map.Entry<String, Class<?>> argumentEntry : arguments.entrySet()) {
final String argName = argumentEntry.getKey();
final Class<?> argTypeClass = argumentEntry.getValue();
final TreeValueExpression argExpression =
this.expressionFactory.createValueExpression(this.context, String.format("${%s}", argName), argTypeClass);
Argument argument = new Argument(argIndex++, argTypeClass, argExpression);
argumentTypeClasses[argument.index] = argument.typeClass;
this.arguments.put(argName, argument);
}
// Create the JUEL method.
this.expression = expressionFactory.createValueExpression(this.context, juelExpression, resultClass);
// this.expression = expressionFactory.createMethodExpression(this.context, juelExpression, resultClass, argumentTypeClasses);
}
示例2: createExpression
import de.odysseus.el.TreeValueExpression; //导入依赖的package包/类
public ElExpression createExpression(String expression) {
TreeValueExpression juelExpr = factory.createValueExpression(parsingElContext, expression, Object.class);
return new JuelExpression(juelExpr, elContextFactory);
}
示例3: execute
import de.odysseus.el.TreeValueExpression; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
initClient();
SimpleContext context = new SimpleContext();
for(String variable : variables) {
context.getELResolver().setValue(context, null, variable, project.getProperties().getProperty(variable));
}
try {
Map<String, String> changes = new HashMap<String, String>();
for(Property property : properties) {
String propertyValue = project.getProperties().getProperty(property.getName());
getLog().info(String.format("%s = %s", property.getName(), propertyValue));
if(StringUtils.equalsIgnoreCase(propertyValue, "latest")) {
String name = property.getJobExpr();
Matcher matcher = EXPRESSION_PATTERN.matcher(name);
if(matcher.find()) {
String content = matcher.group(1);
TreeValueExpression expr = (TreeValueExpression) expressionFactory.createValueExpression(context, String.format("${%s}", content), String.class);
name = (String) expr.getValue(context);
}
JobDetails jobDetails = client.getJobDetails(name);
changes.put(property.getName() + "-modified", String.valueOf(jobDetails.getLastSuccessfulBuild().getNumber()));
} else {
changes.put(String.format("%s-modified", property.getName()), propertyValue);
}
}
if(MapUtils.isNotEmpty(changes)) {
getLog().info(String.format("Property changes: %s", changes));
for(Map.Entry<String, String> entry : changes.entrySet()) {
if(entry.getValue() == null) {
continue;
}
project.getProperties().setProperty(entry.getKey(), entry.getValue());
}
}
} catch(Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}