Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| jBPM distribution 6.1.0.Final
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jbpm.process.core.transformation
Class JavaScriptingDataTransformer

    java.lang.Object
      org.jbpm.process.core.transformation.JavaScriptingDataTransformer

All Implemented Interfaces:
  DataTransformer

    public class JavaScriptingDataTransformer

extends Object
implements DataTransformer

Implementation of `DataTransformer` that is based on standard Java scripting capabilities (javax.script). By default it uses Rhino scripting engine for JavaScript evaluation. But supports all scripting engine that are compliant with JSR 223. It's just a matter of placing them on classpath so Java itself can discover it and then new instance of this class will be registered for that engine.
Allows to pass custom properties to the engine via property file that should be placed on root of the classpath named 'FQCN of the script engine factory'.properties
When reading the properties file transformer recognizes three types of data:

- boolean - when value is either true or false string
- integer - when value is a number (matches \d+ regex)
- string - default type

return value of the expression is either:

- value returned from scriptEngine.eval if not null
- result of the output produced by the script engine - will be used only when eval returns null

Constructor Summary
`JavaScriptingDataTransformer(ScriptEngineFactory factory)`

Method Summary
`Object` | `compile(String expression)` Compiles given expression into reusable unit.
`protected Object` | `evaluateExpression(Object expression, Map<String,Object> parameters)`
`protected void` | `registerAttributes()`
`Object` | `transform(Object expression, Map<String,Object> parameters)` Transforms the given expression object (might be compiled expression) using `parameters` as contextual information (aka bindings) used during evaluation of the expression.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JavaScriptingDataTransformer

    public JavaScriptingDataTransformer(ScriptEngineFactory factory)

Method Detail

### transform

    public Object transform(Object expression,
                            Map<String,Object> parameters)

  Description copied from interface: `DataTransformer`
  Transforms the given expression object (might be compiled expression) using `parameters` as contextual information (aka bindings) used during evaluation of the expression.

  Specified by:
    `transform` in interface `DataTransformer`
  Parameters:
    `expression` - expression to evaluate
    `parameters` - binding parameters
  Returns:
    result of the evaluation

### compile

    public Object compile(String expression)

  Description copied from interface: `DataTransformer`
  Compiles given expression into reusable unit. This is optional operation and in case it's not supported by given transformed it should return the same expression that was given in the input. If compilation is supported a compiled instance of the expression should be returned.

  Specified by:
    `compile` in interface `DataTransformer`
  Parameters:
    `expression` - language specific expression
  Returns:
    compiled expression instance or same as given as argument expression

### evaluateExpression

    protected Object evaluateExpression(Object expression,
                                        Map<String,Object> parameters)

### registerAttributes

    protected void registerAttributes()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| jBPM distribution 6.1.0.Final
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2001-2014 JBoss by Red Hat. All Rights Reserved.