Skip to content

Commit f85b3b6

Browse files
authored
XCOMMONS-2777: Add support for jakarta.inject annotations (#1075)
XCOMMONS-2797: Allow accessing a javax.inject.Provider as a jakarta.inject.Provider and the opposite XCOMMONS-2963: Upgrade to Servlet 5.0 XCOMMONS-2962: Provide a javax/jakarta bridge for Servlet APIs XCOMMONS-2994: Upgrade to Websocket 2.1.1 XCOMMONS-2108: Upgrade to Bean Validation 3.0.2 XCOMMONS-2109: Upgrade to Hibernate Validator 8.0.1 XCOMMONS-2475: Use Expressly instead of Apache EL
1 parent a43308e commit f85b3b6

File tree

148 files changed

+13536
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+13536
-505
lines changed

pom.xml

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,12 @@
255255
<antlr4.version>4.13.2</antlr4.version>
256256

257257
<!-- Servlet specifications -->
258-
<servlet.version>3.1.0</servlet.version>
258+
<javax.servlet.version>3.1.0</javax.servlet.version>
259+
<jakarta.servlet.version>5.0.0</jakarta.servlet.version>
259260

260-
<!-- EL implementation -->
261-
<!-- Use the same version as the one that comes with the custom XWiki Jetty application server -->
262-
<apache-el.version>9.0.90</apache-el.version>
261+
<!-- WebSocket specifications -->
262+
<javax.websocket.version>1.1</javax.websocket.version>
263+
<jakarta.websocket.version>2.1.1</jakarta.websocket.version>
263264

264265
<webdrivermanager.version>5.9.2</webdrivermanager.version>
265266

@@ -763,13 +764,6 @@
763764
<groupId>com.fasterxml.jackson.module</groupId>
764765
<artifactId>jackson-module-jsonSchema</artifactId>
765766
<version>${jackson.version}</version>
766-
<exclusions>
767-
<!-- We use jakarta.validation:jakarta.validation-api -->
768-
<exclusion>
769-
<groupId>javax.validation</groupId>
770-
<artifactId>validation-api</artifactId>
771-
</exclusion>
772-
</exclusions>
773767
</dependency>
774768
<dependency>
775769
<groupId>com.fasterxml.jackson.datatype</groupId>
@@ -964,6 +958,13 @@
964958
<version>3.30.2-GA</version>
965959
</dependency>
966960

961+
<!-- Injection -->
962+
<dependency>
963+
<groupId>jakarta.inject</groupId>
964+
<artifactId>jakarta.inject-api</artifactId>
965+
<version>2.0.1</version>
966+
</dependency>
967+
967968
<!-- Triggered by several Maven related projects (Doxia, Maven, Aether) as transitive dependency. We need
968969
these explicit versions to help Maven decide which version to use. -->
969970
<dependency>
@@ -1265,15 +1266,31 @@
12651266
<dependency>
12661267
<groupId>javax.servlet</groupId>
12671268
<artifactId>javax.servlet-api</artifactId>
1268-
<version>${servlet.version}</version>
1269+
<version>${javax.servlet.version}</version>
1270+
</dependency>
1271+
<dependency>
1272+
<groupId>jakarta.servlet</groupId>
1273+
<artifactId>jakarta.servlet-api</artifactId>
1274+
<version>${jakarta.servlet.version}</version>
12691275
<!-- It should always be provided as the API jar is provided by the Servlet Container in which XWiki is
12701276
deployed -->
12711277
<scope>provided</scope>
12721278
</dependency>
12731279
<dependency>
12741280
<groupId>javax.websocket</groupId>
12751281
<artifactId>javax.websocket-api</artifactId>
1276-
<version>1.1</version>
1282+
<version>${javax.websocket.version}</version>
1283+
</dependency>
1284+
<dependency>
1285+
<groupId>jakarta.websocket</groupId>
1286+
<artifactId>jakarta.websocket-api</artifactId>
1287+
<version>${jakarta.websocket.version}</version>
1288+
<scope>provided</scope>
1289+
</dependency>
1290+
<dependency>
1291+
<groupId>jakarta.websocket</groupId>
1292+
<artifactId>jakarta.websocket-client-api</artifactId>
1293+
<version>${jakarta.websocket.version}</version>
12771294
<scope>provided</scope>
12781295
</dependency>
12791296
<!-- Needed for Legacy modules. The version needs to be in sync with the one used by the AspectJ plugin -->
@@ -1288,24 +1305,30 @@
12881305
<artifactId>cssparser</artifactId>
12891306
<version>0.9.30</version>
12901307
</dependency>
1308+
12911309
<!-- Bean validation -->
1310+
<dependency>
1311+
<groupId>javax.validation</groupId>
1312+
<artifactId>validation-api</artifactId>
1313+
<version>2.0.1.Final</version>
1314+
</dependency>
12921315
<dependency>
12931316
<groupId>jakarta.validation</groupId>
12941317
<artifactId>jakarta.validation-api</artifactId>
1295-
<version>2.0.2</version>
1318+
<version>3.0.2</version>
12961319
</dependency>
12971320
<dependency>
12981321
<groupId>org.hibernate.validator</groupId>
12991322
<artifactId>hibernate-validator</artifactId>
1300-
<version>6.2.5.Final</version>
1323+
<version>8.0.1.Final</version>
13011324
<scope>runtime</scope>
13021325
</dependency>
13031326
<dependency>
1304-
<groupId>org.mortbay.jasper</groupId>
1305-
<artifactId>apache-el</artifactId>
1306-
<version>${apache-el.version}</version>
1307-
<!-- The EL implementation is supposed to come with the application server, but we need one for tests -->
1308-
<scope>test</scope>
1327+
<groupId>org.glassfish.expressly</groupId>
1328+
<artifactId>expressly</artifactId>
1329+
<version>5.0.0</version>
1330+
<!-- The implementation of Expression Language is supposed to come with the application server -->
1331+
<scope>provided</scope>
13091332
</dependency>
13101333

13111334
<!-- Mail -->
@@ -2078,25 +2101,6 @@
20782101
</rules>
20792102
</configuration>
20802103
</execution>
2081-
<!-- Check that we use the right version of the Validation API -->
2082-
<execution>
2083-
<id>enforce-jakarta.validation-api</id>
2084-
<goals>
2085-
<goal>enforce</goal>
2086-
</goals>
2087-
<configuration>
2088-
<skip>${xwiki.enforcer.enforce-jakarta.validation-api.skip}</skip>
2089-
<rules>
2090-
<bannedDependencies>
2091-
<searchTransitive>true</searchTransitive>
2092-
<message>Use jakarta.validation:jakarta.validation-api instead</message>
2093-
<excludes>
2094-
<exclude>javax.validation:validation-api</exclude>
2095-
</excludes>
2096-
</bannedDependencies>
2097-
</rules>
2098-
</configuration>
2099-
</execution>
21002104
<!-- Check that we use the right version of the Hibernate Validator -->
21012105
<execution>
21022106
<id>enforce-hibernate-validator</id>

xwiki-commons-core/pom.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<module>xwiki-commons-websocket</module>
6565
<module>xwiki-commons-xml</module>
6666
<module>xwiki-commons-xstream</module>
67+
<module>xwiki-commons-jakartabridge</module>
6768
</modules>
6869
<build>
6970
<pluginManagement>
@@ -238,6 +239,68 @@
238239
</item>
239240
</differences>
240241
</revapi.differences>
242+
243+
<!-- Jakarta -->
244+
<revapi.differences>
245+
<justification>revapi false positives</justification>
246+
<criticality>allowed</criticality>
247+
<differences>
248+
<item>
249+
<ignore>true</ignore>
250+
<code>java.class.nonFinalClassInheritsFromNewClass</code>
251+
<old>class org.xwiki.component.embed.GenericProvider&lt;T&gt;</old>
252+
<new>class org.xwiki.component.embed.GenericProvider&lt;T&gt;</new>
253+
<superClass>org.xwiki.component.internal.AbstractGenericProvider&lt;T&gt;</superClass>
254+
</item>
255+
<item>
256+
<ignore>true</ignore>
257+
<code>java.class.nonFinalClassInheritsFromNewClass</code>
258+
<old>class org.xwiki.component.embed.GenericProvider&lt;T&gt;</old>
259+
<new>class org.xwiki.component.embed.GenericProvider&lt;T&gt;</new>
260+
<superClass>org.xwiki.component.internal.JavaXGenericProvider&lt;T&gt;</superClass>
261+
</item>
262+
</differences>
263+
</revapi.differences>
264+
<revapi.differences>
265+
<justification>Moved to WebSocket 2.1.1</justification>
266+
<criticality>highlight</criticality>
267+
<differences>
268+
<item>
269+
<ignore>true</ignore>
270+
<code>java.class.noLongerImplementsInterface</code>
271+
<old>class org.xwiki.websocket.AbstractPartialMessageHandler&lt;T&gt;</old>
272+
<new>class org.xwiki.websocket.AbstractPartialMessageHandler&lt;T&gt;</new>
273+
<interface>javax.websocket.MessageHandler.Partial&lt;T&gt;</interface>
274+
</item>
275+
<item>
276+
<ignore>true</ignore>
277+
<code>java.class.noLongerImplementsInterface</code>
278+
<old>class org.xwiki.websocket.AbstractPartialMessageHandler&lt;T&gt;</old>
279+
<new>class org.xwiki.websocket.AbstractPartialMessageHandler&lt;T&gt;</new>
280+
<interface>javax.websocket.MessageHandler</interface>
281+
</item>
282+
<item>
283+
<ignore>true</ignore>
284+
<code>java.class.noLongerImplementsInterface</code>
285+
<old>class org.xwiki.websocket.AbstractPartialStringMessageHandler</old>
286+
<new>class org.xwiki.websocket.AbstractPartialStringMessageHandler</new>
287+
<interface>javax.websocket.MessageHandler.Partial&lt;java.lang.String&gt;</interface>
288+
</item>
289+
<item>
290+
<ignore>true</ignore>
291+
<code>java.class.noLongerImplementsInterface</code>
292+
<old>class org.xwiki.websocket.AbstractPartialStringMessageHandler</old>
293+
<new>class org.xwiki.websocket.AbstractPartialStringMessageHandler</new>
294+
<interface>javax.websocket.MessageHandler</interface>
295+
</item>
296+
<item>
297+
<ignore>true</ignore>
298+
<regex>true</regex>
299+
<code>java.method.parameterTypeChanged</code>
300+
<old>parameter .* org.xwiki.websocket.WebSocketContext::.*</old>
301+
</item>
302+
</differences>
303+
</revapi.differences>
241304
</analysisConfiguration>
242305
</configuration>
243306
</plugin>

xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/pom.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,17 @@
5555
<groupId>org.slf4j</groupId>
5656
<artifactId>slf4j-api</artifactId>
5757
</dependency>
58-
<!-- We add this dependency here so that users of the Component API just need to depend on this artifact and
59-
don't have to explicitly add a dependency on javax.inject:java.inject. -->
58+
<dependency>
59+
<groupId>jakarta.inject</groupId>
60+
<artifactId>jakarta.inject-api</artifactId>
61+
</dependency>
62+
<!-- Keep supporting both the Jakarta and Javax injection APIs -->
6063
<dependency>
6164
<groupId>javax.inject</groupId>
6265
<artifactId>javax.inject</artifactId>
6366
<version>1</version>
6467
</dependency>
68+
6569
<!-- Testing dependencies -->
6670
<dependency>
6771
<groupId>org.xwiki.commons</groupId>

xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/main/java/org/xwiki/component/descriptor/DefaultComponentDependency.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
import java.util.List;
2727
import java.util.Map;
2828
import java.util.Objects;
29+
import java.util.Set;
2930

30-
import javax.inject.Provider;
31+
import jakarta.inject.Provider;
3132

3233
import org.apache.commons.lang3.builder.HashCodeBuilder;
3334
import org.xwiki.component.util.DefaultParameterizedType;
@@ -42,6 +43,9 @@
4243
*/
4344
public class DefaultComponentDependency<T> extends DefaultComponentRole<T> implements ComponentDependency<T>
4445
{
46+
private static final Set<Class<?>> SPECIAL_ROLES =
47+
Set.of(List.class, Collection.class, Map.class, javax.inject.Provider.class, Provider.class);
48+
4549
/**
4650
* @see #getName()
4751
*/
@@ -115,7 +119,8 @@ public boolean equals(Object object)
115119
{
116120
boolean result;
117121

118-
// See http://www.technofundo.com/tech/java/equalhash.html for the detail of this algorithm.
122+
// See http://www.technofundo.com/tech/java/equalhash.html for the detail of
123+
// this algorithm.
119124
if (this == object) {
120125
result = true;
121126
} else {
@@ -192,7 +197,7 @@ public Class<T> getRole()
192197
{
193198
Class mapping = getMappingType();
194199

195-
if (mapping == List.class || mapping == Collection.class || mapping == Map.class || mapping == Provider.class) {
200+
if (SPECIAL_ROLES.contains(mapping)) {
196201
return ReflectionUtils.getTypeClass(ReflectionUtils.getLastTypeGenericArgument(getRoleType()));
197202
} else {
198203
return mapping;
@@ -204,7 +209,7 @@ public void setRole(Class<T> role)
204209
{
205210
Class mapping = getMappingType();
206211

207-
if (mapping == List.class || mapping == Collection.class || mapping == Map.class || mapping == Provider.class) {
212+
if (SPECIAL_ROLES.contains(mapping)) {
208213
Type ownerType;
209214
Class<?> rawType;
210215
if (getRoleType() instanceof ParameterizedType) {

xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/main/java/org/xwiki/component/internal/multi/AbstractGenericComponentManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import java.lang.reflect.Type;
2323

24-
import javax.inject.Inject;
24+
import jakarta.inject.Inject;
2525

2626
import org.xwiki.component.descriptor.ComponentDescriptor;
2727
import org.xwiki.component.manager.ComponentManager;

xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/main/java/org/xwiki/component/internal/multi/DefaultComponentManagerManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
import java.util.Map;
2323
import java.util.concurrent.ConcurrentHashMap;
2424

25-
import javax.inject.Inject;
26-
import javax.inject.Singleton;
25+
import jakarta.inject.Inject;
26+
import jakarta.inject.Singleton;
2727

2828
import org.xwiki.component.annotation.Component;
2929
import org.xwiki.component.manager.ComponentLookupException;

xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/main/java/org/xwiki/component/internal/namespace/DefaultNamespaceValidator.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
import java.util.regex.Matcher;
2626
import java.util.regex.Pattern;
2727

28-
import javax.inject.Inject;
29-
import javax.inject.Named;
30-
import javax.inject.Provider;
31-
import javax.inject.Singleton;
28+
import jakarta.inject.Inject;
29+
import jakarta.inject.Named;
30+
import jakarta.inject.Provider;
31+
import jakarta.inject.Singleton;
3232

3333
import org.apache.commons.lang3.StringUtils;
3434
import org.xwiki.component.annotation.Component;

xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/test/java/org/xwiki/component/descriptor/DefaultComponentRoleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @version $Id$
3131
* @since 3.3M1
3232
*/
33-
public class DefaultComponentRoleTest
33+
class DefaultComponentRoleTest
3434
{
3535
private interface Role
3636
{

xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/test/java/org/xwiki/component/internal/namespace/DefaultNamespaceValidatorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* @version $Id$
3636
*/
37-
public class DefaultNamespaceValidatorTest
37+
class DefaultNamespaceValidatorTest
3838
{
3939
private DefaultNamespaceValidator validator = new DefaultNamespaceValidator();
4040

xwiki-commons-core/xwiki-commons-component/xwiki-commons-component-api/src/test/java/org/xwiki/component/internal/namespace/NamespaceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* @version $Id$
3333
*/
34-
public class NamespaceTest
34+
class NamespaceTest
3535
{
3636
@Test
3737
void equalsAndHashCode()

0 commit comments

Comments
 (0)