Example usage for javax.el ExpressionFactory newInstance

List of usage examples for javax.el ExpressionFactory newInstance

Introduction

In this page you can find the example usage for javax.el ExpressionFactory newInstance.

Prototype

public static ExpressionFactory newInstance() 

Source Link

Document

Create a new ExpressionFactory .

Usage

From source file:com.github.sebhoss.contract.verifier.JuelConfiguration.java

/**
 * @return A new ExpressionFactory./*from w ww.ja  v a  2  s .c o  m*/
 */
@Bean
@SuppressWarnings(CompilerWarnings.STATIC_METHOD)
public ExpressionFactory expressionFactory() {
    return Nullsafe.nullsafe(ExpressionFactory.newInstance());
}

From source file:inti.ws.spring.resource.FilteredWebResource.java

@Override
public void update() throws Exception {
    ExpressionFactory factory;//w  w  w  .  j  a  v  a 2  s. com
    ValueExpression var;
    Object val;
    StringBuilder builder = new StringBuilder(32);
    MessageDigest digest = DIGESTS.get();

    for (WebResource dependency : dependencies) {
        dependency.updateIfNeeded();
    }

    super.update();

    factory = ExpressionFactory.newInstance();
    content = factory.createValueExpression(context, compressedFile, String.class);
    for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
        var = factory.createValueExpression(context, "${" + parameter.getKey() + '}', String.class);
        val = parameter.getValue();
        if (val instanceof WebResource) {
            ((WebResource) val).updateIfNeeded();
            val = ((WebResource) val).getContent().hashCode();
        }
        var.setValue(context, val);
    }
    compressedFile = (String) content.getValue(context);

    digest.reset();
    builder.append(Hex.encodeHexString(digest.digest(compressedFile.getBytes(StandardCharsets.UTF_8))));
    messageDigest = builder.toString();
    builder.delete(0, builder.length());

    DATE_FORMATTER.formatDate(lastModified, builder);
    lastModifiedString = builder.toString();
}

From source file:inti.ws.spring.resource.template.TemplateResource.java

@Override
public void update() throws Exception {
    ExpressionFactory factory;//from  w  w  w  .  ja  v a  2 s  .  co m
    ValueExpression var;
    Object val;
    StringBuilder builder = new StringBuilder(2048);
    MessageDigest digest = DIGESTS.get();

    factory = ExpressionFactory.newInstance();

    for (WebResource file : files) {
        if (file.hasChanged()) {
            file.update();
        }
        builder.append(applyTemplate(factory, file.getName(), file.getContent().replaceAll("\\s+", " ")));
        builder.append(',');
    }
    builder.delete(builder.length() - 1, builder.length());

    super.update();

    content = factory.createValueExpression(context, compressedFile, String.class);

    var = factory.createValueExpression(context, "${files}", String.class);
    var.setValue(context, builder.toString());

    if (parameters != null) {

        for (Map.Entry<String, Object> parameter : parameters.entrySet()) {
            var = factory.createValueExpression(context, "${" + parameter.getKey() + '}', String.class);
            val = parameter.getValue();

            if ("$filename".equals(val)) {
                val = resource.getFile();
            } else if ("$modulename".equals(val)) {
                val = moduleName;
            }

            var.setValue(context, val);
        }

    }
    compressedFile = (String) content.getValue(context);
    builder.delete(0, builder.length());

    digest.reset();
    builder.append(Hex.encodeHexString(digest.digest(compressedFile.getBytes(StandardCharsets.UTF_8))));
    messageDigest = builder.toString();
    builder.delete(0, builder.length());

    DATE_FORMATTER.formatDate(lastModified, builder);
    lastModifiedString = builder.toString();
}

From source file:org.gerzog.jstataggr.expressions.juel.JuelExpressionHandlerBuilder.java

public static JuelExpressionHandlerBuilder newBuilder() {
    return newBuilder(ExpressionFactory.newInstance());
}