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

Support environment variables for all supported system properties in a uniform way #126

Closed
wants to merge 1 commit into from

Conversation

bertfrees
Copy link
Member

<daisy.webservice-utils.version>2.2.2</daisy.webservice-utils.version>
<daisy.updater-wrapper.version>1.0.2-SNAPSHOT</daisy.updater-wrapper.version>
<daisy.webservice.version>2.1.3-SNAPSHOT</daisy.webservice.version>
<daisy.webservice-utils.version>3.0.0-SNAPSHOT</daisy.webservice-utils.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see API change in the webservice module, am I correct that the major change is due to change in the web service payload?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember TBH. Might be a mistake.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember now. It's because I changed the Properties class into an enum.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok!


import java.util.Map;

public class Properties {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this class isn't intended to be extended, better make it final already, and if it's only intended as a static helper, we can add a private constructor too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK good point. I normally preferfinal abstract, is that OK too?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final abstract is not allowed. Normally I just add abstract without final. So your suggestion (final + private contructor) is the only real solution.

public class Properties {

private final static java.util.Properties systemProperties = System.getProperties();
private final static Map<String,String> systemEnv = System.getenv();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works only if properties can't change dynamically. I think it's OK (?) but this should probably be documented in Javadoc?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really care that much about dynamic changes when I wrote this. But if we can support it we probably should. So you say that the Properties object that System.getProperties() returns does not return a different value for getProperty() after a property was changed? In that case I should change it. And same question for System.getenv()?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I don't remember if System.getProperties() or System.getenv() are dynamic, so it needs to be checked first. If they aren't, then problem solved :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked, System.getProperties() is indeed dynamic. I'll add a comment. @rdeltour You meant that if they are, then problem solved, right?

in a uniform way.

A utility function was added to read from both System.properties and
System.env. If a property starts with "org.daisy.pipeline", the
function first looks for an environment variable and falls back to a
system property. Otherwise it looks only for a system property.

For example, if the key is "org.daisy.pipeline.ws.host", an
environment variable "PIPELINE2_WS_HOST" will have precedence over the
system property.
@bertfrees bertfrees closed this Nov 27, 2017
@bertfrees bertfrees deleted the environment-variables branch November 27, 2017 13:12
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.

None yet

2 participants