OpenLiberty / open-liberty

Open Liberty is a highly composable, fast to start, dynamic application server runtime environment
https://openliberty.io
Eclipse Public License 2.0
1.15k stars 590 forks source link

JakartaEE: Transformer: Allow regular expressions to match strings to transform #13937

Open dazavala opened 4 years ago

dazavala commented 4 years ago

A string that requires replacement may appear in different contexts within a source, wherein some contexts the string must be transformed and in others the string must remain intact. Currently, the only way to configure the transformer to match a string that appears in different contexts is to declare, within the transformer metadata properties, the longest possible string which includes part of the context. For example, in the following XML stanzas the string "javax.jms" must transform within the creates.ObjectClass element, only.

<OCD id="com.ibm.ws.jca.jmsQueue.properties.wasJms.javax.jms.Queue-com.ibm.ws.sib.api.jms.impl.JmsTopicImpl"
        ibm:extendsAlias="wasJms" ibm:extends="com.ibm.ws.jca.jmsQueue.properties" name="%properties.wasJms.Queue" 
        description="%properties.wasJms.Queue.desc" >
    <AD id="creates.objectClass" type="String" ibm:final="true" default="javax.jms.Queue,javax.jms.Destination" cardinality="1"  />

To configure the desired transformation today I would declare property "javax.jms.Queue,javax.jms.Destination"="jakarta.jms.Queue,jakarta.jms.Destination" in the transformation metadata. This approach becomes tedious when string "javax.jms" appears frequently in different contexts throughout a source.

It would be preferable to declare a regular expression on the left-hand side of a transform metadata property that matches "javax.jms" whenever the string follows the " or , characters; or, does not match the string whenever it follows a . character.

jhanders34 commented 2 years ago

I wonder if this is already resolved.

tbitonti commented 2 years ago

Regular expressions are not currently supported. The closest is that we match and replace substrings in the per-class direct string updates.

tbitonti commented 2 years ago

Per @dazavala, this can be deferred.