Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable environment property replacement anywhere #554

Merged
merged 4 commits into from
Jul 28, 2023
Merged

Conversation

alcarraz
Copy link
Contributor

@alcarraz alcarraz commented Jul 20, 2023

This draft PR is a possible implementation of what's discussed in #546.

When an element is instantiated via QFactory.instantiate the element is passed to the added replaceEnvProperties method, which replaces all environment properties recursively on its children and its attributes.

If an element has the verbatim attribute set to true it will not process it or its children, I'm inclined to think this should be the correct behavior because it also acts as a performance hint to not recursively process its children. However, one may expect to override the parent's option in a child, so this is debatable. This also simplifies the code, by not having to track changes in the attribute down the line in the recursion.

It may be necessary to remark that the verbatim option does not apply to the Configuration elements or other classes that call Environment.getProperty on its own. This may sound obvious, but some may get confused about that.

In `QFactory`'s tests for environment properties replacement.

Signed-off-by: Andrés Alcarraz <alcarraz@gmail.com>
@alcarraz alcarraz marked this pull request as ready for review July 21, 2023 22:42
@alcarraz
Copy link
Contributor Author

I removed the draft flag, because I added the verbatim tests.

However, I'm not entirely convinced on performing the replacement in the instantiate method instead of in setConfiguration. This let us avoid multiple passes when calling setConfiguration on children, but would not catch eventual setConfiguration calls with XML fragments taken from other places.

Credit to @apr.

- Don't call the method in `instantiate`, since there, it is more of a secondary effect.
- Instead, call the property expansion method before instantiate in `Q2.deploy`
file to better express the intent.

Signed-off-by: Andrés Alcarraz <alcarraz@gmail.com>
@alcarraz
Copy link
Contributor Author

Once this PR is merged, I commit myself to add something on the programmer's guide, documenting this.

@ar ar merged commit e3a5fae into jpos:next Jul 28, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants