Skip to content
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

Move to Jakarta based application servers #1075

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 43 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -255,11 +255,12 @@
<antlr4.version>4.13.2</antlr4.version>

<!-- Servlet specifications -->
<servlet.version>3.1.0</servlet.version>
<javax.servlet.version>3.1.0</javax.servlet.version>
<jakarta.servlet.version>5.0.0</jakarta.servlet.version>

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

<webdrivermanager.version>5.9.2</webdrivermanager.version>

Expand Down Expand Up @@ -757,13 +758,6 @@
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-jsonSchema</artifactId>
<version>${jackson.version}</version>
<exclusions>
<!-- We use jakarta.validation:jakarta.validation-api -->
<exclusion>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
Expand Down Expand Up @@ -958,6 +952,13 @@
<version>3.30.2-GA</version>
</dependency>

<!-- Injection -->
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
<version>2.0.1</version>
</dependency>

<!-- Triggered by several Maven related projects (Doxia, Maven, Aether) as transitive dependency. We need
these explicit versions to help Maven decide which version to use. -->
<dependency>
Expand Down Expand Up @@ -1259,15 +1260,31 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<version>${javax.servlet.version}</version>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${jakarta.servlet.version}</version>
<!-- It should always be provided as the API jar is provided by the Servlet Container in which XWiki is
deployed -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
<version>${javax.websocket.version}</version>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-api</artifactId>
<version>${jakarta.websocket.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-client-api</artifactId>
<version>${jakarta.websocket.version}</version>
<scope>provided</scope>
</dependency>
<!-- Needed for Legacy modules. The version needs to be in sync with the one used by the AspectJ plugin -->
Expand All @@ -1282,24 +1299,30 @@
<artifactId>cssparser</artifactId>
<version>0.9.30</version>
</dependency>

<!-- Bean validation -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
<version>2.0.2</version>
<version>3.0.2</version>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.2.5.Final</version>
<version>8.0.1.Final</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jasper</groupId>
<artifactId>apache-el</artifactId>
<version>${apache-el.version}</version>
<!-- The EL implementation is supposed to come with the application server, but we need one for tests -->
<scope>test</scope>
<groupId>org.glassfish.expressly</groupId>
<artifactId>expressly</artifactId>
<version>5.0.0</version>
<!-- The implementation of Expression Language is supposed to come with the application server -->
<scope>provided</scope>
</dependency>

<!-- Mail -->
Expand Down Expand Up @@ -2049,25 +2072,6 @@
</rules>
</configuration>
</execution>
<!-- Check that we use the right version of the Validation API -->
<execution>
<id>enforce-jakarta.validation-api</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<skip>${xwiki.enforcer.enforce-jakarta.validation-api.skip}</skip>
<rules>
<bannedDependencies>
<searchTransitive>true</searchTransitive>
<message>Use jakarta.validation:jakarta.validation-api instead</message>
<excludes>
<exclude>javax.validation:validation-api</exclude>
</excludes>
</bannedDependencies>
</rules>
</configuration>
</execution>
<!-- Check that we use the right version of the Hibernate Validator -->
<execution>
<id>enforce-hibernate-validator</id>
Expand Down
63 changes: 63 additions & 0 deletions xwiki-commons-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<module>xwiki-commons-websocket</module>
<module>xwiki-commons-xml</module>
<module>xwiki-commons-xstream</module>
<module>xwiki-commons-jakartabridge</module>
</modules>
<build>
<pluginManagement>
Expand Down Expand Up @@ -249,6 +250,68 @@
</item>
</differences>
</revapi.differences>

<!-- Jakarta -->
<revapi.differences>
<justification>revapi false positives</justification>
<criticality>allowed</criticality>
<differences>
<item>
<ignore>true</ignore>
<code>java.class.nonFinalClassInheritsFromNewClass</code>
<old>class org.xwiki.component.embed.GenericProvider&lt;T&gt;</old>
<new>class org.xwiki.component.embed.GenericProvider&lt;T&gt;</new>
<superClass>org.xwiki.component.internal.AbstractGenericProvider&lt;T&gt;</superClass>
</item>
<item>
<ignore>true</ignore>
<code>java.class.nonFinalClassInheritsFromNewClass</code>
<old>class org.xwiki.component.embed.GenericProvider&lt;T&gt;</old>
<new>class org.xwiki.component.embed.GenericProvider&lt;T&gt;</new>
<superClass>org.xwiki.component.internal.JavaXGenericProvider&lt;T&gt;</superClass>
</item>
</differences>
</revapi.differences>
<revapi.differences>
<justification>Moved to WebSocket 2.1.1</justification>
<criticality>highlight</criticality>
<differences>
<item>
<ignore>true</ignore>
<code>java.class.noLongerImplementsInterface</code>
<old>class org.xwiki.websocket.AbstractPartialMessageHandler&lt;T&gt;</old>
<new>class org.xwiki.websocket.AbstractPartialMessageHandler&lt;T&gt;</new>
<interface>javax.websocket.MessageHandler.Partial&lt;T&gt;</interface>
</item>
<item>
<ignore>true</ignore>
<code>java.class.noLongerImplementsInterface</code>
<old>class org.xwiki.websocket.AbstractPartialMessageHandler&lt;T&gt;</old>
<new>class org.xwiki.websocket.AbstractPartialMessageHandler&lt;T&gt;</new>
<interface>javax.websocket.MessageHandler</interface>
</item>
<item>
<ignore>true</ignore>
<code>java.class.noLongerImplementsInterface</code>
<old>class org.xwiki.websocket.AbstractPartialStringMessageHandler</old>
<new>class org.xwiki.websocket.AbstractPartialStringMessageHandler</new>
<interface>javax.websocket.MessageHandler.Partial&lt;java.lang.String&gt;</interface>
</item>
<item>
<ignore>true</ignore>
<code>java.class.noLongerImplementsInterface</code>
<old>class org.xwiki.websocket.AbstractPartialStringMessageHandler</old>
<new>class org.xwiki.websocket.AbstractPartialStringMessageHandler</new>
<interface>javax.websocket.MessageHandler</interface>
</item>
<item>
<ignore>true</ignore>
<regex>true</regex>
<code>java.method.parameterTypeChanged</code>
<old>parameter .* org.xwiki.websocket.WebSocketContext::.*</old>
</item>
</differences>
</revapi.differences>
</analysisConfiguration>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,17 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<!-- We add this dependency here so that users of the Component API just need to depend on this artifact and
don't have to explicitly add a dependency on javax.inject:java.inject. -->
<dependency>
<groupId>jakarta.inject</groupId>
<artifactId>jakarta.inject-api</artifactId>
</dependency>
<!-- Keep supporting both the Jakarta and Javax injection APIs -->
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>

<!-- Testing dependencies -->
<dependency>
<groupId>org.xwiki.commons</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@
import java.util.List;
import java.util.Map;
import java.util.Objects;

import javax.inject.Provider;
import java.util.Set;

import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.xwiki.component.util.DefaultParameterizedType;
import org.xwiki.component.util.ReflectionUtils;

import jakarta.inject.Provider;

/**
* Default implementation of {@link ComponentDependency}.
*
Expand All @@ -42,6 +43,9 @@
*/
public class DefaultComponentDependency<T> extends DefaultComponentRole<T> implements ComponentDependency<T>
{
private static final Set<Class<?>> SPECIAL_ROLES =
Set.of(List.class, Collection.class, Map.class, javax.inject.Provider.class, Provider.class);

/**
* @see #getName()
*/
Expand Down Expand Up @@ -115,7 +119,8 @@ public boolean equals(Object object)
{
boolean result;

// See http://www.technofundo.com/tech/java/equalhash.html for the detail of this algorithm.
// See http://www.technofundo.com/tech/java/equalhash.html for the detail of
// this algorithm.
if (this == object) {
result = true;
} else {
Expand Down Expand Up @@ -192,7 +197,7 @@ public Class<T> getRole()
{
Class mapping = getMappingType();

if (mapping == List.class || mapping == Collection.class || mapping == Map.class || mapping == Provider.class) {
if (SPECIAL_ROLES.contains(mapping)) {
return ReflectionUtils.getTypeClass(ReflectionUtils.getLastTypeGenericArgument(getRoleType()));
} else {
return mapping;
Expand All @@ -204,7 +209,7 @@ public void setRole(Class<T> role)
{
Class mapping = getMappingType();

if (mapping == List.class || mapping == Collection.class || mapping == Map.class || mapping == Provider.class) {
if (SPECIAL_ROLES.contains(mapping)) {
Type ownerType;
Class<?> rawType;
if (getRoleType() instanceof ParameterizedType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

import java.lang.reflect.Type;

import javax.inject.Inject;

import org.xwiki.component.descriptor.ComponentDescriptor;
import org.xwiki.component.manager.ComponentManager;
import org.xwiki.component.manager.ComponentRepositoryException;

import jakarta.inject.Inject;

/**
* Generic implementation that creates Component Manager instances based on the generic notion of a key. This is used
* for example by the Wiki Component Manager or the User Component Manager which respectively have a key returning the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.inject.Inject;
import javax.inject.Singleton;

import org.xwiki.component.annotation.Component;
import org.xwiki.component.manager.ComponentLookupException;
import org.xwiki.component.manager.ComponentManager;
import org.xwiki.component.namespace.NamespaceUtils;

import jakarta.inject.Inject;
import jakarta.inject.Singleton;

/**
* Default implementation of {@link ComponentManagerManager}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;

import org.apache.commons.lang3.StringUtils;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.manager.ComponentManager;
import org.xwiki.component.namespace.NamespaceNotAllowedException;
import org.xwiki.component.namespace.NamespaceValidator;

import jakarta.inject.Inject;
import jakarta.inject.Named;
import jakarta.inject.Provider;
import jakarta.inject.Singleton;

/**
* Default implementation of {@link NamespaceValidator}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @version $Id$
* @since 3.3M1
*/
public class DefaultComponentRoleTest
class DefaultComponentRoleTest
{
private interface Role
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*
* @version $Id$
*/
public class DefaultNamespaceValidatorTest
class DefaultNamespaceValidatorTest
{
private DefaultNamespaceValidator validator = new DefaultNamespaceValidator();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @version $Id$
*/
public class NamespaceTest
class NamespaceTest
{
@Test
void equalsAndHashCode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*
* @version $Id$
*/
public class NamespaceUtilsTest
class NamespaceUtilsTest
{
@Test
void getPrefix()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @version $Id$
*/
public class DefaultParameterizedTypeTest
class DefaultParameterizedTypeTest
{
@Test
void toStringTest()
Expand Down
Loading