ConfigJSR icon indicating copy to clipboard operation
ConfigJSR copied to clipboard

Think about how and if to support a ProjectStage

Open struberg opened this issue 7 years ago • 15 comments

Should we introduce a ProjectStage in JSR-382?

struberg avatar Nov 16 '17 15:11 struberg

I would vote for other features, such as the change notification instead. Not that I isn't useful, just about priorities. If I think about real-world scenarios, reloads would IMO help more, e.g.

sdaschner avatar Nov 23 '17 12:11 sdaschner

I never used a ProjectStage (https://deltaspike.apache.org/documentation/projectstage.html) but what I find quite useful are the profiles in Spring. From my point of view this is more or less the same (don't hit if I'm wrong). I'm currently use this feature often to have different properties for a spring service in Docker / in IDE. So a +1 from me.

hendrikebbers avatar Nov 23 '17 13:11 hendrikebbers

Yes, AFAIK this is more or less the same than Spring profiles.

This is my point, for enterprise environments at least, that profiles are not a best practice (anymore). We don't want to ship applications that include all configuration permutations for all envs and then decide at runtime, within the application / runtime. Instead, we want to define the (few) parts that are different from the outside and inject the proper configuration then, i. e. via Docker environment variables, volumes, Kubernetes config maps, etc. That means the application includes and "sees" only the final set of configuration values, which are then easily usable by our JSR.

This matches the idea of 12-factor applications of "store config in the environment", see https://12factor.net/config

This is why, at least for modern enterprise environments, I discourage the use of profiles, thus I wouldn't support it (initially).

sdaschner avatar Nov 23 '17 14:11 sdaschner

I agree with @sdaschner , a ProjectStage promote internally configuration. But developers use this system. if that can permit that they don't build artifact per environment So a +1 from me

lilian-benoit avatar Nov 29 '17 13:11 lilian-benoit

@sdaschner This do not help in non server environments like Java based command line tools or desktop clients ;)

hendrikebbers avatar Nov 30 '17 15:11 hendrikebbers

Discussed today in the weekly: The preferred way is to simply have a key - value pair that defines the currently profile / stage. This one needs to be added as an argument (for example java.config.stage) to the app. Based on this we only need to define the key name and the pattern how the properties file needs to be named. No specific API is needed.

hendrikebbers avatar Nov 30 '17 15:11 hendrikebbers

Based on this we only need to define the key name and the pattern how the properties file needs to be named. No specific API is needed

About that, i think spring uses a very nice and clear way to define a Stage(profile) property file that is application-${profile}.properties. So if a dev profile is passed as parameter when the application starts up the application-dev.properties is loaded.

jeyvison avatar Nov 30 '17 16:11 jeyvison

Let's discuss naming:

I would prefer javax.config.stage or javax.config.profile as name for the param key to define the profile.

I really like application-${profile}.properties for the config file. As described in #31 the property file name is currently different. So at the moment it would be META-INF/javaconfig-${profile}

hendrikebbers avatar Dec 01 '17 07:12 hendrikebbers

In general I think that profile is a better naming than stage. But maybe this is related to the Spring Boot stuff I did the last 3 years.

hendrikebbers avatar Dec 01 '17 07:12 hendrikebbers

@jeyvison and how to tweak those settings via env or -D? This way is not really well thought through I fear. In DeltaSpike we used a postfix

some.server.url vs some.server.url.Production

struberg avatar Dec 01 '17 21:12 struberg

As deltaspike, have we a list of stage ? or name is completely free ? it's perhaps the different between stage and profile

I prefer multi-file for stage or profile.

lilian-benoit avatar Dec 02 '17 13:12 lilian-benoit

But file javaconfig-${stage or profile}.properties overload properties of file javaconfig.properties We can have only specific properties by this profile or stage

wdyt ?

lilian-benoit avatar Dec 02 '17 13:12 lilian-benoit

@struberg We could load the files depending on the pattern(i.e *-dev.properties). If we just use postfix, we may end with a very big file with different configurations for different environments. It may work for small-medium projects, but for large projects this file would be hard to manage.

@lilian-benoit

But file javaconfig-${stage or profile}.properties overload properties of file javaconfig.properties We can have only specific properties by this profile or stage

Totally agree with this approach. This way we can specify even more what are general and enviroment-specific properties

jeyvison avatar Dec 04 '17 11:12 jeyvison

just a bump that the ConfigJSR now has some notion of project stage as mentioned in https://github.com/eclipse/ConfigJSR/blob/25edda2914155ac6b30f821f9ef13e92b7350a3a/api/src/main/java/javax/config/ConfigAccessor.java#L172.

@struberg I'm not sure whether that was intentional to have it with ConfigAccessor API or if that should have been added by a subsequent PR as there are still some disagreement with that feature as discussed in this thread.

jmesnil avatar May 28 '18 15:05 jmesnil

let's discuss more.

Emily-Jiang avatar Apr 24 '19 21:04 Emily-Jiang