Class Jexl3ComponentDescriptorProcessor

  • All Implemented Interfaces:
    com.zfabrik.components.provider.IComponentDescriptorProcessor

    public class Jexl3ComponentDescriptorProcessor
    extends java.lang.Object
    implements com.zfabrik.components.provider.IComponentDescriptorProcessor
    A jexl3 component descriptor processor. This processor is based on the Apache Commons JEXL library version 3.0 (see https://commons.apache.org/proper/commons-jexl).

    All values of properties tagged as of JEXL3 processing style in the original component descriptor source will be considered JEXL expressions. If evaluating to a non-null value, the expression evaluation result will be set as resulting property value of the same property name. If the expression evaluates to null, the corresponding property will not be set.

    The following implicit variables are made available by this processor:

    Variable nameDefinitionExample
    systemSystem.getProperties()`user dir is ${system["user.dir"]}`
    envSystem.getenv()"JAVA_HOME is ${env.JAVA_HOME}"
    thisThe actual property set in its evaluated form. This may be used to resolve properties that are again computed by some processor. Note that a max evaluation depth of 50 is enforced when resolving properties defined in the property set.this['com.zfabrik.component.type']
    components IComponentsManager.INSTANCEcomponents.getComponent("mymodule/mycomponent").getProperty("myProp")

    Using the this variable, re-use of definitions within a single descriptor is possible. For example, assuming some other processor ext is involved, a property set
    
     hostName\:JEXl3=env.hostName
     database\:ext=_THE_DB_
     ds.prop.url\:JEXl3=`jdbc:derby://${this.hostName}/${this.database};create=true`
     
    would be evaluated resolving across processors.

    Note that a JEXL expression does not necessarily evaluate to a string object. Neither is the input property value to be processed considered a JEXL string. For example, the expression

     `Hallo this is ${system["user.name"]}`
     
    does indeed evaluate to a string. As does
     "Hallo this is ${system[\"user.name\"]}"
     
    (without processing the ${} expression) and more advanced
     system["os.name"].startsWith("Linux")? "We are running on a Linux OS" : "We are running on something else"
     
    but not
     500+10
     
    which is indeed an integer.

    See also https://commons.apache.org/proper/commons-jexl/reference/syntax.html for more syntax information.
    Author:
    hb
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String JEXL3_STYLE
      Style processed by this processor
      • Fields inherited from interface com.zfabrik.components.provider.IComponentDescriptorProcessor

        EXTENSION_POINT, STYLE_PROCESSED
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.zfabrik.components.provider.props.Evaluator createEvaluator()
      Provide an evaluator instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • JEXL3_STYLE

        public static final java.lang.String JEXL3_STYLE
        Style processed by this processor
        See Also:
        Constant Field Values
    • Constructor Detail

      • Jexl3ComponentDescriptorProcessor

        public Jexl3ComponentDescriptorProcessor()
    • Method Detail

      • createEvaluator

        public com.zfabrik.components.provider.props.Evaluator createEvaluator()
        Description copied from interface: com.zfabrik.components.provider.IComponentDescriptorProcessor
        Provide an evaluator instance. The evaluator will be used during the processing of on component descriptor property map.
        Specified by:
        createEvaluator in interface com.zfabrik.components.provider.IComponentDescriptorProcessor