1
+ <?xml version =" 1.0" ?>
2
+ <!--
3
+
4
+ Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved.
5
+
6
+ This program and the accompanying materials are made available under the
7
+ terms of the Eclipse Public License v. 2.0, which is available at
8
+ http://www.eclipse.org/legal/epl-2.0.
9
+
10
+ This Source Code may also be made available under the following Secondary
11
+ Licenses when the conditions for such availability set forth in the
12
+ Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
13
+ version 2 with the GNU Classpath Exception, which is available at
14
+ https://www.gnu.org/software/classpath/license.html.
15
+
16
+ SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
17
+
18
+ -->
19
+
20
+ <!DOCTYPE chapter [<!ENTITY % ents SYSTEM " jersey.ent" > %ents; ]>
21
+ <chapter xmlns =" http://docbook.org/ns/docbook"
22
+ version =" 5.0"
23
+ xml : lang =" en"
24
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
25
+ xmlns : xi =" http://www.w3.org/2001/XInclude"
26
+ xmlns : xlink =" http://www.w3.org/1999/xlink"
27
+ xsi : schemaLocation =" http://docbook.org/ns/docbook http://docbook.org/xml/5.0/xsd/docbook.xsd
28
+ http://www.w3.org/1999/xlink http://www.w3.org/1999/xlink.xsd"
29
+ xml : id =" jersey-configuration" >
30
+ <title >Jersey configuration</title >
31
+ <para >
32
+ This chapter provides Jersey configuration basics which includes configuration using default configuration
33
+ provider (included in Jersey by default) using system properties. And micro-profile configuration extension
34
+ which allows plugging-in of configuration modules based on micro profile configuration specification
35
+ </para >
36
+ <section xml : id =" default-config" >
37
+ <title >Jersey default configuration provider</title >
38
+ <para >
39
+ Since Jersey 2.29 it is possible to turn on the ability to convert the System properties into
40
+ Configuration properties. That can be done by using the System property, too:
41
+ <programlisting language =" bash" linenumbering =" unnumbered" >java -Djersey.config.allowSystemPropertiesProvider=true -DNAME=VALUE
42
+ </programlisting >
43
+ Note that with the security manager turned on, write access permission is required to execute
44
+ System.getProperties(). With insufficient permissions, the warning message is logged (with Level.FINER) and
45
+ only &jersey.common.CommonProperties; , &jersey.client.ClientProperties; ,
46
+ and &jersey.server.ServerProperties;
47
+ properties are used, as the property names are known and System.getProperty(name) method can be used,
48
+ which does not require the write access permission.
49
+ </para >
50
+ </section >
51
+ <section xml : id =" mp-config" >
52
+ <title >Micro profile configuration provider</title >
53
+ <para >
54
+ Microprofile platform became very popular lately and µprofile.spec.link;
55
+ is a recommended way in the Jakarta EE world to configure the specifications under the Jakarta EE umbrella.
56
+ </para >
57
+ <para >
58
+ Jersey 2.29 comes with support for Microprofile Config implementation such as &helidon.link; or &smallrye.link; .
59
+ To configure the Jersey application, the microprofile-config.properties file needs to be created in the
60
+ META-INF folder. The required properties are then simply set in the microprofile-config.properties:
61
+ <programlisting language =" java" linenumbering =" unnumbered" >
62
+ NAME=VALUE
63
+ </programlisting >
64
+ </para >
65
+ <para >
66
+ Then Jersey Microprofile Config extension is needed to be added:
67
+ <programlisting language =" xml" linenumbering =" unnumbered" >
68
+ < dependency>
69
+ < groupId>org.glassfish.jersey.ext.microprofile< /groupId>
70
+ < artifactId>jersey-mp-config< /artifactId>
71
+ < version>2.30< /scope>
72
+ < /dependency>
73
+ </programlisting >
74
+ And the Microprofile Config implementation, such as Helidon:
75
+ <programlisting language =" xml" linenumbering =" unnumbered" >
76
+ < dependency>
77
+ < groupId>io.helidon.microprofile.config< /groupId>
78
+ < artifactId>helidon-microprofile-config< /artifactId>
79
+ < version>1.3.1< /version>
80
+ < /dependency>
81
+ </programlisting >
82
+ Or SmallRye:
83
+ <programlisting language =" xml" linenumbering =" unnumbered" >
84
+ < dependency>
85
+ < groupId>io.smallrye< /groupId>
86
+ < artifactId>smallrye-config< /artifactId>
87
+ < version>1.3.6< /version>
88
+ < /dependency>
89
+ </programlisting >
90
+ or any other suitable Microprofile Config implementation.
91
+ </para >
92
+ </section >
93
+ </chapter >
0 commit comments