Skip to content

Commit

Permalink
Merge pull request #4118 from jamezp/RESTEASY-3379
Browse files Browse the repository at this point in the history
[RESTEASY-3379] Jakarta REST 4.0
  • Loading branch information
jamezp committed Apr 2, 2024
2 parents a45dd4c + 15af0f9 commit c15f480
Show file tree
Hide file tree
Showing 64 changed files with 1,826 additions and 168 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cloud-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
kubectl port-forward --namespace kube-system service/registry 5000:80 &
- name: Cloud Tests - JDK ${{ matrix.java }}
run: |
mvn clean install -Pcloud-tests -pl resteasy-feature-pack/common,resteasy-feature-pack/galleon-feature-pack,testsuite/cloud-tests -amd -am '-Ddebug.logs'
mvn clean install -Pcloud-tests -pl resteasy-feature-pack/common,resteasy-feature-pack/galleon-feature-pack,testsuite/cloud-tests -amd -am '-Ddebug.logs' '-Pjakarta-staging'
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
distribution: 'temurin'
cache: 'maven'
- name: Build on ${{ inputs.os }} with Java ${{ inputs.javaVersion }}
run: mvn clean install
run: mvn clean install '-Pjakarta-staging'
- name: Upload surefire reports
uses: actions/upload-artifact@v4
if: failure()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manual-wildfly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
distribution: 'temurin'
cache: 'maven'
- name: Build on ${{ inputs.os }} with Java ${{ inputs.javaVersion }}
run: mvn clean install '-Dserver.version=${{needs.wildfly-build.outputs.wildfly-version}}'
run: mvn clean install '-Dserver.version=${{needs.wildfly-build.outputs.wildfly-version}}' '-Pjakarta-staging'
- name: Upload surefire reports
uses: actions/upload-artifact@v4
if: failure()
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
cache: 'maven'
- name: Build with Maven Java ${{ matrix.java }} - ${{ matrix.os }}
run: |
mvn clean install -U -B -fae '-Dgithub.actions'
mvn clean install -U -B -fae '-Dgithub.actions' '-Pjakarta-staging'
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
cache: 'maven'
- name: Test with ${{ matrix.profile }} - JDK ${{ matrix.java }}
run: |
mvn clean install -U -B -fae ${{ matrix.profile }} '-Dgithub.actions'
mvn clean install -U -B -fae ${{ matrix.profile }} '-Dgithub.actions' '-Pjakarta-staging'
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand All @@ -119,5 +119,5 @@ jobs:
cache: 'maven'
- name: Build Java Docs with Java 17
run: |
mvn clean install -B -DskipTests
mvn clean site -B -DskipTests
mvn clean install -B -DskipTests '-Pjakarta-staging'
mvn clean site -B -DskipTests '-Pjakarta-staging'
4 changes: 2 additions & 2 deletions .github/workflows/resteasy-tck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ jobs:
id: resteasy-build
run: |
cd resteasy
mvn clean install -U -B -fae -DskipTests
mvn clean install -U -B -fae -DskipTests -Pjakarta-staging
RESTEASY_VERSION="$(mvn -B help:evaluate -Dexpression=project.version -DforceStdout -q)"
echo "RESTEASY_VERSION=$RESTEASY_VERSION"
echo "RESTEASY_VERSION=$RESTEASY_VERSION" >> "$GITHUB_OUTPUT"
- name: Run the Jakarta REST TCK - JDK ${{ matrix.java }}
run: |
echo "RESTEASY_VERSION=${{ steps.resteasy-build.outputs.RESTEASY_VERSION }}"
cd resteasy-tck-runner
mvn clean install -U -B -fae -Dtck.debug.log=true -Dversion.org.jboss.resteasy="${{ steps.resteasy-build.outputs.RESTEASY_VERSION }}"
mvn clean install -U -B -fae -Dtck.debug.log=true -Dversion.org.jboss.resteasy="${{ steps.resteasy-build.outputs.RESTEASY_VERSION }}" -Djakarta.staging
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wildfly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
distribution: 'temurin'
cache: 'maven'
- name: Build with Maven Java ${{ matrix.java }}
run: mvn clean install '-Dserver.version=${{needs.wildfly-build.outputs.wildfly-version}}'
run: mvn clean install '-Dserver.version=${{needs.wildfly-build.outputs.wildfly-version}}' '-Pjakarta-staging'
- name: Upload surefire reports
uses: actions/upload-artifact@v4
if: failure()
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
cache: 'maven'
- name: Test with ${{ matrix.profile }} - JDK ${{ matrix.java }}
run: |
mvn clean install -U -B -fae ${{ matrix.profile }} '-Dserver.version=${{needs.wildfly-build.outputs.wildfly-version}}'
mvn clean install -U -B -fae ${{ matrix.profile }} '-Dserver.version=${{needs.wildfly-build.outputs.wildfly-version}}' '-Pjakarta-staging'
- uses: actions/upload-artifact@v4
if: failure()
with:
Expand Down
30 changes: 30 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,36 @@
<maven.test.redirectTestOutputToFile>false</maven.test.redirectTestOutputToFile>
</properties>
</profile>
<!-- Enable only with caution and delete download artifacts when completed -->
<profile>
<id>jakarta-staging</id>
<repositories>
<!-- Check Maven Central first -->
<repository>
<id>central</id>
<name>Maven Central</name>
<layout>default</layout>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>jakarta-sonatype-nexus-staging</id>
<name>Jakarta Sonatype Nexus Staging</name>
<url>https://jakarta.oss.sonatype.org/content/repositories/staging/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

<contributors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.function.Predicate;

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientRequestContext;
Expand All @@ -21,6 +22,8 @@
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;

import org.jboss.resteasy.util.HeaderHelper;

/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
Expand Down Expand Up @@ -198,6 +201,17 @@ public String getHeaderString(String name) {
return invocation.getHeaders().getHeader(name);
}

@Override
public boolean containsHeaderString(final String name, final Predicate<String> valuePredicate) {
return containsHeaderString(name, ",", valuePredicate);
}

@Override
public boolean containsHeaderString(final String name, final String valueSeparatorRegex,
final Predicate<String> valuePredicate) {
return HeaderHelper.containsHeaderString(invocation.getHeaders().getHeader(name), valueSeparatorRegex, valuePredicate);
}

/**
* exposes the client invocation for easier integration with other libraries
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Predicate;

import jakarta.ws.rs.client.ClientResponseContext;
import jakarta.ws.rs.core.EntityTag;
Expand All @@ -15,6 +16,8 @@
import jakarta.ws.rs.core.NewCookie;
import jakarta.ws.rs.core.Response;

import org.jboss.resteasy.util.HeaderHelper;

/**
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
* @version $Revision: 1 $
Expand Down Expand Up @@ -138,6 +141,17 @@ public String getHeaderString(String name) {
return response.getHeaderString(name);
}

@Override
public boolean containsHeaderString(final String name, final Predicate<String> valuePredicate) {
return containsHeaderString(name, ",", valuePredicate);
}

@Override
public boolean containsHeaderString(final String name, final String valueSeparatorRegex,
final Predicate<String> valuePredicate) {
return HeaderHelper.containsHeaderString(getHeaderString(name), valueSeparatorRegex, valuePredicate);
}

// hack for MP exception mapping. TODO revisit this implementation
public ClientResponse getClientResponse() {
return response;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/*
* JBoss, Home of Professional Open Source.
*
* Copyright 2024 Red Hat, Inc., and individual contributors
* as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jboss.resteasy.core;

import java.util.Objects;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

import org.jboss.resteasy.plugins.server.servlet.ResteasyContextParameters;
import org.jboss.resteasy.resteasy_jaxrs.i18n.Messages;
import org.jboss.resteasy.spi.config.Configuration;
import org.jboss.resteasy.spi.config.ConfigurationFactory;

/**
* Describes basic information about an {@link Application}.
*
* @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a>
*/
public class ApplicationDescription {

private final Class<? extends Application> type;
private final Application instance;
private final String path;

private ApplicationDescription(final Class<? extends Application> type, final Application instance, final String path) {
this.type = type;
this.instance = instance;
this.path = path;
}

/**
* Returns the class of the application.
*
* @return the class for the application
*/
public Class<? extends Application> type() {
return type;
}

/**
* Returns the instance of the application.
*
* @return the instance of the application
*/
public Application instance() {
return instance;
}

/**
* Returns the path of the application. An empty path is always represented as {@code /}.
*
* @return the path of the application
*/
public String path() {
return path;
}

/**
* Builds an application description.
*/
public static class Builder {
private final Application application;
private Class<? extends Application> type;
private String path;

private Builder(final Application application) {
this.application = application;
}

/**
* Creates a new build based on the application.
*
* @param application the application to create the description for, cannot be {@code null}
*
* @return the builder
*/
public static Builder of(final Application application) {
return new Builder(Objects.requireNonNull(application, () -> Messages.MESSAGES.nullParameter("application")));
}

/**
* Defines the type for the application. If set to {@code null}, the type will be resolved from the
* {@linkplain Application#getClass() application}.
*
* @param type the applications class
*
* @return the builder
*/
public Builder type(final Class<? extends Application> type) {
this.type = type;
return this;
}

/**
* Defines the path of the application. If set to {@code null}, the path is resolved from the
* {@link ApplicationPath}. If the application is not annotated, an attempt to look up the defined mapping is
* done. If neither can be found, the assumed path is {@code /}.
*
* @param path the path for the application
*
* @return the builder
*/
public Builder path(final String path) {
this.path = path;
return this;
}

/**
* Builds the application description.
*
* @return the application description
*/
public ApplicationDescription build() {
if (type == null) {
type = application.getClass();
}
if (path == null) {
final ApplicationPath applicationPath = type.getAnnotation(ApplicationPath.class);
if (applicationPath != null) {
path = applicationPath.value();
if (path.isBlank()) {
path = "/";
}
} else {
// Check for a servlet mapping name
final Configuration configuration = ConfigurationFactory.getInstance().getConfiguration();
final var mapping = configuration
.getOptionalValue(ResteasyContextParameters.RESTEASY_SERVLET_MAPPING_PREFIX, String.class);
path = mapping.filter((v) -> !v.isBlank()).orElse("/");
}
}
return new ApplicationDescription(type, application, path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,11 @@ protected void doComplete() {
// we can be done by exception before we've even subscribed
if (subscription != null)
subscription.cancel();
sseEventSink.close();
try {
sseEventSink.close();
} catch (IOException e) {
complete(e);
}
}

@Override
Expand Down

0 comments on commit c15f480

Please sign in to comment.