Skip to content

Commit

Permalink
Support Spring Framework 6+ and Java 17+
Browse files Browse the repository at this point in the history
  • Loading branch information
mercyblitz committed Aug 10, 2024
1 parent 7a2d283 commit a4b879a
Show file tree
Hide file tree
Showing 32 changed files with 108 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.beans.factory.support.MergedBeanDefinitionPostProcessor;
import org.springframework.beans.factory.support.RootBeanDefinition;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.lang.Nullable;

import java.time.Duration;
import java.util.concurrent.CompletableFuture;

import static io.microsphere.spring.cache.TTLContext.doWithTTL;

Expand All @@ -46,12 +47,22 @@ public void put(String name, byte[] key, byte[] value, Duration ttl) {
}, ttl);
}

@Override
public CompletableFuture<Void> store(String name, byte[] key, byte[] value, Duration ttl) {
return delegate.store(name, key, value, ttl);
}

@Override
@Nullable
public byte[] get(String name, byte[] key) {
return delegate.get(name, key);
}

@Override
public CompletableFuture<byte[]> retrieve(String name, byte[] key, Duration ttl) {
return delegate.retrieve(name, key, ttl);
}

@Override
@Nullable
public byte[] putIfAbsent(String name, byte[] key, byte[] value, Duration ttl) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ protected Yaml createYaml() {
loaderOptions.setProcessComments(true);
loaderOptions.setMaxAliasesForCollections(Integer.MAX_VALUE);
loaderOptions.setAllowRecursiveKeys(true);
return new Yaml(new FilteringConstructor(loaderOptions), new Representer(),
new DumperOptions(), loaderOptions);
DumperOptions dumperOptions = new DumperOptions();
return new Yaml(new FilteringConstructor(loaderOptions), new Representer(dumperOptions), dumperOptions, loaderOptions);
}

private class FilteringConstructor extends Constructor {
Expand Down
10 changes: 1 addition & 9 deletions microsphere-spring-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<properties>
<microsphere-java.version>0.0.6</microsphere-java.version>
<microsphere-java-enterprise.version>0.0.3</microsphere-java-enterprise.version>
<spring-boot.version>2.7.18</spring-boot.version>
<spring-boot.version>3.3.2</spring-boot.version>
<sqlite-jdbc.version>3.36.0.3</sqlite-jdbc.version>
<mariadb-java-client.version>2.7.12</mariadb-java-client.version>
<mariadb4j.version>2.5.3</mariadb4j.version>
Expand All @@ -48,14 +48,6 @@
<scope>import</scope>
</dependency>

<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-java-enterprise-dependencies</artifactId>
<version>${microsphere-java-enterprise.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
Expand Down
10 changes: 2 additions & 8 deletions microsphere-spring-web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,10 @@
<version>${revision}</version>
</dependency>

<!-- MicroSphere Servlet -->
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-servlet</artifactId>
</dependency>

<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<optional>true</optional>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package io.microsphere.spring.web.metadata;

import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import jakarta.servlet.FilterRegistration;
import jakarta.servlet.ServletContext;
import java.util.Collection;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import org.springframework.lang.NonNull;

import javax.servlet.Registration;
import javax.servlet.ServletContext;
import jakarta.servlet.Registration;
import jakarta.servlet.ServletContext;
import java.util.Collection;

import static io.microsphere.spring.web.metadata.WebEndpointMapping.Kind.SERVLET;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package io.microsphere.spring.web.metadata;

import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletRegistration;
import java.util.Collection;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
/**
* The meta-data class for Web Endpoint Mapping that could be one of these endpoints:
* <ul>
* <li>{@link javax.servlet.Servlet Servlet}</li>
* <li>{@link javax.servlet.Filter Servlet's Filter}</li>
* <li>{@link jakarta.servlet.Servlet Servlet}</li>
* <li>{@link jakarta.servlet.Filter Servlet's Filter}</li>
* <li>Spring WebMVC {@link org.springframework.web.servlet.DispatcherServlet DispatcherServlet}</li>
* <li>Spring WebFlux {@link org.springframework.web.reactive.DispatcherHandler DispatcherHandler}</li>
* <li>Customized</li>
Expand All @@ -51,8 +51,8 @@
* The method {@link #getKind()} can be used to identify the kind of endpoints, and the method
* {@link #getEndpoint()} is an abstract presentation of actual endpoint that may be :
* <ul>
* <li>{@link javax.servlet.ServletRegistration#getName() the name of Servlet}</li>
* <li>{@link javax.servlet.FilterRegistration#getName() the name of Servlet's Filter}</li>
* <li>{@link jakarta.servlet.ServletRegistration#getName() the name of Servlet}</li>
* <li>{@link jakarta.servlet.FilterRegistration#getName() the name of Servlet's Filter}</li>
* <li>the any handler of Spring WebMVC {@link org.springframework.web.servlet.HandlerMapping}:
* <ul>
* <li>The {@link String} presenting the name of Handler bean</li>
Expand All @@ -72,17 +72,17 @@
* <p>
* The method {@link #getSource()} can trace the source of {@link WebEndpointMapping} if present, it could be :
* <ul>
* <li>{@link javax.servlet.ServletContext ServletContext}</li>
* <li>{@link jakarta.servlet.ServletContext ServletContext}</li>
* <li>Spring WebMVC {@link org.springframework.web.servlet.HandlerMapping}</li>
* <li>Spring WebFlux {@link org.springframework.web.reactive.HandlerMapping}</li>
* </ul>, or it's {@link #NON_SOURCE non-source}
*
* @param <E> the type of endpoint
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
* @see javax.servlet.ServletRegistration
* @see javax.servlet.FilterRegistration
* @see javax.servlet.annotation.WebServlet
* @see javax.servlet.annotation.WebFilter
* @see jakarta.servlet.ServletRegistration
* @see jakarta.servlet.FilterRegistration
* @see jakarta.servlet.annotation.WebServlet
* @see jakarta.servlet.annotation.WebFilter
* @see org.springframework.web.servlet.DispatcherServlet
* @see org.springframework.web.reactive.DispatcherHandler
* @see org.springframework.web.servlet.HandlerMapping
Expand Down Expand Up @@ -134,12 +134,12 @@ public class WebEndpointMapping<E> {
public enum Kind {

/**
* {@link javax.servlet.Servlet}
* {@link jakarta.servlet.Servlet}
*/
SERVLET,

/**
* {@link javax.servlet.Filter}
* {@link jakarta.servlet.Filter}
*/
FILTER,

Expand Down Expand Up @@ -317,8 +317,8 @@ private WebEndpointMapping() {
/**
* The kind of endpoint:
* <ul>
* <li>{@link javax.servlet.Servlet Servlet}</li>
* <li>{@link javax.servlet.Filter Servlet's Filter}</li>
* <li>{@link jakarta.servlet.Servlet Servlet}</li>
* <li>{@link jakarta.servlet.Filter Servlet's Filter}</li>
* <li>Spring WebMVC {@link org.springframework.web.servlet.DispatcherServlet DispatcherServlet}</li>
* <li>Spring WebFlux {@link org.springframework.web.reactive.DispatcherHandler DispatcherHandler}</li>
* <li>Customized</li>
Expand All @@ -334,8 +334,8 @@ public Kind getKind() {
/**
* The abstract presentation of actual endpoint that may be :
* <ul>
* <li>{@link javax.servlet.ServletRegistration#getName() the name of Servlet}</li>
* <li>{@link javax.servlet.FilterRegistration#getName() the name of Servlet's Filter}</li>
* <li>{@link jakarta.servlet.ServletRegistration#getName() the name of Servlet}</li>
* <li>{@link jakarta.servlet.FilterRegistration#getName() the name of Servlet's Filter}</li>
* <li>the any handler of Spring WebMVC {@link org.springframework.web.servlet.HandlerMapping}:
* <ul>
* <li>The {@link String} presenting the name of Handler bean</li>
Expand Down Expand Up @@ -372,7 +372,7 @@ public int getId() {
/**
* The source of {@link WebEndpointMapping} if present, it could be :
* <ul>
* <li>{@link javax.servlet.ServletContext ServletContext}</li>
* <li>{@link jakarta.servlet.ServletContext ServletContext}</li>
* <li>Spring WebMVC {@link org.springframework.web.servlet.HandlerMapping}</li>
* <li>Spring WebFlux {@link org.springframework.web.reactive.HandlerMapping}</li>
* </ul>, or it's {@link #NON_SOURCE non-source}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public interface WebEndpointMappingFactory<E> {
*
* @param endpoint could be one of these :
* <ul>
* <li>{@link javax.servlet.ServletRegistration}</li>
* <li>{@link javax.servlet.FilterRegistration}</li>
* <li>{@link jakarta.servlet.ServletRegistration}</li>
* <li>{@link jakarta.servlet.FilterRegistration}</li>
* <li>{@link org.springframework.web.servlet.mvc.method.RequestMappingInfo}</li>
* <li>{@link org.springframework.web.reactive.result.method.RequestMappingInfo}</li>
* </ul>
Expand All @@ -52,8 +52,8 @@ default boolean supports(E endpoint) {
*
* @param endpoint could be one of these :
* <ul>
* <li>{@link javax.servlet.ServletRegistration}</li>
* <li>{@link javax.servlet.FilterRegistration}</li>
* <li>{@link jakarta.servlet.ServletRegistration}</li>
* <li>{@link jakarta.servlet.FilterRegistration}</li>
* <li>{@link org.springframework.web.servlet.mvc.method.RequestMappingInfo}</li>
* <li>{@link org.springframework.web.reactive.result.method.RequestMappingInfo}</li>
* </ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
//import org.junit.jupiter.api.BeforeEach;
//import org.junit.jupiter.api.Test;
//
//import javax.servlet.DispatcherType;
//import javax.servlet.FilterRegistration;
//import javax.servlet.ServletException;
//import jakarta.servlet.DispatcherType;
//import jakarta.servlet.FilterRegistration;
//import jakarta.servlet.ServletException;
//import java.util.EnumSet;
//import java.util.Optional;
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.junit.jupiter.api.Test;
import org.springframework.mock.web.MockServletConfig;

import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRegistration;
import java.util.Optional;

import static io.microsphere.util.ArrayUtils.of;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package io.microsphere.spring.web.servlet;

import javax.servlet.DispatcherType;
import javax.servlet.FilterRegistration;
import jakarta.servlet.DispatcherType;
import jakarta.servlet.FilterRegistration;
import java.util.Collection;
import java.util.EnumSet;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
*/
package io.microsphere.spring.web.servlet;

import javax.servlet.Servlet;
import javax.servlet.http.HttpServlet;
import jakarta.servlet.Servlet;
import jakarta.servlet.http.HttpServlet;

/**
* {@link Servlet} for Testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import org.springframework.lang.Nullable;
import org.springframework.mock.web.MockServletContext;

import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletRegistration;
import java.util.HashMap;
import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
*/
package io.microsphere.spring.web.servlet;

import javax.servlet.MultipartConfigElement;
import javax.servlet.ServletRegistration;
import javax.servlet.ServletSecurityElement;
import jakarta.servlet.MultipartConfigElement;
import jakarta.servlet.ServletRegistration;
import jakarta.servlet.ServletSecurityElement;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
Expand Down
6 changes: 3 additions & 3 deletions microsphere-spring-webmvc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@

<!-- Servlet API -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<optional>true</optional>
</dependency>

<!-- Spring WebMVC -->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package io.microsphere.spring.web.servlet.filter;

import jakarta.servlet.Filter;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.ContentCachingResponseWrapper;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package io.microsphere.spring.web.servlet.util;

import jakarta.servlet.Filter;
import jakarta.servlet.FilterRegistration;
import jakarta.servlet.Registration;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletRegistration;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.util.ClassUtils;

import javax.servlet.Filter;
import javax.servlet.FilterRegistration;
import javax.servlet.Registration;
import javax.servlet.Servlet;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;
import javax.servlet.http.HttpServletRequest;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
Expand All @@ -28,9 +28,9 @@ public abstract class WebUtils {
private static final boolean servlet3OrAbove;

/**
* javax.servlet.ServletContainerInitializer @since 3.0
* jakarta.servlet.ServletContainerInitializer @since 3.0
*/
private static final String SERVLET_CONTAINER_INITIALIZER_CLASS_NAME = "javax.servlet.ServletContainerInitializer";
private static final String SERVLET_CONTAINER_INITIALIZER_CLASS_NAME = "jakarta.servlet.ServletContainerInitializer";

static {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.microsphere.spring.webmvc.advice;

import io.microsphere.spring.webmvc.util.WebMvcUtils;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
Expand All @@ -9,7 +10,6 @@
import org.springframework.http.server.ServletServerHttpRequest;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;

/**
Expand Down
Loading

0 comments on commit a4b879a

Please sign in to comment.