Skip to content

Commit

Permalink
Merge pull request #18 from buession/development
Browse files Browse the repository at this point in the history
Release 3.0.0
  • Loading branch information
eduosi authored Nov 6, 2024
2 parents 4c019f5 + bc9290f commit c191706
Show file tree
Hide file tree
Showing 1,195 changed files with 260,660 additions and 30,071 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ node_modules
.settings/
target/
.idea/
docs/doc/
docs/doc/
91 changes: 91 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,97 @@
===========================


## [3.0.0](https://github.com/buession/buessionframework/releases/tag/v3.0.0) (2024-11-07)

### 🔨依赖升级

- [依赖库版本升级和安全漏洞修复](https://github.com/buession/buession-parent/releases/tag/v3.0.0)


### ⭐ 新特性

- ClassUtils 新增检测类是否存在方法 isPresent
- 新增 list 到 set 转换器 ListSetConverter
- 新增 set 到 list 转换器 SetListConverter
- 新增断言转换器 PredicateConverter
- 新增 集合转换器 CollectionConverter
- 新增 Map.Entry 到 Map 转换器 MapEntryMapConverter
- httpClient Configuration 新增 expectContinueEnabled、hardCancellationEnabled、targetPreferredAuthSchemes、cookieSpec、proxy 配置
- httpClient 新增代理支持
- ApacheClient 新增支持 apache httpcomponents 5,根据依赖的 apache httpcomponents 5 和 apache httpcomponents 4 自动判断,优先使用 apache httpcomponents 5
- 新增支持 Lettuce(stream 命令不稳定,不推荐使用)
- jedis 模式下,集群支持管道
- 新增代理方法调用者 ProxyMethodInvoker
- 新增代理调用处理器 InvocationHandler 抽象类 AbstractInvocationHandler
- PropertyMapper 增加正数断言 alwaysApplyingWhenPositiveNumber
- com.buession.io.file.File 新增支持将 InputStream 写入文件
- JSON 序列化和反序列化支持对原生对象进行配置
- 增加范围类 Range 及其衍生类
- 新增日期时间工具类 DateTimeUtils


### 🔔 变化

- Maps.toList 参数为 LinkedHashMap 时返回 LinkedList
- Lists.toSet 参数为 LinkedList 返回 LinkedHashSet
- Sets.toList 参数为 LinkedHashSet 返回 LinkedList
- core 包中删除依赖 commons-beanutils
- 删除 ArrayUtils、StatusUtils、ObjectUtils、MapUtils、BuesssionFrameworkVersion
- 删除 AbstractAspectAnnotationsMethodInterceptor
- geoip 删除依赖 apache httpcomponents
- 废弃 ApacheRequest、ApacheRequestBuilder、ApacheHttpClientBuilder
- httpClient 优化 ConnectionManager 创建默认原生 ConnectionManager,以解决在创建原生 ConnectionManager 之前,更新了 Configuration 不生效的问题
- ApacheHttpClient 删除 apache httpcomponents 4 中的特有方法
- httpClient 参数为 URL 时,不再验证是否为 null
- apache httpcomponents 异步请求时 HttpAsyncResponseConsumer 采用 ZeroCopyConsumer
- okhttp maxRequestsPerHost 大于 0 时,才会更新 okhttp 原生 maxRequestsPerHost 的值
- 删除 OkHttpClient
- 重构 JDBC 连接池和数据源
- MyBatisDao 废弃 masterTemplate、slaveSqlSessionTemplate,通过其它数据库本身或其它中间件实现读写分离
- redis 删除参数为字符串数组或 byte[] 数组的方法 bitField
- redis 废弃字符串型 / byte[]型 min、max 参数的方法
- redis role 命令直接返回 Role,不再返回 List<Role>
- redis 重构管道、事务内部实现
- redis 哨兵连接,如果指定了连接超时、读取超时,但未指定哨兵节点连接超时、读取超时,哨兵节点连接超时、读取超时也使用该值
- redis 连接池调整在连接对象中创建,不再在 DataSource 中创建
- redis 不再推荐从 DataSource 中创建 RedisConnection 实例
- IO MimeType 忽略大小写比较
- 删除 com.buession.web.mvc.Response 中参数为 com.buession.core.Pagination 的构造函数和 setter 函数
- 删除 buession-cron 和 buession-session
- 删除 MobileFilter、PoweredByHeaderFilter
- 序列化类删除反序列化方法


### 🐞 Bug 修复

- httpClient 修复 ConnectionManager 未设置 connectionManagerShared 时,无法从 Configuration 中获取 connectionManagerShared 值的 BUG
- 修复 okhttp 设置 followRedirects 时,followSslRedirects 未生效的 BUG
- 修复 jedis 模式下 role 命令未返回数据的 BUG
- 修复 jedis 模式下 API 中,“命令”参数设置错误的 BUG
- 修复 jedis GeoRadiusResponseConverter coordinate 为 null 时,空指针异常
- 修复 jedis 模式下连接中的错误和参数丢失等问题
- 修复 Validate IPV4 验证,第一段为 10 ~ 99 时,验证失败的 BUG


### ⏪ 优化
- 优化 redis 转换器,不使用静态属性,以减少内存占用
- jedis 模式命令运算优化
- 优化 JDBC 数据源连接池设置
- 优化 httpclient 配置、连接管理器以及连接客户端
- 优化默认线程池执行器 DefaultThreadPoolExecutor 初始化
- com.buession.io.file.File 读取文件优化


### 📔 文档

- 完善 redis 注释
- 修正 httpclient 错误注释
- 完善 httpclient 注释


---


## [2.3.3](https://github.com/buession/buessionframework/releases/tag/v2.3.3) (2024-05-06)

### 🔨依赖升级
Expand Down
12 changes: 5 additions & 7 deletions buession-aop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.buession</groupId>
<artifactId>buession-parent</artifactId>
<relativePath>../buession-parent</relativePath>
<version>2.3.3</version>
<version>3.0.0</version>
</parent>
<artifactId>buession-aop</artifactId>
<url>http://www.buession.com/</url>
Expand Down Expand Up @@ -61,8 +61,6 @@
<dependency>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -77,8 +75,8 @@
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</dependency>
</dependencies>

Expand Down Expand Up @@ -122,8 +120,8 @@
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<groupId>org.sonatype.central</groupId>
<artifactId>central-publishing-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information regarding copyright ownership.
* The ASF licenses this file to you 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.
*
* =========================================================================================================
*
* This software consists of voluntary contributions made by many individuals on behalf of the
* Apache Software Foundation. For more information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* +-------------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng <[email protected]> |
* | Copyright @ 2013-2024 Buession.com Inc. |
* +-------------------------------------------------------------------------------------------------------+
*/
package com.buession.aop;

import com.buession.aop.utils.ProxyUtils;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
* {@link InvocationHandler} 抽象类
*
* @author Yong.Teng
* @since 3.0.0
*/
public abstract class AbstractInvocationHandler implements InvocationHandler {

private final static int ALLOWED_MODES = MethodHandles.Lookup.PRIVATE | MethodHandles.Lookup.PROTECTED
| MethodHandles.Lookup.PUBLIC | MethodHandles.Lookup.PACKAGE;

protected final static Constructor<MethodHandles.Lookup> lookupConstructor;

protected final static Method privateLookupInMethod;

static {
Method privateLookupIn;
try{
privateLookupIn = MethodHandles.class.getMethod("privateLookupIn", Class.class, MethodHandles.Lookup.class);
}catch(NoSuchMethodException e){
privateLookupIn = null;
}
privateLookupInMethod = privateLookupIn;

Constructor<MethodHandles.Lookup> lookup = null;
if(privateLookupInMethod == null){
// JDK 1.8
try{
lookup = MethodHandles.Lookup.class.getDeclaredConstructor(Class.class, int.class);
lookup.setAccessible(true);
}catch(NoSuchMethodException e){
throw new IllegalStateException(
"There is neither 'privateLookupIn(Class, Lookup)' nor 'Lookup(Class, int)' method in java.lang.invoke.MethodHandles.",
e);
}catch(Exception e){
lookup = null;
}
}
lookupConstructor = lookup;
}

@Override
public final Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if(args == null){
args = ProxyMethodInvoker.NO_ARGS;
}

if(args.length == 0){
if("hashCode".equals(method.getName())){
return doHashCode();
}else if("toString".equals(method.getName())){
return doToString();
}
}

if(args.length == 1 && "equals".equals(method.getName()) && method.getParameterTypes()[0] == Object.class){
Object arg = args[0];
return doEquals(proxy, arg);
}

return doInvoke(proxy, method, args);
}

protected Object doHashCode() {
return hashCode();
}

protected Object doEquals(final Object proxy, final Object arg) {
if(arg == null){
return false;
}

if(proxy == arg){
return true;
}

return ProxyUtils.isProxyOfSameInterfaces(arg, proxy.getClass()) && equals(Proxy.getInvocationHandler(arg));
}

protected Object doToString() {
return toString();
}

protected Object doInvoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
if(Object.class.equals(method.getDeclaringClass())){
return method.invoke(this, args);
}

return handleInvocation(proxy, method, args);
}

protected abstract Object handleInvocation(final Object proxy, final Method method, final Object[] args)
throws Throwable;

protected int getAllowedModes() {
return ALLOWED_MODES;
}

protected <T> ProxyMethodInvoker<T> createMethodInvoker(final Method method)
throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
if(method.isDefault()){
final MethodHandle methodHandle = privateLookupInMethod == null ? getMethodHandleJava8(method) :
getMethodHandleJava9(method);
return new DefaultMethodInvoker<>(methodHandle);
}else{
return new PlainMethodInvoker<>();
}
}

protected MethodHandle getMethodHandleJava8(final Method method)
throws IllegalAccessException, InstantiationException, InvocationTargetException {
final Class<?> declaringClass = method.getDeclaringClass();
return lookupConstructor.newInstance(declaringClass, getAllowedModes())
.unreflectSpecial(method, declaringClass);
}

protected MethodHandle getMethodHandleJava9(final Method method)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
final Class<?> declaringClass = method.getDeclaringClass();
final MethodType methodType = MethodType.methodType(method.getReturnType(), method.getParameterTypes());

return ((MethodHandles.Lookup) privateLookupInMethod.invoke(null, declaringClass, MethodHandles.lookup()))
.findSpecial(declaringClass, method.getName(), methodType, declaringClass);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information regarding copyright ownership.
* The ASF licenses this file to you 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.
*
* =========================================================================================================
*
* This software consists of voluntary contributions made by many individuals on behalf of the
* Apache Software Foundation. For more information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* +-------------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng <[email protected]> |
* | Copyright @ 2013-2024 Buession.com Inc. |
* +-------------------------------------------------------------------------------------------------------+
*/
package com.buession.aop;

import com.buession.core.utils.Assert;

import java.lang.invoke.MethodHandle;
import java.lang.reflect.Method;

/**
* 默认代理方法调用者
*
* @param <T>
* 代理类型
*
* @author Yong.Teng
* @since 3.0.0
*/
public class DefaultMethodInvoker<T> implements ProxyMethodInvoker<T> {

private final MethodHandle methodHandle;

/**
* 构造函数
*
* @param methodHandle
* {@link MethodHandle}
*/
public DefaultMethodInvoker(final MethodHandle methodHandle) {
Assert.isNull(methodHandle, "MethodHandle cloud not be null");
this.methodHandle = methodHandle;
}

@Override
public Object invoke(Object proxy, Method method, Object[] args, T object) throws Throwable {
return methodHandle.bindTo(proxy).invokeWithArguments(args);
}

}
Loading

0 comments on commit c191706

Please sign in to comment.