diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7b650aecc..5d42ebcdb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,71 @@
===========================
+## [2.3.2](https://github.com/buession/buessionframework/releases/tag/v2.3.2) (2023-12-27)
+
+### 🔨依赖升级
+
+- [依赖库版本升级和安全漏洞修复](https://github.com/buession/buession-parent/releases/tag/v2.3.2)
+
+
+### ⭐ 新特性
+
+- **buession-core:** ClassUtils、MethodUtils、FieldUtils 增加检测是否含义任意注解的方法
+- **buession-core:** AnnotationUtils 增加检测属性是否含义任意注解的方法
+- **buession-core:** 断言 Assert 可指定异常
+- **buession-core:** 新增对象工具类 ObjectUtils
+- **buession-core:** AbstractBeanConverter 新增支持 String 转枚举
+- **buession-core:** 新增反射工具类 ReflectionUtils
+- **buession-aop:** 新增注解处理器支持解析注解属性中的变量
+- **buession-json:** 注解 @Sensitive 增加支持邮箱脱敏
+- **buession-httpclient:** OKHTTP client 增加可设置 maxRequests
+- **buession-velocity:** 新增验证工具 ValidateTool
+- **buession-web:** 新增注解处理器支持解析注解属性中的变量
+
+
+### 🔔 变化
+
+- **buession-core:** 废弃 JsonSerializer 和 JsonDeserializer
+- **buession-core:** ListConverter、SetConverter、MapConverter 默认返回原始类型
+- **buession-core:** 移除 spring-beans 依赖
+- **buession-json:** 注解 @Sensitive 内容替换策略,替换符可通过属性 replacement 设置
+
+
+### 🐞 Bug 修复
+
+- **buession-core:** 修改错误的类名 BuesssionFrameworkVersion 为 BuessionFrameworkVersion
+- **buession-beans:** 修复 NumberPropertyConverter 字符串转换为数字时异常的 BUG
+- **buession-beans:** 修复 Map 转换为 bean 时字段为 null 值的 BUG
+- **buession-beans:** 修复 Map 转换为 bean 或 bean 转换为 map 时缓存导致的异常
+- **buession-dao:** 修复分页插件 PaginationInterceptor 当页码大于等于 2 时,无法返回数据的 BUG
+- **buession-dao:** 修复分页对象下一页值错误的 BUG
+- **buession-git:** 修复无法解析 git 信息时,空指针异常
+- **buession-web:** 修复分页对象下一页值错误的 BUG
+
+
+### ⏪ 优化
+
+- **buession-beans:** 代码优化
+- **buession-httpclient:** 代码优化
+- **buession-redis:** 代码优化
+- **buession-redis:** 优化 RedisAccessor 多次调用 afterPropertiesSet 时,重复初始化 RedisConnectionFactory
+- **buession-geoip:** 优化 GeoIPResolverFactoryBean 多次调用 afterPropertiesSet 时,重复初始化 DatabaseResolver
+- **buession-thesaurus:** 优化 ThesaurusFactoryBean 多次调用 afterPropertiesSet 时,重复初始化 Parser
+- **buession-velocity:** 优化 VelocityEngineFactoryBean 多次调用 afterPropertiesSet 时,重复初始化 VelocityEngine
+
+
+### 📔 文档
+
+- **buession-aop:** 完善注释
+- **buession-httpclient:** 完善注释
+- **buession-redis:** 完善注释
+- **buession-velocity:** 完善注释
+- **buession-web:** 完善注释
+
+
+---
+
+
## [2.3.1](https://github.com/buession/buessionframework/releases/tag/v2.3.1) (2023-11-17)
### 🔨依赖升级
diff --git a/buession-aop/pom.xml b/buession-aop/pom.xml
index 79a97c450..e6ef5ada9 100644
--- a/buession-aop/pom.xml
+++ b/buession-aop/pom.xml
@@ -7,7 +7,7 @@
com.buession
buession-parent
../buession-parent
- 2.3.1
+ 2.3.2
buession-aop
http://www.buession.com/
diff --git a/buession-aop/src/main/java/com/buession/aop/aspectj/AbstractAspectjAnnotationsMethodInterceptor.java b/buession-aop/src/main/java/com/buession/aop/aspectj/AbstractAspectjAnnotationsMethodInterceptor.java
index adf9b29dd..709f4909c 100644
--- a/buession-aop/src/main/java/com/buession/aop/aspectj/AbstractAspectjAnnotationsMethodInterceptor.java
+++ b/buession-aop/src/main/java/com/buession/aop/aspectj/AbstractAspectjAnnotationsMethodInterceptor.java
@@ -46,6 +46,15 @@ public AbstractAspectjAnnotationsMethodInterceptor() {
super();
}
+ /**
+ * 切点方法之前执行
+ *
+ * @param joinPoint
+ * {@link JoinPoint}
+ *
+ * @throws Throwable
+ * 异常
+ */
public void performBeforeInterception(JoinPoint joinPoint) throws Throwable {
if(logger.isDebugEnabled()){
performInterceptionDebug(joinPoint);
@@ -57,6 +66,15 @@ public void performBeforeInterception(JoinPoint joinPoint) throws Throwable {
super.invoke(mi);
}
+ /**
+ * 切点方法之后执行
+ *
+ * @param joinPoint
+ * {@link JoinPoint}
+ *
+ * @throws Throwable
+ * 异常
+ */
public void performAfterInterception(JoinPoint joinPoint) throws Throwable {
if(logger.isDebugEnabled()){
performInterceptionDebug(joinPoint);
@@ -69,6 +87,13 @@ public void performAfterInterception(JoinPoint joinPoint) throws Throwable {
}
/**
+ * 切点方法的返回值并进行增强
+ *
+ * @param joinPoint
+ * {@link JoinPoint}
+ *
+ * @throws Throwable
+ * 异常
* @since 2.3.0
*/
public void performAfterReturningInterception(JoinPoint joinPoint) throws Throwable {
@@ -84,6 +109,13 @@ public void performAfterReturningInterception(JoinPoint joinPoint) throws Throwa
}
/**
+ * 切点方法的返回值后执行
+ *
+ * @param joinPoint
+ * {@link JoinPoint}
+ *
+ * @throws Throwable
+ * 异常
* @since 2.3.0
*/
public void performAfterThrowingInterception(JoinPoint joinPoint) throws Throwable {
@@ -99,6 +131,8 @@ public void performAfterThrowingInterception(JoinPoint joinPoint) throws Throwab
}
/**
+ * 点方法抛出异常时会执行
+ *
* @since 2.3.0
*/
public void performAroundInterception(JoinPoint joinPoint) throws Throwable {
diff --git a/buession-aop/src/main/java/com/buession/aop/handler/AbstractAnnotationHandler.java b/buession-aop/src/main/java/com/buession/aop/handler/AbstractAnnotationHandler.java
index 2a3587901..e1af7cc42 100644
--- a/buession-aop/src/main/java/com/buession/aop/handler/AbstractAnnotationHandler.java
+++ b/buession-aop/src/main/java/com/buession/aop/handler/AbstractAnnotationHandler.java
@@ -19,12 +19,13 @@
* +-------------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng |
- * | Copyright @ 2013-2022 Buession.com Inc. |
+ * | Copyright @ 2013-2023 Buession.com Inc. |
* +-------------------------------------------------------------------------------------------------------+
*/
package com.buession.aop.handler;
import com.buession.core.utils.Assert;
+import org.springframework.util.StringValueResolver;
import java.lang.annotation.Annotation;
@@ -43,23 +44,46 @@ public abstract class AbstractAnnotationHandler implements
*/
protected Class annotationClass;
+ /**
+ * 占位符解析器
+ *
+ * @since 2.3.2
+ */
+ protected StringValueResolver stringValueResolver;
+
+ /**
+ * 构造函数
+ *
+ * @param annotationClass
+ * 注解类
+ */
+ @Deprecated
+ public AbstractAnnotationHandler(Class annotationClass) {
+ setAnnotationClass(annotationClass);
+ }
+
/**
* 构造函数
*
* @param annotationClass
* 注解类
+ * @param stringValueResolver
+ * 占位符解析器
+ *
+ * @since 2.3.2
*/
- public AbstractAnnotationHandler(Class annotationClass){
+ public AbstractAnnotationHandler(Class annotationClass, StringValueResolver stringValueResolver) {
setAnnotationClass(annotationClass);
+ this.stringValueResolver = stringValueResolver;
}
@Override
- public Class getAnnotationClass(){
+ public Class getAnnotationClass() {
return annotationClass;
}
@Override
- public void setAnnotationClass(Class annotationClass){
+ public void setAnnotationClass(Class annotationClass) {
Assert.isNull(annotationClass, "Annotation class argument could not be null");
this.annotationClass = annotationClass;
}
diff --git a/buession-aop/src/main/java/com/buession/aop/interceptor/AbstractAttributeSourceAdvisor.java b/buession-aop/src/main/java/com/buession/aop/interceptor/AbstractAttributeSourceAdvisor.java
index 6879eede4..3e085e90d 100644
--- a/buession-aop/src/main/java/com/buession/aop/interceptor/AbstractAttributeSourceAdvisor.java
+++ b/buession-aop/src/main/java/com/buession/aop/interceptor/AbstractAttributeSourceAdvisor.java
@@ -19,14 +19,14 @@
* +-------------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng |
- * | Copyright @ 2013-2022 Buession.com Inc. |
+ * | Copyright @ 2013-2023 Buession.com Inc. |
* +-------------------------------------------------------------------------------------------------------+
*/
package com.buession.aop.interceptor;
+import com.buession.core.utils.AnnotationUtils;
import com.buession.core.utils.Assert;
import org.springframework.aop.support.StaticMethodMatcherPointcutAdvisor;
-import org.springframework.core.annotation.AnnotationUtils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
@@ -42,7 +42,7 @@ public abstract class AbstractAttributeSourceAdvisor extends StaticMethodMatcher
private final Class extends Annotation>[] annotations;
public AbstractAttributeSourceAdvisor(final AnnotationsMethodInterceptor annotationsMethodInterceptor,
- final Class extends Annotation>[] annotations){
+ final Class extends Annotation>[] annotations) {
Assert.isNull(annotationsMethodInterceptor, "AnnotationsMethodInterceptor cloud not be null.");
Assert.isNull(annotations, "Annotations cloud not be null.");
@@ -51,7 +51,7 @@ public AbstractAttributeSourceAdvisor(final AnnotationsMethodInterceptor annotat
}
@Override
- public boolean matches(Method method, Class> targetClass){
+ public boolean matches(Method method, Class> targetClass) {
Method m = method;
if(isAnnotationPresent(m)){
@@ -70,26 +70,12 @@ public boolean matches(Method method, Class> targetClass){
return false;
}
- private boolean isAnnotationPresent(final Class> targetClazz){
- for(Class extends Annotation> annotationClass : annotations){
- Annotation annotation = AnnotationUtils.findAnnotation(targetClazz, annotationClass);
- if(annotation != null){
- return true;
- }
- }
-
- return false;
+ private boolean isAnnotationPresent(final Class> targetClazz) {
+ return AnnotationUtils.hasClassAnnotationPresent(targetClazz, annotations);
}
- private boolean isAnnotationPresent(final Method method){
- for(Class extends Annotation> annotationClass : annotations){
- Annotation annotation = AnnotationUtils.findAnnotation(method, annotationClass);
- if(annotation != null){
- return true;
- }
- }
-
- return false;
+ private boolean isAnnotationPresent(final Method method) {
+ return AnnotationUtils.hasMethodAnnotationPresent(method, annotations);
}
}
diff --git a/buession-beans/pom.xml b/buession-beans/pom.xml
index 99b019973..b47040d35 100644
--- a/buession-beans/pom.xml
+++ b/buession-beans/pom.xml
@@ -7,7 +7,7 @@
com.buession
buession-parent
../buession-parent
- 2.3.1
+ 2.3.2
buession-beans
http://www.buession.com/
diff --git a/buession-beans/src/main/java/com/buession/beans/AbstractBeanConverter.java b/buession-beans/src/main/java/com/buession/beans/AbstractBeanConverter.java
index b951ac292..97cc4d971 100644
--- a/buession-beans/src/main/java/com/buession/beans/AbstractBeanConverter.java
+++ b/buession-beans/src/main/java/com/buession/beans/AbstractBeanConverter.java
@@ -26,11 +26,10 @@
import com.buession.beans.converters.*;
import com.buession.core.utils.Assert;
+import com.buession.core.utils.EnumUtils;
import com.buession.core.utils.FieldUtils;
import com.buession.core.utils.StringUtils;
import com.buession.lang.Primitive;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.cglib.beans.BeanMap;
@@ -58,12 +57,8 @@ public abstract class AbstractBeanConverter implements BeanConverter {
private final static Map BEAN_COPIERS = new ConcurrentHashMap<>(32);
- private final static Map BEAN_MAPS = new ConcurrentHashMap<>(32);
-
private final static Map, BeanPropertyConverter>> converters = new ConcurrentHashMap<>(24);
- private final static Logger logger = LoggerFactory.getLogger(AbstractBeanConverter.class);
-
/**
* 构造函数
*/
@@ -109,6 +104,24 @@ public T convert(final S source, final T target) {
return beanToBean(source, target);
}
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ protected static Object convertValue(final Object value, final Class> targetType) {
+ if(value == null){
+ return null;
+ }else if(targetType.isEnum()){
+ return EnumUtils.getEnumIgnoreCase((Class) targetType, value.toString());
+ }else{
+ final Class> targetWrapperType = Primitive.primitiveToWrapper(targetType);
+
+ if(targetWrapperType == value.getClass()){
+ return value;
+ }else{
+ final BeanPropertyConverter> propertyConverter = converters.get(targetWrapperType);
+ return propertyConverter == null ? value : propertyConverter.convert(value);
+ }
+ }
+ }
+
@SuppressWarnings({"unchecked"})
protected T mapToMap(final S source, final T target) {
Map