Can custom Registered Functions be added without modifying PubSubPlus Transformer itself?
The pubsubplus-processor-message-transformer-1.2.2-User-Guide.pdf document outlines how user configured header transforms can be achieved using Spel Expressions.
It also outlines how these Spel Expressions can use Registered Functions (plural) but then lists one function 'isPayloadBytes()' as a built-in function.
My questions:
- is it possible to register new custom functions for use in Spel expressions for header transforms?
- given that pubsubplus transformer is a packaged product, can custom functions be registered in new code external to the transformer and if so, how ?
Best Answer
-
You can't register the function like
isPayloadBytes
however, you can put your static class(es) on the classpath (like in the /libs folder) and then call it withT(package.customClass).customFunction()
1
Answers
-
Hi, I am looking into this for you with our dev team. While it is possible to put a JAR on your classpath with the method you want to call, we do take steps to prevent arbitrary code execution as this os a security risk.
I should also mention that in the next few months we will be migrating away from the transform payload configuration to something more powerful that allows for header, payload, and custom funtions to participate in transforming/mapping source to target in the connectors.
Therefore, the solution you are looking at will continue to work, but will be deprecated over time for the new solution.
0 -
Thanks for the response Andrew.
Yes, there are two (external) items that have to be put on the classpath - a hash function definition and a code snippet which registers this function with the SpEL environment, so that it can be subsequently used in a SpEL expression.
The dilemma is: How to get the transformer to pick up the (external) code that registers the custom function with SpEL?
I thought about using Spring annotations e.g. @Component because these are scanned at run-time but not having much luck with it. Should this work and if so how? If not, is there another solution/approach?
Thanks.
0 -
You can't register the function like
isPayloadBytes
however, you can put your static class(es) on the classpath (like in the /libs folder) and then call it withT(package.customClass).customFunction()
1