├── .gitattributes
├── .github
├── dependabot.yml
└── workflows
│ └── build.yml
├── .gitignore
├── CONTRIBUTING.adoc
├── LICENSE
├── README.adoc
├── api
├── pom.xml
└── src
│ └── main
│ ├── java
│ ├── jakarta
│ │ └── config
│ │ │ ├── Config.java
│ │ │ ├── ConfigDefault.java
│ │ │ ├── ConfigException.java
│ │ │ ├── ConfigMapping.java
│ │ │ ├── ConfigName.java
│ │ │ └── package-info.java
│ └── module-info.java
│ └── javadoc
│ └── jakarta.config.api
│ └── jakarta
│ └── config
│ └── doc-files
│ └── terminology.html
├── pom.xml
├── spec
├── pom.xml
├── site.yaml
└── src
│ └── main
│ ├── asciidoc
│ ├── 01-config-spec.adoc
│ ├── 02-config.adoc
│ ├── 03-config-mapping.adoc
│ ├── XX-config-mapping.adoc
│ ├── XX-structure-and-format.adoc
│ ├── images
│ │ └── jakarta_ee_logo_schooner_color_stacked_default.png
│ ├── license-alv2.adoc
│ └── license-efsl.adoc
│ └── theme
│ └── jakartaee-theme.yml
└── tck
├── pom.xml
└── src
└── main
├── java
└── jakarta
│ └── config
│ └── tck
│ ├── ConfigTest.java
│ ├── NegativeConfigTest.java
│ └── common
│ ├── AnyConfiguration.java
│ ├── JakartaConfigValues.java
│ ├── My.java
│ ├── Other.java
│ └── TopLevelConfig.java
└── resources
└── META-INF
└── jakarta-config.properties
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Handle line endings automatically for files detected as text
2 | # and leave all files detected as binary untouched.
3 | * text=auto
4 |
5 | #
6 | # The above will handle all files NOT found below
7 | #
8 | # These files are text and should be normalized (Convert crlf => lf)
9 | *.adoc text
10 | *.conf text
11 | *.config text
12 | *.css text
13 | *.df text
14 | *.extension text
15 | *.groovy text
16 | *.htm text
17 | *.html text
18 | *.java text
19 | *.js text
20 | *.json text
21 | *.jsp text
22 | *.jspf text
23 | *.md text
24 | *.properties text
25 | *.sbt text
26 | *.scala text
27 | *.sh text
28 | *.sql text
29 | *.svg text
30 | *.template text
31 | *.tld text
32 | *.txt text
33 | *.vm text
34 | *.wadl text
35 | *.wsdl text
36 | *.xhtml text
37 | *.xml text
38 | *.xsd text
39 | *.yml text
40 |
41 | cipher text
42 | jaas text
43 | LICENSE text
44 | NOTICE text
45 |
46 | # These files are binary and should be left untouched
47 | # (binary is a macro for -text -diff)
48 | *.class binary
49 | *.dll binary
50 | *.ear binary
51 | *.gif binary
52 | *.ico binary
53 | *.jar binary
54 | *.jpg binary
55 | *.jpeg binary
56 | *.png binary
57 | *.ser binary
58 | *.so binary
59 | *.war binary
60 | *.zip binary
61 | *.exe binary
62 | *.gz binary
63 |
64 | #Windows
65 | *.bat text eol=crlf
66 | *.cmd text eol=crlf
67 |
68 | #Unix/Linux
69 | *.sh text eol=lf
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "maven"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 | - package-ecosystem: "github-actions"
8 | directory: "/"
9 | schedule:
10 | interval: "daily"
11 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Jakarta Config Build
2 |
3 | on:
4 | push:
5 | paths-ignore:
6 | - '.gitattributes'
7 | - '.gitignore'
8 | - 'CONTRIBUTING*'
9 | - 'KEYS'
10 | - 'LICENSE'
11 | - 'NOTICE'
12 | - 'README*'
13 | pull_request:
14 | paths-ignore:
15 | - '.gitattributes'
16 | - '.gitignore'
17 | - 'CONTRIBUTING*'
18 | - 'KEYS'
19 | - 'LICENSE'
20 | - 'NOTICE'
21 | - 'README*'
22 |
23 | permissions:
24 | contents: read
25 |
26 | jobs:
27 | build:
28 | runs-on: ubuntu-latest
29 | strategy:
30 | matrix:
31 | java: [ 11, 17 ]
32 | name: build with jdk ${{matrix.java}}
33 |
34 | steps:
35 | - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
36 | name: checkout
37 | with:
38 | ref: ${{ github.event.pull_request.merge_commit_sha }}
39 |
40 | - uses: actions/setup-java@v4.4.0
41 | name: set up jdk ${{matrix.java}}
42 | with:
43 | distribution: 'temurin'
44 | java-version: ${{matrix.java}}
45 | cache: 'maven'
46 |
47 | - name: build with maven
48 | run: mvn --batch-mode --no-transfer-progress --show-version --errors install
49 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # Editors
8 | *~
9 | .settings/
10 | .project
11 | .classpath
12 | .idea/
13 | *.iml
14 | *.iwl
15 | *.ipr
16 | .vscode/
17 |
18 | # Build tools
19 | target/
20 | build/
21 | test-output/
22 |
23 | # Package Files #
24 | *.jar
25 | *.war
26 | *.nar
27 | *.ear
28 | *.zip
29 | *.tar.gz
30 | *.rar
31 |
32 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
33 | hs_err_pid*
34 |
35 | # Other
36 | .checkstyle
37 | tck/bin/
38 | .factorypath
39 | # Ignore a release.conf for perform_release/* script usage
40 | release.conf
41 | **.DS_Store
42 | *.cache/
43 |
--------------------------------------------------------------------------------
/CONTRIBUTING.adoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // You may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | == How to contribute
21 |
22 | Do you want to contribute to this project?
23 | Here is what you can do:
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // you may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | :doctype: book
21 |
22 | image:https://img.shields.io/badge/License-Apacahe%202.0-green.svg[link="https://opensource.org/licenses/Apache-2.0"]
23 |
24 | = Jakarta Configuration
25 |
26 | Jakarta Configuration Specification
27 |
28 | == Rationale
29 |
30 | == Building
31 |
32 | The whole Jakarta Config project can be built via Apache Maven
33 |
34 | $> mvn clean install
35 |
36 | == Contributing
37 |
38 | Do you want to contribute to this project? link:CONTRIBUTING.adoc[Find out how you can help here].
39 |
--------------------------------------------------------------------------------
/api/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
23 | 4.0.0
24 |
25 |
26 | jakarta.config
27 | jakarta.config
28 | 1.0.0-SNAPSHOT
29 |
30 |
31 | jakarta.config-api
32 | Jakarta Config API
33 | Jakarta Config :: API
34 |
35 |
36 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/config/Config.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package jakarta.config;
20 |
21 | import java.util.NoSuchElementException;
22 | import java.util.ServiceLoader;
23 |
24 | /**
25 | * A loader of configuration-related objects.
26 | *
27 | *
The loader resolves configuration data of the provided configuration interface with a portion of
28 | * application's persistent configuration identified by configuration path. The portion of the
29 | * persistent configuration is identified by configuration path.
30 | *
31 | *
The loader must support persistent configuration stored in META-INF/jakarta-config.properties
32 | * file found on the classpath that follows a format that is recognized by the class {@link java.util.Properties}.
33 | *
34 | *
In the following example the {@code MyConfigurationRelatedObject} is the configuration interface to be
35 | * resolved. An instance of the configuration interface is created by the {@link Config}:
Implementations of the methods in this class must be:
50 | *
51 | *
idempotent
52 | *
safe for concurrent use by multiple threads
53 | *
must not return {@code null}.
54 | *
55 | */
56 | public interface Config {
57 | /**
58 | * Loads an object of the supplied {@code type} from the current {@link Config} configuration path.
59 | *
60 | * @param the type of object to load
61 | * @param type the type of object to load; must not be {@code null}
62 | * @return the loaded object; never {@code null}
63 | * @exception NoSuchElementException if the requested object is not found.
64 | * @exception IllegalArgumentException if the supplied {@code type} was invalid for any reason
65 | * @exception NullPointerException if the supplied {@code type} was {@code null}
66 | */
67 | T load(Class type);
68 |
69 | /**
70 | * Return a new instance of a {@link Config} with the configuration path set.
71 | *
72 | *
The configuration path may contain one or more elements. A configuration path element
73 | * only includes the single name of the {@link Config} child hierarchy.
74 | *
75 | *
76 | * For instance, if the configuration contains a properties file with:
77 | *
my.configuration.user=tester
78 | * the configuration path for the configuration name user is my and
79 | * configuration.
80 | *
81 | * @param paths a String array of configuration paths
82 | * @return a new instance of the {@link Config} class with the new configuration path
83 | */
84 | Config path(String... paths);
85 |
86 | /**
87 | * Return a new instance of a {@link Config} with the configuration path set.
88 | *
89 | *
The configuration path is the single name of the {@link Config} child hierarchy.
90 | *
91 | * @param path a String of a configuration path
92 | * @return a new instance of the {@link Config} class with the new configuration path
93 | * @see Config#path(String...)
94 | */
95 | default Config path(String path) {
96 | return path(new String[] {path});
97 | }
98 |
99 | /**
100 | * {@linkplain #bootstrap(ClassLoader) Bootstraps} a {@link Config} instance for subsequent usage using
101 | * the {@linkplain Thread#getContextClassLoader() context classloader}.
102 | *
103 | *
This method is idempotent.
104 | *
105 | *
This method is safe for concurrent use by multiple threads.
106 | *
107 | *
Except as possibly noted above, the observable behavior of this method is specified to be identical to that
108 | * of the {@link #bootstrap(ClassLoader)} method.
109 | *
110 | * @return a {@link Config}; never {@code null}
111 | *
112 | * @exception java.util.ServiceConfigurationError if bootstrapping failed because of a
113 | * {@link ServiceLoader#load(Class, ClassLoader)} or {@link ServiceLoader#findFirst()} problem.
114 | * @exception ConfigException if bootstrapping failed because of a {@link Config#load(Class)} problem.
115 | *
116 | * @see #bootstrap(ClassLoader)
117 | */
118 | static Config bootstrap() {
119 | return bootstrap(Thread.currentThread().getContextClassLoader());
120 | }
121 |
122 | /**
123 | * Bootstraps a {@link Config} instance for subsequent usage.
124 | *
125 | * A primordial {@link Config} is located with observable effects equal to those resulting from
126 | * executing the following code:
127 | *
128 | *
135 | *
136 | * @param classLoader the {@link ClassLoader} used
137 | * to {@linkplain ServiceLoader#load(Class, ClassLoader) locate service provider files};
138 | * may be {@code null} to indicate the system classloader (or bootstrap class loader) in
139 | * accordance with the contract of the {@link ServiceLoader#load(Class, ClassLoader)} method;
140 | * often is the return value of an invocation of
141 | * {@link Thread#getContextClassLoader() Thread.currentThread().getContextClassLoader()}
142 | *
143 | * @return a {@link Config}; never {@code null}
144 | *
145 | * @exception java.util.ServiceConfigurationError if bootstrapping failed because of a {@link ServiceLoader#load(Class, ClassLoader)} problem.
146 | * @exception NoSuchElementException if a {@linkplain Config} is not found.
147 | */
148 | static Config bootstrap(ClassLoader classLoader) {
149 | return ServiceLoader.load(Config.class, classLoader)
150 | .findFirst()
151 | .orElseThrow(NoSuchElementException::new);
152 | }
153 | }
154 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/config/ConfigDefault.java:
--------------------------------------------------------------------------------
1 | package jakarta.config;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | // TODO - Should we leave this as is, or add ways to accept other defaults types (ints, booleans, etc)
10 | /**
11 | * Specify the default value of a configuration member.
12 | */
13 | @Documented
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Target({ ElementType.METHOD })
16 | public @interface ConfigDefault {
17 | /**
18 | * The default value of the member.
19 | *
20 | * @return the default value as a String
21 | */
22 | String value();
23 | }
24 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/config/ConfigException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2022 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package jakarta.config;
20 |
21 | /**
22 | * A {@link RuntimeException} thrown when a problem is encountered in
23 | * an implementation of the Jakarta Config specfication.
24 | */
25 | public class ConfigException extends RuntimeException {
26 |
27 | /**
28 | * Creates a new {@link ConfigException}.
29 | */
30 | public ConfigException() {
31 | super();
32 | }
33 |
34 | /**
35 | * Creates a new {@link ConfigException}.
36 | *
37 | * @param message a detail message; may be {@code null}
38 | */
39 | public ConfigException(String message) {
40 | super(message);
41 | }
42 |
43 | /**
44 | * Creates a new {@link ConfigException}.
45 | *
46 | * @param cause the {@link Throwable} responsible for this {@link
47 | * ConfigException}'s existence; may be {@code null}
48 | */
49 | public ConfigException(Throwable cause) {
50 | super(cause);
51 | }
52 |
53 | /**
54 | * Creates a new {@link ConfigException}.
55 | *
56 | * @param message a detail message; may be {@code null}
57 | *
58 | * @param cause the {@link Throwable} responsible for this {@link
59 | * ConfigException}'s existence; may be {@code null}
60 | */
61 | public ConfigException(String message, Throwable cause) {
62 | super(message, cause);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/config/ConfigMapping.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 | package jakarta.config;
20 |
21 | import java.lang.annotation.Documented;
22 | import java.lang.annotation.ElementType;
23 | import java.lang.annotation.Retention;
24 | import java.lang.annotation.RetentionPolicy;
25 | import java.lang.annotation.Target;
26 |
27 | /**
28 | * Marks an interface type as capable of mapping a configuration hierarchy.
29 | *
30 | *
Config Mapping allows mapping configuration entries to complex object types (usually user defined).
31 | *
32 | *
33 | *
A configuration path uniquely identifies object member
34 | *
A configuration value maps to the object member value type
35 | *
36 | *
37 | *
A complex object type uses the following rules to map configuration values to their member values:
38 | *
39 | *
40 | *
A configuration path is built by taking the object type path and the mapping member name
41 | *
The member name is converted to its kebab-case format
42 | *
If the member name is a getter, the member name is taken from its property name equivalent, and then converted to its kebab-case format
43 | *
The configuration value is automatically converted to the member type
44 | *
The configuration path is required to exist with a valid configuration value or the mapping will fail
The {@link ConfigMapping} members will be populated with the configuration found in the configuration paths:
72 | *
73 | *
74 | *
Server#host in server, host
75 | *
Server#port in server, port
76 | *
Server#ioThreads in server, io-threads
77 | *
78 | * Server#endpoints() in server, endpoints
79 | *
80 | *
Endpoint#path in server, endpoints, path
81 | *
Endpoint#methods in server, endpoints, methods
82 | *
83 | *
84 | *
85 | * Server#ssl in server, ssl
86 | *
87 | *
Ssl#port in server, ssl, port
88 | *
Ssl#certificate in server, ssl, certificate
89 | *
Ssl#protocols in server, ssl, protocols
90 | *
91 | *
92 | *
Server#form in server, form
93 | *
94 | *
95 | *
Usage
96 | *
97 | *
A {@link ConfigMapping} annotated interface must be retrieved with {@link Config#load(Class)}:
98 | *
99 | *
100 | * Config config = Config.bootstrap();
101 | * Server server = config.load(Server.class);
102 | *
103 | *
104 | * @see Config#load(Class)
105 | * @see ConfigName
106 | * @see ConfigDefault
107 | */
108 | @Target({ElementType.TYPE})
109 | @Retention(RetentionPolicy.RUNTIME)
110 | @Documented
111 | public @interface ConfigMapping {
112 | /**
113 | * The configuration path may contain one or more elements. A configuration path element
114 | * only includes the single name of the {@link Config} child hierarchy.
115 | *
116 | * @return a String array of configuration paths
117 | */
118 | String[] value() default {};
119 | }
120 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/config/ConfigName.java:
--------------------------------------------------------------------------------
1 | package jakarta.config;
2 |
3 | import java.lang.annotation.Documented;
4 | import java.lang.annotation.ElementType;
5 | import java.lang.annotation.Retention;
6 | import java.lang.annotation.RetentionPolicy;
7 | import java.lang.annotation.Target;
8 |
9 | /**
10 | * Override the configuration member name.
11 | */
12 | @Documented
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Target({ElementType.METHOD })
15 | public @interface ConfigName {
16 | /**
17 | * The name of the configuration member name. Must not be empty.
18 | *
19 | * @return the configuration member name
20 | */
21 | String value();
22 | }
23 |
--------------------------------------------------------------------------------
/api/src/main/java/jakarta/config/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | /**
21 | * Jakarta Config.
22 | *
23 | * TODO: We should add intro how config is created once API is clarified
24 | */
25 | package jakarta.config;
26 |
--------------------------------------------------------------------------------
/api/src/main/java/module-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2021, 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | import jakarta.config.Config;
21 |
22 | /**
23 | * Jakarta Config API.
24 | */
25 | module jakarta.config.api {
26 | exports jakarta.config;
27 | uses Config;
28 | }
29 |
--------------------------------------------------------------------------------
/api/src/main/javadoc/jakarta.config.api/jakarta/config/doc-files/terminology.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Terminology
6 |
7 |
8 |
Describes a method invocation's return value as being
14 | missing. An absent return value is often, but not always,
15 | represented by null,
16 | an empty Optional,
17 | or the throwing of
18 | an appropriate
19 | exception. The opposite of an absent value is
20 | a present value.
Describes a method invocation's return value as being wholly
25 | determined by the invocation's arguments, i.e. if
26 | the method is invoked with the same arguments multiple times,
27 | each such invocation will return a value that is equal to the
28 | return value of any other invocation with arguments equal to
29 | the invocation's arguments. A method invocation's return
30 | value that is not wholly determined by the invocation's
31 | arguments is said to be indeterminate.
The property that any given configuration-related object has
63 | that describes its fitness for a
64 | given load request. The
65 | process of finding a suitable configuration-related object for
66 | a given load request is known
67 | as selection. Any given
68 | configuration-related object may be more or less suitable than
69 | another for any given load request.
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
23 | 4.0.0
24 |
25 | org.eclipse.ee4j
26 | project
27 | 1.0.9
28 |
29 |
30 | jakarta.config
31 | jakarta.config
32 | 1.0.0-SNAPSHOT
33 | pom
34 |
35 | Jakarta Config
36 | Jakarta Config Specification
37 | 2021
38 | https://eclipse-ee4j.github.io/config
39 |
40 |
41 | spec
42 | api
43 | tck
44 |
45 |
46 |
47 | UTF-8
48 | UTF-8
49 |
50 | 11
51 |
52 | 1.9.1.Final
53 | 2.5.13
54 | 2.3.18
55 | 1.3
56 | 2.1.1
57 | 2.0.1
58 | 9.4.8.0
59 | 5.10.2
60 | 7.10.2
61 |
62 | 3.13.0
63 | 3.5.0
64 | 3.0.0
65 |
66 |
67 |
68 | github
69 | https://github.com/eclipse-ee4j/config/issues
70 |
71 |
72 |
73 |
74 | Mailing list
75 | config-dev@eclipse.org
76 |
77 |
78 |
79 |
80 |
81 | Apache 2.0
82 | https://www.apache.org/licenses/LICENSE-2.0
83 |
84 |
85 |
86 |
87 | scm:git:git://github.com/eclipse-ee4j/config.git
88 | scm:git:git@github.com:eclipse-ee4j/config.git
89 | https://github.com/eclipse-ee4j/config
90 | HEAD
91 |
92 |
93 |
94 |
95 | m0mus
96 | Dmitry Kornilov
97 | dmitry.kornilov@oracle.com
98 | https://dmitrykornilov.net
99 | Oracle
100 | CET
101 |
102 |
103 | Emily-Jiang
104 | Emily Jiang
105 | https://github.com/Emily-Jiang
106 | IBM
107 | https://www.ibm.com
108 |
109 |
110 | tlanger
111 | Tomas Langer
112 | tomas.langer@oracle.com
113 | https://github.com/tomas-langer
114 | Oracle
115 | CET
116 |
117 |
118 | struberg
119 | Mark Struberg
120 | https://github.com/struberg
121 |
122 |
123 | radcortez
124 | Roberto Cortez
125 | https://radcortez.com
126 | Red Hat Inc.
127 | https://redhat.com
128 |
129 |
130 |
131 |
132 |
133 |
134 | jakarta.annotation
135 | jakarta.annotation-api
136 | ${version.jakarta.annotation}
137 |
138 |
139 | jakarta.inject
140 | jakarta.inject-api
141 | ${version.jakarta.inject}
142 |
143 |
144 |
145 | org.junit.jupiter
146 | junit-jupiter-api
147 | ${version.junit}
148 |
149 |
150 | org.testng
151 | testng
152 | ${version.testng}
153 |
154 |
155 | org.hamcrest
156 | hamcrest-all
157 | ${version.hamcrest}
158 |
159 |
160 | org.jboss.arquillian
161 | arquillian-bom
162 | ${version.arquillian}
163 | import
164 | pom
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 | org.apache.maven.plugins
174 | maven-compiler-plugin
175 | ${version.plugin.compiler}
176 |
177 | ${version.java}
178 | ${version.java}
179 | ${version.java}
180 | true
181 |
182 | -Xlint:unchecked
183 |
186 | -Xpkginfo:always
187 |
188 |
189 |
190 |
191 | org.apache.maven.plugins
192 | maven-enforcer-plugin
193 | ${version.plugin.enforcer}
194 |
195 |
196 | org.asciidoctor
197 | asciidoctor-maven-plugin
198 | ${version.plugin.asciidoctor}
199 |
200 |
201 | org.jruby
202 | jruby-complete
203 | ${version.jruby}
204 |
205 |
206 | org.asciidoctor
207 | asciidoctorj
208 | ${version.asciidoctorj}
209 |
210 |
211 | org.asciidoctor
212 | asciidoctorj-pdf
213 | ${version.asciidoctorj.pdf}
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 | javadocs
224 |
225 |
226 | skipDocs
227 | !true
228 |
229 |
230 | src/main/java
231 |
232 |
233 |
234 |
235 |
236 | org.apache.maven.plugins
237 | maven-javadoc-plugin
238 |
239 |
240 | attach-javadocs
241 |
242 | jar
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
--------------------------------------------------------------------------------
/spec/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
23 | 4.0.0
24 |
25 |
26 | jakarta.config
27 | jakarta.config
28 | 1.0.0-SNAPSHOT
29 |
30 |
31 | jakarta.config-spec
32 | Jakarta Config Specification
33 | Jakarta Config :: Specification
34 | pom
35 |
36 |
37 | ${project.build.directory}/staging
38 | true
39 |
40 | DRAFT
41 | MMMM dd, yyyy
42 | ${maven.build.timestamp}
43 |
44 |
45 |
46 | package
47 |
48 |
49 | org.apache.maven.plugins
50 | maven-enforcer-plugin
51 |
52 |
53 | enforce-versions
54 |
55 | enforce
56 |
57 |
58 |
59 |
60 | [11,)
61 | You need JDK11 or later
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 | org.asciidoctor
70 | asciidoctor-maven-plugin
71 |
72 |
73 | asciidoc-to-html
74 | generate-resources
75 |
76 | process-asciidoc
77 |
78 |
79 | html5
80 | ${project.build.directory}/generated-docs/config-spec-${project.version}.html
81 |
82 | book
83 | ${status}
84 |
85 | font
86 | left
87 | font
88 | true
89 |
90 | -
91 | true
92 |
93 |
94 |
95 |
96 | asciidoc-to-pdf
97 | generate-resources
98 |
99 | process-asciidoc
100 |
101 |
102 | pdf
103 | ${project.build.directory}/generated-docs/config-spec-${project.version}.pdf
104 |
105 | ${project.basedir}/src/main/theme
106 | jakartaee
107 | book
108 | ${status}
109 |
110 | font
111 |
112 |
113 | font
114 | true
115 |
116 | -
117 | true
118 | true
119 |
120 |
121 |
122 |
123 |
124 | src/main/asciidoc
125 | 01-config-spec.adoc
126 |
127 | ${project.version}
128 | ${status}
129 | ${revisiondate}
130 | coderay
131 | Jakarta Config
132 |
133 |
134 |
135 |
136 |
137 |
138 |
--------------------------------------------------------------------------------
/spec/site.yaml:
--------------------------------------------------------------------------------
1 | #######################################################################
2 | ##
3 | ## Copyright (c) 2021 Contributors to the Eclipse Foundation
4 | ##
5 | ## See the NOTICE file(s) distributed with this work for additional
6 | ## information regarding copyright ownership.
7 | ##
8 | ## Licensed under the Apache License, Version 2.0 (the "License");
9 | ## you may not use this file except in compliance with the License.
10 | ## You may obtain a copy of the License at
11 | ##
12 | ## http://www.apache.org/licenses/LICENSE-2.0
13 | ##
14 | ## Unless required by applicable law or agreed to in writing, software
15 | ## distributed under the License is distributed on an "AS IS" BASIS,
16 | ## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | ## See the License for the specific language governing permissions and
18 | ## limitations under the License.
19 | ##
20 | #######################################################################
21 | %YAML 1.2
22 | ---
23 | documentation:
24 | - title: Jakarta Config
25 | file: src/main/asciidoc/01-jakarta-config-spec.asciidoc
26 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/01-config-spec.adoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // you may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | = Jakarta Config
21 | :authors: Contributors to the Jakarta Config Specification (https://github.com/eclipse-ee4j/config/graphs/contributors)
22 | :email: config-dev@eclipse.org
23 | :sectanchors:
24 | :doctype: book
25 | :license: Eclipse Foundation Specification License v1.0
26 | :source-highlighter: coderay
27 | :toc: left
28 | :toclevels: 4
29 | :sectnumlevels: 4
30 | ifdef::backend-pdf[]
31 | :pagenums:
32 | :numbered:
33 | :title-logo-image: image:jakarta_ee_logo_schooner_color_stacked_default.png[pdfwidth=4.25in,align=right]
34 | endif::[]
35 | ifndef::imagesdir[:imagesdir: images]
36 |
37 | // == License
38 | :sectnums!:
39 | include::license-efsl.adoc[]
40 |
41 | :sectnums:
42 | include::02-config.adoc[]
43 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/02-config.adoc:
--------------------------------------------------------------------------------
1 | = Jakarta Config Specification
2 |
3 | == Introduction
4 |
5 |
6 | == Support Injection
7 | A ConfigMapping interface can be injected via the `@Inject`. The following example demonstrates the usage.
8 |
9 | [source]
10 | ----
11 | customer.name=Bob
12 | customer.age=28
13 | ----
14 |
15 | [Usage example]
16 |
17 | The following is a usage example for how `@Inject` may be used:
18 |
19 | [source, java]
20 | ----
21 | @ConfigMapping("customer")
22 | public interface MyConfigMapping{
23 | String name();
24 | int age();
25 | }
26 |
27 | @Inject MyConfigMapping myConfigMapping;
28 | ----
29 |
30 | In the above example, the values for `myConfigMapping.name()` for `myConfigMapping.age()` will be `Bob`, `28` correspondingly.
31 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/03-config-mapping.adoc:
--------------------------------------------------------------------------------
1 | = Config Mapping
2 |
3 | Config Mapping allows mapping configuration entries to complex object types (usually user defined), following certain
4 | rules:
5 |
6 | - A configuration path uniquely identifies object member
7 | - A configuration value maps to the object member value type
8 |
9 | == Mapping Rules
10 |
11 | A complex object type uses the following rules to map configuration values to their member values:
12 |
13 | - A configuration path is built by taking the object type prefix (or namespace) and the mapping member name
14 | - The member name is converted to its kebab-case format
15 | - If the member name is represented as a getter, the member name is taken from its property name equivalent, and then
16 | converted to its kebab-case format.
17 | - The configuration value is automatically converted to the member type
18 | - The configuration path is required to exist with a valid configuration value or the mapping will fail.
19 |
20 | === Nested Types
21 |
22 | - A nested type contributes with its name (converted to its kebab-case format)
23 | - The configuration path is built by taking the root object type prefix (or namespace), the nested
24 | type name and the member name of the nested type
25 |
26 | === Collections and Arrays
27 |
28 | - A member with a `Collection` or `Array` type requires the configuration name to be in its indexed format
29 | - Each configuration name, plus its index maps the configuration value to the corresponding `Collection` or
30 | `Array` element in the object type
31 | - The index must be part of the configuration path, by appending the index between square brackets to the
32 | `Collection` or `Array` member
33 | - The index specified in the configuration name is used to order the element in the `Collection` or `Array`
34 | - Missing elements or gaps are removed
35 |
36 | === Maps
37 |
38 | - A member with a `Map` type requires an additional configuration name added to the configuration path of the `Map`
39 | member to act as a map key
40 | - The additional configuration name maps a Map entry with the configuration name as the `Map` entry key and
41 | the configuration value as the Map entry value
42 |
43 | === Optionals
44 |
45 | - A mapping can wrap any complex type with an `Optional`
46 | - `Optional` mappings do not require the configuration path and value to be present
47 |
48 | == Override Conventions
49 |
50 | It is possible to override:
51 |
52 | - The base configuration path (prefix or namespace) of the mapping
53 | - Mapping member names
54 | - The default Converter of a member
55 | - Add a default value to a member
56 |
57 | == Examples
58 |
59 | === Mapping definition
60 | [source,java]
61 | ----
62 | @ConfigMapping("my.config")
63 | interface Server {
64 | // my.config.host
65 | String host();
66 |
67 | // my.config.port
68 | int port();
69 |
70 | // my.config.io-threads
71 | int ioThreads();
72 |
73 | // my.config.endpoints[*].path
74 | // my.config.endpoints[*].methods
75 | List endpoints();
76 |
77 | Optional ssl();
78 |
79 | // my.config.form.login-page
80 | Map form();
81 |
82 | interface Ssl {
83 | // my.config.ssl.port
84 | int port();
85 |
86 | // my.config.ssl.certificate
87 | String certificate();
88 |
89 | // my.config.ssl.protocols[*]
90 | List protocols();
91 | }
92 |
93 | interface Endpoint {
94 | String path();
95 |
96 | List methods();
97 | }
98 | }
99 | ----
100 |
101 | === Programmatic Access
102 |
103 | [source,java]
104 | ----
105 | class Service {
106 | Config config;
107 |
108 | void service() {
109 | Server server = config.load(Server.class);
110 | }
111 | }
112 | ----
113 |
114 | === Overriding Conventions
115 |
116 | [source,java]
117 | ----
118 | @ConfigMapping("my.config")
119 | interface Server {
120 | @ConfigName("hostname")
121 | Host host();
122 |
123 | @ConfigDefault("8080")
124 | int port();
125 |
126 | @ConfigConverter(IOThreadsConverter.class)
127 | int ioThreads();
128 | }
129 | ----
130 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/XX-config-mapping.adoc:
--------------------------------------------------------------------------------
1 | = Config Mapping
2 |
3 | Config Mapping allows mapping configuration entries to complex object types (usually user defined), following certain
4 | rules:
5 |
6 | - A configuration path uniquely identifies object member
7 | - A configuration value maps to the object member value type
8 |
9 | == Mapping Rules
10 |
11 | A complex object type uses the following rules to map configuration values to their member values:
12 |
13 | - A configuration path is built by taking the object type prefix (or namespace) and the mapping member name
14 | - The member name is converted to its kebab-case format
15 | - If the member name is represented as a getter, the member name is taken from its property name equivalent, and then
16 | converted to its kebab-case format.
17 | - The configuration value is automatically converted to the member type
18 | - The configuration path is required to exist with a valid configuration value or the mapping will fail.
19 |
20 | === Nested Types
21 |
22 | - A nested type contributes with its name (converted to its kebab-case format)
23 | - The configuration path is built by taking the root object type prefix (or namespace), the nested
24 | type name and the member name of the nested type
25 |
26 | === Collections and Arrays
27 |
28 | - A member with a `Collection` or `Array` type requires the configuration name to be in its indexed format
29 | - Each configuration name, plus its index maps the configuration value to the corresponding `Collection` or
30 | `Array` element in the object type
31 | - TODO - Define how to represent the indexed format. A well accepted representation is the presence of square brackets
32 | with the collection / array index inside after the name.
33 | - The index specified in the configuration name is used to order the element in the `Collection` or `Array`. Missing
34 | elements or gaps are removed.
35 |
36 | === Maps
37 |
38 | - A member with a `Map` type requires an additional configuration name added to the configuration path of the `Map`
39 | member to act as a map key
40 | - The additional configuration name maps a Map entry with the configuration name as the `Map` entry key and
41 | the configuration value as the Map entry value
42 |
43 | === Optionals
44 |
45 | - A mapping can wrap any complex type with an `Optional`
46 | - `Optional` mappings do not require the corresponding configuration path and value to be present
47 |
48 | == Override Conventions
49 |
50 | It is possible to override:
51 |
52 | - The base configuration path (prefix or namespace) of the mapping
53 | - Mapping member names
54 | - The default Converter of a member
55 | - Add a default value to a member
56 |
57 | == Examples
58 |
59 | === Mapping definition
60 | [source,java]
61 | ----
62 | @ConfigMapping("my.config")
63 | interface Server {
64 | // my.config.host
65 | String host();
66 |
67 | // my.config.port
68 | int port();
69 |
70 | // my.config.io-threads
71 | int ioThreads();
72 |
73 | // my.config.endpoints[*].path
74 | // my.config.endpoints[*].methods
75 | List endpoints();
76 |
77 | Optional ssl();
78 |
79 | // my.config.form.login-page
80 | Map form();
81 |
82 | interface Ssl {
83 | // my.config.ssl.port
84 | int port();
85 |
86 | // my.config.ssl.certificate
87 | String certificate();
88 |
89 | // my.config.ssl.protocols[*]
90 | List protocols();
91 | }
92 |
93 | interface Endpoint {
94 | String path();
95 |
96 | List methods();
97 | }
98 | }
99 | ----
100 |
101 | === Programmatic Access
102 |
103 | [source,java]
104 | ----
105 | class Service {
106 | Config config;
107 |
108 | void service() {
109 | Server server = config.getMapping(Server.class);
110 | }
111 | }
112 | ----
113 |
114 | === Overriding Conventions
115 |
116 | [source,java]
117 | ----
118 | @ConfigMapping("my.config")
119 | interface Server {
120 | @ConfigName("hostname")
121 | Host host();
122 |
123 | @ConfigDefault("8080")
124 | int port();
125 |
126 | @ConfigConverter(IOThreadsConverter.class)
127 | int ioThreads();
128 | }
129 | ----
130 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/XX-structure-and-format.adoc:
--------------------------------------------------------------------------------
1 | == Structure and format
2 |
3 | === Terms
4 |
5 | .Terms and definitions
6 | Configuration:: An optional _top-level value_, with a collection of zero or more nested _configuration entries_ (organized by _configuration key_).
7 | Also informally known as a "configuration tree node" or "configuration node".
8 | A configuration with no value and no nested entries is considered to be an _empty configuration_.
9 |
10 | Configuration entry:: An _configuration key_ and _configuration value_ combination.
11 |
12 | Configuration key:: A non-empty string which uniquely identifies a configuration entry within a single nesting level of a configuration.
13 | A configuration key *must not* contain embedded newlines or other control characters.
14 | A configuration key string *must* be normalized using https://www.unicode.org/reports/tr15/#Norm_Forms)[Unicode Normalization Form C (NFC)].
15 |
16 | Configuration path:: A sequence of _configuration keys_ which uniquely identify a descendant _configuration entry_ within a configuration, at an arbitrary level of nesting.
17 | Each configuration key within the sequence identifies one level of nested configuration.
18 |
19 | Configuration source:: A provider of configuration data in _raw value_ form. [TODO: high level structure of config sources, ordering etc]
20 |
21 | Configuration value:: An object which is stored within a _configuration_ and is accessible at the _configuration path_ which corresponds to that _configuration_.
22 |
23 | Empty configuration:: A configuration which has no _top-level value_ and zero nested _configuration entries_.
24 |
25 | Raw value:: A _configuration value_ in its uncoverted (string) form.
26 |
27 | Root:: The _configuration_ which is identified by a empty (zero-length) _configuration path_.
28 | Every _configuration_ is its own _root_ when considered in isolation.
29 |
30 | Top-level value:: A _configuration value_ which resides at the _root_ of a _configuration_.
31 |
32 | == Standard mapping formats
33 |
34 |
35 |
36 | === Mapping to `properties` format
37 |
38 | The `properties` file format corresponds to a text file in a format that is loadable by `java.util.Properties`.
39 | Note that `properties` files recognized by this specification *must* be encoded using the UTF-8 character encoding.
40 | Each key in the `properties` file is treated as a _configuration path_, with dot (`.`) characters acting as separators between the individual component _configuration keys_.
41 |
42 | ==== Property key encoding
43 |
44 | Since an individual _configuration key_ may contain a dot (`.`) character, using a `.` character to separate `property` keys into a _configuration path_ poses a problem.
45 | Because of this, an encoding scheme should be used when dealing with keys that contain `.` characters.
46 |
47 | When properties are loaded from a `properties` file or from the system `properties` map, each encountered key is transformed into a _configuration path_ as follows:
48 |
49 | * Any backslash (`\`) character found in the `property` key is considered to be an _escape_ for the next character
50 | * Any character which is immediately preceded by an _escape_ is added to the configuration key verbatim
51 | * Any dot (`.`) character which is _not_ immediately preceded by an _escape_ marks a separate _configuration key_ in the _configuration path_
52 |
53 | The implementation *must* reject `properties` files or sets which contain a key that ends with an _escape_ backslash (`\`).
54 |
55 | *Note:* The `properties` format also escapes backslashes, so when looking inside a `properties` file, a dot (`.`) which is embedded within a configuration key will appear to be encoded as `\\.`, and a backslash (`\`) which is embedded within a configuration key will appear to be encoded as `\\\\`.
56 |
57 | The encoded property name is then looked up in the corresponding `properties` file, and the corresponding value (if any) is used as the _raw value_ for that configuration key.
58 |
59 | ==== TODO: List key encoding per previous discussions
60 |
61 | ==== TODO: Value encoding (esp. lists, complex types, cross-references, etc.)
62 |
63 | The `properties` value string is used as the _raw_ value of the corresponding configuration.
64 | [...etc...]
65 |
66 | === Mapping to YAML format
67 |
68 | The YAML file format is defined by https://yaml.org/spec/1.2.2/[a specification].
69 | A YAML file is recognized as a configuration source by this specification, according to the following rules:
70 |
71 | * A _configuration entry_ corresponds to a YAML https://yaml.org/spec/1.2.2/#mapping[mapping], with the _mapping key_ being used as the _configuration key_ and the _mapping value_ as the nested _configuration_.
72 | * TODO: YAML sequences are lists...
73 | * The _raw value_ for a given _configuration_ is produced by creating a _canonical representation_ of the scalar value of the property, mapped according to the YAML _tag_ of the value:
74 | * TODO: lists again...?
75 | * A value which has a YAML _tag_ of `tag:yaml.org,2002:null` corresponds to a `null` (missing) _raw value_.
76 | * A value which has a YAML _tag_ of `tag:yaml.org,2002:str` is directly used as a _raw value_.
77 | * A value which has a YAML _tag_ of `tag:yaml.org,2002:bool` is parsed according to the YAML parsing rules for that type; `true` values are then represented as the string `"true"`, and `false` values are represented as the string `"false"`.
78 | * TODO: FP types canonical form
79 | * TODO: Integer canonical form
80 | * TODO: Custom tags for conversion types...?
81 | * ...etc...
82 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/images/jakarta_ee_logo_schooner_color_stacked_default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jakartaee/config/d1337cd2411c5a5e9ad55e3e1db3aa3e1d62352a/spec/src/main/asciidoc/images/jakarta_ee_logo_schooner_color_stacked_default.png
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/license-alv2.adoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // you may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | [subs="normal"]
21 | ....
22 |
23 | Specification: {doctitle}
24 |
25 | Version: {revnumber}
26 |
27 | Status: {revremark}
28 |
29 | Release: {revdate}
30 |
31 | Copyright (c) 2016-2018 Contributors to the Eclipse Foundation
32 |
33 | Licensed under the Apache License, Version 2.0 (the "License");
34 | you may not use this file except in compliance with the License.
35 | You may obtain a copy of the License at
36 |
37 | http://www.apache.org/licenses/LICENSE-2.0
38 |
39 | Unless required by applicable law or agreed to in writing, software
40 | distributed under the License is distributed on an "AS IS" BASIS,
41 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 | See the License for the specific language governing permissions and
43 | limitations under the License.
44 |
45 | ....
46 |
--------------------------------------------------------------------------------
/spec/src/main/asciidoc/license-efsl.adoc:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2021 Contributors to the Eclipse Foundation
3 | //
4 | // See the NOTICE file(s) distributed with this work for additional
5 | // information regarding copyright ownership.
6 | //
7 | // Licensed under the Apache License, Version 2.0 (the "License");
8 | // you may not use this file except in compliance with the License.
9 | // You may obtain a copy of the License at
10 | //
11 | // http://www.apache.org/licenses/LICENSE-2.0
12 | //
13 | // Unless required by applicable law or agreed to in writing, software
14 | // distributed under the License is distributed on an "AS IS" BASIS,
15 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | // See the License for the specific language governing permissions and
17 | // limitations under the License.
18 | //
19 |
20 | [subs="normal"]
21 | ....
22 | Specification: {doctitle}
23 |
24 | Version: {revnumber}
25 |
26 | Status: {revremark}
27 |
28 | Release: {revdate}
29 | ....
30 |
31 | == Copyright
32 |
33 | Copyright (c) 2016, 2020 Eclipse Foundation.
34 |
35 | === Eclipse Foundation Specification License
36 |
37 | By using and/or copying this document, or the Eclipse Foundation document from which this statement is linked, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions:
38 |
39 | Permission to copy, and distribute the contents of this document, or the Eclipse Foundation document from which this statement is linked, in any medium for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the document, or portions thereof, that you use:
40 |
41 | * link or URL to the original Eclipse Foundation document.
42 | * All existing copyright notices, or if one does not exist, a notice (hypertext is preferred, but a textual representation is permitted) of the form: "Copyright (c) [$date-of-document]
43 | Eclipse Foundation, Inc. \<>"
44 |
45 | Inclusion of the full text of this NOTICE must be provided.
46 | We request that authorship attribution be provided in any software, documents, or other items or products that you create pursuant to the implementation of the contents of this document, or any portion thereof.
47 |
48 | No right to create modifications or derivatives of Eclipse Foundation documents is granted pursuant to this license, except anyone may prepare and distribute derivative works and portions of this document in software that implements the specification, in supporting materials accompanying such software, and in documentation of such software, PROVIDED that all such works include the notice below.
49 | HOWEVER, the publication of derivative works of this document for use as a technical specification is expressly prohibited.
50 |
51 | The notice is:
52 |
53 | "Copyright (c) [$date-of-document] Eclipse Foundation.
54 | This software or document includes material copied from or derived from [title and URI of the Eclipse Foundation specification document]."
55 |
56 | ==== Disclaimers
57 |
58 | THIS DOCUMENT IS PROVIDED "AS IS," AND THE COPYRIGHT HOLDERS AND THE ECLIPSE FOUNDATION MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE; THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
59 |
60 | THE COPYRIGHT HOLDERS AND THE ECLIPSE FOUNDATION WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE OR IMPLEMENTATION OF THE CONTENTS THEREOF.
61 |
62 | The name and trademarks of the copyright holders or the Eclipse Foundation may NOT be used in advertising or publicity pertaining to this document or its contents without specific, written prior permission.
63 | Title to copyright in this document will at all times remain with copyright holders.
64 |
--------------------------------------------------------------------------------
/spec/src/main/theme/jakartaee-theme.yml:
--------------------------------------------------------------------------------
1 | #
2 | # Following is the asciidoctor-pdf default theme [1], with small
3 | # customizations, mostly for header and footer, marked "EE".
4 | #
5 | # [1] https://github.com/asciidoctor/asciidoctor-pdf/blob/master/data/themes/default-theme.yml
6 | #
7 | font:
8 | catalog:
9 | # Noto Serif supports Latin, Latin-1 Supplement, Latin Extended-A, Greek, Cyrillic, Vietnamese & an assortment of symbols
10 | Noto Serif:
11 | normal: notoserif-regular-subset.ttf
12 | bold: notoserif-bold-subset.ttf
13 | italic: notoserif-italic-subset.ttf
14 | bold_italic: notoserif-bold_italic-subset.ttf
15 | # M+ 1mn supports ASCII and the circled numbers used for conums
16 | M+ 1mn:
17 | normal: mplus1mn-regular-ascii-conums.ttf
18 | bold: mplus1mn-bold-ascii.ttf
19 | italic: mplus1mn-italic-ascii.ttf
20 | bold_italic: mplus1mn-bold_italic-ascii.ttf
21 | # M+ 1p supports Latin, Latin-1 Supplement, Latin Extended, Greek, Cyrillic, Vietnamese, Japanese & an assortment of symbols
22 | # It also provides arrows for ->, <-, => and <= replacements in case these glyphs are missing from font
23 | M+ 1p Fallback:
24 | normal: mplus1p-regular-fallback.ttf
25 | bold: mplus1p-regular-fallback.ttf
26 | italic: mplus1p-regular-fallback.ttf
27 | bold_italic: mplus1p-regular-fallback.ttf
28 | fallbacks:
29 | - M+ 1p Fallback
30 | page:
31 | background_color: ffffff
32 | layout: portrait
33 | margin: [ 0.5in, 0.67in, 0.67in, 0.67in ]
34 | # margin_inner and margin_outer keys are used for recto/verso print margins when media=prepress
35 | margin_inner: 0.75in
36 | margin_outer: 0.59in
37 | #size: A4 # EE
38 | size: Letter # EE
39 | base:
40 | align: justify
41 | # color as hex string (leading # is optional)
42 | font_color: 333333
43 | # color as RGB array
44 | #font_color: [51, 51, 51]
45 | # color as CMYK array (approximated)
46 | #font_color: [0, 0, 0, 0.92]
47 | #font_color: [0, 0, 0, 92%]
48 | font_family: Noto Serif
49 | # choose one of these font_size/line_height_length combinations
50 | #font_size: 14
51 | #line_height_length: 20
52 | #font_size: 11.25
53 | #line_height_length: 18
54 | #font_size: 11.2
55 | #line_height_length: 16
56 | font_size: 10.5
57 | #line_height_length: 15
58 | # correct line height for Noto Serif metrics
59 | line_height_length: 12
60 | #font_size: 11.25
61 | #line_height_length: 18
62 | line_height: $base_line_height_length / $base_font_size
63 | font_size_large: round($base_font_size * 1.25)
64 | font_size_small: round($base_font_size * 0.85)
65 | font_size_min: $base_font_size * 0.75
66 | font_style: normal
67 | border_color: eeeeee
68 | border_radius: 4
69 | border_width: 0.5
70 | # FIXME vertical_rhythm is weird; we should think in terms of ems
71 | #vertical_rhythm: $base_line_height_length * 2 / 3
72 | # correct line height for Noto Serif metrics (comes with built-in line height)
73 | vertical_rhythm: $base_line_height_length
74 | horizontal_rhythm: $base_line_height_length
75 | # QUESTION should vertical_spacing be block_spacing instead?
76 | vertical_spacing: $vertical_rhythm
77 | link:
78 | font_color: 428bca
79 | # literal is currently used for inline monospaced in prose and table cells
80 | literal:
81 | font_color: b12146
82 | font_family: M+ 1mn
83 | menu_caret_content: " \u203a "
84 | heading:
85 | align: left
86 | #font_color: 181818
87 | font_color: $base_font_color
88 | font_family: $base_font_family
89 | font_style: bold
90 | # h1 is used for part titles (book doctype) or the doctitle (article doctype)
91 | #h1_font_size: floor($base_font_size * 2.6) # EE
92 | h1_font_size: floor($base_font_size * 2.5) # EE, squeeze title onto one line
93 | # h2 is used for chapter titles (book doctype only)
94 | h2_font_size: floor($base_font_size * 2.15)
95 | h3_font_size: round($base_font_size * 1.7)
96 | h4_font_size: $base_font_size_large
97 | h5_font_size: $base_font_size
98 | h6_font_size: $base_font_size_small
99 | #line_height: 1.4
100 | # correct line height for Noto Serif metrics (comes with built-in line height)
101 | line_height: 1
102 | margin_top: $vertical_rhythm * 0.4
103 | margin_bottom: $vertical_rhythm * 0.9
104 | title_page:
105 | align: right
106 | logo:
107 | top: 10%
108 | title:
109 | top: 55%
110 | font_size: $heading_h1_font_size
111 | font_color: 999999
112 | line_height: 0.9
113 | subtitle:
114 | font_size: $heading_h3_font_size
115 | font_style: bold_italic
116 | line_height: 1
117 | authors:
118 | margin_top: $base_font_size * 1.25
119 | font_size: $base_font_size_large
120 | font_color: 181818
121 | revision:
122 | margin_top: $base_font_size * 1.25
123 | block:
124 | margin_top: 0
125 | margin_bottom: $vertical_rhythm
126 | caption:
127 | align: left
128 | font_size: $base_font_size * 0.95
129 | font_style: italic
130 | # FIXME perhaps set line_height instead of / in addition to margins?
131 | margin_inside: $vertical_rhythm / 3
132 | #margin_inside: $vertical_rhythm / 4
133 | margin_outside: 0
134 | lead:
135 | font_size: $base_font_size_large
136 | line_height: 1.4
137 | abstract:
138 | font_color: 5c6266
139 | font_size: $lead_font_size
140 | line_height: $lead_line_height
141 | font_style: italic
142 | first_line_font_style: bold
143 | title:
144 | align: center
145 | font_color: $heading_font_color
146 | font_family: $heading_font_family
147 | font_size: $heading_h4_font_size
148 | font_style: $heading_font_style
149 | admonition:
150 | column_rule_color: $base_border_color
151 | column_rule_width: $base_border_width
152 | padding: [ 0, $horizontal_rhythm, 0, $horizontal_rhythm ]
153 | #icon:
154 | # tip:
155 | # name: fa-lightbulb-o
156 | # stroke_color: 111111
157 | # size: 24
158 | label:
159 | text_transform: uppercase
160 | font_style: bold
161 | blockquote:
162 | font_color: $base_font_color
163 | font_size: $base_font_size_large
164 | border_color: $base_border_color
165 | border_width: 5
166 | # FIXME disable negative padding bottom once margin collapsing is implemented
167 | padding: [ 0, $horizontal_rhythm, $block_margin_bottom * -0.75, $horizontal_rhythm + $blockquote_border_width / 2 ]
168 | cite_font_size: $base_font_size_small
169 | cite_font_color: 999999
170 | # code is used for source blocks (perhaps change to source or listing?)
171 | code:
172 | font_color: $base_font_color
173 | font_family: $literal_font_family
174 | font_size: ceil($base_font_size)
175 | padding: $code_font_size
176 | line_height: 1.25
177 | # line_gap is an experimental property to control how a background color is applied to an inline block element
178 | line_gap: 3.8
179 | background_color: f5f5f5
180 | border_color: cccccc
181 | border_radius: $base_border_radius
182 | border_width: 0.75
183 | conum:
184 | font_family: M+ 1mn
185 | font_color: $literal_font_color
186 | font_size: $base_font_size
187 | line_height: 4 / 3
188 | example:
189 | border_color: $base_border_color
190 | border_radius: $base_border_radius
191 | border_width: 0.75
192 | background_color: ffffff
193 | # FIXME reenable padding bottom once margin collapsing is implemented
194 | padding: [ $vertical_rhythm, $horizontal_rhythm, 0, $horizontal_rhythm ]
195 | image:
196 | align: left
197 | prose:
198 | margin_top: $block_margin_top
199 | margin_bottom: $block_margin_bottom
200 | sidebar:
201 | background_color: eeeeee
202 | border_color: e1e1e1
203 | border_radius: $base_border_radius
204 | border_width: $base_border_width
205 | # FIXME reenable padding bottom once margin collapsing is implemented
206 | padding: [ $vertical_rhythm, $vertical_rhythm * 1.25, 0, $vertical_rhythm * 1.25 ]
207 | title:
208 | align: center
209 | font_color: $heading_font_color
210 | font_family: $heading_font_family
211 | font_size: $heading_h4_font_size
212 | font_style: $heading_font_style
213 | thematic_break:
214 | border_color: $base_border_color
215 | border_style: solid
216 | border_width: $base_border_width
217 | margin_top: $vertical_rhythm * 0.5
218 | margin_bottom: $vertical_rhythm * 1.5
219 | description_list:
220 | term_font_style: bold
221 | term_spacing: $vertical_rhythm / 4
222 | description_indent: $horizontal_rhythm * 1.25
223 | outline_list:
224 | indent: $horizontal_rhythm * 1.5
225 | #marker_font_color: 404040
226 | # NOTE outline_list_item_spacing applies to list items that do not have complex content
227 | item_spacing: $vertical_rhythm / 2
228 | table:
229 | background_color: $page_background_color
230 | #head_background_color:
231 | #head_font_color: $base_font_color
232 | head_font_style: bold
233 | #body_background_color:
234 | body_stripe_background_color: f9f9f9
235 | foot_background_color: f0f0f0
236 | border_color: dddddd
237 | border_width: $base_border_width
238 | cell_padding: 3
239 | toc:
240 | indent: $horizontal_rhythm
241 | line_height: 1.4
242 | dot_leader:
243 | #content: ". "
244 | font_color: a9a9a9
245 | #levels: 2 3
246 | # NOTE in addition to footer, header is also supported
247 | footer:
248 | font_size: $base_font_size_small
249 | # NOTE if background_color is set, background and border will span width of page
250 | #border_color: dddddd # EE
251 | #border_width: 0.25 # EE
252 | height: $base_line_height_length * 2.5
253 | line_height: 1
254 | padding: [ $base_line_height_length / 2, 1, 0, 1 ]
255 | vertical_align: top
256 | #image_vertical_align: or
257 | # additional attributes for content:
258 | # * {page-count}
259 | # * {page-number}
260 | # * {document-title}
261 | # * {document-subtitle}
262 | # * {chapter-title}
263 | # * {section-title}
264 | # * {section-or-chapter-title}
265 | recto:
266 | #columns: "<50% =0% >50%"
267 | right:
268 | #content: '{page-number}' # EE
269 | #content: '{section-or-chapter-title} | {page-number}'
270 | #content: '{document-title} | {page-number}'
271 | content: '{document-title}{nbsp}{nbsp}{nbsp} *{page-number}*' # EE
272 | #center:
273 | # content: '{page-number}'
274 | left: # EE
275 | content: '{status}' # EE
276 | verso:
277 | #columns: $footer_recto_columns
278 | left:
279 | #content: $footer_recto_right_content # EE
280 | #content: '{page-number} | {chapter-title}'
281 | content: '*{page-number}* {nbsp}{nbsp}{nbsp}{document-title}' # EE
282 | #center:
283 | # content: '{page-number}'
284 | right: # EE
285 | content: '{status}' # EE
286 | header: # EE
287 | font_size: $base_font_size_small # EE
288 | border_color: dddddd # EE
289 | border_width: 0.25 # EE
290 | height: $base_line_height_length * 2.5 # EE
291 | line_height: 1 # EE
292 | padding: [ $base_line_height_length / 2, 1, 0, 1 ] # EE
293 | vertical_align: top # EE
294 | recto: # EE
295 | right: # EE
296 | content: '{section-or-chapter-title}' # EE
297 | verso: # EE
298 | left: # EE
299 | content: '{section-or-chapter-title}' # EE
300 |
--------------------------------------------------------------------------------
/tck/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
23 | 4.0.0
24 |
25 |
26 | jakarta.config
27 | jakarta.config
28 | 1.0.0-SNAPSHOT
29 |
30 |
31 | jakarta.config-tck
32 | Jakarta Config TCK
33 | Jakarta Config :: TCK
34 | 1.0.0-SNAPSHOT
35 |
36 |
37 |
38 | jakarta.config
39 | jakarta.config-api
40 | ${project.version}
41 |
42 |
43 | org.junit.jupiter
44 | junit-jupiter-api
45 |
46 |
47 | org.hamcrest
48 | hamcrest-all
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/tck/src/main/java/jakarta/config/tck/ConfigTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | package jakarta.config.tck;
21 |
22 | import jakarta.config.Config;
23 | import jakarta.config.tck.common.AnyConfiguration;
24 | import jakarta.config.tck.common.JakartaConfigValues;
25 | import jakarta.config.tck.common.My;
26 | import jakarta.config.tck.common.Other;
27 | import jakarta.config.tck.common.TopLevelConfig;
28 | import org.junit.jupiter.api.Test;
29 |
30 | import static org.hamcrest.MatcherAssert.assertThat;
31 | import static org.hamcrest.Matchers.equalTo;
32 |
33 | public class ConfigTest {
34 | @Test
35 | public void testTopLevelConfig() {
36 | TopLevelConfig configuration = Config.bootstrap().load(TopLevelConfig.class);
37 | assertThat(configuration.my().username(), equalTo(JakartaConfigValues.myUserName));
38 | assertThat(configuration.my().password(), equalTo(JakartaConfigValues.myPassword));
39 | assertThat(configuration.my().configuration().key(), equalTo(JakartaConfigValues.myConfigurationKey));
40 | assertThat(configuration.other().configuration().key(), equalTo(JakartaConfigValues.otherConfigurationKey));
41 | }
42 |
43 | @Test
44 | public void testSecondLevelMyInterface() {
45 | My configuration = Config.bootstrap().load(My.class);
46 | assertThat(configuration.username(), equalTo(JakartaConfigValues.myUserName));
47 | assertThat(configuration.password(), equalTo(JakartaConfigValues.myPassword));
48 | assertThat(configuration.configuration().key(), equalTo(JakartaConfigValues.myConfigurationKey));
49 | }
50 |
51 | @Test
52 | public void testSecondLevelOtherInterface() {
53 | Other configuration = Config.bootstrap().load(Other.class);
54 | assertThat(configuration.configuration().key(), equalTo(JakartaConfigValues.otherConfigurationKey));
55 | }
56 |
57 | @Test
58 | public void testOverridePathSecondLevelOtherInterface() {
59 | Other configuration = Config.bootstrap().path("my").load(Other.class);
60 | assertThat(configuration.configuration().key(), equalTo(JakartaConfigValues.myConfigurationKey));
61 | }
62 |
63 | @Test
64 | public void testThirdLevelAnyConfigurationInterface() {
65 | AnyConfiguration configuration = Config.bootstrap().load(AnyConfiguration.class);
66 | assertThat(configuration.key(), equalTo(JakartaConfigValues.myConfigurationKey));
67 | }
68 |
69 | @Test
70 | public void testOverridePathThirdLevelAnyConfigurationInterface() {
71 | AnyConfiguration configuration = Config.bootstrap().path("other", "configuration").load(AnyConfiguration.class);
72 | assertThat(configuration.key(), equalTo(JakartaConfigValues.otherConfigurationKey));
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/tck/src/main/java/jakarta/config/tck/NegativeConfigTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | package jakarta.config.tck;
21 |
22 | import jakarta.config.ConfigException;
23 | import jakarta.config.Config;
24 | import jakarta.config.tck.common.AnyConfiguration;
25 | import org.junit.jupiter.api.Assertions;
26 | import org.junit.jupiter.api.Test;
27 |
28 | import java.util.NoSuchElementException;
29 |
30 | public class NegativeConfigTest {
31 | @Test
32 | public void testFailWhenNotAnnotatedInterface() {
33 | try {
34 | Config.bootstrap().path("my", "configuration").load(NotAnnotatedConfiguration.class);
35 | Assertions.fail("Expected ConfigException has not been thrown when the interface does not contain @Configuration");
36 | } catch (ConfigException configException) {
37 | // pass
38 | }
39 | }
40 |
41 | @Test
42 | public void testFailWhenUnknowPath() {
43 | try {
44 | Config.bootstrap().path("my", "config").load(AnyConfiguration.class);
45 | Assertions.fail("Expected NoSuchObjectException has not been thrown when the configuration object not found");
46 | } catch (NoSuchElementException noSuchElementException) {
47 | // pass
48 | }
49 | }
50 |
51 | public static interface NotAnnotatedConfiguration {
52 | String key();
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/tck/src/main/java/jakarta/config/tck/common/AnyConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | package jakarta.config.tck.common;
21 |
22 | import jakarta.config.ConfigMapping;
23 |
24 | @ConfigMapping({"my", "configuration"})
25 | public interface AnyConfiguration {
26 | String key();
27 | }
28 |
--------------------------------------------------------------------------------
/tck/src/main/java/jakarta/config/tck/common/JakartaConfigValues.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | package jakarta.config.tck.common;
21 |
22 | public class JakartaConfigValues {
23 | public static final String myUserName = "user012345";
24 | public static final String myPassword = "pass012345";
25 | public static final String myConfigurationKey = "value";
26 | public static final String otherConfigurationKey = "anothervalue";
27 | }
28 |
--------------------------------------------------------------------------------
/tck/src/main/java/jakarta/config/tck/common/My.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | package jakarta.config.tck.common;
21 |
22 | import jakarta.config.ConfigMapping;
23 |
24 | @ConfigMapping("my")
25 | public interface My {
26 | String username();
27 | String password();
28 | AnyConfiguration configuration();
29 | }
30 |
--------------------------------------------------------------------------------
/tck/src/main/java/jakarta/config/tck/common/Other.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | package jakarta.config.tck.common;
21 |
22 | import jakarta.config.ConfigMapping;
23 |
24 | @ConfigMapping("other")
25 | public interface Other {
26 | AnyConfiguration configuration();
27 | }
28 |
--------------------------------------------------------------------------------
/tck/src/main/java/jakarta/config/tck/common/TopLevelConfig.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (c) 2023 Contributors to the Eclipse Foundation
3 | *
4 | * See the NOTICE file(s) distributed with this work for additional
5 | * information regarding copyright ownership.
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 | package jakarta.config.tck.common;
21 |
22 | import jakarta.config.ConfigMapping;
23 |
24 | @ConfigMapping
25 | public interface TopLevelConfig {
26 | My my();
27 | Other other();
28 | }
--------------------------------------------------------------------------------
/tck/src/main/resources/META-INF/jakarta-config.properties:
--------------------------------------------------------------------------------
1 | my.username=user012345
2 | my.password=pass012345
3 | my.configuration.key=value
4 | other.configuration.key=anothervalue
--------------------------------------------------------------------------------