Draft: Adds lookup in system properties for WAR contextRoot in EAR
Hi GlassFish team !
I'm looking up to implement a simple system property lookup in GlassFish so we can externalize contextRoot and urlPattern (and more, such as JNDI names, EJB persistance unit names, ...).
This is mainly a prototype to see how this can be implemented since I don't know how it would be the most correct place to put this translation, neither if this is the correct way to do it (for instance, in Payara it only looks for the properties declared in the domain.xml). The goal of this PR is to get some input to see in which way this can go.
Based on my example, the goal is to have a definition like below, so we can build an EAR where the URLs can be configured outside the application itself (so we could eventually have the EAR/WAR/JAR file signed):
<modules>
<webModule>
<groupId>ch.astorm.gf-embedded</groupId>
<artifactId>war</artifactId>
<contextRoot>/${ch.astorm.root}</contextRoot>
<bundleFileName>sample-war.war</bundleFileName>
</webModule>
<ejbModule>
<groupId>ch.astorm.gf-embedded</groupId>
<artifactId>ejb</artifactId>
<bundleFileName>sample-ejb.jar</bundleFileName>
</ejbModule>
</modules>
Here are some places that I'd like to see this implemented:
- context root WAR in the EAR
- URL patterns in
@WebServlet -
jta-data-sourceinpersistence.xml
Any feedback is welcome :-)
You can see most, if not all places where Payara supports expansion of deployment descriptor values or annotation values in this PR: https://github.com/payara/Payara/pull/4132/files.
URL patterns are set in WebComponentDescriptorImpl.addUrlPattern() method. Other @WebServlet properties can be expanded there too. For servletName, WebServletHandler uses it to find an existing web servlet definition if it exists. The servletName has to be translated also in this search. However, I would do it inside the WebBundleDescriptor.getWebComponentByCanonicalName
persistence.xml values are I think set in setters in PersistenceUnitDescriptor.
We at OmniFish are working on this in another branch so that such lookup works in all deployment descriptors and annotations, not only for the contextRoot property. I'll close this PR now. We'll create a PR with the more complete solution soon.
@OndroMih Amazing :thumbsup: Looking forward to see this implemented in GlassFish and sorry I didn't have the time to work on this.