-
Notifications
You must be signed in to change notification settings - Fork 180
Bundle jersey-cdi-rs-inject to allow @Inject of Jakarta REST artifacts #26079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
ee83f15
9a25a00
ea967ce
058a1cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,19 @@ | ||
| // | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't add copyright headers to adoc files, please remove this header. |
||
| // Copyright (c) 2026 Contributors to the Eclipse Foundation | ||
| // | ||
| // This program and the accompanying materials are made available under the | ||
| // terms of the Eclipse Public License v. 2.0, which is available at | ||
| // http://www.eclipse.org/legal/epl-2.0. | ||
| // | ||
| // This Source Code may also be made available under the following Secondary | ||
| // Licenses when the conditions for such availability set forth in the | ||
| // Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||
| // version 2 with the GNU Classpath Exception, which is available at | ||
| // https://www.gnu.org/software/classpath/license.html. | ||
| // | ||
| // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
| // | ||
|
|
||
| type=page | ||
| status=published | ||
| title=Developing Web Applications | ||
|
|
@@ -1362,6 +1378,67 @@ https://docs.cometd.org/current/reference/#_bayeux[Bayeux Protocol] | |
| For more information about the Dojo toolkit, see | ||
| `http://dojotoolkit.org/`. | ||
|
|
||
| [[using-jakarta-rest]] | ||
|
|
||
| === Using Jakarta REST | ||
|
|
||
| {productName} implements https://jakarta.ee/specifications/restful-ws/[Jakarta REST] | ||
| with https://eclipse-ee4j.github.io/jersey/[Eclipse Jersey]. | ||
|
|
||
| [[injecting-jakarta-rest-artifacts-with-cdi]] | ||
|
|
||
| ==== Injecting Jakarta REST Artifacts with CDI | ||
|
|
||
| The Jakarta REST specification requires injection of REST artifacts such as | ||
| `UriInfo`, `Sse`, `SecurityContext`, `HttpHeaders`, `Request` or `Providers` | ||
| via the `@Context` annotation. The `@Context` annotation is deprecated since | ||
| Jakarta REST 3.1 in favor of a future alignment with CDI. | ||
|
|
||
| As an extension to the specification, {productName} bundles the Jersey module | ||
| `jersey-cdi-rs-inject`, which already allows injecting these artifacts with the | ||
| standard CDI `@Inject` annotation: | ||
|
|
||
| [source,java] | ||
| ---- | ||
| import jakarta.inject.Inject; | ||
| import jakarta.ws.rs.Path; | ||
| import jakarta.ws.rs.core.UriInfo; | ||
| import jakarta.ws.rs.sse.Sse; | ||
|
|
||
| @Path("example") | ||
| public class ExampleResource { | ||
|
|
||
| @Inject | ||
| private UriInfo uriInfo; | ||
|
|
||
| @Inject | ||
| private Sse sse; | ||
|
|
||
| // ... | ||
| } | ||
| ---- | ||
|
|
||
| Unlike `@Context`, which for resources managed by CDI or Enterprise Beans is | ||
| only supported on fields and bean properties, `@Inject` also works for | ||
| constructor injection, following the usual CDI rules: | ||
|
|
||
| [source,java] | ||
| ---- | ||
| @Path("example") | ||
| @ApplicationScoped | ||
| public class ExampleResource { | ||
|
|
||
| private final Sse sse; | ||
|
|
||
| @Inject | ||
| public ExampleResource(Sse sse) { | ||
| this.sse = sse; | ||
| } | ||
|
|
||
| // ... | ||
| } | ||
| ---- | ||
|
|
||
| [[advanced-web-application-features]] | ||
|
|
||
| === Advanced Web Application Features | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,19 @@ | ||||||
| // | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't add copyright headers to adoc files, please remove this header. |
||||||
| // Copyright (c) 2026 Contributors to the Eclipse Foundation | ||||||
| // | ||||||
| // This program and the accompanying materials are made available under the | ||||||
| // terms of the Eclipse Public License v. 2.0, which is available at | ||||||
| // http://www.eclipse.org/legal/epl-2.0. | ||||||
| // | ||||||
| // This Source Code may also be made available under the following Secondary | ||||||
| // Licenses when the conditions for such availability set forth in the | ||||||
| // Eclipse Public License v. 2.0 are satisfied: GNU General Public License, | ||||||
| // version 2 with the GNU Classpath Exception, which is available at | ||||||
| // https://www.gnu.org/software/classpath/license.html. | ||||||
| // | ||||||
| // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||||||
| // | ||||||
|
|
||||||
| type=page | ||||||
| status=published | ||||||
| title={productName} {product-majorVersion} Release Notes | ||||||
|
|
@@ -67,6 +83,7 @@ Key new features in {productName} {product-majorVersion} include: | |||||
| * xref:embedded-server-guide.adoc#running-from-command-line[Runnable Embedded GlassFish JAR] (since {productName} 7.0.18) | ||||||
| * xref:administration-guide.adoc#log-executed-admin-commands[Admin Command Logger] (since {productName} 7.0.16) | ||||||
| * https://github.com/eclipse-ee4j/glassfish/discussions/25343[SSH nodes on Windows] via the native Windows SSH service (since {productName} 7.0.23) | ||||||
| * xref:application-development-guide.adoc#injecting-jakarta-rest-artifacts-with-cdi[CDI injection of Jakarta REST artifacts] using `@Inject` via the bundled Jersey `jersey-cdi-rs-inject` extension (since {productName} {product-majorVersion}.0.4) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Version 8.0.4 should never change, while {product-majorVersion} will change when Glassfish 9 is released.
Suggested change
|
||||||
|
|
||||||
| For a complete list of the Jakarta EE technologies included in {productName} {product-currentVersion}, | ||||||
| see xref:#jakarta-ee-support[Jakarta EE Standards Support]. | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really needed, @dmatej ? Do we use this runner nowadays?