本文整理匯總了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);
}
}