Search in sources :

Example 1 with SimpleExpressionResolver

use of org.jboss.metadata.property.SimpleExpressionResolver in project wildfly by wildfly.

the class FunctionalResolverProcessor method deploy.

public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final List<Function<String, String>> functions = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_EXPRESSION_RESOLVERS);
    if (functions != null) {
        SimpleExpressionResolver[] sers = new SimpleExpressionResolver[functions.size()];
        for (int i = 0; i < functions.size(); i++) {
            Function<String, String> funct = functions.get(i);
            sers[i] = expressionContent -> {
                String input = "${" + expressionContent + "}";
                String resolved = funct.apply(input);
                return resolved == null ? null : new SimpleExpressionResolver.ResolutionResult(resolved, false);
            };
        }
        deploymentUnit.addToAttachmentList(Attachments.DEPLOYMENT_PROPERTY_RESOLVERS, new CompositePropertyResolver(sers));
    }
}
Also used : Function(java.util.function.Function) SimpleExpressionResolver(org.jboss.metadata.property.SimpleExpressionResolver) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) CompositePropertyResolver(org.jboss.metadata.property.CompositePropertyResolver)

Aggregations

Function (java.util.function.Function)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 CompositePropertyResolver (org.jboss.metadata.property.CompositePropertyResolver)1 SimpleExpressionResolver (org.jboss.metadata.property.SimpleExpressionResolver)1