You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/01/28 15:39:38 UTC

[GitHub] [camel-quarkus] DenisIstomin opened a new issue #3503: Camel-xslt-quarkus: add extension functions support

DenisIstomin opened a new issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503


   Camel-xslt-quarkus uses hardcoded Xalan [org.apache.xalan.xsltc.trax.TransformerFactoryImpl](https://github.com/apache/camel-quarkus/blob/main/extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/XalanTransformerFactory.java#L47) to compile XSL at the build-time.
   Also feature [FEATURE_SECURE_PROCESSING](https://github.com/apache/camel-quarkus/blob/main/extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/XalanTransformerFactory.java#L50) is enabled by default. Which means that [Xalan extension functions](https://xml.apache.org/xalan-j/extensions.html) cannot be used.
   
   Related to **JVM** and **Native** modes.
   
   Proposal:
   1. Add setting `quarkus.camel.xslt.transformerFactory`
   2. Add setting `quarkus.camel.xslt.extensionFunctions`
   
   Example:
   ```
   package my.extentionfunctions;
   
   public class Functions {
       public static XObject customFunc() throws Exception {
           return new XObject(...);
       }
   }
   ```
   
   ```
   <xsl:stylesheet version="1.0"
           ...
           xmlns:myfunc="xalan://my.extensionfunctions.Functions"
           ... >
           <node>
               <xsl:value-of select="myfunc:customFunc()"/>
           </node>
   </xsl:stylesheet>
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on issue #3503: Camel-xslt-quarkus: add extension functions support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503#issuecomment-1032997845


   Fixed via #3526


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga closed issue #3503: Camel-xslt-quarkus: add extension functions support

Posted by GitBox <gi...@apache.org>.
ppalaga closed issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] DenisIstomin edited a comment on issue #3503: Camel-xslt-quarkus: add extension functions support

Posted by GitBox <gi...@apache.org>.
DenisIstomin edited a comment on issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503#issuecomment-1029098421


   Thanks @ppalaga, I'm working on providing PR.
   I verified that extension functions work with my local changes with disabled FEATURE_SECURE_PROCESSING.
   There is also no need for any improvements to make them work in Native mode.
   
   There is only one issue: extension functions work only when they are defined in a separate jar, otherwise QuarkusClassloader is not able to load class from `target` folder when you run tests. Because all classes from ApplicationPath are marked as `banned` and cannot be loaded.
   I'll address this issue in the upcoming PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on issue #3503: Camel-xslt-quarkus: add extension functions support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503#issuecomment-1025793940


   > Proposal:
   > 
   > 1. Add setting `quarkus.camel.xslt.transformerFactory`
   > 2. Add setting `quarkus.camel.xslt.extensionFunctions`
   
   I guess those should be new configuration parameters, right? Could you please specify their expected range of values, defaults, and explain what they should actually do?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on issue #3503: Camel-xslt-quarkus: add extension functions support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503#issuecomment-1027791376


   Thanks for the explanation @DenisIstomin, it is much clearer to me now!
   
   Step 1: 
   I think giving users the option to set their own TrasformerFactory could awake the impression that any transformer factory implementation would work. In fact our extension expects this particular Xalan TrasformerFactory. So I'd be in favor of allowing end users to configure this factory via config params rather than passing their own class.
   
   Now how could we make the factory configurable. I'd vote for having a generic map of parameters, something like:
   
   ```
   quarkus.camel.xalan.feature."http://javax.xml.XMLConstants/feature/secure-processing" = true
   quarkus.camel.xalan.feature."http://xml.apache.org/xalan/features/optimize" = true
   ```
   
   They have something similar in Quarkus Agoal config https://github.com/quarkusio/quarkus/blob/main/extensions/agroal/runtime/src/main/java/io/quarkus/agroal/runtime/DataSourceJdbcRuntimeConfig.java#L138-L139
   
   The defaults could be mainitained in a Map containing the current only feature `javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true`
   
   Step 2.:
   
   I do not think we need something special only for the reflection registration. Given that those functions will mostly be provided by end users themselves, can't they simply add `@io.quarkus.runtime.annotations.RegisterForReflection` to the classes?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] ppalaga commented on issue #3503: Camel-xslt-quarkus: add extension functions support

Posted by GitBox <gi...@apache.org>.
ppalaga commented on issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503#issuecomment-1027792539


   If you like the above, please feel free to send a PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] DenisIstomin commented on issue #3503: Camel-xslt-quarkus: add extension functions support

Posted by GitBox <gi...@apache.org>.
DenisIstomin commented on issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503#issuecomment-1029098421


   Thanks @ppalaga, I'm working on providing PR.
   I verified that extension functions work with my local changes that disable FEATURE_SECURE_PROCESSING.
   There is also no need for any improvements to make them work in Native mode.
   
   There is only one issue: extension functions work only when they are defined in a separate jar, otherwise QuarkusClassloader is not able to load class from `target` folder when you run tests. Because all classes from ApplicationPath are marked as `banned` and cannot be loaded.
   I'll address this issue in the upcoming PR.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [camel-quarkus] DenisIstomin commented on issue #3503: Camel-xslt-quarkus: add extension functions support

Posted by GitBox <gi...@apache.org>.
DenisIstomin commented on issue #3503:
URL: https://github.com/apache/camel-quarkus/issues/3503#issuecomment-1027376184


   Hi @ppalaga, to be able to use extension functions in JVM mode (as well as in Native mode), these configuration steps have to be done:
   **1.** Set `FEATURE_SECURE_PROCESSING` to `false`
   **2.** Specify extension function classes, so they will be registered for reflection to run in Native mode
   
   **Step 1**. can be achieved in different ways:
   - add new setting `quarkus.camel.xslt.secureProcessing` with values `true/false`
   - add new setting `quarkus.camel.xslt.features` with comma separated features, that should be enabled by default. For example,  `quarkus.camel.xslt.features=http://javax.xml.XMLConstants/feature/secure-processing,http://xml.apache.org/xalan/features/optimize,...`
   - add new setting `quarkus.camel.xslt.transformerFactory` to specify custom class, where developer can override features that are enabled by default. For example `quarkus.camel.xslt.transformerFactory=my.namespace.MyTrasformerFactory`
   
   **Step 2**. can be achieved by specifying classNames, so xslt component will register them automatically for reflection using `new ReflectiveClassBuildItem(...)`.
   Example: `quarkus.camel.xslt.extensionFunctions=my.extensionfunctions.Functions1,my.extensionfunctions.Functions2,...`
   
   **To summarize:**
   Taking into the account existing Camel setting [transformerFactoryClass](https://camel.apache.org/components/3.14.x/xslt-component.html#_component_option_transformerFactoryClass) I think that it would be reasonable to have these 2 settings:
   - `quarkus.camel.xslt.transformerFactory=my.namespace.MyTrasformerFactory`
   Also it would be usefult to be able to override `transformerFactoryConfigurationStrategy`
   - `quarkus.camel.xslt.extensionFunctions=my.extensionfunctions.Functions1,my.extensionfunctions.Functions2,...`
   
   But maybe I'm missing something and it could be implemented in simpler way.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org