-
Feature Request
-
Resolution: Done
-
Major
-
None
-
None
sdouglas1@redhat.com says:
[We] want Servlet 4.0 in the next WF release for HTTP/2 support, however [...] this is not allowed. To get around this we would like to have a system property to switch
between the modules at boot time. [...]
It is likely that there are other specifications that will be similarly restricted, so we need a general mechanism to accomplish this kind of thing.
NOTE: This is not the ideal general solution to this class of problem. It is more of a workaround when there is no other option. The best solution to supporting multiple API or spec versions is to have n API modules with backing implementations that all talk to the same SPI. This is not always possible with existing code.
Option 1
Introduce a "switch" construct inside of "resources"
<resources> <switch property="jboss.servlet.spec"> <case value="3.1"> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_3.1_spec:1.0.1.Final"/> </case> <default> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_4.0_spec:1.0.0.Final"/> </default> </switch> </resources>
With this option we would need to ensure that the wildfly build tools are updated to find <artifact> elements inside of the <switch> branches (which should be easy since the XOM conversion).
We could add <switch> to many places in this case.
Option 2
Use simple predicates like this:
<resources> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_3.1_spec:1.0.1.Final" if-set="jboss.servlet.3.1"/> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_4.0_spec:1.0.0.Final" if-not-set="jboss.servlet.3.1"/> </resources>
This is much simpler but also quite brittle: in particular it doesn't work well if there are more than two options.
Option 3
Use a nested predicate like this:
<resources> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_3.1_spec:1.0.1.Final"> <when-property-equals name="jboss.servlet.spec" value="3.1"/> </artifact> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_4.0_spec:1.0.0.Final"> <when-property-not-equals name="jboss.servlet.spec" value="3.1"/> </artifact> </resources>
This is somewhat more flexible than Option 2, but easier to implement than Option 1. Three or more options could be implemented like this:
<resources> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_3.1_spec:1.0.1.Final"> <when-property-equals name="jboss.servlet.spec" value="3.1"/> </artifact> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_4.0_spec:1.0.0.Final"> <when-property-equals name="jboss.servlet.spec" value="4.0"/> </artifact> <artifact name="org.jboss.spec.javax.servlet:jboss-servlet-api_4.1_spec:1.0.0.Final"> <when-property-not-equals name="jboss.servlet.spec" value="3.1"/> <when-property-not-equals name="jboss.servlet.spec" value="4.0"/> </artifact> </resources>