├── .github
├── FUNDING.yml
└── workflows
│ └── gradle.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.adoc
├── build.gradle
├── diagrams
├── diagrams.gradle
└── src
│ └── docs
│ └── asciidoc
│ └── index.adoc
├── gradle.properties
├── gradle
├── LICENSE_HEADER
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── jsr377-api
├── gradle.properties
├── jsr377-api.gradle
└── src
│ └── main
│ ├── java
│ └── javax
│ │ └── application
│ │ ├── Application.java
│ │ ├── ApplicationPhase.java
│ │ ├── ExceptionHandler.java
│ │ ├── ExitState.java
│ │ ├── ShutdownHandler.java
│ │ ├── action
│ │ ├── AbortActionExecution.java
│ │ ├── Action.java
│ │ ├── ActionExecutionStatus.java
│ │ ├── ActionHandler.java
│ │ ├── ActionInterceptor.java
│ │ ├── ActionMetadata.java
│ │ ├── ActionParameter.java
│ │ └── package-info.java
│ │ ├── configuration
│ │ ├── Configuration.java
│ │ ├── Configured.java
│ │ └── package-info.java
│ │ ├── converter
│ │ ├── ConversionException.java
│ │ ├── Converter.java
│ │ ├── ConverterRegistry.java
│ │ ├── NoopConverter.java
│ │ ├── package-info.java
│ │ └── spi
│ │ │ ├── ConverterProvider.java
│ │ │ └── package-info.java
│ │ ├── event
│ │ ├── EventBus.java
│ │ ├── EventFilter.java
│ │ ├── EventHandler.java
│ │ ├── EventMetadata.java
│ │ └── package-info.java
│ │ ├── i18n
│ │ ├── MessageSource.java
│ │ ├── NoSuchMessageException.java
│ │ └── package-info.java
│ │ ├── package-info.java
│ │ ├── resources
│ │ ├── InjectedResource.java
│ │ ├── NoSuchResourceException.java
│ │ ├── ResourceInjector.java
│ │ ├── ResourceResolver.java
│ │ └── package-info.java
│ │ └── threading
│ │ ├── Threading.java
│ │ ├── ThreadingHandler.java
│ │ └── package-info.java
│ └── module
│ └── module-info.java
├── jsr377-spec
├── CONTRIBUTING.adoc
├── jsr377-spec.gradle
└── src
│ └── docs
│ └── asciidoc
│ ├── _license_asl2.adoc
│ ├── _license_jcp.adoc
│ ├── _links.adoc
│ ├── architecture.adoc
│ ├── index.adoc
│ ├── preface.adoc
│ └── references.adoc
└── settings.gradle
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | patreon: aalmiray
2 | github: aalmiray
3 |
--------------------------------------------------------------------------------
/.github/workflows/gradle.yml:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Copyright 2015-2021 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | name: Build
20 |
21 | on: [push, pull_request]
22 |
23 | jobs:
24 | build:
25 | name: Build
26 | runs-on: ubuntu-latest
27 | env:
28 | CI: true
29 | steps:
30 | - uses: actions/checkout@v2
31 |
32 | - name: Set up JDK 1.8
33 | uses: actions/setup-java@v1
34 | with:
35 | java-version: 8
36 | distribution: 'zulu'
37 |
38 | - uses: actions/cache@v2
39 | with:
40 | path: ~/.gradle/caches
41 | key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle') }}-${{ hashFiles('**/gradle.properties') }}
42 | restore-keys: |
43 | ${{ runner.os }}-gradle-
44 |
45 | - uses: actions/cache@v2
46 | with:
47 | path: ~/.gradle/wrapper
48 | key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradlew') }}
49 | restore-keys: |
50 | ${{ runner.os }}-gradlew-
51 |
52 | - name: Build with Gradle
53 | run: ./gradlew build -S
54 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # gradle
2 | .gradle
3 | build/
4 |
5 | # Ignore Gradle GUI config
6 | gradle-app.setting
7 |
8 | # intellij
9 | .idea
10 | out/
11 | *.iml
12 | *.ipr
13 | *.iws
14 |
15 | # eclipse
16 | .project
17 | .classpath
18 | .settings/
19 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contribution Guidelines
2 |
3 | We love to see contributions to the project and have tried to make it easy to
4 | do so, for example by keeping its scope small and the code equally so. If you
5 | wish to contribute code, then please keep to the following guidelines to
6 | ensure consistency within the codebase and that we have happy users.
7 |
8 | ## Conribution License Agreement
9 |
10 | Please make sure to sign the [JSR-377 CLA](https://www.clahub.com/agreements/jsr377/jsr377-api) first if you want to make
11 | any contributions to the specification.
12 |
13 | ## Philosophy
14 |
15 | Our approach to the project is to keep it small and narrowly focused. Expect new
16 | features to be discussed in-depth before being accepted (or rejected).
17 |
18 | ## Documentation
19 |
20 | If you contribute anything that changes the behaviour of the application,
21 | document it in the README! This includes new features, additional variants
22 | of behaviour and breaking changes.
23 |
24 | Make a note of breaking changes in the pull request because they will need
25 | to go into the release notes.
26 |
27 | ## Commit messages
28 |
29 | It may seem anal to request a particular format for commit messages, but these
30 | are a historical record of what's happening in the code base and consistency
31 | makes investigating that history much easier.
32 |
33 | Please follow the advice of the [Phonegap guys](https://github.com/phonegap/phonegap/wiki/Git-Commit-Message-Format)
34 | when crafting commit messages. The advice basically comes down to:
35 |
36 | * First line should be maximum 50 characters long
37 | * It should summarise the change and use imperative present tense
38 | * The rest of the commit message should come after a blank line
39 | * We encourage you to use Markdown syntax in the rest of the commit message
40 | * Preferably keep to an 80 character limit on lines in the rest of the message.
41 |
42 | If a commit is related to a particular issue, put the issue number after a
43 | hash (#) somewhere in the detail. You can put the issue number in the first
44 | line summary, but only if you can also fit in a useful summary of what was
45 | changed in the commit.
46 |
47 | Here's an example git message:
48 |
49 | > Fix UI thread usage document.
50 | >
51 | > Fixes issue #3. The examples for async and sync usages were mixed up.
52 | > Also, fixed a few typos.
53 |
54 | ## Formatting
55 |
56 | The rules are simple: use the same formatting as the rest of the code. The
57 | following is a list of the styles we are particularly particular about:
58 |
59 | * 4 space indent, no tabs
60 | * a space between if/elseif/catch/etc. keywords and the parenthesis
61 | * elseif/else/catch on their own lines
62 |
63 | If in doubt, submit the change and mention in the pull request that you're not
64 | sure about a particular style you used. We'd rather have the contribution and
65 | fix any minor problems than not have the contribution at all.
66 |
67 | Ultimately, be aware that the maintainers don't have much time to dedicate to
68 | processing pull requests, so the less work they have to do the more likely and
69 | quickly they can merge those pull requests in.
70 |
71 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
--------------------------------------------------------------------------------
/README.adoc:
--------------------------------------------------------------------------------
1 | = JSR 377 - Desktop|Embedded Application API
2 | :linkattrs:
3 | :project-owner: jsr377
4 | :project-name: jsr377-api
5 |
6 | Contains the specification and API sources for link:https://jcp.org/en/jsr/detail?id=377[JSR-377].
7 |
8 | image:https://github.com/{project-owner}/{project-name}/workflows/Build/badge.svg["Build Status", link="https://github.com/{project-owner}/{project-name}/actions"]
9 | image:https://badges.gitter.im/Join%20Chat.svg[Gitter, link="https://gitter.im/jsr377/jsr377-api?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge"]
10 | image:http://img.shields.io/badge/license-ASF2-blue.svg["Apache License 2", link="http://www.apache.org/licenses/LICENSE-2.0.txt"]
11 |
12 | == Contributing
13 |
14 | - All contributions made by JSR377 Expert Group members are governed by the JSPA.
15 | - All contributions made by non Expert Group members are governed by the Apache Software License v2.
16 |
17 | If you'd like to join the EG then please send your nomination to link:https://jcp.org/en/jsr/egnom?id=377[https://jcp.org/en/jsr/egnom?id=377, window="_blank"] Please bear in mind that you must be a JCP member and have signed the JSPA. You may require an additional signed Exhibit B depending on your membership type.
18 |
19 | To get started (non-EG contributors), link:https://www.clahub.com/agreements/{project-owner}/jsr377-api[sign the Contributor License Agreement, window="_blank"].
20 |
21 | == Additional resources
22 |
23 | * link:http://jsr377.github.io/site/[JSR377 website, window="_blank"]
24 | * link:http://jsr377-api.40747.n7.nabble.com[Forum / Mailing List, window="_blank"]
25 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | plugins {
19 | id 'org.kordamp.gradle.java-project'
20 | }
21 |
22 | if (!project.hasProperty('sonatypeUsername')) ext.sonatypeUsername = '**undefined**'
23 | if (!project.hasProperty('sonatypePassword')) ext.sonatypePassword = '**undefined**'
24 |
25 | config {
26 | release = (rootProject.findProperty('release') ?: false).toBoolean()
27 |
28 | info {
29 | name = 'jsr377-api'
30 | vendor = 'JSR-377'
31 | description = 'JSR 377 - Desktop|Embedded Application API'
32 | inceptionYear = '2015'
33 | tags = ['desktop', 'java', 'jsr377']
34 |
35 | links {
36 | website = 'https://github.com/jsr377/jsr377-api'
37 | issueTracker = 'https://github.com/jsr377/jsr377-api/issues'
38 | scm = 'https://github.com/jsr377/jsr377-api.git'
39 | }
40 |
41 | people {
42 | person {
43 | id = 'aalmiray'
44 | name = 'Andres Almiray'
45 | roles = ['Spec Lead', 'Developer']
46 | }
47 | }
48 |
49 | specification {
50 | title = 'JSR-377 API'
51 | }
52 |
53 | implementation { enabled = false }
54 |
55 | credentials {
56 | sonatype {
57 | username = project.sonatypeUsername
58 | password = project.sonatypePassword
59 | }
60 | }
61 | }
62 |
63 | licensing {
64 | licenses {
65 | license {
66 | id = 'Apache-2.0'
67 | }
68 | }
69 | }
70 |
71 | stats {
72 | formats = ['xml', 'txt']
73 | }
74 |
75 | docs {
76 | javadoc {
77 | autoLinks {
78 | enabled = false
79 | }
80 | }
81 | }
82 | }
83 |
84 | allprojects {
85 | apply plugin: 'idea'
86 |
87 | repositories {
88 | mavenCentral()
89 | }
90 | }
91 |
92 | idea {
93 | project {
94 | jdkName rootProject.sourceCompatibility
95 | languageLevel rootProject.sourceCompatibility
96 | }
97 | }
98 |
99 | subprojects { subproj ->
100 | plugins.withType(JavaPlugin) {
101 | subproj.tasks.withType(JavaCompile) {
102 | sourceCompatibility = rootProject.sourceCompatibility
103 | targetCompatibility = rootProject.sourceCompatibility
104 | options.compilerArgs = ['-Xlint:all', '-Xlint:deprecation', '-Xlint:unchecked']
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/diagrams/diagrams.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 |
19 | plugins {
20 | id 'org.asciidoctor.jvm.convert'
21 | }
22 |
23 | asciidoctorj {
24 | options doctype: 'book'
25 |
26 | modules {
27 | diagram.use()
28 | diagram.version '2.1.0'
29 | }
30 |
31 | attributes 'source-highlighter' : 'coderay',
32 | 'coderay-linenums-mode' : 'table',
33 | imagesdir : 'images',
34 | toc : 'left',
35 | icon : 'font',
36 | linkattrs : true,
37 | encoding : 'utf-8'
38 | }
39 |
--------------------------------------------------------------------------------
/diagrams/src/docs/asciidoc/index.adoc:
--------------------------------------------------------------------------------
1 | = Document Title
2 |
3 | [ditaa,target="javax/application/application-phases"]
4 | ----
5 | +------------+
6 | | |
7 | | Initialize |--------------+
8 | | | |
9 | +------------+ |
10 | | |
11 | v |
12 | +------------+ |
13 | | | |
14 | | Startup |--------------+
15 | | | |
16 | +------------+ |
17 | | |
18 | v |
19 | +------------+ |
20 | | | |
21 | | Ready |--------------+
22 | | | |
23 | +------------+ |
24 | | |
25 | v v
26 | +------------+ +------------+
27 | | | | |
28 | | Main |------->| Shutdown |
29 | | | | |
30 | +------------+ +------------+
31 | ----
32 |
33 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Copyright 2015-2021 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | version = 1.0.0-SNAPSHOT
20 | group = javax.application
21 | sourceCompatibility = 1.8
22 | targetCompatibility = 1.8
23 |
24 | asciidoctorVersion = 3.3.2
25 | kordampPluginVersion = 0.46.0
26 |
27 | org.gradle.daemon = true
28 | org.gradle.caching = true
29 | org.gradle.parallel = false
30 |
--------------------------------------------------------------------------------
/gradle/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | SPDX-License-Identifier: Apache-2.0
2 |
3 | Copyright ${copyrightYear} the original author or authors.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | http://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jsr377/jsr377-api/b71fc9a6cc8c0b2211b9d37d3a4eb6bde76c7a72/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 |
86 | # Determine the Java command to use to start the JVM.
87 | if [ -n "$JAVA_HOME" ] ; then
88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89 | # IBM's JDK on AIX uses strange locations for the executables
90 | JAVACMD="$JAVA_HOME/jre/sh/java"
91 | else
92 | JAVACMD="$JAVA_HOME/bin/java"
93 | fi
94 | if [ ! -x "$JAVACMD" ] ; then
95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96 |
97 | Please set the JAVA_HOME variable in your environment to match the
98 | location of your Java installation."
99 | fi
100 | else
101 | JAVACMD="java"
102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103 |
104 | Please set the JAVA_HOME variable in your environment to match the
105 | location of your Java installation."
106 | fi
107 |
108 | # Increase the maximum file descriptors if we can.
109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110 | MAX_FD_LIMIT=`ulimit -H -n`
111 | if [ $? -eq 0 ] ; then
112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113 | MAX_FD="$MAX_FD_LIMIT"
114 | fi
115 | ulimit -n $MAX_FD
116 | if [ $? -ne 0 ] ; then
117 | warn "Could not set maximum file descriptor limit: $MAX_FD"
118 | fi
119 | else
120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121 | fi
122 | fi
123 |
124 | # For Darwin, add options to specify how the application appears in the dock
125 | if $darwin; then
126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127 | fi
128 |
129 | # For Cygwin or MSYS, switch paths to Windows format before running java
130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133 |
134 | JAVACMD=`cygpath --unix "$JAVACMD"`
135 |
136 | # We build the pattern for arguments to be converted via cygpath
137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138 | SEP=""
139 | for dir in $ROOTDIRSRAW ; do
140 | ROOTDIRS="$ROOTDIRS$SEP$dir"
141 | SEP="|"
142 | done
143 | OURCYGPATTERN="(^($ROOTDIRS))"
144 | # Add a user-defined pattern to the cygpath arguments
145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147 | fi
148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
149 | i=0
150 | for arg in "$@" ; do
151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153 |
154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156 | else
157 | eval `echo args$i`="\"$arg\""
158 | fi
159 | i=`expr $i + 1`
160 | done
161 | case $i in
162 | 0) set -- ;;
163 | 1) set -- "$args0" ;;
164 | 2) set -- "$args0" "$args1" ;;
165 | 3) set -- "$args0" "$args1" "$args2" ;;
166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
172 | esac
173 | fi
174 |
175 | # Escape application args
176 | save () {
177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178 | echo " "
179 | }
180 | APP_ARGS=`save "$@"`
181 |
182 | # Collect all arguments for the java command, following the shell quoting and substitution rules
183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184 |
185 | exec "$JAVACMD" "$@"
186 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/jsr377-api/gradle.properties:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | # Copyright 2015-2021 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | javaCompatibility = 8
20 | project_description = JSR 377 - Desktop|Embedded Application API
--------------------------------------------------------------------------------
/jsr377-api/jsr377-api.gradle:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | plugins {
19 | id 'java-library'
20 | id 'org.beryx.jar'
21 | }
22 |
23 | evaluationDependsOn(':diagrams')
24 |
25 | task copyDiagrams(type: Copy) {
26 | dependsOn project(':diagrams').asciidoctor
27 | from project(':diagrams').file('build/asciidoc/html5/images')
28 | into javadoc.destinationDir
29 | }
30 |
31 | javadoc.finalizedBy copyDiagrams
32 |
33 | jar {
34 | moduleInfoPath = 'src/main/module/module-info.java'
35 | }
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/Application.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application;
19 |
20 | import javax.application.configuration.Configuration;
21 | import java.util.Locale;
22 |
23 | /**
24 | * @author Andres Almiray
25 | */
26 | public interface Application {
27 | /**
28 | * Lifecycle method. Signals the application to bootstrap itself and load its configuration.
29 | * {@code ApplicationPhase} should be set automatically to {@code ApplicationPhase.INITIALIZE}.
30 | */
31 | void initialize();
32 |
33 | /**
34 | * Lifecycle method. Signals the application to assemble its components/artifacts.
35 | * {@code ApplicationPhase} should be set automatically to {@code ApplicationPhase.STARTUP}.
36 | */
37 | void startup();
38 |
39 | /**
40 | * Lifecycle method. Signals the application to display its main entry point (Window).
41 | * {@code ApplicationPhase} should be set automatically to {@code ApplicationPhase.READY}, followed
42 | * immediately with {@code ApplicationPhase.MAIN} once the ready sequence has finished.
43 | */
44 | void ready();
45 |
46 | /**
47 | * Lifecycle method. Shutdowns the application gracefully.
48 | * {@code ApplicationPhase} should be set automatically to {@code ApplicationPhase.SHUTDOWN}.
49 | *
50 | * @return the exit code that may be sent to the underlying platform process as exit value. Never returns {@code null}.
51 | */
52 | ExitState shutdown();
53 |
54 | /**
55 | * Queries any available {@code ShutdownHandler}s do determine if the application can be shutdown.
56 | *
57 | * @return {@code true} if the shutdown sequence can proceed, (@code false} otherwise
58 | */
59 | boolean canShutdown();
60 |
61 | /**
62 | * Registers a {@code ShutdownHandler} on this application
63 | *
64 | * @param handler the shutdown handler to be registered. Must not be {@code null}.
65 | * Duplicate values must be ignored.
66 | */
67 | void addShutdownHandler(ShutdownHandler handler);
68 |
69 | /**
70 | * Removes a {@code ShutdownHandler} from this application
71 | *
72 | * @param handler the shutdown handler to be removed. Must not be {@code null}.
73 | * Duplicate values must be ignored.
74 | */
75 | void removeShutdownHandler(ShutdownHandler handler);
76 |
77 | /**
78 | * Retrieves the {@code Configuration} of this application.
79 | *
80 | * @return the {@code Configuration} used by this application. Never returns {@code null}.
81 | */
82 | Configuration getConfiguration();
83 |
84 | /**
85 | * Returns the current phase.
86 | *
87 | * @return returns the current {@code ApplicationPhase}. Never returns {@code null}.
88 | */
89 | ApplicationPhase getPhase();
90 |
91 | /**
92 | * Gets the application locale.
93 | *
94 | * @return the current Locale used by the application. Never returns {@code null}.
95 | */
96 | Locale getLocale();
97 |
98 | /**
99 | * Returns the arguments set on the command line (if any).
100 | *
101 | * @return an array of command line arguments. Never returns {@code null}.
102 | */
103 | String[] getStartupArguments();
104 | }
105 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/ApplicationPhase.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application;
19 |
20 | /**
21 | * Defines the application's life-cycle phases.
22 | *
Every instance of {@code javax.application.Application} must follow this life-cycle.
23 | * The life-cycle has few transitions between phases, as shown by the following diagram.
24 | *
25 | *
26 | *
27 | * @author Andres Almiray
28 | */
29 | public enum ApplicationPhase {
30 | /**
31 | * 1st phase. All applications start with this one
32 | */
33 | INITIALIZE,
34 | /**
35 | * 2nd phase. This is where MVC groups are created
36 | */
37 | STARTUP,
38 | /**
39 | * 3rd phase. Called after main window is shown
40 | */
41 | READY,
42 | /**
43 | * Main phase.
44 | */
45 | MAIN,
46 | /**
47 | * Last phase.
48 | */
49 | SHUTDOWN
50 | }
51 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/ExceptionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application;
19 |
20 | /**
21 | * {@code ExceptionHandler} is responsible for handling exceptions and throwables in a centralized manner.
22 | *
23 | * @author Andres Almiray
24 | */
25 | public interface ExceptionHandler {
26 | /**
27 | * Processes a {@code Throwable} thrown by application code but that was not caught earlier.
28 | * Implementors must guarantee that no further exceptions or throwables will be thrown
29 | * from this method.
30 | *
31 | * @param thread the {@code Thread} on which the throwable was thrown. Must not be {@code null}.
32 | * @param throwable an uncaught throwable. Must not be {@code null}.
33 | */
34 | void handleUncaught(Thread thread, Throwable throwable);
35 | }
36 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/ExitState.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application;
19 |
20 | /**
21 | * @author Andres Almiray
22 | */
23 | public interface ExitState {
24 | /**
25 | * Returns the integer value for this code.
26 | *
27 | * @return an integer.
28 | */
29 | int exitCode();
30 |
31 | /**
32 | * Finds out if this exit code is allowed to shutdown the application.
33 | *
34 | * @return {@code true} if the application can shutdown, {@code false} otherwise.
35 | */
36 | default boolean canShutdown() {
37 | return true;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/ShutdownHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application;
19 |
20 | /**
21 | * @author Andres Almiray
22 | */
23 | public interface ShutdownHandler {
24 | /**
25 | * Asks this handler if the application's shutdown sequence can proceed or not.
26 | * Returns {@code false} if the shutdown sequence must be aborted.
27 | *
28 | * @param application the current running application. Must not be {@code null}.
29 | *
30 | * @return {@code true} if the shutdown sequence can proceed, {@code false} otherwise
31 | */
32 | default boolean canShutdown(Application application) {
33 | return true;
34 | }
35 |
36 | /**
37 | * Called when the shutdown sequence continues.
38 | *
39 | * @param application the current running application. Must not be {@code null}.
40 | */
41 | void onShutdown(Application application);
42 | }
43 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/action/AbortActionExecution.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.action;
19 |
20 | /**
21 | * Marker Exception used to abort execution of a controller action during the
22 | * BEFORE phase of a ActionHandler.
23 | *
24 | * @author Andres Almiray
25 | */
26 | public class AbortActionExecution extends RuntimeException {
27 | private static final long serialVersionUID = -8090900669443696189L;
28 | }
29 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/action/Action.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.action;
19 |
20 | /**
21 | * @author Andres Almiray
22 | */
23 | public interface Action {
24 | String PROPERTY_ID= "id";
25 | String PROPERTY_NAME = "name";
26 | String PROPERTY_ENABLED = "enabled";
27 |
28 | /**
29 | * Returns the metadata associated with this action.
30 | *
31 | * @return a non-null value.
32 | */
33 | ActionMetadata getActionMetadata();
34 |
35 | /**
36 | * Returns the owner of this action, this will typically be a (@code Controller} or {@code Presenter}.
37 | *
38 | * @return a non-null value.
39 | */
40 | Object getOwner();
41 |
42 | /**
43 | * Returns the id of this action.
44 | * The value for this property must not be null.
45 | *
46 | * @return the id of this action.
47 | */
48 | String getId();
49 |
50 | /**
51 | * Sets the id of this action.
52 | *
53 | * @param id the id of this action. Must not be {@code null}, empty, nor blank.
54 | */
55 | void setId(String id);
56 |
57 | /**
58 | * Returns the name of this action.
59 | * The value for this property may be empty but not null.
60 | *
61 | * @return the name of this action.
62 | */
63 | String getName();
64 |
65 | /**
66 | * Sets the name of this action.
67 | *
68 | * @param name the name of this action. Must not be {@code null} but may be emtpy.
69 | */
70 | void setName(String name);
71 |
72 | /**
73 | * Finds ouf if this action is enabled or not.
74 | *
75 | * @return {@code true} if the action is enabled, {@code false} otherwise.
76 | */
77 | boolean isEnabled();
78 |
79 | /**
80 | * Toggles the enabled tate of this action.
81 | *
82 | * @param enabled {@code true} to enabled, {@code false} to disable.
83 | */
84 | void setEnabled(boolean enabled);
85 |
86 | /**
87 | * Executes the action with the given arguments.
88 | * Executing an action in this way will trigger all {@code ActionHandler}s that may be registered with the application.
89 | *
90 | * @param args a set of arguments. Mey be {@code null}.
91 | */
92 | void execute(Object... args);
93 | }
94 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/action/ActionExecutionStatus.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.action;
19 |
20 | /**
21 | * @author Andres Almiray
22 | */
23 | public enum ActionExecutionStatus {
24 | /**
25 | * The Action was successfully executed
26 | */
27 | OK,
28 |
29 | /**
30 | * An action interceptor aborted execution during before()
31 | */
32 | ABORTED,
33 |
34 | /**
35 | * The Action threw an exception during its execution
36 | */
37 | EXCEPTION
38 | }
39 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/action/ActionHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.action;
19 |
20 | import java.lang.annotation.Documented;
21 | import java.lang.annotation.ElementType;
22 | import java.lang.annotation.Inherited;
23 | import java.lang.annotation.Retention;
24 | import java.lang.annotation.RetentionPolicy;
25 | import java.lang.annotation.Target;
26 |
27 | /**
28 | * @author Andres Almiray
29 | */
30 | @Documented
31 | @Inherited
32 | @Retention(RetentionPolicy.RUNTIME)
33 | @Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD})
34 | public @interface ActionHandler {
35 | /**
36 | * Defines the action's id.
37 | */
38 | String value() default "";
39 |
40 | /**
41 | * Defines the action's name.
42 | */
43 | String name() default "";
44 |
45 | /**
46 | * Defines the action's enabled state.
47 | */
48 | boolean enabled() default true;
49 | }
50 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/action/ActionInterceptor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.action;
19 |
20 | import java.lang.reflect.Method;
21 |
22 | /**
23 | * @author Andres Almiray
24 | */
25 | public interface ActionInterceptor {
26 | /**
27 | * Update the action's properties.
28 | *
29 | * @param action the action to be updated. Must not be {@code null}.
30 | */
31 | void update(Action action);
32 |
33 | /**
34 | * Inspect the action during the configuration phase.
35 | *
36 | * This is the perfect time to search for annotations or any other information
37 | * required by the action. interceptors have the option to cache such inspections
38 | * and recall them during {@code before()}, {@code after()} and {@code exception()}.
39 | *
40 | * @param action the action to be configured. Must not be {@code null}.
41 | * @param method the method that represents the action itself. Must not be {@code null}.
42 | */
43 | void configure(Action action, Method method);
44 |
45 | /**
46 | * Called before an action is executed.
47 | *
48 | * Implementors have the choice of throwing an {@code AbortActionExecution} in
49 | * order to signal that the action should not be invoked. In any case this method
50 | * returns the arguments to be sent to the action, thus allowing the action interceptor
51 | * to modify the arguments as it deem necessary. Failure to return an appropriate
52 | * value will most likely cause an error during the action's execution.
53 | *
54 | * @param action the action to execute. Must not be {@code null}.
55 | * @param args the action's arguments. Must not be {@code null}.
56 | *
57 | * @return arguments to be sent to the action
58 | *
59 | * @throws AbortActionExecution if action execution should be aborted.
60 | */
61 | Object[] before(Action action, Object[] args);
62 |
63 | /**
64 | * Called after the action has been aborted or executed, even if an exception
65 | * occurred during execution.
66 | *
67 | *
68 | * @param status a flag that indicates the execution status of the action. Must not be {@code null}.
69 | * @param action the action to execute. Must not be {@code null}.
70 | * @param args the arguments sent to the action. Must not be {@code null}.
71 | * @param result the result of executing the action. May be {@code null}.
72 | */
73 | Object after(ActionExecutionStatus status, Action action, Object[] args, Object result);
74 |
75 | /**
76 | * Called after the action has been executed, when an exception occurred
77 | * during execution.
78 | *
79 | * The exception must be rethrown if was not handled by any action interceptor.
80 | *
81 | * @param exception the exception thrown during the action's execution. Must not be {@code null}.
82 | * @param action the action to execute. Must not be {@code null}.
83 | * @param args the arguments sent to the action during execution. Must not be {@code null}.
84 | *
85 | * @return {@code true} if the exception was handled successfully,
86 | * {@code false} otherwise.
87 | */
88 | boolean exception(Exception exception, Action action, Object[] args);
89 | }
90 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/action/ActionMetadata.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.action;
19 |
20 | import java.lang.annotation.Annotation;
21 |
22 | /**
23 | * @author Andres Almiray
24 | */
25 | public interface ActionMetadata {
26 | /**
27 | * Returns the set of annotations attached to the method related to an action.
28 | *
29 | * @return a non-null array of annotations.
30 | */
31 | Annotation[] getAnnotations();
32 |
33 | /**
34 | * Returns the type associated with the method related to an action.
35 | *
36 | * @return a non-null type.
37 | */
38 | Class> getReturnType();
39 |
40 | /**
41 | * Returns the set of parameters of the method related to an action.
42 | *
43 | * @return a non-null array of parameters.
44 | */
45 | ActionParameter[] getParameters();
46 |
47 | /**
48 | * Returns the id for the action.
49 | * This value is computed from the name of the method associated with an action.
50 | * Example, invoking this method returns "{@code click}" given an action defined as follows:
51 | *
61 | *
62 | * @return a non-null name.
63 | */
64 | String getActionId();
65 |
66 | /**
67 | * Returns the simple name for the action.
68 | * This value is computed from the name of the method associated with an action.
69 | * Example, invoking this method returns "{@code click}" given an action defined as follows:
70 | *
80 | *
81 | * The computed value may be overridden by supplying a different value to the {@code name} attribute
82 | * of the {@code @ActionHandler} annotation, in the following example the result of invoking this method
83 | * is "{@code clickAndGo}"
84 | *
94 | *
95 | * @return a non-null name.
96 | */
97 | String getActionName();
98 |
99 | /**
100 | * Returns the name of the action with the fully qualified class name of its owner as prefix.
101 | * Example, invoking this method returns "{@code org.example.SampleController.click}" given an action defined as follows:
102 | *
113 | *
114 | * @return a non-null name.
115 | */
116 | String getFullyQualifiedName();
117 |
118 | /**
119 | * Finds out if there are any contextual arguments defined in the method's arguments.
120 | *
121 | * @return {@code true} if any parameter is annotated with {@code Contextual}, {@code false} otherwise.
122 | */
123 | boolean hasContextualArgs();
124 | }
125 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/action/ActionParameter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.action;
19 |
20 | import java.lang.annotation.Annotation;
21 |
22 | /**
23 | * @author Andres Almiray
24 | */
25 | public interface ActionParameter {
26 | /**
27 | * Returns the index of this parameter in the array of parameters for an action.
28 | *
29 | * @return a number equal or greater than {@code 0}.
30 | */
31 | int getIndex();
32 |
33 | /**
34 | * Returns the set of annotations attached to parameter.
35 | *
36 | * @return a non-null array of annotations.
37 | */
38 | Annotation[] getAnnotations();
39 |
40 | /**
41 | * Returns the type of this parameter.
42 | *
43 | * @return a non-null type.
44 | */
45 | Class> getType();
46 |
47 | /**
48 | * Returns the name of this parameter.
49 | *
50 | * @return a non-null name.
51 | */
52 | String getName();
53 |
54 | /**
55 | * Finds out if this parameter is a contextual one, ie., it's annotated with {@code Contextual}.
56 | *
57 | * @return {@code true} if annotated with {@code Contextual}, {@code false} otherwise.
58 | */
59 | boolean isContextual();
60 |
61 | /**
62 | * Finds out if this parameter accepts null values.
63 | *
64 | * @return {@code true} if annotated with an implementation specific qualifier that identifies this parameter as nullable,
65 | * {@code false} otherwise.
66 | */
67 | boolean isNullable();
68 | }
69 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/action/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.action;
19 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/configuration/Configuration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.configuration;
19 |
20 | /**
21 | * @author Andres Almiray
22 | */
23 | public interface Configuration {
24 | /**
25 | * Searches for the key in this configuration.
26 | *
27 | * @param key the key to search. Must not be {@code null}.
28 | *
29 | * @return {@code true} if the context (or its parent) contains the given key, {@code false} otherwise.
30 | */
31 | boolean containsKey(String key);
32 |
33 | /**
34 | * /**
35 | * Finds a value associated with the given key. The value is
36 | * blindly cast to type {@code T} if found.
37 | *
38 | * @param key the key to search. Must not be {@code null}.
39 | *
40 | * @return the value associated with {@code key}, {@code null} otherwise.
41 | *
42 | * @throws ClassCastException if the value is not of the expected type.
43 | */
44 | T get(String key);
45 |
46 | /**
47 | * Finds a value associated with the given key. The value is
48 | * blindly cast to type {@code T} if found. If not found then the
49 | * supplied {@code defaultValue} will be returned.
50 | *
51 | * @param key the key to search. Must not be {@code null}.
52 | * @param defaultValue the value to be returned if the key is not found. May be {@code null}.
53 | *
54 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
55 | *
56 | * @throws ClassCastException if the value is not of the expected type.
57 | */
58 | T get(String key, T defaultValue);
59 |
60 | /**
61 | * Finds a value associated with the given key. The value is
62 | * converted to a {@code boolean} if found.
63 | *
64 | * @param key the key to search. Must not be {@code null}.
65 | *
66 | * @return the value associated with {@code key}, or {@code false} if it was not found.
67 | *
68 | * @throws javax.application.converter.ConversionException if the resource could not be converted to a {@code boolean}.
69 | */
70 | boolean getAsBoolean(String key);
71 |
72 | /**
73 | * Finds a value associated with the given key. The value is
74 | * converted to a {@code boolean} if found. If not found then the
75 | * supplied {@code defaultValue} will be returned.
76 | *
77 | * @param key the key to search. Must not be {@code null}.
78 | * @param defaultValue the value to be returned if the key is not found.
79 | *
80 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
81 | *
82 | * @throws javax.application.converter.ConversionException if the resource could not be converted to a {@code boolean}.
83 | */
84 | boolean getAsBoolean(String key, boolean defaultValue);
85 |
86 | /**
87 | * Finds a value associated with the given key. The value is
88 | * converted to an {@code int} if found.
89 | *
90 | * @param key the key to search. Must not be {@code null}.
91 | *
92 | * @return the value associated with {@code key}, or {@code 0} if it was not found.
93 | *
94 | * @throws javax.application.converter.ConversionException if the resource could not be converted to an {@code int}.
95 | */
96 | int getAsInt(String key);
97 |
98 | /**
99 | * Finds a value associated with the given key. The value is
100 | * converted to an {@code int} if found. If not found then the
101 | * supplied {@code defaultValue} will be returned.
102 | *
103 | * @param key the key to search. Must not be {@code null}.
104 | * @param defaultValue the value to be returned if the key is not found.
105 | *
106 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
107 | *
108 | * @throws javax.application.converter.ConversionException if the resource could not be converted to an {@code int}.
109 | */
110 | int getAsInt(String key, int defaultValue);
111 |
112 | /**
113 | * Finds a value associated with the given key. The value is
114 | * converted to a {@code long} if found.
115 | *
116 | * @param key the key to search. Must not be {@code null}.
117 | *
118 | * @return the value associated with {@code key}, or {@code 0L} if it was not found.
119 | *
120 | * @throws javax.application.converter.ConversionException if the resource could not be converted to a {@code long}.
121 | */
122 | long getAsLong(String key);
123 |
124 | /**
125 | * Finds a value associated with the given key. The value is
126 | * converted to a {@code long} if found. If not found then the
127 | * supplied {@code defaultValue} will be returned.
128 | *
129 | * @param key the key to search. Must not be {@code null}.
130 | * @param defaultValue the value to be returned if the key is not found.
131 | *
132 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
133 | *
134 | * @throws javax.application.converter.ConversionException if the resource could not be converted to a {@code long}.
135 | */
136 | long getAsLong(String key, long defaultValue);
137 |
138 | /**
139 | * Finds a value associated with the given key. The value is
140 | * converted to a {@code float} if found.
141 | *
142 | * @param key the key to search. Must not be {@code null}.
143 | *
144 | * @return the value associated with {@code key}, or {@code 0.0f} if it was not found.
145 | *
146 | * @throws javax.application.converter.ConversionException if the resource could not be converted to a {@code float}.
147 | */
148 | float getAsFloat(String key);
149 |
150 | /**
151 | * Finds a value associated with the given key. The value is
152 | * converted to a {@code float} if found. If not found then the
153 | * supplied {@code defaultValue} will be returned.
154 | *
155 | * @param key the key to search. Must not be {@code null}.
156 | * @param defaultValue the value to be returned if the key is not found.
157 | *
158 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
159 | *
160 | * @throws javax.application.converter.ConversionException if the resource could not be converted to a {@code float}.
161 | */
162 | float getAsFloat(String key, float defaultValue);
163 |
164 | /**
165 | * Finds a value associated with the given key. The value is
166 | * converted to a {@code double} if found.
167 | *
168 | * @param key the key to search. Must not be {@code null}.
169 | *
170 | * @return the value associated with {@code key}, or {@code 0.0d} if it was not found.
171 | *
172 | * @throws javax.application.converter.ConversionException if the resource could not be converted to a {@code double}.
173 | */
174 | double getAsDouble(String key);
175 |
176 | /**
177 | * Finds a value associated with the given key. The value is
178 | * converted to a {@code double} if found. If not found then the
179 | * supplied {@code defaultValue} will be returned.
180 | *
181 | * @param key the key to search. Must not be {@code null}.
182 | * @param defaultValue the value to be returned if the key is not found.
183 | *
184 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
185 | *
186 | * @throws javax.application.converter.ConversionException if the resource could not be converted to a {@code double}.
187 | */
188 | double getAsDouble(String key, double defaultValue);
189 |
190 | /**
191 | * Finds a value associated with the given key. The value is
192 | * converted to a {@code String} if found.
193 | *
194 | * @param key the key to search. Must not be {@code null}.
195 | *
196 | * @return the literal value associated with {@code key}, or {@code null} if it was not found.
197 | */
198 | String getAsString(String key);
199 |
200 | /**
201 | * Finds a value associated with the given key. The value is
202 | * converted to a {@code String} if found. If not found then the
203 | * supplied {@code defaultValue} will be returned.
204 | *
205 | * @param key the key to search. Must not be {@code null}.
206 | * @param defaultValue the value to be returned if the key is not found. May be {@code null}.
207 | *
208 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
209 | */
210 | String getAsString(String key, String defaultValue);
211 |
212 | /**
213 | * Finds a value associated with the given key. The value is
214 | * converted to type {@code T} if found using a {@code Converter}.
215 | *
216 | * @param key the key to search. Must not be {@code null}.
217 | * @param type the type to be returned. Must not be {@code null}.
218 | *
219 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
220 | *
221 | * @throws javax.application.converter.ConversionException if the resource could not be converted to the target type {@code T}.
222 | */
223 | T getConverted(String key, Class type);
224 |
225 | /**
226 | * Finds a value associated with the given key. The value is
227 | * converted to type {@code T}if found using a {@code Converter}.
228 | *
229 | * @param key the key to search. Must not be {@code null}.
230 | * @param type the type to be returned. Must not be {@code null}.
231 | * @param format format used to convert the value. Must not be {@code null}.
232 | *
233 | * @return the value associated with {@code key}, {@code null} otherwise.
234 | *
235 | * @throws javax.application.converter.ConversionException if the resource could not be converted to the target type {@code T}.
236 | */
237 | T getConverted(String key, Class type, String format);
238 |
239 | /**
240 | * Finds a value associated with the given key. The value is
241 | * converted to type {@code T} if found using a {@code Converter}.
242 | * If not found then the supplied {@code defaultValue} will be returned.
243 | *
244 | * @param key the key to search. Must not be {@code null}.
245 | * @param type the type to be returned. Must not be {@code null}.
246 | * @param defaultValue the value to be returned if the key is not found. May be {@code null}.
247 | *
248 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
249 | *
250 | * @throws javax.application.converter.ConversionException if the resource could not be converted to the target type {@code T}.
251 | */
252 | T getConverted(String key, Class type, T defaultValue);
253 |
254 | /**
255 | * Finds a value associated with the given key. The value is
256 | * converted to type {@code T} if found using a {@code Converter}.
257 | * If not found then the supplied {@code defaultValue} will be returned.
258 | *
259 | * @param key the key to search. Must not be {@code null}.
260 | * @param type the type to be returned. Must not be {@code null}.
261 | * @param format format used to convert the value. Must not be {@code null}.
262 | * @param defaultValue the value to be returned if the key is not found. May be {@code null}.
263 | *
264 | * @return the value associated with {@code key}, or {@code defaultValue} if it was not found.
265 | *
266 | * @throws javax.application.converter.ConversionException if the resource could not be converted to the target type {@code T}.
267 | */
268 | T getConverted(String key, Class type, String format, T defaultValue);
269 | }
270 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/configuration/Configured.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.configuration;
19 |
20 | import javax.application.converter.Converter;
21 | import javax.application.converter.NoopConverter;
22 | import java.lang.annotation.Documented;
23 | import java.lang.annotation.ElementType;
24 | import java.lang.annotation.Inherited;
25 | import java.lang.annotation.Retention;
26 | import java.lang.annotation.RetentionPolicy;
27 | import java.lang.annotation.Target;
28 |
29 | /**
30 | * @author Andres Almiray
31 | */
32 | @Documented
33 | @Inherited
34 | @Retention(RetentionPolicy.RUNTIME)
35 | @Target({ElementType.FIELD, ElementType.METHOD})
36 | public @interface Configured {
37 | String NO_VALUE = "javax.application.configuration.Configured.NO_VALUE";
38 |
39 | String value();
40 |
41 | String[] args() default {};
42 |
43 | String defaultValue() default NO_VALUE;
44 |
45 | String format() default "";
46 |
47 | Class extends Converter>> converter() default NoopConverter.class;
48 |
49 | String configuration() default "";
50 | }
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/configuration/package-info.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.configuration;
19 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/converter/ConversionException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.converter;
19 |
20 | /*
21 | * @author Andres Almiray
22 | */
23 | public class ConversionException extends RuntimeException {
24 | private static final long serialVersionUID = -9122143348121235390L;
25 |
26 | private final transient Object value;
27 | private Class> type;
28 |
29 | public ConversionException(Object value) {
30 | this(value, (Exception) null);
31 | }
32 |
33 | public ConversionException(Object value, Class> type) {
34 | this(value, type, null);
35 | }
36 |
37 | public ConversionException(Object value, Class> type, Exception cause) {
38 | super("Can't convert '" + value + "' into " + type.getName(), cause);
39 | this.value = value;
40 | this.type = type;
41 | }
42 |
43 | public ConversionException(Object value, Exception cause) {
44 | super("Can't convert '" + value + "'", cause);
45 | this.value = value;
46 | }
47 |
48 | public Object getValue() {
49 | return value;
50 | }
51 |
52 | public Class> getType() {
53 | return type;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/converter/Converter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.converter;
19 |
20 | import java.util.Objects;
21 |
22 | /**
23 | * @author Andres Almiray
24 | */
25 | public interface Converter {
26 | /**
27 | * Converts the input argument to the given type {@code T}.
28 | *
29 | * @param value the value to be converted. May be {@code null}.
30 | *
31 | * @return the converted value. May be {@code null}.
32 | *
33 | * @throws ConversionException if the given value could not be converted to the target type.
34 | */
35 | T fromObject(Object value) throws ConversionException;
36 |
37 | /**
38 | * Converts the input argument to the a {@code String}.
39 | *
40 | * @param value the value to be converted. May be {@code null}.
41 | *
42 | * @return the {@code String} representation of the given value. May be {@code null}.
43 | *
44 | * @throws ConversionException if the given value could not be converted to a String.
45 | */
46 | default String toString(T value) throws ConversionException {
47 | return Objects.toString(value, null);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/converter/ConverterRegistry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.converter;
19 |
20 | /**
21 | * The ConverterRegistry can be used to locate a converter for
22 | * any given type name. Converters must support the
23 | * {@code javax.application.converter.Converter} interface for converting a given value.
24 | *
25 | *
26 | * @author Andres Almiray
27 | */
28 | public interface ConverterRegistry {
29 | /**
30 | * Registers a converter class used to convert values of the given target class.
31 | *
32 | * @param targetType the class object of the type to be converted. Must not be {@code null}
33 | * @param converterClass the class object of the converter class. Must not be {@code null}
34 | */
35 | void registerConverter(Class targetType, Class extends Converter> converterClass);
36 |
37 | /**
38 | * Unregisters a converter class used to convert values of the given target class.
39 | * If the given {@code converterClass} is {@code null} then all registrations matching {@code targetType}
40 | * are removed.
41 | *
42 | * @param targetType the class object of the type to be converted. Must not be {@code null}
43 | * @param converterClass the class object of the converter class. May be {@code null}
44 | */
45 | void unregisterConverter(Class targetType, Class extends Converter> converterClass);
46 |
47 | /**
48 | * Locates a value converter for a given target type.
49 | *
50 | * @param targetType The Class object for the type to be converter. Must not be {@code null}
51 | *
52 | * @return A converter object for the given target class.
53 | * The result is {@code null} if no suitable converter can be found.
54 | */
55 | Converter findConverter(Class targetType);
56 |
57 | /**
58 | * Removes all currently registered converters.
59 | */
60 | void clear();
61 | }
62 |
--------------------------------------------------------------------------------
/jsr377-api/src/main/java/javax/application/converter/NoopConverter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * SPDX-License-Identifier: Apache-2.0
3 | *
4 | * Copyright 2015-2021 the original author or authors.
5 | *
6 | * Licensed under the Apache License, Version 2.0 (the "License");
7 | * you may not use this file except in compliance with the License.
8 | * You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package javax.application.converter;
19 |
20 | /**
21 | * A {@code Converter} that performs no cconversion; it simply returns the given value as is.
22 | *
23 | * @author Andres Almiray
24 | */
25 | public class NoopConverter implements Converter