Compare commits

...
4 changed files with 48 additions and 53 deletions
+35 -40
View File
@@ -6,7 +6,7 @@
<groupId>com.inteligr8</groupId>
<artifactId>common-rest-client</artifactId>
<version>3.0.2-jersey</version>
<version>3.0.4-jersey</version>
<packaging>jar</packaging>
<name>ReST API Client for Java</name>
@@ -43,17 +43,16 @@
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<junit.version>5.12.0</junit.version>
<spring.version>6.0.23</spring.version>
<jackson.version>2.17.3</jackson.version>
<jersey.version>3.1.10</jersey.version>
<spring.version>6.2.18</spring.version>
<jackson.version>2.21.1</jackson.version>
<jersey.version>4.0.2</jersey.version>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
<artifactId>jakarta.annotation-api</artifactId>
<version>2.1.1</version>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -78,7 +77,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
<version>3.20.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@@ -90,10 +89,11 @@
<artifactId>jakarta.ws.rs-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<version>5.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -140,11 +140,27 @@
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.5</version>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.5.5</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.6.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.4.0</version>
<executions>
<execution>
<id>add-jaxrs-src</id>
@@ -166,34 +182,12 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.4.0</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.4.0</version>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ossrh-release</id>
<id>central-publish</id>
<properties>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
@@ -233,19 +227,20 @@
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.14</version>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
<version>0.10.0</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
<publishingServerId>central</publishingServerId>
<autoPublish>true</autoPublish>
</configuration>
<!-- for some reason this is required... -->
<executions>
<execution>
<id>ossrh-deploy</id>
<id>deploy</id>
<phase>deploy</phase>
<goals><goal>deploy</goal></goals>
<goals><goal>publish</goal></goals>
</execution>
</executions>
</plugin>
@@ -30,7 +30,7 @@ import jakarta.ws.rs.client.ClientRequestContext;
*/
public class HeaderAuthorizationFilter implements AuthorizationFilter {
private final MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
private final MultiValueMap<String, Object> headers = new LinkedMultiValueMap<>();
/**
* This constructor instantiates the filter with required fields.
@@ -38,7 +38,7 @@ public class HeaderAuthorizationFilter implements AuthorizationFilter {
* @param headerName A header name.
* @param headerValue A header value.
*/
public HeaderAuthorizationFilter(String headerName, String headerValue) {
public HeaderAuthorizationFilter(String headerName, Object headerValue) {
this.headers.add(headerName, headerValue);
}
@@ -49,7 +49,7 @@ public class HeaderAuthorizationFilter implements AuthorizationFilter {
* @param headerValue A header value.
* @return This class for fluent chaining.
*/
public HeaderAuthorizationFilter add(String headerName, String headerValue) {
public HeaderAuthorizationFilter add(String headerName, Object headerValue) {
this.headers.add(headerName, headerValue);
return this;
}
@@ -61,8 +61,8 @@ public class HeaderAuthorizationFilter implements AuthorizationFilter {
*/
@Override
public void filter(ClientRequestContext requestContext) throws UnsupportedEncodingException {
for (Entry<String, List<String>> header : this.headers.entrySet())
requestContext.getHeaders().addAll(header.getKey(), header.getValue());
for (Entry<String, List<Object>> header : this.headers.entrySet())
requestContext.getHeaders().put(header.getKey(), header.getValue());
}
}
@@ -16,7 +16,7 @@ package com.inteligr8.rs;
/**
* This interface defines additional configurations specific to the Jersey
* JAX-RS library and its nuances.
* Jakarta RS library and its nuances.
*
* @author brian@inteligr8.com
*/
@@ -47,17 +47,17 @@ public class ClientJerseyImpl extends Client {
/**
* This method registers the Jersey library as the default provider for the
* JAX-RS specification.
* Jakarta RS specification.
*/
@PostConstruct
public void register() {
if (RuntimeDelegate.getInstance() == null) {
this.logger.info("Setting JAX-RS runtime delegate to the Jersey library");
this.logger.info("Setting Jakarta RS runtime delegate to the Jersey library");
RuntimeDelegate.setInstance(new RuntimeDelegateImpl());
} else if (RuntimeDelegate.getInstance() instanceof RuntimeDelegateImpl) {
this.logger.info("JAX-RS runtime delegate already the Jersey library");
this.logger.info("Jakarta RS runtime delegate already the Jersey library");
} else {
this.logger.warn("Setting JAX-RS runtime delegate to the Jersey library; was: " + RuntimeDelegate.getInstance().getClass().getName());
this.logger.warn("Setting Jakarta RS runtime delegate to the Jersey library; was: " + RuntimeDelegate.getInstance().getClass().getName());
RuntimeDelegate.setInstance(new RuntimeDelegateImpl());
}
@@ -86,11 +86,11 @@ public class ClientJerseyImpl extends Client {
}
/**
* This method retrieves a JAX-RS implementation of the specified API with
* the specified authorization.
* This method retrieves a Jakarta RS implementation of the specified API
* with the specified authorization.
*
* @param authFilter A dynamic authorization filter.
* @param apiClass A JAX-RS annotation API class.
* @param apiClass A Jakarta RS annotation API class.
* @return An instance of the API class.
*/
@Override