Details
-
Feature
-
Status: Released (View Workflow)
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
Current Situation
- The JS7 Job API supports the following prefix-based syntax for automatic resolution of argument values:
- base64:<base64 encoded value>
- enc:<encrypted values>
- See
JITL-740
- See
- Automatic resolution supports:
- The "flat" argument types (like a String). Resolution of the values of the Map or List types is not supported.
- Only values of arguments/variables whose names are declared in the corresponding JS7 Job JobArgument class are resolved.
Desired Behavior
- The JS7 Job Java API should provide a public interface for implementing/registering the custom argument value resolvers.
- Support for resolving values of types Map or List should be added.
- Value resolution of all arguments/variables available in a Job.
Maintaner Notes
- Implementation
- A custom resolver class should extend the abstract class com.sos.js7.job.resolver.JobArgumentValueResolver or directly implement the interface com.sos.js7.job.resolver.IJobArgumentValueResolver
- The two public static methods required to implement are:
- public static String getPrefix()
- public static void resolve(OrderProcessStepLogger logger, List<JobArgument<?>> argumentsToResolve, Map<String,JobArgument<?>> allArguments)
- See examples:
- https://github.com/sos-berlin/sos-components/blob/master/sos-js7/sos-js7-job/src/test/java/com/sos/js7/job/examples/resolver/ExampleUpperCaseResolver.java
- https://github.com/sos-berlin/sos-components/blob/master/sos-js7/sos-js7-job/src/test/java/com/sos/js7/job/examples/resolver/ExampleAbsolutePathResolver.java
- Note: The resolver prefix should be unique, otherwise an already registered resolver will be overwritten.
- Deployment
- Library classes should be packaged in a .jar file and the .jar file should be deployed to the <AGENT_HOME>/lib/user_lib directory
- JAR file naming convention (case insensitive):
- jobapi-register-<custom name>.jar
- The agent should be restarted.
- Note: Registration happens only once when any JS7 API Job is executed first.
- The registered resolvers are visible in the agent.log
- see JobArgumentValueResolverCache lines
- The registered resolvers are visible in the agent.log
Test Instructions
- Test standard JS7 Job API resolvers (base64, enc):
- Notes:
- Any JITL/Custom JS7 (including script engine) Job can be used for testing.
- The standard/example resolvers throw an exception (Job fails) if any argument cannot be resolved.
- Use different argument/variable types – STRING, LIST, MAP, etc.
- Notes:
- Test custom resolvers
- Use jobapi-register-examples-resolver.zip
- This zip file contains the following jars
- jobapi-register-examples-2-resolver.jar
- contains the example resolvers ExampleUpperCaseResolver and ExampleAbsolutePathResolver – prefix see above
- jobapi-register-examples-1002-resolver.jar
- contains the example resolvers and 1000 resolvers with the prefixes from p1: to p1000:
- converts values to uppercase and adds the resolver class name and prefix,e.g.:
- val_001 is resolved to VAL_0001(GeneratedValueResolver0001-p1
- jobapi-register-examples-2-resolver.jar
- This zip file contains the following jars
- Perform stress tests using e.g. 100,300,1000 arguments and standard/custom resolvers
- Note: use the reals JITL/Custom Jobs or com.sos.jitl.jobs.examples.EmptyJob
- Write your own resolver and repeat the tests
- Use jobapi-register-examples-resolver.zip
- Test a "failed" case
- For example using the standard resolvers enc: or example ExampleAbsolutePathResolver (apath: ) to check whether an exception is thrown and this exception provides all information about the cause and the affected entry.
- Especially if any entry of a List or Map variable cannot be resolved
- For example using the standard resolvers enc: or example ExampleAbsolutePathResolver (apath: ) to check whether an exception is thrown and this exception provides all information about the cause and the affected entry.