diff --git a/README.md b/README.md index 1d7be4608f..aedcfa7531 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@

- + diff --git a/VERSION b/VERSION index 608c4e7100..eb113b3869 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.0.2 \ No newline at end of file +8.0.5 \ No newline at end of file diff --git a/bus-all/pom.xml b/bus-all/pom.xml index ff1945d281..bc068e40c8 100755 --- a/bus-all/pom.xml +++ b/bus-all/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-all - 8.0.2 + 8.0.3 jar ${project.artifactId} @@ -75,163 +75,7 @@ ${project.groupId} - bus-base - ${project.version} - true - - - ${project.groupId} - bus-cache - ${project.version} - true - - - ${project.groupId} - bus-core - ${project.version} - true - - - ${project.groupId} - bus-cron - ${project.version} - true - - - ${project.groupId} - bus-crypto - ${project.version} - true - - - ${project.groupId} - bus-extra - ${project.version} - true - - - ${project.groupId} - bus-goalie - ${project.version} - true - - - ${project.groupId} - bus-health - ${project.version} - true - - - ${project.groupId} - bus-http - ${project.version} - true - - - ${project.groupId} - bus-image - ${project.version} - true - - - ${project.groupId} - bus-limiter - ${project.version} - true - - - ${project.groupId} - bus-logger - ${project.version} - true - - - ${project.groupId} - bus-mapper - ${project.version} - true - - - ${project.groupId} - bus-notify - ${project.version} - true - - - ${project.groupId} - bus-oauth - ${project.version} - true - - - ${project.groupId} - bus-office - ${project.version} - true - - - ${project.groupId} - bus-pager - ${project.version} - true - - - ${project.groupId} - bus-pay - ${project.version} - true - - - ${project.groupId} - bus-proxy - ${project.version} - true - - - ${project.groupId} - bus-sensitive - ${project.version} - true - - - ${project.groupId} - bus-setting - ${project.version} - true - - - ${project.groupId} - bus-socket - ${project.version} - true - - - ${project.groupId} - bus-spring - ${project.version} - true - - - ${project.groupId} - bus-starter - ${project.version} - true - - - ${project.groupId} - bus-storage - ${project.version} - true - - - ${project.groupId} - bus-tracer - ${project.version} - true - - - ${project.groupId} - bus-validate + bus-bom ${project.version} true @@ -262,84 +106,74 @@ - - - - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.5.2 - - - package - - shade - - - false - true - - - ${project.groupId}:*:* - - - - - *:* - - META-INF/maven/** - - - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.apache.maven.plugins + maven-shade-plugin + 3.5.2 + + + package + + shade + - central - true + false + true + + + ${project.groupId}:*:* + + + + + *:* + + META-INF/maven/** + + + - - - - - + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + + + diff --git a/bus-base/pom.xml b/bus-base/pom.xml index 7e7e77368b..22d1eef564 100755 --- a/bus-base/pom.xml +++ b/bus-base/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-base - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -71,8 +71,8 @@ 21 21 1.18.32 - 3.3.0 - 3.2.0-M2 + 3.3.1 + 3.2.0 @@ -86,6 +86,11 @@ bus-spring ${project.version} + + ${project.groupId} + bus-validate + ${project.version} + org.projectlombok lombok @@ -131,55 +136,45 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-base/src/main/java/org/miaixz/bus/base/advice/BaseAdvice.java b/bus-base/src/main/java/org/miaixz/bus/base/advice/BaseAdvice.java index 3ceb6eea59..883fc66808 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/advice/BaseAdvice.java +++ b/bus-base/src/main/java/org/miaixz/bus/base/advice/BaseAdvice.java @@ -27,8 +27,9 @@ */ package org.miaixz.bus.base.advice; -import org.miaixz.bus.base.normal.ErrorCode; -import org.miaixz.bus.base.spring.Controller; +import org.miaixz.bus.core.basics.advice.ErrorAdvice; +import org.miaixz.bus.core.basics.normal.ErrorCode; +import org.miaixz.bus.core.basics.spring.Controller; import org.miaixz.bus.core.instance.Instances; import org.miaixz.bus.core.lang.exception.BusinessException; import org.miaixz.bus.core.lang.exception.CrontabException; @@ -136,7 +137,7 @@ public Object businessException(BusinessException e) { public Object crontabException(CrontabException e) { this.defaultExceptionHandler(e); if (StringKit.isBlank(e.getErrcode())) { - return write(ErrorCode.EM_100514); + return write(ErrorCode.EM_100600); } return write(e.getErrcode(), e.getErrmsg()); } diff --git a/bus-base/src/main/java/org/miaixz/bus/base/entity/BaseEntity.java b/bus-base/src/main/java/org/miaixz/bus/base/entity/BaseEntity.java index ca0db407c6..b062bdfb91 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/entity/BaseEntity.java +++ b/bus-base/src/main/java/org/miaixz/bus/base/entity/BaseEntity.java @@ -28,12 +28,14 @@ package org.miaixz.bus.base.entity; import jakarta.persistence.Transient; -import lombok.EqualsAndHashCode; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; -import org.miaixz.bus.base.normal.Consts; -import org.miaixz.bus.core.data.ObjectId; -import org.miaixz.bus.core.lang.Normal; +import lombok.experimental.SuperBuilder; +import org.miaixz.bus.core.basics.entity.Tracer; +import org.miaixz.bus.core.basics.normal.Consts; +import org.miaixz.bus.core.data.id.ID; import org.miaixz.bus.core.xyz.*; import java.util.List; @@ -47,7 +49,9 @@ */ @Getter @Setter -@EqualsAndHashCode(callSuper = true) +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class BaseEntity extends Tracer { private static final long serialVersionUID = 1L; @@ -101,6 +105,23 @@ public class BaseEntity extends Tracer { @Transient protected transient String orderBy; + /** + * 重置数字型字符串为null,防止插入数据库表异常 + * + * @param 对象泛型 + * @param entity 实体对象 + * @param fields 数字型字符串属性数组 + * @param values 值数据 + */ + public static void resetIntField(T entity, String[] fields, String[] values) { + for (int i = 0; i < fields.length; i++) { + String field = fields[i]; + if (Consts.EMPTY.equals(values[i]) && FieldKit.hasField(entity.getClass(), field)) { + MethodKit.invokeSetter(entity, field, null); + } + } + } + /** * 设置访问信息 * @@ -108,7 +129,7 @@ public class BaseEntity extends Tracer { * @param source 源始实体 * @param target 目标实体 */ - public static void setAccess(T source, T target) { + public void setAccess(T source, T target) { if (Objects.isNull(source) || Objects.isNull(target)) { return; } @@ -123,12 +144,12 @@ public static void setAccess(T source, T target) { * @param source 源始实体 * @param target 目标实体 */ - public static void setAccess(T source, T... target) { + public void setAccess(T source, T... target) { if (Objects.isNull(source) || ArrayKit.isEmpty(target)) { return; } for (T targetEntity : target) { - setAccess(source, targetEntity); + this.setAccess(source, targetEntity); } } @@ -140,38 +161,21 @@ public static void setAccess(T source, T... target) { * @param source 源始实体 * @param target 目标实体 */ - public static void setAccess(S source, List target) { + public void setAccess(S source, List target) { if (Objects.isNull(source) || CollKit.isEmpty(target)) { return; } - target.forEach(targetEntity -> setAccess(source, targetEntity)); - } - - /** - * 重置数字型字符串为null,防止插入数据库表异常 - * - * @param 对象泛型 - * @param entity 实体对象 - * @param fields 数字型字符串属性数组 - * @param values 值数据 - */ - public static void resetIntField(T entity, String[] fields, String[] values) { - for (int i = 0; i < fields.length; i++) { - String field = fields[i]; - if (Consts.EMPTY.equals(values[i]) && FieldKit.hasField(entity.getClass(), field)) { - MethodKit.invokeSetter(entity, field, null); - } - } + target.forEach(targetEntity -> this.setAccess(source, targetEntity)); } /** - * 快速将bean的creator、created附上相关值 + * 快速设置操作者属性值 * * @param 对象 * @param entity 反射对象 */ - public void setCreateInfo(T entity) { - String id = ObjectKit.isEmpty(getValue(entity, "id")) ? ObjectId.id() : (String) getValue(entity, "id"); + public void setInsert(T entity) { + String id = ObjectKit.isEmpty(getValue(entity, "id")) ? ID.objectId() : (String) getValue(entity, "id"); String timestamp = StringKit.toString(DateKit.current()); String[] fields = {"id", "created"}; Object[] value = new Object[]{id, timestamp}; @@ -181,16 +185,16 @@ public void setCreateInfo(T entity) { ObjectKit.isEmpty(getValue(entity, "x_user_id")) ? "-1" : getValue(entity, "x_user_id"), timestamp}; } - setValue(entity, fields, value); + this.setValue(entity, fields, value); } /** - * 快速将bean的modifier、modified附上相关值 + * 快速设置操作者属性值 * - * @param 对象 + * @param 泛型对象 * @param entity 反射对象 */ - public void setUpdatedInfo(T entity) { + public void setUpdate(T entity) { String timestamp = StringKit.toString(DateKit.current()); String[] fields = {"modified"}; Object[] value = new Object[]{timestamp}; @@ -200,61 +204,18 @@ public void setUpdatedInfo(T entity) { timestamp}; } - setValue(entity, fields, value); - } - - public void setCreatAndUpdatInfo(T entity) { - setCreateInfo(entity); - setUpdatedInfo(entity); + this.setValue(entity, fields, value); } /** - * 根据主键属性,判断主键是否值为空 + * 快速设置操作者属性值 * - * @param 对象 * @param entity 反射对象 - * @param field 属性 - * @return 主键为空, 则返回false;主键有值,返回true + * @param 泛型对象 */ - public boolean isPKNotNull(T entity, String field) { - if (!FieldKit.hasField(entity.getClass(), field)) { - return false; - } - Object value = FieldKit.getFieldValue(entity, field); - return null != value && !Normal.EMPTY.equals(value); - } - - /** - * 依据对象的属性获取对象值 - * - * @param 对象 - * @param entity 反射对象 - * @param field 属性数组 - * @return 返回对象属性值 - */ - public Object getValue(T entity, String field) { - if (FieldKit.hasField(entity.getClass(), field)) { - Object object = MethodKit.invokeGetter(entity, field); - return null != object ? object.toString() : null; - } - return null; - } - - /** - * 依据对象的属性数组和值数组对进行赋值 - * - * @param 对象 - * @param entity 反射对象 - * @param fields 属性数组 - * @param value 值数组 - */ - public void setValue(T entity, String[] fields, Object[] value) { - for (int i = 0; i < fields.length; i++) { - String field = fields[i]; - if (FieldKit.hasField(entity.getClass(), field)) { - MethodKit.invokeSetter(entity, field, value[i]); - } - } + public void setValue(T entity) { + this.setInsert(entity); + this.setUpdate(entity); } } \ No newline at end of file diff --git a/bus-base/src/main/java/org/miaixz/bus/base/service/BaseService.java b/bus-base/src/main/java/org/miaixz/bus/base/service/BaseService.java old mode 100755 new mode 100644 index 3d12da0f4d..dbc8900631 --- a/bus-base/src/main/java/org/miaixz/bus/base/service/BaseService.java +++ b/bus-base/src/main/java/org/miaixz/bus/base/service/BaseService.java @@ -27,7 +27,8 @@ */ package org.miaixz.bus.base.service; -import org.miaixz.bus.base.entity.Result; +import org.miaixz.bus.core.basics.entity.Result; +import org.miaixz.bus.core.basics.service.Service; import java.util.List; @@ -71,19 +72,26 @@ public interface BaseService extends Service { */ Object insertBatchSelective(List list); + /** + * 通用:逻辑数据 + * + * @param entity 对象参数 + */ + int remove(T entity); + /** * 通用:删除数据 * * @param entity 对象参数 */ - void delete(T entity); + int delete(T entity); /** * 通用:删除数据 * * @param id 对象主键 */ - void deleteById(Object id); + int deleteById(Object id); /** * 通用:删除数据 @@ -106,7 +114,7 @@ public interface BaseService extends Service { * * @param entity 对象参数 */ - void updateById(T entity); + int updateById(T entity); /** * 通用:更新数据 @@ -230,4 +238,4 @@ public interface BaseService extends Service { */ Result page(T entity); -} +} \ No newline at end of file diff --git a/bus-base/src/main/java/org/miaixz/bus/base/service/impl/BaseServiceImpl.java b/bus-base/src/main/java/org/miaixz/bus/base/service/DefaultService.java similarity index 81% rename from bus-base/src/main/java/org/miaixz/bus/base/service/impl/BaseServiceImpl.java rename to bus-base/src/main/java/org/miaixz/bus/base/service/DefaultService.java index 7f2e27f462..cd3300f87c 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/service/impl/BaseServiceImpl.java +++ b/bus-base/src/main/java/org/miaixz/bus/base/service/DefaultService.java @@ -25,13 +25,12 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.service.impl; +package org.miaixz.bus.base.service; import org.miaixz.bus.base.entity.BaseEntity; -import org.miaixz.bus.base.entity.Result; import org.miaixz.bus.base.mapper.BaseMapper; -import org.miaixz.bus.base.normal.Consts; -import org.miaixz.bus.base.service.BaseService; +import org.miaixz.bus.core.basics.entity.Result; +import org.miaixz.bus.core.basics.normal.Consts; import org.miaixz.bus.core.xyz.FieldKit; import org.miaixz.bus.core.xyz.ObjectKit; import org.miaixz.bus.core.xyz.StringKit; @@ -44,14 +43,14 @@ import java.util.List; /** - * BaseService 接口实现 + * 基于spring 实现BaseService 接口 * 根据业务需要如无status,creator等相关属性内容 * 重写此类及{@link BaseEntity} 业务类继承新类 * * @author Kimi Liu * @since Java 17+ */ -public class BaseServiceImpl, T extends BaseEntity> +public class DefaultService, T extends BaseEntity> implements BaseService { @Autowired @@ -75,7 +74,7 @@ public String insertSelective(T entity) { public Object insertBatch(List list) { List data = new ArrayList<>(); list.forEach(item -> { - String id = insertSelective(item); + String id = this.insertSelective(item); data.add(id); }); return data; @@ -85,20 +84,27 @@ public Object insertBatch(List list) { public Object insertBatchSelective(List list) { List data = new ArrayList<>(); list.forEach(item -> { - String id = insertSelective(item); + String id = this.insertSelective(item); data.add(id); }); return data; } @Override - public void delete(T entity) { - mapper.delete(entity); + public int remove(T entity) { + entity.setStatus(Consts.STATUS_MINUS_ONE); + entity.setUpdate(entity); + return mapper.updateByPrimaryKey(entity); } @Override - public void deleteById(Object id) { - mapper.deleteByPrimaryKey(id); + public int delete(T entity) { + return mapper.delete(entity); + } + + @Override + public int deleteById(Object id) { + return mapper.deleteByPrimaryKey(id); } @Override @@ -112,14 +118,14 @@ public int deleteByWhere(Object object) { } @Override - public void updateById(T entity) { - entity.setUpdatedInfo(entity); - mapper.updateByPrimaryKey(entity); + public int updateById(T entity) { + entity.setUpdate(entity); + return mapper.updateByPrimaryKey(entity); } @Override public int updateSelectiveById(T entity) { - entity.setUpdatedInfo(entity); + entity.setUpdate(entity); return mapper.updateByPrimaryKeySelective(entity); } @@ -130,7 +136,7 @@ public T updateByIdCas(T entity, String locking) { Object id = FieldKit.getFieldValue(entity, "id"); condition.createCriteria().andEqualTo(locking, before); condition.createCriteria().andEqualTo("id", id); - updateByWhereSelective(entity, condition); + this.updateByWhereSelective(entity, condition); return entity; } @@ -139,7 +145,7 @@ public T updateSelectiveByIdOrInsert(T entity) { if (StringKit.isEmpty(entity.getId())) { this.insert(entity); } else { - entity.setUpdatedInfo(entity); + entity.setUpdate(entity); mapper.updateByPrimaryKeySelective(entity); } return entity; @@ -147,19 +153,19 @@ public T updateSelectiveByIdOrInsert(T entity) { @Override public int updateByWhere(T entity, Object object) { - entity.setUpdatedInfo(entity); + entity.setUpdate(entity); return mapper.updateByCondition(entity, object); } @Override public int updateByWhereSelective(T entity, Object object) { - entity.setUpdatedInfo(entity); + entity.setUpdate(entity); return mapper.updateByConditionSelective(entity, object); } @Override public int updateStatus(T entity) { - entity.setUpdatedInfo(entity); + entity.setUpdate(entity); return mapper.updateByPrimaryKeySelective(entity); } @@ -210,18 +216,27 @@ public Result page(T entity) { PageContext.orderBy(entity.getOrderBy()); } Page list = (Page) mapper.select(entity); - return new Result<>((int) list.getTotal(), list.getResult()); - } - - private String setValue(T entity) { + return Result.builder() + .rows(list.getResult()) + .total(list.getTotal()) + .build(); + } + + /** + * 更新对象属性值 + * 数据状态/操作人/操作时间 + * + * @param entity 对象 + * @return the string + */ + protected String setValue(T entity) { if (ObjectKit.isEmpty(entity)) { return null; } if (StringKit.isEmpty(entity.getStatus())) { entity.setStatus(Consts.STATUS_ONE); } - entity.setCreateInfo(entity); - entity.setUpdatedInfo(entity); + entity.setValue(entity); return entity.getId(); } diff --git a/bus-base/src/main/java/org/miaixz/bus/base/service/package-info.java b/bus-base/src/main/java/org/miaixz/bus/base/service/package-info.java index 3693f977ce..04e0705bf4 100644 --- a/bus-base/src/main/java/org/miaixz/bus/base/service/package-info.java +++ b/bus-base/src/main/java/org/miaixz/bus/base/service/package-info.java @@ -26,7 +26,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ /** - * 基础业务接口 + * 基础业务实现 * * @author Kimi Liu * @since Java 17+ diff --git a/bus-base/src/main/java/org/miaixz/bus/base/spring/BaseController.java b/bus-base/src/main/java/org/miaixz/bus/base/spring/BaseController.java index c249c3551e..c484c1fc4c 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/spring/BaseController.java +++ b/bus-base/src/main/java/org/miaixz/bus/base/spring/BaseController.java @@ -27,8 +27,12 @@ */ package org.miaixz.bus.base.spring; -import org.miaixz.bus.base.normal.ErrorCode; import org.miaixz.bus.base.service.BaseService; +import org.miaixz.bus.core.basics.normal.ErrorCode; +import org.miaixz.bus.core.basics.spring.Controller; +import org.miaixz.bus.core.xyz.MapKit; +import org.miaixz.bus.core.xyz.StringKit; +import org.miaixz.bus.validate.magic.annotation.Valid; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -54,11 +58,15 @@ public class BaseController, T> extends Controlle @ResponseBody @RequestMapping(value = "/add", method = RequestMethod.POST) public Object add(T entity) { - return write(ErrorCode.EM_SUCCESS, service.insertSelective(entity)); + String id = service.insertSelective(entity); + if (StringKit.isNotBlank(id)) { + return write(MapKit.of("id", id)); + } + return write(ErrorCode.EM_100513); } /** - * 通用:删除数据 + * 通用:逻辑删除 * * @param entity 对象参数 * @return 操作结果 @@ -66,8 +74,27 @@ public Object add(T entity) { @ResponseBody @RequestMapping(value = "/remove", method = RequestMethod.POST) public Object remove(T entity) { - service.deleteById(entity); - return write(ErrorCode.EM_SUCCESS); + int total = service.remove(entity); + if (total >= 0) { + return write(MapKit.of("total", total)); + } + return write(ErrorCode.EM_100513); + } + + /** + * 通用:物理删除 + * + * @param entity 对象参数 + * @return 操作结果 + */ + @ResponseBody + @RequestMapping(value = "/delete", method = RequestMethod.POST) + public Object delete(T entity) { + int total = service.delete(entity); + if (total >= 0) { + return write(MapKit.of("total", total)); + } + return write(ErrorCode.EM_100513); } /** @@ -79,7 +106,11 @@ public Object remove(T entity) { @ResponseBody @RequestMapping(value = "/update", method = RequestMethod.POST) public Object update(T entity) { - return write(ErrorCode.EM_SUCCESS, service.updateSelectiveById(entity)); + int total = service.updateSelectiveById(entity); + if (total >= 0) { + return write(MapKit.of("total", total)); + } + return write(ErrorCode.EM_100513); } /** @@ -114,7 +145,7 @@ public Object list(T entity) { */ @ResponseBody @RequestMapping(value = "/page", method = RequestMethod.GET) - public Object page(T entity) { + public Object page(@Valid({"pageSize", "pageNo"}) T entity) { return write(service.page(entity)); } diff --git a/bus-base/src/main/resources/META-INF/services/org.miaixz.bus.base.service.ErrorService b/bus-base/src/main/resources/META-INF/services/org.miaixz.bus.base.service.ErrorService deleted file mode 100644 index 7e80a709ce..0000000000 --- a/bus-base/src/main/resources/META-INF/services/org.miaixz.bus.base.service.ErrorService +++ /dev/null @@ -1 +0,0 @@ -org.miaixz.bus.base.service.ErrorService \ No newline at end of file diff --git a/bus-bom/README.md b/bus-bom/README.md old mode 100755 new mode 100644 diff --git a/bus-bom/pom.xml b/bus-bom/pom.xml old mode 100755 new mode 100644 index d61325119a..478b6c9733 --- a/bus-bom/pom.xml +++ b/bus-bom/pom.xml @@ -33,8 +33,8 @@ org.miaixz bus-bom - 8.0.2 - pom + 8.0.3 + jar ${project.artifactId} Bus Bom @@ -153,11 +153,6 @@ bus-office ${project.version} - - ${project.groupId} - bus-opencv - ${project.version} - ${project.groupId} bus-pager @@ -230,54 +225,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - - + \ No newline at end of file diff --git a/bus-cache/pom.xml b/bus-cache/pom.xml index efb7dac938..afe45da543 100755 --- a/bus-cache/pom.xml +++ b/bus-cache/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-cache - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -71,14 +71,14 @@ 21 21 1.18.32 - 3.3.0 + 3.3.1 7.0.0 5.1.3 2.4.8 5.6.0 33.2.1-jre 4.0.66 - 8.3.0 + 8.4.0 @@ -242,54 +242,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-core/pom.xml b/bus-core/pom.xml index e9ca738301..b6c8a87c03 100755 --- a/bus-core/pom.xml +++ b/bus-core/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-core - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -71,6 +71,7 @@ 21 21 1.18.32 + 3.2.0 @@ -80,6 +81,12 @@ ${lombok.version} true + + jakarta.persistence + jakarta.persistence-api + ${persistence.version} + true + @@ -107,54 +114,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-core/src/main/java/org/miaixz/bus/core/Version.java b/bus-core/src/main/java/org/miaixz/bus/core/Version.java index abf58c98ea..b6aaec4806 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/Version.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/Version.java @@ -49,7 +49,7 @@ public class Version implements Comparable, Serializable { /** * 版本信息 */ - public static final String _VERSION = "8.0.2"; + public static final String _VERSION = "8.0.5"; private static final long serialVersionUID = -1L; private final String version; @@ -176,7 +176,6 @@ public static Version of(final String v) { *

      * [大版本].[小版本].[发布流水号]
      * 
- *

* 这里有点说明 *

    *
  • 大版本 - 表示API的版本,如果没有重大变化,基本上同样的大版本号,使用方式是一致的 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/AnnotatedElements.java b/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/AnnotatedElements.java index 71f4f64da6..e7ba883691 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/AnnotatedElements.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/AnnotatedElements.java @@ -44,11 +44,11 @@ import java.util.stream.Stream; /** - *

    {@link AnnotatedElement}工具类,提供对层级结构中{@link AnnotatedElement}上注解及元注解的访问支持, + * {@link AnnotatedElement}工具类,提供对层级结构中{@link AnnotatedElement}上注解及元注解的访问支持, * 并提供诸如基于{@link Alias}的属性别名、基于父子注解间的属性值覆盖等特殊的属性映射机制支持。 * - *

    搜索层级结构 - *

    参考 Spring 中{@code AnnotatedElementUtils}, + * 搜索层级结构 + * 参考 Spring 中{@code AnnotatedElementUtils}, * 工具类提供get以及find两种语义的搜索: *

      *
    • get:表示搜索范围仅限于指定的{@link AnnotatedElement}本身;
    • @@ -63,8 +63,8 @@ * 则通过getXXX方法将只能获得A上的注解, * 而通过findXXX方法将能获得ABC上的注解。 * - *

      搜索元注解 - *

      工具类支持搜索注解的元注解。在所有格式为getXXXfindXXX的静态方法中, + * 搜索元注解 + * 工具类支持搜索注解的元注解。在所有格式为getXXXfindXXX的静态方法中, * 若不带有directly关键字,则该方法支持搜索元注解,否则不支持搜索元注解。 * eg: * 若类A分别有父类和父接口BC,上面分别有注解X与其元注解Y, @@ -77,8 +77,8 @@ *

    * 注意:在当前实例中将无视{@link Inherited}的效果,即通过directly方法将无法获得父类上带有{@link Inherited}的注解。 * - *

    注解属性映射 - *

    工具类支持注解对象属性上的一些属性映射机制,即当注解被扫描时, + * 注解属性映射 + * 工具类支持注解对象属性上的一些属性映射机制,即当注解被扫描时, * 将根据一些属性映射机制“解析”为其他类型的属性,这里支持的机制包括: *

      *
    • @@ -125,8 +125,8 @@ *
    • *
    * - *

    可重复注解支持 - *

    工具类中格式为findAllXXXgetAllXXX格式的方法, + * 可重复注解支持 + * 工具类中格式为findAllXXXgetAllXXX格式的方法, * 支持获得{@link AnnotatedElement}上的可重复注解。 * 此处的可重复注解定义包括两方面: *

      @@ -147,8 +147,8 @@ * *
    * - *

    缓存 - *

    为了避免注解以及{@link AnnotatedElement}层级结构解析过程中的大量反射调用, + * 缓存 + * 为了避免注解以及{@link AnnotatedElement}层级结构解析过程中的大量反射调用, * 工具类为{@link AnnotatedElement}及其元注解信息进行了缓存。 * 缓存功能默认基于{@link WeakConcurrentMap}实现,会在gc时自动回收部分缓存数据。 * 但是若有必要,也可以调用{@link #clearCaches()}方法主动清空缓存。 @@ -542,7 +542,7 @@ public static AnnotatedElement toHierarchyMetaElement(final AnnotatedElement ele } /** - *

    扫描{@code element}所处层级结构中的{@link AnnotatedElement}, + * 扫描{@code element}所处层级结构中的{@link AnnotatedElement}, * 并将其全部转为{@link RepeatableMetaAnnotatedElement}后, * 再把所有对象合并为{@link HierarchicalAnnotatedElements}。 * 得到的对象可访问{@code element}所处层级结构中所有{@link AnnotatedElement}上的直接声明的注解, @@ -565,7 +565,7 @@ public static AnnotatedElement toHierarchyRepeatableMetaElement(final AnnotatedE } /** - *

    扫描{@code element}所处层级结构中的{@link AnnotatedElement}, + * 扫描{@code element}所处层级结构中的{@link AnnotatedElement}, * 再把所有对象合并为{@link HierarchicalAnnotatedElements} * 得到的对象可访问{@code element}所处层级结构中所有{@link AnnotatedElement}上的注解。 * @@ -611,7 +611,7 @@ public static AnnotatedElement toRepeatableMetaElement(final AnnotatedElement el } /** - *

    将{@link AnnotatedElement}转为{@link RepeatableMetaAnnotatedElement}, + * 将{@link AnnotatedElement}转为{@link RepeatableMetaAnnotatedElement}, * 得到的对象可访问{@link AnnotatedElement}上的直接声明的注解, * 通过{@code collector}从这些注解获得的可重复注解,以及上述注解的所有元注解。 * 注意:方法将不会通过缓存结果,因此每次调用都需要重新通过反射并获得相关注解。 @@ -666,7 +666,7 @@ public static AnnotatedElement emptyElement() { * @param element {@link AnnotatedElement} * @return {@link MetaAnnotatedElement}实例 */ - static MetaAnnotatedElement getResolvedMetaElementCache(final AnnotatedElement element) { + public static MetaAnnotatedElement getResolvedMetaElementCache(final AnnotatedElement element) { return RESOLVED_ELEMENT_CACHE.computeIfAbsent(element, ele -> MetaAnnotatedElement.create( element, (source, annotation) -> ResolvedAnnotationMapping.create(source, annotation, true) )); @@ -678,7 +678,7 @@ static MetaAnnotatedElement getResolvedMetaElementCac * @param element {@link AnnotatedElement} * @return {@link MetaAnnotatedElement}实例 */ - static MetaAnnotatedElement getMetaElementCache(final AnnotatedElement element) { + public static MetaAnnotatedElement getMetaElementCache(final AnnotatedElement element) { return ELEMENT_CACHE.computeIfAbsent(element, ele -> MetaAnnotatedElement.create( element, (source, annotation) -> GenericAnnotationMapping.create(annotation, Objects.isNull(source)) )); @@ -690,7 +690,7 @@ static MetaAnnotatedElement getMetaElementCache(final * @param element {@link AnnotatedElement} * @return {@link MetaAnnotatedElement}实例 */ - static RepeatableMetaAnnotatedElement getResolvedRepeatableMetaElementCache(final AnnotatedElement element) { + public static RepeatableMetaAnnotatedElement getResolvedRepeatableMetaElementCache(final AnnotatedElement element) { return RESOLVED_REPEATABLE_ELEMENT_CACHE.computeIfAbsent(element, ele -> RepeatableMetaAnnotatedElement.create( element, (source, annotation) -> ResolvedAnnotationMapping.create(source, annotation, true) )); @@ -702,7 +702,7 @@ static RepeatableMetaAnnotatedElement getResolvedRepe * @param element {@link AnnotatedElement} * @return {@link MetaAnnotatedElement}实例 */ - static RepeatableMetaAnnotatedElement getRepeatableMetaElementCache(final AnnotatedElement element) { + public static RepeatableMetaAnnotatedElement getRepeatableMetaElementCache(final AnnotatedElement element) { return REPEATABLE_ELEMENT_CACHE.computeIfAbsent(element, ele -> RepeatableMetaAnnotatedElement.create( element, (source, annotation) -> GenericAnnotationMapping.create(annotation, Objects.isNull(source)) )); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/AnnotationMappingProxy.java b/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/AnnotationMappingProxy.java index d41fdbb5e4..a7c8e38d38 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/AnnotationMappingProxy.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/AnnotationMappingProxy.java @@ -189,7 +189,7 @@ private Object getAttributeValue(final String attributeName, final Class attr /** * 表明注解是一个合成的注解 */ - interface Proxied { + public interface Proxied { /** * 获取注解映射对象 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/GenericAnnotationMapping.java b/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/GenericAnnotationMapping.java index f3aab35813..e1ef3c4c3e 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/GenericAnnotationMapping.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/GenericAnnotationMapping.java @@ -55,7 +55,7 @@ public class GenericAnnotationMapping implements AnnotationMapping { * @param annotation 注解对象 * @param isRoot 是否根注解 */ - GenericAnnotationMapping(final Annotation annotation, final boolean isRoot) { + public GenericAnnotationMapping(final Annotation annotation, final boolean isRoot) { this.annotation = Objects.requireNonNull(annotation); this.isRoot = isRoot; this.attributes = AnnoKit.getAnnotationAttributes(annotation.annotationType()); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/ResolvedAnnotationMapping.java b/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/ResolvedAnnotationMapping.java index ab2ea88216..0f744a5079 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/ResolvedAnnotationMapping.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/annotation/resolve/ResolvedAnnotationMapping.java @@ -146,7 +146,7 @@ public class ResolvedAnnotationMapping implements AnnotationMapping *

  • 当{@code annotation}包装的注解对象类型为{@code ResolvedAnnotationMapping}时抛出;
  • *
*/ - ResolvedAnnotationMapping(final ResolvedAnnotationMapping source, final Annotation annotation, final boolean resolveAttribute) { + public ResolvedAnnotationMapping(final ResolvedAnnotationMapping source, final Annotation annotation, final boolean resolveAttribute) { Objects.requireNonNull(annotation); Assert.isFalse(AnnotationMappingProxy.isProxied(annotation), "annotation has been proxied"); Assert.isFalse(annotation instanceof ResolvedAnnotationMapping, "annotation has been wrapped"); @@ -200,6 +200,7 @@ public static ResolvedAnnotationMapping create( * 解析属性 */ private boolean resolveAttributes() { + // TODO 支持处理@Ignore,被标记的属性无法被覆写,也不会被别名关联 // 解析同一注解中的别名 resolveAliasAttributes(); // 使用子注解覆写当前注解中的属性 diff --git a/bus-base/src/main/java/org/miaixz/bus/base/advice/ErrorAdvice.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/advice/ErrorAdvice.java similarity index 97% rename from bus-base/src/main/java/org/miaixz/bus/base/advice/ErrorAdvice.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/advice/ErrorAdvice.java index 5de6ff07e4..fc0819ae5e 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/advice/ErrorAdvice.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/advice/ErrorAdvice.java @@ -25,9 +25,9 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.advice; +package org.miaixz.bus.core.basics.advice; -import org.miaixz.bus.base.service.ErrorService; +import org.miaixz.bus.core.basics.service.ErrorService; import java.util.ServiceLoader; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/basics/advice/package-info.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/advice/package-info.java new file mode 100644 index 0000000000..30663762a2 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/advice/package-info.java @@ -0,0 +1,34 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +/** + * 异常信息处理 + * + * @author Kimi Liu + * @since Java 17+ + */ +package org.miaixz.bus.core.basics.advice; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Entity.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Entity.java new file mode 100755 index 0000000000..12db9b6b87 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Entity.java @@ -0,0 +1,111 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.basics.entity; + +import jakarta.persistence.Id; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; +import org.miaixz.bus.core.lang.Normal; +import org.miaixz.bus.core.xyz.FieldKit; + +import java.io.Serializable; + +/** + * Entity 实体 + * + * @author Kimi Liu + * @since Java 17+ + */ +@Getter +@Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class Entity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 数据主键 + */ + @Id + protected String id; + + /** + * 根据主键属性,判断主键是否值为空 + * + * @param 对象 + * @param entity 反射对象 + * @param field 属性 + * @return 主键为空, 则返回false;主键有值,返回true + */ + public boolean isPKNotNull(T entity, String field) { + if (!FieldKit.hasField(entity.getClass(), field)) { + return false; + } + Object value = FieldKit.getFieldValue(entity, field); + return null != value && !Normal.EMPTY.equals(value); + } + + /** + * 依据对象的属性获取对象值 + * + * @param 对象 + * @param entity 反射对象 + * @param field 属性数组 + * @return 返回对象属性值 + */ + public Object getValue(T entity, String field) { + if (FieldKit.hasField(entity.getClass(), field)) { + Object value = FieldKit.getFieldValue(entity, field); + return null != value ? value.toString() : null; + } + return null; + } + + /** + * 依据对象的属性数组和值数组对进行赋值 + * + * @param 对象 + * @param entity 反射对象 + * @param fields 属性数组 + * @param value 值数组 + */ + public void setValue(T entity, String[] fields, Object[] value) { + for (int i = 0; i < fields.length; i++) { + String field = fields[i]; + if (FieldKit.hasField(entity.getClass(), field)) { + FieldKit.setFieldValue(entity, field, value[i]); + } + } + } + +} diff --git a/bus-base/src/main/java/org/miaixz/bus/base/entity/Message.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Message.java similarity index 89% rename from bus-base/src/main/java/org/miaixz/bus/base/entity/Message.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Message.java index 296b9087ca..e3a41acaa2 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/entity/Message.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Message.java @@ -25,35 +25,39 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.entity; +package org.miaixz.bus.core.basics.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** - * 返回值公用类 + * 响应结果 * * @author Kimi Liu * @since Java 17+ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Message { /** - * 请求返回码 + * 响应码 */ public String errcode; /** - * 请求返回消息 + * 提示信息 */ public String errmsg; /** - * 请求返回数据 + * 数据集 */ public Object data; diff --git a/bus-base/src/main/java/org/miaixz/bus/base/entity/OAuth2.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/OAuth2.java similarity index 90% rename from bus-base/src/main/java/org/miaixz/bus/base/entity/OAuth2.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/entity/OAuth2.java index 8985a4ea84..c659785ae0 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/entity/OAuth2.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/OAuth2.java @@ -25,22 +25,26 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.entity; +package org.miaixz.bus.core.basics.entity; import jakarta.persistence.Transient; -import lombok.EqualsAndHashCode; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; /** - * 授权公用类 + * 访问授权 * * @author Kimi Liu * @since Java 17+ */ @Getter @Setter -@EqualsAndHashCode(callSuper = true) +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class OAuth2 extends Entity { private static final long serialVersionUID = 1L; @@ -51,6 +55,12 @@ public class OAuth2 extends Entity { @Transient protected String x_user_id; + /** + * 当前用户编码 + */ + @Transient + protected String x_user_code; + /** * 当前用户名称 */ diff --git a/bus-base/src/main/java/org/miaixz/bus/base/entity/Result.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Result.java similarity index 76% rename from bus-base/src/main/java/org/miaixz/bus/base/entity/Result.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Result.java index ff47c6124f..ce4f9d55b0 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/entity/Result.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Result.java @@ -25,66 +25,50 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.entity; +package org.miaixz.bus.core.basics.entity; -import lombok.EqualsAndHashCode; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.util.Collections; import java.util.List; /** - * 返回结果公用 + * 数据结果 * * @author Kimi Liu * @since Java 17+ */ @Getter @Setter -@EqualsAndHashCode(callSuper = true) -public class Result extends BaseEntity { +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor +public class Result { private static final long serialVersionUID = 1L; /** * 总数据 */ - protected int total; + protected long total; /** * 查询记录数 */ protected List rows; - public Result() { - - } - - public Result(List rows) { - this.rows = rows; - } - - public Result(int total, List rows) { - this.total = total; - this.rows = rows; - } - - public Result(List rows, int pageSize) { - if (null == rows || rows.isEmpty()) { - throw new IllegalArgumentException("data must be not empty!"); - } - new Result<>(rows, rows.size(), pageSize); - } - - public Result(List rows, int total, int pageSize) { - this.total = total; - this.pageSize = pageSize; - this.rows = rows; - } + /** + * 分页页码 + */ + protected transient Integer pageNo; - public static Result Result(List rows, int pageSize) { - return new Result<>(rows, pageSize); - } + /** + * 分页大小 + */ + protected transient Integer pageSize; /** * 得到分页后的数据 diff --git a/bus-base/src/main/java/org/miaixz/bus/base/entity/Tracer.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Tracer.java similarity index 93% rename from bus-base/src/main/java/org/miaixz/bus/base/entity/Tracer.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Tracer.java index a72c7c1582..b2205d1c2c 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/entity/Tracer.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/Tracer.java @@ -25,22 +25,26 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.entity; +package org.miaixz.bus.core.basics.entity; import jakarta.persistence.Transient; -import lombok.EqualsAndHashCode; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; /** - * 访问链路跟踪 + * 链路跟踪 * * @author Kimi Liu * @since Java 17+ */ @Getter @Setter -@EqualsAndHashCode(callSuper = true) +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class Tracer extends OAuth2 { /** diff --git a/bus-base/src/main/java/org/miaixz/bus/base/entity/package-info.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/package-info.java similarity index 98% rename from bus-base/src/main/java/org/miaixz/bus/base/entity/package-info.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/entity/package-info.java index 6798618927..377aa2e3da 100644 --- a/bus-base/src/main/java/org/miaixz/bus/base/entity/package-info.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/entity/package-info.java @@ -31,4 +31,4 @@ * @author Kimi Liu * @since Java 17+ */ -package org.miaixz.bus.base.entity; +package org.miaixz.bus.core.basics.entity; diff --git a/bus-base/src/main/java/org/miaixz/bus/base/normal/Consts.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/normal/Consts.java similarity index 98% rename from bus-base/src/main/java/org/miaixz/bus/base/normal/Consts.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/normal/Consts.java index 3e9b0d7b1e..04940a3a49 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/normal/Consts.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/normal/Consts.java @@ -25,13 +25,13 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.normal; +package org.miaixz.bus.core.basics.normal; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; /** - * 公共常量 + * 业务常量 * * @author Kimi Liu * @since Java 17+ diff --git a/bus-base/src/main/java/org/miaixz/bus/base/normal/ErrorCode.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/normal/ErrorCode.java similarity index 98% rename from bus-base/src/main/java/org/miaixz/bus/base/normal/ErrorCode.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/normal/ErrorCode.java index 3f2361a39a..bffffbebd0 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/normal/ErrorCode.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/normal/ErrorCode.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.normal; +package org.miaixz.bus.core.basics.normal; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; @@ -236,7 +236,7 @@ public class ErrorCode { /** * 任务执行失败 */ - public static String EM_100514 = "100514"; + public static String EM_100600 = "100600"; /** * 错误码缓存 @@ -292,7 +292,7 @@ public class ErrorCode { register(EM_100511, "验证失败!"); register(EM_100512, "数据已存在"); register(EM_100513, "业务处理失败"); - register(EM_100514, "任务执行失败"); + register(EM_100600, "任务执行失败"); } /** diff --git a/bus-base/src/main/java/org/miaixz/bus/base/normal/package-info.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/normal/package-info.java similarity index 98% rename from bus-base/src/main/java/org/miaixz/bus/base/normal/package-info.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/normal/package-info.java index 01f914517c..f86ae8128f 100644 --- a/bus-base/src/main/java/org/miaixz/bus/base/normal/package-info.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/normal/package-info.java @@ -31,4 +31,4 @@ * @author Kimi Liu * @since Java 17+ */ -package org.miaixz.bus.base.normal; +package org.miaixz.bus.core.basics.normal; diff --git a/bus-base/src/main/java/org/miaixz/bus/base/service/impl/package-info.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/package-info.java similarity index 97% rename from bus-base/src/main/java/org/miaixz/bus/base/service/impl/package-info.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/package-info.java index de98252e9b..8e02eead6c 100644 --- a/bus-base/src/main/java/org/miaixz/bus/base/service/impl/package-info.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/package-info.java @@ -26,9 +26,9 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ /** - * 基础业务实现 + * 业务基础功能 * * @author Kimi Liu * @since Java 17+ */ -package org.miaixz.bus.base.service.impl; +package org.miaixz.bus.core.basics; diff --git a/bus-base/src/main/java/org/miaixz/bus/base/service/ErrorService.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/service/ErrorService.java similarity index 81% rename from bus-base/src/main/java/org/miaixz/bus/base/service/ErrorService.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/service/ErrorService.java index 249b34b146..9283ba5aca 100644 --- a/bus-base/src/main/java/org/miaixz/bus/base/service/ErrorService.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/service/ErrorService.java @@ -25,27 +25,26 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.service; +package org.miaixz.bus.core.basics.service; -import lombok.NoArgsConstructor; +import org.miaixz.bus.core.lang.Console; import org.miaixz.bus.core.xyz.ExceptionKit; -import org.miaixz.bus.logger.Logger; /** * 异常信息处理 * 此类未找到实现的情况下,采用默认实现 - * 可以根据不同业务需求,继承此类实现对应业务逻辑即可 - * 项目中可通过SPI自定义接入 - * 例:META-INF/services/org.miaixz.bus.base.service.ErrorService + * 可以根据不同业务需求,重写方法实现对应业务逻辑即可 + * 项目中可通过SPI形式接入 + * 例:META-INF/services/org.miaixz.bus.core.basics.service.ErrorService * - * org.miaixz.bus.xxx.ErrorService + * org.miaixz.bus.xxx.BusinessErrorService + * ...... * * * @author Kimi Liu * @since Java 17+ */ -@NoArgsConstructor -public class ErrorService { +public interface ErrorService { /** * 完成请求处理前调用 @@ -53,8 +52,8 @@ public class ErrorService { * @param ex 对象参数 * @return 如果执行链应该继续执行, 则为:true 否则:false */ - public boolean before(Exception ex) { - Logger.error(ExceptionKit.stacktraceToString(ex)); + default boolean before(Exception ex) { + Console.error("Before error of : " + ExceptionKit.stacktraceToString(ex)); return true; } @@ -64,7 +63,8 @@ public boolean before(Exception ex) { * @param ex 对象参数 * @return 如果执行链应该继续执行, 则为:true 否则:false */ - public boolean after(Exception ex) { + default boolean after(Exception ex) { + Console.error("After error of : " + ExceptionKit.stacktraceToString(ex)); return true; } diff --git a/bus-base/src/main/java/org/miaixz/bus/base/service/Service.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/service/Service.java similarity index 98% rename from bus-base/src/main/java/org/miaixz/bus/base/service/Service.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/service/Service.java index f42a793f3f..a50a1675c3 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/service/Service.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/service/Service.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.service; +package org.miaixz.bus.core.basics.service; /** * Service 接口 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/basics/service/package-info.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/service/package-info.java new file mode 100644 index 0000000000..94303d6559 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/service/package-info.java @@ -0,0 +1,34 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +/** + * 业务接口 + * + * @author Kimi Liu + * @since Java 17+ + */ +package org.miaixz.bus.core.basics.service; diff --git a/bus-base/src/main/java/org/miaixz/bus/base/spring/Controller.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/spring/Controller.java similarity index 97% rename from bus-base/src/main/java/org/miaixz/bus/base/spring/Controller.java rename to bus-core/src/main/java/org/miaixz/bus/core/basics/spring/Controller.java index 7786d7a159..309e6dcdaf 100755 --- a/bus-base/src/main/java/org/miaixz/bus/base/spring/Controller.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/spring/Controller.java @@ -25,10 +25,10 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.spring; +package org.miaixz.bus.core.basics.spring; -import org.miaixz.bus.base.entity.Message; -import org.miaixz.bus.base.normal.ErrorCode; +import org.miaixz.bus.core.basics.entity.Message; +import org.miaixz.bus.core.basics.normal.ErrorCode; import org.miaixz.bus.core.xyz.StringKit; /** diff --git a/bus-core/src/main/java/org/miaixz/bus/core/basics/spring/package-info.java b/bus-core/src/main/java/org/miaixz/bus/core/basics/spring/package-info.java new file mode 100644 index 0000000000..864518fe78 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/basics/spring/package-info.java @@ -0,0 +1,34 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +/** + * 业务控制器 + * + * @author Kimi Liu + * @since Java 17+ + */ +package org.miaixz.bus.core.basics.spring; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/beans/BeanDescCache.java b/bus-core/src/main/java/org/miaixz/bus/core/beans/BeanDescCache.java index 3c68580b3d..763927788b 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/beans/BeanDescCache.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/beans/BeanDescCache.java @@ -27,9 +27,10 @@ */ package org.miaixz.bus.core.beans; -import org.miaixz.bus.core.center.function.SupplierX; import org.miaixz.bus.core.center.map.reference.WeakConcurrentMap; +import java.util.function.Supplier; + /** * Bean属性缓存 * 缓存用于防止多次反射造成的性能问题 @@ -44,17 +45,18 @@ public enum BeanDescCache { */ INSTANCE; - private final WeakConcurrentMap, StrictBeanDesc> bdCache = new WeakConcurrentMap<>(); + private final WeakConcurrentMap, BeanDesc> bdCache = new WeakConcurrentMap<>(); /** - * 获得属性名和{@link StrictBeanDesc}Map映射 + * 获得属性名和{@link BeanDesc}Map映射 * * @param beanClass Bean的类 * @param supplier 对象不存在时创建对象的函数 - * @return 属性名和 {@link StrictBeanDesc}映射 + * @param BeanDesc子类 + * @return 属性名和 {@link BeanDesc}映射 */ - public StrictBeanDesc getBeanDesc(final Class beanClass, final SupplierX supplier) { - return bdCache.computeIfAbsent(beanClass, (key) -> supplier.get()); + public T getBeanDesc(final Class beanClass, final Supplier supplier) { + return (T) bdCache.computeIfAbsent(beanClass, (key) -> supplier.get()); } /** diff --git a/bus-core/src/main/java/org/miaixz/bus/core/cache/provider/AbstractCache.java b/bus-core/src/main/java/org/miaixz/bus/core/cache/provider/AbstractCache.java index 010e63495e..b431e34cb7 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/cache/provider/AbstractCache.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/cache/provider/AbstractCache.java @@ -111,10 +111,18 @@ protected void putWithoutLock(final K key, final V object, final long timeout) { if (timeout != 0) { existCustomTimeout = true; } - if (isFull()) { - pruneCache(); + final MutableObject mKey = MutableObject.of(key); + + // 对于替换的键值对,不做满队列检查和清除 + if (cacheMap.containsKey(mKey)) { + // 存在相同key,覆盖之 + cacheMap.put(mKey, co); + } else { + if (isFull()) { + pruneCache(); + } + cacheMap.put(mKey, co); } - cacheMap.put(MutableObject.of(key), co); } /** diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/magic/Message.java b/bus-core/src/main/java/org/miaixz/bus/core/center/BoundedCollection.java old mode 100755 new mode 100644 similarity index 83% rename from bus-storage/src/main/java/org/miaixz/bus/storage/magic/Message.java rename to bus-core/src/main/java/org/miaixz/bus/core/center/BoundedCollection.java index e6266c399f..758bd3e052 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/magic/Message.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/BoundedCollection.java @@ -25,34 +25,31 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.storage.magic; +package org.miaixz.bus.core.center; -import lombok.Builder; -import lombok.Getter; +import java.util.Collection; /** - * 响应结果 + * 有边界限制的集合,边界集合有最大容量限制 * + * @param 元素类型 * @author Kimi Liu * @since Java 17+ */ -@Getter -@Builder -public class Message { +public interface BoundedCollection extends Collection { /** - * 请求返回码,正确为 0 + * 是否已满,如果集合已满,不允许新增元素 + * + * @return 是否已满 */ - public String errcode; + boolean isFull(); /** - * 请求返回消息 + * 获取集合最大允许容量 + * + * @return 容量 */ - public String errmsg; - - /** - * 请求返回数据 - */ - public Object data; + int maxSize(); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/CollectionOperation.java b/bus-core/src/main/java/org/miaixz/bus/core/center/CollectionOperation.java index 2a5122f2c8..2c4cc704d2 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/CollectionOperation.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/CollectionOperation.java @@ -44,7 +44,7 @@ *
  • 求集合的差集
  • * * - * @param 集合元素类型 + * @param 元素类型 * @author Kimi Liu * @since Java 17+ */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/TransCollection.java b/bus-core/src/main/java/org/miaixz/bus/core/center/TransCollection.java index e09a6fdebf..d60ac30d4e 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/TransCollection.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/TransCollection.java @@ -48,17 +48,17 @@ */ public class TransCollection extends AbstractCollection { - private final Collection fromCollection; + private final Collection from; private final Function function; /** * 构造 * - * @param fromCollection 源集合 + * @param from 源集合 * @param function 转换函数 */ - public TransCollection(final Collection fromCollection, final Function function) { - this.fromCollection = Assert.notNull(fromCollection); + public TransCollection(final Collection from, final Function function) { + this.from = Assert.notNull(from); this.function = Assert.notNull(function); } @@ -67,49 +67,49 @@ public TransCollection(final Collection fromCollection, final Function 源元素类型 * @param 目标元素类型 - * @param fromSpliterator 源{@link Spliterator} + * @param from 源{@link Spliterator} * @param function 转换函数 * @return 新类型的{@link Spliterator} */ - public static Spliterator trans(final Spliterator fromSpliterator, final Function function) { - return new TransSpliterator<>(fromSpliterator, function); + public static Spliterator trans(final Spliterator from, final Function function) { + return new TransSpliterator<>(from, function); } @Override public Iterator iterator() { - return IteratorKit.trans(fromCollection.iterator(), function); + return IteratorKit.trans(from.iterator(), function); } @Override public void clear() { - fromCollection.clear(); + from.clear(); } @Override public boolean isEmpty() { - return fromCollection.isEmpty(); + return from.isEmpty(); } @Override public void forEach(final Consumer action) { Assert.notNull(action); - fromCollection.forEach((f) -> action.accept(function.apply(f))); + from.forEach((f) -> action.accept(function.apply(f))); } @Override public boolean removeIf(final Predicate filter) { Assert.notNull(filter); - return fromCollection.removeIf(element -> filter.test(function.apply(element))); + return from.removeIf(element -> filter.test(function.apply(element))); } @Override public Spliterator spliterator() { - return trans(fromCollection.spliterator(), function); + return trans(from.spliterator(), function); } @Override public int size() { - return fromCollection.size(); + return from.size(); } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/TransSpliterator.java b/bus-core/src/main/java/org/miaixz/bus/core/center/TransSpliterator.java index d9aa060e7d..a812524ccf 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/TransSpliterator.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/TransSpliterator.java @@ -41,45 +41,45 @@ */ public class TransSpliterator implements Spliterator { - private final Spliterator fromSpliterator; + private final Spliterator from; private final Function function; /** * 构造 * - * @param fromSpliterator 源iterator + * @param from 源iterator * @param function 函数 */ - public TransSpliterator(final Spliterator fromSpliterator, final Function function) { - this.fromSpliterator = fromSpliterator; + public TransSpliterator(final Spliterator from, final Function function) { + this.from = from; this.function = function; } @Override public boolean tryAdvance(final Consumer action) { - return fromSpliterator.tryAdvance( + return from.tryAdvance( fromElement -> action.accept(function.apply(fromElement))); } @Override public void forEachRemaining(final Consumer action) { - fromSpliterator.forEachRemaining(fromElement -> action.accept(function.apply(fromElement))); + from.forEachRemaining(fromElement -> action.accept(function.apply(fromElement))); } @Override public Spliterator trySplit() { - final Spliterator fromSplit = fromSpliterator.trySplit(); + final Spliterator fromSplit = from.trySplit(); return (fromSplit != null) ? new TransSpliterator<>(fromSplit, function) : null; } @Override public long estimateSize() { - return fromSpliterator.estimateSize(); + return from.estimateSize(); } @Override public int characteristics() { - return fromSpliterator.characteristics() + return from.characteristics() & ~(Spliterator.DISTINCT | Spliterator.NONNULL | Spliterator.SORTED); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/builder/DateBuilder.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/builder/DateBuilder.java index 8c615f4c4c..54de95170e 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/builder/DateBuilder.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/builder/DateBuilder.java @@ -495,7 +495,7 @@ public Calendar toCalendar() { * * @return LocalDateTime 表示当前对象日期时间的LocalDateTime实例。 */ - LocalDateTime toLocalDateTime() { + public LocalDateTime toLocalDateTime() { this.prepare(); // 如果unixsecond大于0,使用unix时间戳创建LocalDateTime @@ -532,7 +532,7 @@ LocalDateTime toLocalDateTime() { * * @return OffsetDateTime 表示当前时间的 OffsetDateTime 对象。 */ - OffsetDateTime toOffsetDateTime() { + public OffsetDateTime toOffsetDateTime() { // 准备工作,可能涉及一些初始化或数据处理 this.prepare(); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/Galaxy.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/Galaxy.java index 2057f06976..f8f82b5432 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/Galaxy.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/Galaxy.java @@ -658,10 +658,7 @@ public static double qiAccurate2(double jd) { if (a - jd > 5) { return qiAccurate(w - d); } - if (a - jd < -5) { - return qiAccurate(w + d); - } - return a; + return a - jd < -5 ? qiAccurate(w + d) : a; } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/Holiday.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/Holiday.java index 7c91ac7c74..2269c17a0e 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/Holiday.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/Holiday.java @@ -280,12 +280,10 @@ public Holiday(int year, int month, int day, String data) { public static Holiday fromYmd(int year, int month, int day) { Matcher matcher = Pattern.compile(String.format("%04d%02d%02d[0-1][0-8][\\+|-]\\d{2}", year, month, day)).matcher(DATA); - if (!matcher.find()) { - return null; - } - return new Holiday(year, month, day, matcher.group()); + return !matcher.find() ? null : new Holiday(year, month, day, matcher.group()); } + public Holiday next(int n) { SolarMonth m = day.getMonth(); int year = m.getYear().getYear(); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/birth/Fortune.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/birth/Fortune.java index 5f33449c14..49575631b9 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/birth/Fortune.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/birth/Fortune.java @@ -59,7 +59,7 @@ public Fortune(ChildLimit childLimit, int index) { * * @param childLimit 童限 * @param index 序号 - * @return 大运 + * @return 小运 */ public static Fortune fromChildLimit(ChildLimit childLimit, int index) { return new Fortune(childLimit, index); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/PlumRain.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/PlumRain.java new file mode 100755 index 0000000000..a2221631e1 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/PlumRain.java @@ -0,0 +1,74 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org 6tail and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ +*/ +package org.miaixz.bus.core.center.date.culture.cn.plumrain; + +import org.miaixz.bus.core.center.date.culture.Samsara; + +/** + * 梅雨 + * + * @author Kimi Liu + * @since Java 17+ + */ +public class PlumRain extends Samsara { + + public static final String[] NAMES = {"入梅", "出梅"}; + + public PlumRain(String name) { + super(NAMES, name); + } + + public PlumRain(int index) { + super(NAMES, index); + } + + /** + * 从名称初始化 + * + * @param name 名称 + * @return 梅雨 + */ + public static PlumRain fromName(String name) { + return new PlumRain(name); + } + + /** + * 从索引初始化 + * + * @param index 索引 + * @return 梅雨 + */ + public static PlumRain fromIndex(int index) { + return new PlumRain(index); + } + + public PlumRain next(int n) { + return fromIndex(nextIndex(n)); + } + +} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/NamedInheritableThreadLocal.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/PlumRainDay.java old mode 100644 new mode 100755 similarity index 79% rename from bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/NamedInheritableThreadLocal.java rename to bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/PlumRainDay.java index f5187e4c7f..b50a170c4a --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/NamedInheritableThreadLocal.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/PlumRainDay.java @@ -3,7 +3,7 @@ ~ ~ ~ The MIT License (MIT) ~ ~ ~ - ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ Copyright (c) 2015-2024 miaixz.org 6tail and other contributors. ~ ~ ~ ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ ~ of this software and associated documentation files (the "Software"), to deal ~ @@ -24,32 +24,35 @@ ~ THE SOFTWARE. ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - */ -package org.miaixz.bus.core.lang.thread.threadlocal; +*/ +package org.miaixz.bus.core.center.date.culture.cn.plumrain; + +import org.miaixz.bus.core.center.date.culture.Replenish; /** - * 带有Name标识的 {@link InheritableThreadLocal},调用toString返回name + * 梅雨天 * - * @param 值类型 * @author Kimi Liu * @since Java 17+ */ -public class NamedInheritableThreadLocal extends InheritableThreadLocal { +public class PlumRainDay extends Replenish { - private final String name; + public PlumRainDay(PlumRain plumRain, int dayIndex) { + super(plumRain, dayIndex); + } /** - * 构造 + * 梅雨 * - * @param name 名字 + * @return 梅雨 */ - public NamedInheritableThreadLocal(final String name) { - this.name = name; + public PlumRain getPlumRain() { + return (PlumRain) tradition; } @Override public String toString() { - return this.name; + return getPlumRain().getIndex() == 0 ? super.toString() : tradition.getName(); } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/package-info.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/package-info.java new file mode 100644 index 0000000000..83c6146538 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/plumrain/package-info.java @@ -0,0 +1,34 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +/** + * 梅雨 + * + * @author Kimi Liu + * @since Java 17+ + */ +package org.miaixz.bus.core.center.date.culture.cn.plumrain; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/NamedThreadLocal.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/star/six/SixStar.java old mode 100644 new mode 100755 similarity index 72% rename from bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/NamedThreadLocal.java rename to bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/star/six/SixStar.java index 4034bb9eaa..81ce893cae --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/NamedThreadLocal.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/star/six/SixStar.java @@ -3,7 +3,7 @@ ~ ~ ~ The MIT License (MIT) ~ ~ ~ - ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ Copyright (c) 2015-2024 miaixz.org 6tail and other contributors. ~ ~ ~ ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ ~ of this software and associated documentation files (the "Software"), to deal ~ @@ -24,32 +24,39 @@ ~ THE SOFTWARE. ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - */ -package org.miaixz.bus.core.lang.thread.threadlocal; +*/ +package org.miaixz.bus.core.center.date.culture.cn.star.six; + +import org.miaixz.bus.core.center.date.culture.Samsara; /** - * 带有Name标识的 {@link ThreadLocal},调用toString返回name + * 六曜(孔明六曜星、小六壬) * - * @param 值类型 * @author Kimi Liu * @since Java 17+ */ -public class NamedThreadLocal extends ThreadLocal { +public class SixStar extends Samsara { + + public static final String[] NAMES = {"先胜", "友引", "先负", "佛灭", "大安", "赤口"}; + + public SixStar(int index) { + super(NAMES, index); + } + + public SixStar(String name) { + super(NAMES, name); + } - private final String name; + public static SixStar fromIndex(int index) { + return new SixStar(index); + } - /** - * 构造 - * - * @param name 名字 - */ - public NamedThreadLocal(final String name) { - this.name = name; + public static SixStar fromName(String name) { + return new SixStar(name); } - @Override - public String toString() { - return this.name; + public SixStar next(int n) { + return fromIndex(nextIndex(n)); } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/star/six/package-info.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/star/six/package-info.java new file mode 100644 index 0000000000..d4c13a2ff7 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/cn/star/six/package-info.java @@ -0,0 +1,34 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +/** + * 六曜(孔明六曜星、小六壬) + * + * @author Kimi Liu + * @since Java 17+ + */ +package org.miaixz.bus.core.center.date.culture.cn.star.six; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarDay.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarDay.java index 4dbd7998b5..efad450622 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarDay.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarDay.java @@ -37,6 +37,7 @@ import org.miaixz.bus.core.center.date.culture.cn.sixty.HeavenStem; import org.miaixz.bus.core.center.date.culture.cn.sixty.SixtyCycle; import org.miaixz.bus.core.center.date.culture.cn.star.nine.NineStar; +import org.miaixz.bus.core.center.date.culture.cn.star.six.SixStar; import org.miaixz.bus.core.center.date.culture.cn.star.twelve.TwelveStar; import org.miaixz.bus.core.center.date.culture.cn.star.twentyeight.TwentyEightStar; import org.miaixz.bus.core.center.date.culture.solar.SolarDay; @@ -125,21 +126,21 @@ public LunarDay next(int n) { return fromYmd(month.getYear().getYear(), month.getMonthWithLeap(), day); } int d = day + n; - LunarMonth lm = month; - int daysInMonth = lm.getDayCount(); + LunarMonth m = month; + int daysInMonth = m.getDayCount(); boolean forward = n > 0; int add = forward ? 1 : -1; while (forward ? (d > daysInMonth) : (d <= 0)) { if (forward) { d -= daysInMonth; } - lm = lm.next(add); - daysInMonth = lm.getDayCount(); + m = m.next(add); + daysInMonth = m.getDayCount(); if (!forward) { d += daysInMonth; } } - return fromYmd(lm.getYear().getYear(), lm.getMonthWithLeap(), d); + return fromYmd(m.getYear().getYear(), m.getMonthWithLeap(), d); } /** @@ -149,21 +150,19 @@ public LunarDay next(int n) { * @return true/false */ public boolean isBefore(LunarDay target) { + LunarMonth bMonth = target.getMonth(); int aYear = month.getYear().getYear(); - LunarMonth targetMonth = target.getMonth(); - int bYear = targetMonth.getYear().getYear(); - if (aYear == bYear) { - int aMonth = month.getMonth(); - int bMonth = targetMonth.getMonth(); - if (aMonth == bMonth) { - if (month.isLeap() && !targetMonth.isLeap()) { - return false; - } - return day < target.getDay(); - } - return aMonth < bMonth; + int bYear = bMonth.getYear().getYear(); + if (aYear != bYear) { + return aYear < bYear; + } + if (month.getMonth() != bMonth.getMonth()) { + return month.getMonth() < bMonth.getMonth(); + } + if (month.isLeap() && !bMonth.isLeap()) { + return false; } - return aYear < bYear; + return day < target.getDay(); } /** @@ -173,21 +172,19 @@ public boolean isBefore(LunarDay target) { * @return true/false */ public boolean isAfter(LunarDay target) { + LunarMonth bMonth = target.getMonth(); int aYear = month.getYear().getYear(); - LunarMonth targetMonth = target.getMonth(); - int bYear = targetMonth.getYear().getYear(); - if (aYear == bYear) { - int aMonth = month.getMonth(); - int bMonth = targetMonth.getMonth(); - if (aMonth == bMonth) { - if (month.isLeap() && !targetMonth.isLeap()) { - return true; - } - return day > target.getDay(); - } - return aMonth > bMonth; + int bYear = bMonth.getYear().getYear(); + if (aYear != bYear) { + return aYear > bYear; + } + if (month.getMonth() != bMonth.getMonth()) { + return month.getMonth() > bMonth.getMonth(); + } + if (month.isLeap() && !bMonth.isLeap()) { + return true; } - return aYear > bYear; + return day > target.getDay(); } /** @@ -196,11 +193,11 @@ public boolean isAfter(LunarDay target) { * @return 星期 */ public Week getWeek() { - return getSolarDay().getJulianDay().getWeek(); + return getSolarDay().getWeek(); } /** - * 当天的年干支 + * 当天的年干支(立春换) * * @return 干支 */ @@ -224,7 +221,7 @@ public SixtyCycle getYearSixtyCycle() { } /** - * 当天的月干支 + * 当天的月干支(节气换) * * @return 干支 */ @@ -306,10 +303,7 @@ public NineStar getNineStar() { */ public Direction getJupiterDirection() { int index = getSixtyCycle().getIndex(); - if (index % 12 < 6) { - return Direction.fromIndex(new int[]{2, 8, 4, 6, 0}[index / 12]); - } - return month.getYear().getJupiterDirection(); + return index % 12 < 6 ? Direction.fromIndex(new int[]{2, 8, 4, 6, 0}[index / 12]) : month.getYear().getJupiterDirection(); } /** @@ -330,6 +324,15 @@ public Phase getPhase() { return Phase.fromIndex(day - 1); } + /** + * 六曜 + * + * @return 六曜 + */ + public SixStar getSixStar() { + return SixStar.fromIndex((month.getMonth() + day - 2) % 6); + } + /** * 公历日 * @@ -354,10 +357,10 @@ public TwentyEightStar getTwentyEightStar() { * @return 农历传统节日 */ public LunarFestival getFestival() { - LunarMonth m = getMonth(); - return LunarFestival.fromYmd(m.getYear().getYear(), m.getMonthWithLeap(), day); + return LunarFestival.fromYmd(month.getYear().getYear(), month.getMonthWithLeap(), day); } + @Override public boolean equals(Object o) { if (!(o instanceof LunarDay)) { diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarFestival.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarFestival.java index 58696efc87..b6877ab136 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarFestival.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarFestival.java @@ -87,21 +87,22 @@ public static LunarFestival fromIndex(int year, int index) { throw new IllegalArgumentException(String.format("illegal index: %d", index)); } Matcher matcher = Pattern.compile(String.format("@%02d\\d+", index)).matcher(DATA); - if (matcher.find()) { - String data = matcher.group(); - EnumMap.Festival type = EnumMap.Festival.fromCode(data.charAt(3) - '0'); - switch (type) { - case DAY: - return new LunarFestival(type, LunarDay.fromYmd(year, Integer.parseInt(data.substring(4, 6), 10), Integer.parseInt(data.substring(6), 10)), null, data); - case TERM: - SolarTerms solarTerms = SolarTerms.fromIndex(year, Integer.parseInt(data.substring(4), 10)); - return new LunarFestival(type, solarTerms.getJulianDay().getSolarDay().getLunarDay(), solarTerms, data); - case EVE: - return new LunarFestival(type, LunarDay.fromYmd(year + 1, 1, 1).next(-1), null, data); - default: - } + if (!matcher.find()) { + return null; + } + String data = matcher.group(); + EnumMap.Festival type = EnumMap.Festival.fromCode(data.charAt(3) - '0'); + switch (type) { + case DAY: + return new LunarFestival(type, LunarDay.fromYmd(year, Integer.parseInt(data.substring(4, 6), 10), Integer.parseInt(data.substring(6), 10)), null, data); + case TERM: + SolarTerms solarTerm = SolarTerms.fromIndex(year, Integer.parseInt(data.substring(4), 10)); + return new LunarFestival(type, solarTerm.getJulianDay().getSolarDay().getLunarDay(), solarTerm, data); + case EVE: + return new LunarFestival(type, LunarDay.fromYmd(year + 1, 1, 1).next(-1), null, data); + default: + return null; } - return null; } public static LunarFestival fromYmd(int year, int month, int day) { @@ -120,14 +121,12 @@ public static LunarFestival fromYmd(int year, int month, int day) { } } matcher = Pattern.compile("@\\d{2}2").matcher(DATA); - if (matcher.find()) { - LunarDay lunarDay = LunarDay.fromYmd(year, month, day); - LunarDay nextDay = lunarDay.next(1); - if (nextDay.getMonth().getMonth() == 1 && nextDay.getDay() == 1) { - return new LunarFestival(EnumMap.Festival.EVE, lunarDay, null, matcher.group()); - } + if (!matcher.find()) { + return null; } - return null; + LunarDay lunarDay = LunarDay.fromYmd(year, month, day); + LunarDay nextDay = lunarDay.next(1); + return nextDay.getMonth().getMonth() == 1 && nextDay.getDay() == 1 ? new LunarFestival(EnumMap.Festival.EVE, lunarDay, null, matcher.group()) : null; } public LunarFestival next(int n) { diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarHour.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarHour.java index 709bfd41a2..db4564f293 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarHour.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarHour.java @@ -151,6 +151,11 @@ public String toString() { return day + getSixtyCycle().getName() + "时"; } + /** + * 位于当天的索引 + * + * @return 索引 + */ public int getIndexInDay() { return (hour + 1) / 2; } @@ -166,8 +171,8 @@ public LunarHour next(int n) { days--; } LunarDay d = day.next(days); - LunarMonth month = d.getMonth(); - return fromYmdHms(month.getYear().getYear(), month.getMonthWithLeap(), d.getDay(), hour, minute, second); + LunarMonth m = d.getMonth(); + return fromYmdHms(m.getYear().getYear(), m.getMonthWithLeap(), d.getDay(), hour, minute, second); } /** @@ -180,12 +185,10 @@ public boolean isBefore(LunarHour target) { if (!day.equals(target.getDay())) { return day.isBefore(target.getDay()); } - int bHour = target.getHour(); - if (hour == bHour) { - int bMinute = target.getMinute(); - return minute == bMinute ? second < target.getSecond() : minute < bMinute; + if (hour != target.getHour()) { + return hour < target.getHour(); } - return hour < bHour; + return minute != target.getMinute() ? minute < target.getMinute() : second < target.getSecond(); } /** @@ -198,16 +201,14 @@ public boolean isAfter(LunarHour target) { if (!day.equals(target.getDay())) { return day.isAfter(target.getDay()); } - int bHour = target.getHour(); - if (hour == bHour) { - int bMinute = target.getMinute(); - return minute == bMinute ? second > target.getSecond() : minute > bMinute; + if (hour != target.getHour()) { + return hour > target.getHour(); } - return hour > bHour; + return minute != target.getMinute() ? minute > target.getMinute() : second > target.getSecond(); } /** - * 当时的年干支 + * 当时的年干支(立春换) * * @return 干支 */ @@ -231,7 +232,7 @@ public SixtyCycle getYearSixtyCycle() { } /** - * 当时的月干支 + * 当时的月干支(节气换) * * @return 干支 */ @@ -253,7 +254,7 @@ public SixtyCycle getMonthSixtyCycle() { */ public SixtyCycle getDaySixtyCycle() { SixtyCycle d = day.getSixtyCycle(); - return hour > 22 ? d.next(1) : d; + return hour < 23 ? d : d.next(1); } /** diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarMonth.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarMonth.java index 6dfeaff76f..ccad062c23 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarMonth.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarMonth.java @@ -106,15 +106,11 @@ public LunarMonth(int year, int month) { w -= 29.53; } - // 计算正月初一的偏移 - LunarYear prevYear = LunarYear.fromYear(year - 1); - int prevLeapMonth = prevYear.getLeapMonth(); - // 正常情况正月初一为第3个朔日,但有些特殊的 int offset = 2; if (year > 8 && year < 24) { offset = 1; - } else if (prevLeapMonth > 10 && year != 239 && year != 240) { + } else if (LunarYear.fromYear(year - 1).getLeapMonth() > 10 && year != 239 && year != 240) { offset = 3; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarWeek.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarWeek.java index a26b924f1f..4306576b2f 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarWeek.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/lunar/LunarWeek.java @@ -159,8 +159,7 @@ public LunarWeek next(int n) { * @return 农历日 */ public LunarDay getFirstDay() { - LunarMonth m = getMonth(); - LunarDay firstDay = LunarDay.fromYmd(m.getYear().getYear(), m.getMonthWithLeap(), 1); + LunarDay firstDay = LunarDay.fromYmd(month.getYear().getYear(), month.getMonthWithLeap(), 1); return firstDay.next(index * 7 - indexOf(firstDay.getWeek().getIndex() - start.getIndex(), 7)); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarDay.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarDay.java index 41849a68fa..9d846eff5f 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarDay.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarDay.java @@ -37,6 +37,8 @@ import org.miaixz.bus.core.center.date.culture.cn.dog.DogDay; import org.miaixz.bus.core.center.date.culture.cn.nine.Nine; import org.miaixz.bus.core.center.date.culture.cn.nine.NineDay; +import org.miaixz.bus.core.center.date.culture.cn.plumrain.PlumRain; +import org.miaixz.bus.core.center.date.culture.cn.plumrain.PlumRainDay; import org.miaixz.bus.core.center.date.culture.en.Constellation; import org.miaixz.bus.core.center.date.culture.lunar.LunarDay; import org.miaixz.bus.core.center.date.culture.lunar.LunarMonth; @@ -173,15 +175,13 @@ public SolarDay next(int n) { * @return true/false */ public boolean isBefore(SolarDay target) { + SolarMonth bMonth = target.getMonth(); int aYear = month.getYear().getYear(); - SolarMonth targetMonth = target.getMonth(); - int bYear = targetMonth.getYear().getYear(); - if (aYear == bYear) { - int aMonth = month.getMonth(); - int bMonth = targetMonth.getMonth(); - return aMonth == bMonth ? day < target.getDay() : aMonth < bMonth; + int bYear = bMonth.getYear().getYear(); + if (aYear != bYear) { + return aYear < bYear; } - return aYear < bYear; + return month.getMonth() != bMonth.getMonth() ? month.getMonth() < bMonth.getMonth() : day < target.getDay(); } /** @@ -191,15 +191,13 @@ public boolean isBefore(SolarDay target) { * @return true/false */ public boolean isAfter(SolarDay target) { + SolarMonth bMonth = target.getMonth(); int aYear = month.getYear().getYear(); - SolarMonth targetMonth = target.getMonth(); - int bYear = targetMonth.getYear().getYear(); - if (aYear == bYear) { - int aMonth = month.getMonth(); - int bMonth = targetMonth.getMonth(); - return aMonth == bMonth ? day > target.getDay() : aMonth > bMonth; + int bYear = bMonth.getYear().getYear(); + if (aYear != bYear) { + return aYear > bYear; } - return aYear > bYear; + return month.getMonth() != bMonth.getMonth() ? month.getMonth() > bMonth.getMonth() : day > target.getDay(); } /** @@ -235,7 +233,7 @@ public SolarTermDay getTermDay() { public SolarWeek getSolarWeek(int start) { int y = month.getYear().getYear(); int m = month.getMonth(); - return SolarWeek.fromYm(y, m, (int) Math.ceil((day + SolarDay.fromYmd(y, m, 1).getWeek().next(-start).getIndex()) / 7D) - 1, start); + return SolarWeek.fromYm(y, m, (int) Math.ceil((day + fromYmd(y, m, 1).getWeek().next(-start).getIndex()) / 7D) - 1, start); } /** @@ -243,7 +241,7 @@ public SolarWeek getSolarWeek(int start) { * * @return 七十二候 */ - public ClimateDay getPhenologyDay() { + public ClimateDay getClimateDay() { SolarTerms term = getTerm(); int dayIndex = subtract(term.getJulianDay().getSolarDay()); int index = dayIndex / 5; @@ -295,10 +293,7 @@ public DogDay getDogDay() { start = start.next(10); days = subtract(start); } - if (days < 10) { - return new DogDay(Dog.fromIndex(2), days); - } - return null; + return days >= 10 ? null : new DogDay(Dog.fromIndex(2), days); } /** @@ -320,25 +315,45 @@ public NineDay getNineDay() { return new NineDay(Nine.fromIndex(days / 9), days % 9); } + /** + * 梅雨天(芒种后的第1个丙日入梅,小暑后的第1个未日出梅) + * + * @return 梅雨天 + */ + public PlumRainDay getPlumRainDay() { + // 芒种 + SolarTerms grainInEar = SolarTerms.fromIndex(month.getYear().getYear(), 11); + SolarDay start = grainInEar.getJulianDay().getSolarDay(); + int add = 2 - start.getLunarDay().getSixtyCycle().getHeavenStem().getIndex(); + if (add < 0) { + add += 10; + } + // 芒种后的第1个丙日 + start = start.next(add); + + // 小暑 + SolarTerms slightHeat = grainInEar.next(2); + SolarDay end = slightHeat.getJulianDay().getSolarDay(); + add = 7 - end.getLunarDay().getSixtyCycle().getEarthBranch().getIndex(); + if (add < 0) { + add += 12; + } + // 小暑后的第1个未日 + end = end.next(add); + + if (isBefore(start) || isAfter(end)) { + return null; + } + return equals(end) ? new PlumRainDay(PlumRain.fromIndex(1), 0) : new PlumRainDay(PlumRain.fromIndex(0), subtract(start)); + } + /** * 位于当年的索引 * * @return 索引 */ public int getIndexInYear() { - int m = month.getMonth(); - int y = month.getYear().getYear(); - int days = 0; - for (int i = 1; i < m; i++) { - days += SolarMonth.fromYm(y, i).getDayCount(); - } - int d = day; - if (1582 == y && 10 == m) { - if (d >= 15) { - d -= 10; - } - } - return days + d - 1; + return subtract(fromYmd(month.getYear().getYear(), 1, 1)); } /** @@ -380,9 +395,8 @@ public LunarDay getLunarDay() { * * @return 法定假日 */ - public Holiday getLegalHoliday() { - SolarMonth m = getMonth(); - return Holiday.fromYmd(m.getYear().getYear(), m.getMonth(), day); + public Holiday getHoliday() { + return Holiday.fromYmd(month.getYear().getYear(), month.getMonth(), day); } /** @@ -391,8 +405,7 @@ public Holiday getLegalHoliday() { * @return 公历现代节日 */ public SolarFestival getFestival() { - SolarMonth m = getMonth(); - return SolarFestival.fromYmd(m.getYear().getYear(), m.getMonth(), day); + return SolarFestival.fromYmd(month.getYear().getYear(), month.getMonth(), day); } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarFestival.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarFestival.java index a1863e5cc5..72368275a3 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarFestival.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarFestival.java @@ -86,29 +86,26 @@ public static SolarFestival fromIndex(int year, int index) { throw new IllegalArgumentException(String.format("illegal index: %d", index)); } Matcher matcher = Pattern.compile(String.format("@%02d\\d+", index)).matcher(DATA); - if (matcher.find()) { - String data = matcher.group(); - EnumMap.Festival type = EnumMap.Festival.fromCode(data.charAt(3) - '0'); - if (type == EnumMap.Festival.DAY) { - int startYear = Integer.parseInt(data.substring(8), 10); - if (year >= startYear) { - return new SolarFestival(type, SolarDay.fromYmd(year, Integer.parseInt(data.substring(4, 6), 10), Integer.parseInt(data.substring(6, 8), 10)), startYear, data); - } - } + if (!matcher.find()) { + return null; } - return null; + String data = matcher.group(); + EnumMap.Festival type = EnumMap.Festival.fromCode(data.charAt(3) - '0'); + if (type != EnumMap.Festival.DAY) { + return null; + } + int startYear = Integer.parseInt(data.substring(8), 10); + return year < startYear ? null : new SolarFestival(type, SolarDay.fromYmd(year, Integer.parseInt(data.substring(4, 6), 10), Integer.parseInt(data.substring(6, 8), 10)), startYear, data); } public static SolarFestival fromYmd(int year, int month, int day) { Matcher matcher = Pattern.compile(String.format("@\\d{2}0%02d%02d\\d+", month, day)).matcher(DATA); - if (matcher.find()) { - String data = matcher.group(); - int startYear = Integer.parseInt(data.substring(8), 10); - if (year >= startYear) { - return new SolarFestival(EnumMap.Festival.DAY, SolarDay.fromYmd(year, month, day), startYear, data); - } + if (!matcher.find()) { + return null; } - return null; + String data = matcher.group(); + int startYear = Integer.parseInt(data.substring(8), 10); + return year < startYear ? null : new SolarFestival(EnumMap.Festival.DAY, SolarDay.fromYmd(year, month, day), startYear, data); } public SolarFestival next(int n) { diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarHalfYear.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarHalfYear.java index da2a8fb33e..0144032100 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarHalfYear.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarHalfYear.java @@ -59,10 +59,10 @@ public class SolarHalfYear extends Loops { * @param index 索引,0-1 */ public SolarHalfYear(int year, int index) { - this.year = SolarYear.fromYear(year); if (index < 0 || index > 1) { throw new IllegalArgumentException(String.format("illegal solar half year index: %d", index)); } + this.year = SolarYear.fromYear(year); this.index = index; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarMonth.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarMonth.java index e7413e01c7..40cb99aab0 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarMonth.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarMonth.java @@ -67,10 +67,10 @@ public class SolarMonth extends Loops { * @param month 月 */ public SolarMonth(int year, int month) { - this.year = SolarYear.fromYear(year); if (month < 1 || month > 12) { throw new IllegalArgumentException(String.format("illegal solar month: %d", month)); } + this.year = SolarYear.fromYear(year); this.month = month; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarQuarter.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarQuarter.java index 14630f9ddf..9b5b38068f 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarQuarter.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarQuarter.java @@ -58,10 +58,10 @@ public class SolarQuarter extends Loops { * @param index 索引,0-3 */ public SolarQuarter(int year, int index) { - this.year = SolarYear.fromYear(year); if (index < 0 || index > 3) { throw new IllegalArgumentException(String.format("illegal solar season index: %d", index)); } + this.year = SolarYear.fromYear(year); this.index = index; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarTerms.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarTerms.java index b07ad7de15..ba35a1041f 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarTerms.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarTerms.java @@ -85,7 +85,7 @@ public SolarTerms next(int n) { } /** - * 是否节 + * 是否节令 * * @return true/false */ @@ -94,7 +94,7 @@ public boolean isJie() { } /** - * 是否气 + * 是否气令 * * @return true/false */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarTime.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarTime.java index 9d7f35c3c8..4b63fc865d 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarTime.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarTime.java @@ -146,12 +146,10 @@ public boolean isBefore(SolarTime target) { if (!day.equals(target.getDay())) { return day.isBefore(target.getDay()); } - int bHour = target.getHour(); - if (hour == bHour) { - int bMinute = target.getMinute(); - return minute == bMinute ? second < target.getSecond() : minute < bMinute; + if (hour != target.getHour()) { + return hour < target.getHour(); } - return hour < bHour; + return minute != target.getMinute() ? minute < target.getMinute() : second < target.getSecond(); } /** @@ -164,12 +162,10 @@ public boolean isAfter(SolarTime target) { if (!day.equals(target.getDay())) { return day.isAfter(target.getDay()); } - int bHour = target.getHour(); - if (hour == bHour) { - int bMinute = target.getMinute(); - return minute == bMinute ? second > target.getSecond() : minute > bMinute; + if (hour != target.getHour()) { + return hour > target.getHour(); } - return hour > bHour; + return minute != target.getMinute() ? minute > target.getMinute() : second > target.getSecond(); } /** @@ -191,8 +187,8 @@ public SolarTerms getTerm() { * @return 儒略日 */ public JulianDay getJulianDay() { - SolarMonth month = day.getMonth(); - return JulianDay.fromYmdHms(month.getYear().getYear(), month.getMonth(), day.getDay(), hour, minute, second); + SolarMonth m = day.getMonth(); + return JulianDay.fromYmdHms(m.getYear().getYear(), m.getMonth(), day.getDay(), hour, minute, second); } /** @@ -222,8 +218,8 @@ public int subtract(SolarTime target) { */ public SolarTime next(int n) { if (n == 0) { - SolarMonth month = day.getMonth(); - return SolarTime.fromYmdHms(month.getYear().getYear(), month.getMonth(), day.getDay(), hour, minute, second); + SolarMonth m = day.getMonth(); + return SolarTime.fromYmdHms(m.getYear().getYear(), m.getMonth(), day.getDay(), hour, minute, second); } int ts = second + n; int tm = minute + ts / 60; @@ -246,7 +242,7 @@ public SolarTime next(int n) { } SolarDay d = day.next(td); - SolarMonth m = d.getMonth(); + SolarMonth m = day.getMonth(); return SolarTime.fromYmdHms(m.getYear().getYear(), m.getMonth(), d.getDay(), th, tm, ts); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarWeek.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarWeek.java index 101e720578..4d219f761f 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarWeek.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/culture/solar/SolarWeek.java @@ -149,8 +149,7 @@ public SolarWeek next(int n) { while (forward ? (d >= weeksInMonth) : (d < 0)) { if (forward) { d -= weeksInMonth; - } - if (!forward) { + } else { if (!SolarDay.fromYmd(m.getYear().getYear(), m.getMonth(), 1).getWeek().equals(start)) { d += add; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/date/format/FormatPeriod.java b/bus-core/src/main/java/org/miaixz/bus/core/center/date/format/FormatPeriod.java index fb9bb409ec..cdd7ff615d 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/date/format/FormatPeriod.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/date/format/FormatPeriod.java @@ -28,9 +28,11 @@ package org.miaixz.bus.core.center.date.format; import org.miaixz.bus.core.center.date.culture.en.Units; +import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.xyz.StringKit; import java.io.Serializable; +import java.util.function.Function; /** * 时长格式化器,用于格式化输出两个日期相差的时长 @@ -47,6 +49,7 @@ public class FormatPeriod implements Serializable { private static final long serialVersionUID = -1L; + /** * 格式化级别的最大个数 */ @@ -59,11 +62,20 @@ public class FormatPeriod implements Serializable { * 格式化级别 */ private Level level; + /** + * 格式化器 + */ + private Function formatter = Level::getName; /** * 是否为简化模式,此标记用于自定义是否输出各个位数中间为0的部分 * 如为{@code true},输出 1小时3秒,为{@code false}输出 1小时0分3秒 */ private boolean simpleMode = true; + /** + * 分隔符,默认为"" + * 通过{@link #setSeparator(String)}进行调整 + */ + private String separator = Normal.EMPTY; /** * 构造 @@ -122,14 +134,14 @@ public String format() { // 天 if (isLevelCountValid(levelCount) && day > 0) { - sb.append(day).append(Level.DAY.name); + sb.append(day).append(formatter.apply(Level.DAY)).append(separator); levelCount++; } // 时 if (isLevelCountValid(levelCount) && level >= Level.HOUR.ordinal()) { if (hour > 0 || (!this.simpleMode && StringKit.isNotEmpty(sb))) { - sb.append(hour).append(Level.HOUR.name); + sb.append(hour).append(formatter.apply(Level.HOUR)).append(separator); levelCount++; } } @@ -137,7 +149,7 @@ public String format() { // 分 if (isLevelCountValid(levelCount) && level >= Level.MINUTE.ordinal()) { if (minute > 0 || (!this.simpleMode && StringKit.isNotEmpty(sb))) { - sb.append(minute).append(Level.MINUTE.name); + sb.append(minute).append(formatter.apply(Level.MINUTE)).append(separator); levelCount++; } } @@ -145,23 +157,24 @@ public String format() { // 秒 if (isLevelCountValid(levelCount) && level >= Level.SECOND.ordinal()) { if (second > 0 || (!this.simpleMode && StringKit.isNotEmpty(sb))) { - sb.append(second).append(Level.SECOND.name); + sb.append(second).append(formatter.apply(Level.SECOND)).append(separator); levelCount++; } } // 毫秒 if (isLevelCountValid(levelCount) && millisecond > 0 && level >= Level.MILLISECOND.ordinal()) { - sb.append(millisecond).append(Level.MILLISECOND.name); - // levelCount++; + sb.append(millisecond).append(formatter.apply(Level.MILLISECOND)).append(separator); } } if (StringKit.isEmpty(sb)) { - sb.append(0).append(this.level.name); + sb.append(0).append(formatter.apply(this.level)); + } else if (StringKit.isNotEmpty(separator)) { + sb.delete(sb.length() - separator.length(), sb.length()); } - - return sb.toString(); + // 自定义实现最后可能存在空格 + return sb.toString().trim(); } /** @@ -216,6 +229,28 @@ public FormatPeriod setSimpleMode(final boolean simpleMode) { return this; } + /** + * 设置级别格式化器 + * + * @param formatter 级别格式化器 + * @return this + */ + public FormatPeriod setFormatter(final Function formatter) { + this.formatter = formatter; + return this; + } + + /** + * 设置分隔符 + * + * @param separator 分割符 + * @return this + */ + public FormatPeriod setSeparator(final String separator) { + this.separator = StringKit.emptyIfNull(separator); + return this; + } + @Override public String toString() { return format(); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/list/BoundedList.java b/bus-core/src/main/java/org/miaixz/bus/core/center/list/BoundedList.java new file mode 100644 index 0000000000..e16db06509 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/list/BoundedList.java @@ -0,0 +1,107 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.center.list; + +import org.miaixz.bus.core.center.BoundedCollection; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * 指定边界大小的List + * 通过指定边界,可以限制List的最大容量 + * + * @param 元素类型 + * @author Kimi Liu + * @since Java 17+ + */ +public class BoundedList extends ListWrapper implements BoundedCollection { + + private final int maxSize; + + /** + * 构造 + * + * @param maxSize 最大容量 + */ + public BoundedList(final int maxSize) { + this(new ArrayList<>(maxSize), maxSize); + } + + /** + * 构造,限制集合的最大容量为提供的List + * + * @param raw 原始对象 + * @param maxSize 最大容量 + */ + public BoundedList(final List raw, final int maxSize) { + super(raw); + this.maxSize = maxSize; + } + + @Override + public boolean isFull() { + return size() == this.maxSize; + } + + @Override + public int maxSize() { + return this.maxSize; + } + + @Override + public boolean add(final E e) { + checkFull(1); + return super.add(e); + } + + @Override + public void add(final int index, final E element) { + checkFull(1); + super.add(index, element); + } + + @Override + public boolean addAll(final Collection c) { + checkFull(c.size()); + return super.addAll(c); + } + + @Override + public boolean addAll(final int index, final Collection c) { + checkFull(c.size()); + return super.addAll(index, c); + } + + private void checkFull(final int addSize) { + if (size() + addSize > this.maxSize) { + throw new IndexOutOfBoundsException("List is no space to add " + addSize + " elements!"); + } + } +} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/list/ListWrapper.java b/bus-core/src/main/java/org/miaixz/bus/core/center/list/ListWrapper.java new file mode 100644 index 0000000000..dc3c5f68af --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/list/ListWrapper.java @@ -0,0 +1,209 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.center.list; + +import org.miaixz.bus.core.lang.wrapper.SimpleWrapper; + +import java.util.*; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.function.UnaryOperator; +import java.util.stream.Stream; + +/** + * 列表包装类 + * 提供列表包装,用于在执行列表方法前后自定义处理逻辑 + * + * @param 元素类型 + * @author Kimi Liu + * @since Java 17+ + */ +public class ListWrapper extends SimpleWrapper> implements List { + + /** + * 构造 + * + * @param raw 原始对象 + */ + public ListWrapper(final List raw) { + super(raw); + } + + + @Override + public int size() { + return raw.size(); + } + + @Override + public boolean isEmpty() { + return raw.isEmpty(); + } + + @Override + public boolean contains(final Object o) { + return raw.contains(o); + } + + @Override + public Iterator iterator() { + return raw.iterator(); + } + + @Override + public void forEach(final Consumer action) { + raw.forEach(action); + } + + @Override + public Object[] toArray() { + return raw.toArray(); + } + + @Override + public T[] toArray(final T[] a) { + return raw.toArray(a); + } + + @Override + public boolean add(final E e) { + return raw.add(e); + } + + @Override + public boolean remove(final Object o) { + return raw.remove(o); + } + + @SuppressWarnings("SlowListContainsAll") + @Override + public boolean containsAll(final Collection c) { + return raw.containsAll(c); + } + + @Override + public boolean addAll(final Collection c) { + return raw.addAll(c); + } + + @Override + public boolean addAll(final int index, final Collection c) { + return raw.addAll(index, c); + } + + @Override + public boolean removeAll(final Collection c) { + return raw.removeAll(c); + } + + @Override + public boolean removeIf(final Predicate filter) { + return raw.removeIf(filter); + } + + @Override + public boolean retainAll(final Collection c) { + return raw.retainAll(c); + } + + @Override + public void replaceAll(final UnaryOperator operator) { + raw.replaceAll(operator); + } + + @Override + public void sort(final Comparator c) { + raw.sort(c); + } + + @Override + public void clear() { + raw.clear(); + } + + @Override + public E get(final int index) { + return raw.get(index); + } + + @Override + public E set(final int index, final E element) { + return raw.set(index, element); + } + + @Override + public void add(final int index, final E element) { + raw.add(index, element); + } + + @Override + public E remove(final int index) { + return raw.remove(index); + } + + @Override + public int indexOf(final Object o) { + return raw.indexOf(o); + } + + @Override + public int lastIndexOf(final Object o) { + return raw.lastIndexOf(o); + } + + @Override + public ListIterator listIterator() { + return raw.listIterator(); + } + + @Override + public ListIterator listIterator(final int index) { + return raw.listIterator(index); + } + + @Override + public List subList(final int fromIndex, final int toIndex) { + return raw.subList(fromIndex, toIndex); + } + + @Override + public Spliterator spliterator() { + return raw.spliterator(); + } + + @Override + public Stream stream() { + return raw.stream(); + } + + @Override + public Stream parallelStream() { + return raw.parallelStream(); + } + +} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/map/CamelCaseMap.java b/bus-core/src/main/java/org/miaixz/bus/core/center/map/CamelCaseMap.java index 7c3d97cd1c..43d6d5deaa 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/map/CamelCaseMap.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/map/CamelCaseMap.java @@ -44,7 +44,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class CamelCaseMap extends FuncKeyMap { +public class CamelCaseMap extends FunctionKeyMap { private static final long serialVersionUID = -1L; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/map/CaseInsensitiveMap.java b/bus-core/src/main/java/org/miaixz/bus/core/center/map/CaseInsensitiveMap.java index e9e66f9722..ceda483106 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/map/CaseInsensitiveMap.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/map/CaseInsensitiveMap.java @@ -43,7 +43,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class CaseInsensitiveMap extends FuncKeyMap { +public class CaseInsensitiveMap extends FunctionKeyMap { private static final long serialVersionUID = -1L; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/map/FuncKeyMap.java b/bus-core/src/main/java/org/miaixz/bus/core/center/map/FunctionKeyMap.java similarity index 95% rename from bus-core/src/main/java/org/miaixz/bus/core/center/map/FuncKeyMap.java rename to bus-core/src/main/java/org/miaixz/bus/core/center/map/FunctionKeyMap.java index 78c2d97392..87a0dd5e85 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/map/FuncKeyMap.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/map/FunctionKeyMap.java @@ -38,7 +38,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class FuncKeyMap extends CustomKeyMap { +public class FunctionKeyMap extends CustomKeyMap { private static final long serialVersionUID = -1L; @@ -51,7 +51,7 @@ public class FuncKeyMap extends CustomKeyMap { * @param emptyMap Map,提供的空map * @param keyFunc 自定义KEY的函数 */ - public FuncKeyMap(final Map emptyMap, final Function keyFunc) { + public FunctionKeyMap(final Map emptyMap, final Function keyFunc) { super(emptyMap); this.keyFunc = keyFunc; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/map/FuncMap.java b/bus-core/src/main/java/org/miaixz/bus/core/center/map/FunctionMap.java similarity index 92% rename from bus-core/src/main/java/org/miaixz/bus/core/center/map/FuncMap.java rename to bus-core/src/main/java/org/miaixz/bus/core/center/map/FunctionMap.java index 9cd222b1dc..58b1e49897 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/map/FuncMap.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/map/FunctionMap.java @@ -39,7 +39,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class FuncMap extends TransMap { +public class FunctionMap extends TransMap { private static final long serialVersionUID = -1L; @@ -54,7 +54,7 @@ public class FuncMap extends TransMap { * @param keyFunc 自定义KEY的函数 * @param valueFunc 自定义value函数 */ - public FuncMap(final Supplier> mapFactory, final Function keyFunc, final Function valueFunc) { + public FunctionMap(final Supplier> mapFactory, final Function keyFunc, final Function valueFunc) { this(mapFactory.get(), keyFunc, valueFunc); } @@ -66,7 +66,7 @@ public FuncMap(final Supplier> mapFactory, final Function k * @param keyFunc 自定义KEY的函数 * @param valueFunc 自定义value函数 */ - public FuncMap(final Map emptyMap, final Function keyFunc, final Function valueFunc) { + public FunctionMap(final Map emptyMap, final Function keyFunc, final Function valueFunc) { super(emptyMap); this.keyFunc = keyFunc; this.valueFunc = valueFunc; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/map/reference/ReferenceConcurrentMap.java b/bus-core/src/main/java/org/miaixz/bus/core/center/map/reference/ReferenceConcurrentMap.java index f8b061aad1..b9c44465d3 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/map/reference/ReferenceConcurrentMap.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/map/reference/ReferenceConcurrentMap.java @@ -161,18 +161,40 @@ public void replaceAll(final BiFunction funct @Override public V computeIfAbsent(final K key, final Function mappingFunction) { - this.purgeStale(); - final Ref vReference = this.raw.computeIfAbsent(wrapKey(key), - kReference -> wrapValue(mappingFunction.apply(unwrap(kReference)))); - return unwrap(vReference); + V result = null; + while(null == result){ + this.purgeStale(); + final Ref vReference = this.raw.computeIfAbsent(wrapKey(key), + kReference -> wrapValue(mappingFunction.apply(unwrap(kReference)))); + + // 如果vReference在此时被GC回收,则unwrap后为null,需要循环计算 + // 但是当用户提供的值本身为null,则直接返回之 + if(NullRef.NULL == vReference){ + // 用户提供的值本身为null + return null; + } + result = unwrap(vReference); + } + return result; } @Override public V computeIfPresent(final K key, final BiFunction remappingFunction) { - this.purgeStale(); - final Ref vReference = this.raw.computeIfPresent(wrapKey(key), - (kReference, vReference1) -> wrapValue(remappingFunction.apply(unwrap(kReference), unwrap(vReference1)))); - return unwrap(vReference); + V result = null; + while(null == result){ + this.purgeStale(); + final Ref vReference = this.raw.computeIfPresent(wrapKey(key), + (kReference, vReference1) -> wrapValue(remappingFunction.apply(unwrap(kReference), unwrap(vReference1)))); + + // 如果vReference在此时被GC回收,则unwrap后为null,需要循环计算 + // 但是当用户提供的值本身为null,则直接返回之 + if(NullRef.NULL == vReference){ + // 用户提供的值本身为null + return null; + } + result = unwrap(vReference); + } + return result; } @Override @@ -255,11 +277,11 @@ public int size() { public Set> entrySet() { this.purgeStale(); final Set, Ref>> referenceEntrySet = this.raw.entrySet(); - return new AbstractSet>() { + return new AbstractSet<>() { @Override public Iterator> iterator() { final Iterator, Ref>> referenceIter = referenceEntrySet.iterator(); - return new Iterator>() { + return new Iterator<>() { @Override public boolean hasNext() { return referenceIter.hasNext(); @@ -268,7 +290,7 @@ public boolean hasNext() { @Override public Entry next() { final Entry, Ref> next = referenceIter.next(); - return new Entry() { + return new Entry<>() { @Override public K getKey() { return unwrap(next.getKey()); @@ -382,4 +404,15 @@ private Ref wrapValue(final Object value) { return wrapValue((V) value, this.lastValueQueue); } + private static class NullRef implements Ref { + + public static final Object NULL = new NullRef(); + + @Override + public Object get() { + return null; + } + + } + } diff --git a/bus-base/src/main/java/org/miaixz/bus/base/entity/Entity.java b/bus-core/src/main/java/org/miaixz/bus/core/center/map/reference/WeakKeyConcurrentMap.java old mode 100755 new mode 100644 similarity index 66% rename from bus-base/src/main/java/org/miaixz/bus/base/entity/Entity.java rename to bus-core/src/main/java/org/miaixz/bus/core/center/map/reference/WeakKeyConcurrentMap.java index 04ca99b386..0d234e9d2d --- a/bus-base/src/main/java/org/miaixz/bus/base/entity/Entity.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/map/reference/WeakKeyConcurrentMap.java @@ -25,30 +25,53 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.base.entity; +package org.miaixz.bus.core.center.map.reference; -import jakarta.persistence.Id; -import lombok.Getter; -import lombok.Setter; +import org.miaixz.bus.core.center.map.concurrent.SafeConcurrentHashMap; +import org.miaixz.bus.core.lang.ref.Ref; +import org.miaixz.bus.core.lang.ref.StrongObject; +import org.miaixz.bus.core.lang.ref.WeakObject; -import java.io.Serializable; +import java.lang.ref.ReferenceQueue; +import java.util.concurrent.ConcurrentMap; /** - * Entity 实体 + * 线程安全的WeakMap实现 + * 键为Weak引用,即,在GC时发现弱引用会回收其对象 * + * @param 键类型 + * @param 值类型 * @author Kimi Liu * @since Java 17+ */ -@Getter -@Setter -public abstract class Entity implements Serializable { +public class WeakKeyConcurrentMap extends ReferenceConcurrentMap { private static final long serialVersionUID = 1L; /** - * 数据主键 + * 构造 */ - @Id - protected String id; + public WeakKeyConcurrentMap() { + this(new SafeConcurrentHashMap<>()); + } + + /** + * 构造 + * + * @param raw {@link ConcurrentMap}实现 + */ + public WeakKeyConcurrentMap(final ConcurrentMap, Ref> raw) { + super(raw); + } + + @Override + Ref wrapKey(final K key, final ReferenceQueue queue) { + return new WeakObject<>(key, queue); + } + + @Override + Ref wrapValue(final V value, final ReferenceQueue queue) { + return new StrongObject<>(value); + } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/queue/BoundedPriorityQueue.java b/bus-core/src/main/java/org/miaixz/bus/core/center/queue/BoundedPriorityQueue.java index 91edf45d40..4a2158593a 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/queue/BoundedPriorityQueue.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/queue/BoundedPriorityQueue.java @@ -27,6 +27,8 @@ */ package org.miaixz.bus.core.center.queue; +import org.miaixz.bus.core.center.BoundedCollection; + import java.util.*; /** @@ -37,7 +39,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class BoundedPriorityQueue extends PriorityQueue { +public class BoundedPriorityQueue extends PriorityQueue implements BoundedCollection { private static final long serialVersionUID = -1L; @@ -47,6 +49,11 @@ public class BoundedPriorityQueue extends PriorityQueue { private final int capacity; private final Comparator comparator; + /** + * 构造 + * + * @param capacity 容量 + */ public BoundedPriorityQueue(final int capacity) { this(capacity, null); } @@ -73,6 +80,16 @@ public BoundedPriorityQueue(final int capacity, final Comparator comp this.comparator = comparator; } + @Override + public boolean isFull() { + return size() == capacity; + } + + @Override + public int maxSize() { + return capacity; + } + /** * 加入元素,当队列满时,淘汰末尾元素 * @@ -81,7 +98,7 @@ public BoundedPriorityQueue(final int capacity, final Comparator comp */ @Override public boolean offer(final E e) { - if (size() >= capacity) { + if (isFull()) { final E head = peek(); if (this.comparator().compare(e, head) <= 0) { return true; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/queue/MemorySafeLinkedBlockingQueue.java b/bus-core/src/main/java/org/miaixz/bus/core/center/queue/MemorySafeLinkedBlockingQueue.java index afd087279f..037c62ea77 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/center/queue/MemorySafeLinkedBlockingQueue.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/queue/MemorySafeLinkedBlockingQueue.java @@ -49,6 +49,7 @@ * @since Java 17+ */ public class MemorySafeLinkedBlockingQueue extends CheckedLinkedBlockingQueue { + private static final long serialVersionUID = -1L; /** @@ -72,18 +73,18 @@ public MemorySafeLinkedBlockingQueue(final Collection c, } /** - * get the max free memory. + * 获得最大可用内存 * - * @return the max free memory limit + * @return 最大可用内存限制 */ public long getMaxFreeMemory() { return ((MemoryChecker) this.checker).maxFreeMemory; } /** - * set the max free memory. + * 设置最大可用内存 * - * @param maxFreeMemory the max free memory + * @param maxFreeMemory 最大可用内存 */ public void setMaxFreeMemory(final int maxFreeMemory) { ((MemoryChecker) this.checker).maxFreeMemory = maxFreeMemory; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/center/set/SetWrapper.java b/bus-core/src/main/java/org/miaixz/bus/core/center/set/SetWrapper.java new file mode 100644 index 0000000000..4e4d17e0f0 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/center/set/SetWrapper.java @@ -0,0 +1,149 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.center.set; + +import org.miaixz.bus.core.lang.wrapper.SimpleWrapper; + +import java.util.Collection; +import java.util.Iterator; +import java.util.Set; +import java.util.Spliterator; +import java.util.function.Consumer; +import java.util.function.Predicate; +import java.util.stream.Stream; + +/** + * Set包装类 + * 提供列表包装,用于在执行列表方法前后自定义处理逻辑 + * + * @param 元素类型 + * @author Kimi Liu + * @since Java 17+ + */ +public class SetWrapper extends SimpleWrapper> implements Set { + + /** + * 构造 + * + * @param raw 原始对象 + */ + public SetWrapper(final Set raw) { + super(raw); + } + + @Override + public int size() { + return raw.size(); + } + + @Override + public boolean isEmpty() { + return raw.isEmpty(); + } + + @Override + public boolean contains(final Object o) { + return raw.contains(o); + } + + @Override + public Iterator iterator() { + return raw.iterator(); + } + + @Override + public void forEach(final Consumer action) { + raw.forEach(action); + } + + @Override + public Object[] toArray() { + return new Object[0]; + } + + @Override + public T[] toArray(final T[] a) { + return raw.toArray(a); + } + + @Override + public boolean add(final E e) { + return raw.add(e); + } + + @Override + public boolean remove(final Object o) { + return raw.remove(o); + } + + @Override + public boolean containsAll(final Collection c) { + return raw.containsAll(c); + } + + @Override + public boolean addAll(final Collection c) { + return raw.addAll(c); + } + + @Override + public boolean retainAll(final Collection c) { + return raw.retainAll(c); + } + + @Override + public boolean removeAll(final Collection c) { + return raw.removeAll(c); + } + + @Override + public boolean removeIf(final Predicate filter) { + return raw.removeIf(filter); + } + + @Override + public void clear() { + raw.clear(); + } + + @Override + public Spliterator spliterator() { + return raw.spliterator(); + } + + @Override + public Stream stream() { + return raw.stream(); + } + + @Override + public Stream parallelStream() { + return raw.parallelStream(); + } + +} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/codec/Luhn.java b/bus-core/src/main/java/org/miaixz/bus/core/codec/Luhn.java new file mode 100644 index 0000000000..83bf2d1b9a --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/codec/Luhn.java @@ -0,0 +1,103 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.codec; + +import org.miaixz.bus.core.center.regex.Pattern; +import org.miaixz.bus.core.xyz.PatternKit; +import org.miaixz.bus.core.xyz.StringKit; + +/** + * Luhn算法,也称为“模10”算法,是一种简单的校验和(Checksum)算法,在ISO/IEC 7812-1中定义,校验步骤如下: + *
      + *
    1. 从右边第1个数字(校验数字)开始偶数位乘以2,如果小于10,直接返回,否则将个位数和十位数相加
    2. + *
    3. 把步骤1种获得的乘积的各位数字与原号码中未乘2的各位数字相加
    4. + *
    5. 如果步骤2得到的总和模10为0,则校验通过
    6. + *
    + * + * @author Kimi Liu + * @since Java 17+ + */ +public class Luhn { + + /** + * 校验字符串 + * + * @param text 含校验数字的字符串 + * @return true - 校验通过,false-校验不通过 + * @throws IllegalArgumentException 如果字符串为空或不是8~19位的数字 + */ + public static boolean check(final String text) { + if (StringKit.isBlank(text)) { + return false; + } + if (!PatternKit.isMatch(Pattern.NUMBERS_PATTERN, text)) { + // 必须为全数字 + return false; + } + return sum(text) % 10 == 0; + } + + /** + * 计算校验位数字 + * 忽略已有的校验位数字,根据前N位计算最后一位校验位数字 + * + * @param str 被检查的数字 + * @param withCheckDigit 是否含有校验位 + * @return 校验位数字 + */ + public static int getCheckDigit(String str, final boolean withCheckDigit) { + if (withCheckDigit) { + str = str.substring(0, str.length() - 1); + } + return 10 - (sum(str + "0") % 10); + } + + /** + * 根据Luhn算法计算字符串各位数字之和 + * + * @param text 需要校验的数字字符串 + * @return 数字之和 + */ + private static int sum(final String text) { + final char[] strArray = text.toCharArray(); + final int n = strArray.length; + int sum = strArray[n - 1] - '0'; + ; + for (int i = 2; i <= n; i++) { + int a = strArray[n - i] - '0'; + // 偶数位乘以2 + if ((i & 1) == 0) { + a *= 2; + } + // 十位数和个位数相加,如果不是偶数位,不乘以2,则十位数为0 + sum += a / 10 + a % 10; + } + return sum; + } + +} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/compare/ExplorerCompare.java b/bus-core/src/main/java/org/miaixz/bus/core/compare/ExplorerCompare.java new file mode 100644 index 0000000000..7e487a5310 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/compare/ExplorerCompare.java @@ -0,0 +1,110 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.compare; + +import org.miaixz.bus.core.xyz.StringKit; + +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Iterator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Windows 资源管理器风格字符串比较器 + * 此比较器模拟了 Windows 资源管理器的文件名排序方式,可得到与其相同的排序结果。 + * + *

    假设有一个数组,包含若干个文件名 {@code {"xyz2.doc", "xyz1.doc", "xyz12.doc"}}

    + *

    调用 {@code Arrays.sort(filenames);} 时,得到 {@code {"xyz1.doc", "xyz12.doc", "xyz2.doc" }}

    + *

    调用 {@code Arrays.sort(filenames, new WindowsCompare());} 时,得到 {@code {"xyz1.doc", "xyz2.doc", "xyz12.doc" }},这与在资源管理器中看到的相同

    + * + * @author Kimi Liu + * @see
    Java - Sort Strings like Windows Explorer + * @since Java 17+ + */ +public class ExplorerCompare implements Comparator { + + /** + * 单例 + */ + public static final ExplorerCompare INSTANCE = new ExplorerCompare(); + + @Override + public int compare(final CharSequence str1, final CharSequence str2) { + final Iterator i1 = splitStringPreserveDelimiter(str1).iterator(); + final Iterator i2 = splitStringPreserveDelimiter(str2).iterator(); + while (true) { + // 直到这里都是平等的 + if (!i1.hasNext() && !i2.hasNext()) { + return 0; + } + // i1 没有其他部分 -> 排在最前面 + if (!i1.hasNext()) { + return -1; + } + // i1 的部分比 i2 多 -> 紧随其后 + if (!i2.hasNext()) { + return 1; + } + + final String data1 = i1.next(); + final String data2 = i2.next(); + int result; + try { + // 如果两个数据都是数字,则比较数字 + result = Long.compare(Long.parseLong(data1), Long.parseLong(data2)); + // 如果数字相等,则较长者优先 + if (result == 0) { + result = -Integer.compare(data1.length(), data2.length()); + } + } catch (final NumberFormatException ex) { + // 比较文本不区分大小写 + result = data1.compareToIgnoreCase(data2); + } + + if (result != 0) { + return result; + } + } + } + + private List splitStringPreserveDelimiter(final CharSequence str) { + final Matcher matcher = Pattern.compile("\\d+|\\.|\\s").matcher(str); + final List list = new ArrayList<>(); + int pos = 0; + while (matcher.find()) { + list.add(StringKit.sub(str, pos, matcher.start())); + list.add(matcher.group()); + pos = matcher.end(); + } + list.add(StringKit.subSuf(str, pos)); + return list; + } + +} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/compare/VersionCompare.java b/bus-core/src/main/java/org/miaixz/bus/core/compare/VersionCompare.java index cf6a1df9a1..d435090b40 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/compare/VersionCompare.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/compare/VersionCompare.java @@ -44,11 +44,12 @@ */ public class VersionCompare extends NullCompare implements Serializable { + private static final long serialVersionUID = -1L; + /** * 单例 */ public static final VersionCompare INSTANCE = new VersionCompare(); - private static final long serialVersionUID = -1L; /** * 默认构造 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/convert/Convert.java b/bus-core/src/main/java/org/miaixz/bus/core/convert/Convert.java index e5407a2046..e9c228911b 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/convert/Convert.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/convert/Convert.java @@ -84,7 +84,7 @@ public static String toString(final Object value) { * @param value 被转换的值 * @return String数组 */ - public static String[] toStrArray(final Object value) { + public static String[] toStringArray(final Object value) { return convert(String[].class, value); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/convert/MapConverter.java b/bus-core/src/main/java/org/miaixz/bus/core/convert/MapConverter.java index 0678029708..816d1ec84b 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/convert/MapConverter.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/convert/MapConverter.java @@ -86,9 +86,9 @@ public Object convert(Type targetType, final Object value) throws ConvertExcepti final Class valueClass = value.getClass(); if (valueClass.equals(targetType)) { final Type[] typeArguments = TypeKit.getTypeArguments(valueClass); - if (null != typeArguments // - && 2 == typeArguments.length// - && Objects.equals(keyType, typeArguments[0]) // + if (null != typeArguments + && 2 == typeArguments.length + && Objects.equals(keyType, typeArguments[0]) && Objects.equals(valueType, typeArguments[1])) { // 对于键值对类型一致的Map对象,不再做转换,直接返回原对象 return (Map) value; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/data/CIN.java b/bus-core/src/main/java/org/miaixz/bus/core/data/CIN.java index 21b5592c4c..097bb5c00e 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/data/CIN.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/data/CIN.java @@ -269,7 +269,7 @@ private static char getVerifyCode18(final int iSum) { case 3: return '9'; case 2: - return 'X'; + return Symbol.C_X; case 1: return '0'; case 0: diff --git a/bus-core/src/main/java/org/miaixz/bus/core/data/ID.java b/bus-core/src/main/java/org/miaixz/bus/core/data/id/ID.java similarity index 98% rename from bus-core/src/main/java/org/miaixz/bus/core/data/ID.java rename to bus-core/src/main/java/org/miaixz/bus/core/data/id/ID.java index a13ba17a92..eeef56f700 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/data/ID.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/data/id/ID.java @@ -25,13 +25,12 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.core.data; +package org.miaixz.bus.core.data.id; import org.miaixz.bus.core.instance.Instances; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.exception.InternalException; import org.miaixz.bus.core.net.ip.IPv4; -import org.miaixz.bus.core.xyz.RuntimeKit; /** * ID生成器工具类,此工具类中主要封装: @@ -226,7 +225,7 @@ public static long getWorkerId(final long datacenterId, final long maxWorkerId) final StringBuilder mpid = new StringBuilder(); mpid.append(datacenterId); try { - mpid.append(RuntimeKit.getPid()); + mpid.append(Pid.INSTANCE.get()); } catch (final InternalException igonre) { //ignore } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/data/NanoId.java b/bus-core/src/main/java/org/miaixz/bus/core/data/id/NanoId.java similarity index 99% rename from bus-core/src/main/java/org/miaixz/bus/core/data/NanoId.java rename to bus-core/src/main/java/org/miaixz/bus/core/data/id/NanoId.java index de0eff77f3..b9a5395beb 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/data/NanoId.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/data/id/NanoId.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.core.data; +package org.miaixz.bus.core.data.id; import org.miaixz.bus.core.xyz.RandomKit; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/data/ObjectId.java b/bus-core/src/main/java/org/miaixz/bus/core/data/id/ObjectId.java similarity index 99% rename from bus-core/src/main/java/org/miaixz/bus/core/data/ObjectId.java rename to bus-core/src/main/java/org/miaixz/bus/core/data/id/ObjectId.java index 6ccff9fe11..164253b309 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/data/ObjectId.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/data/id/ObjectId.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.core.data; +package org.miaixz.bus.core.data.id; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/data/Pid.java b/bus-core/src/main/java/org/miaixz/bus/core/data/id/Pid.java similarity index 97% rename from bus-core/src/main/java/org/miaixz/bus/core/data/Pid.java rename to bus-core/src/main/java/org/miaixz/bus/core/data/id/Pid.java index f3e656b761..e2180d74d3 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/data/Pid.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/data/id/Pid.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.core.data; +package org.miaixz.bus.core.data.id; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; @@ -59,7 +59,7 @@ public enum Pid { * @return 进程ID * @throws InternalException 进程名称为空 */ - private static int getPid() throws InternalException { + public static int getPid() throws InternalException { final String processName = ManagementFactory.getRuntimeMXBean().getName(); if (StringKit.isBlank(processName)) { throw new InternalException("Process name is blank!"); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/data/Snowflake.java b/bus-core/src/main/java/org/miaixz/bus/core/data/id/Snowflake.java similarity index 99% rename from bus-core/src/main/java/org/miaixz/bus/core/data/Snowflake.java rename to bus-core/src/main/java/org/miaixz/bus/core/data/id/Snowflake.java index f99919e856..f6fd2eec5a 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/data/Snowflake.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/data/id/Snowflake.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.core.data; +package org.miaixz.bus.core.data.id; import org.miaixz.bus.core.center.date.NonClock; import org.miaixz.bus.core.lang.Assert; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/data/ULID.java b/bus-core/src/main/java/org/miaixz/bus/core/data/id/ULID.java similarity index 99% rename from bus-core/src/main/java/org/miaixz/bus/core/data/ULID.java rename to bus-core/src/main/java/org/miaixz/bus/core/data/id/ULID.java index 34b8773a60..5e324c2cae 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/data/ULID.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/data/id/ULID.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.core.data; +package org.miaixz.bus.core.data.id; import org.miaixz.bus.core.codec.No128; import org.miaixz.bus.core.codec.binary.Crockford; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/data/UUID.java b/bus-core/src/main/java/org/miaixz/bus/core/data/id/UUID.java similarity index 98% rename from bus-core/src/main/java/org/miaixz/bus/core/data/UUID.java rename to bus-core/src/main/java/org/miaixz/bus/core/data/id/UUID.java index 34ffc00d2d..9b13d87e1d 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/data/UUID.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/data/id/UUID.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.core.data; +package org.miaixz.bus.core.data.id; import org.miaixz.bus.core.codec.No128; import org.miaixz.bus.core.lang.Symbol; @@ -235,7 +235,6 @@ public long getMostSignificantBits() { /** * 与此 {@code UUID} 相关联的版本号. 版本号描述此 {@code UUID} 是如何生成的。 - *

    * 版本号具有以下含意: *

      *
    • UUIDv1 基于时间的 UUID @@ -256,7 +255,6 @@ public int version() { /** * 与此 {@code UUID} 相关联的变体号。变体号描述 {@code UUID} 的布局。 - *

      * 变体号具有以下含意: *

        *
      • 0 为 NCS 向后兼容保留 @@ -279,12 +277,8 @@ public int variant() { /** * 与此 UUID 相关联的时间戳值。 - * - *

        * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。 * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。 - * - *

        * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。 * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 * @@ -301,10 +295,7 @@ public long timestamp() throws UnsupportedOperationException { /** * 与此 UUID 相关联的时钟序列值。 - * - *

        * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。 - *

        * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 * * @return 此 {@code UUID} 的时钟序列 @@ -317,10 +308,7 @@ public int clockSequence() throws UnsupportedOperationException { /** * 与此 UUID 相关的节点值。 - * - *

        * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。 - *

        * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。 * @@ -332,12 +320,8 @@ public long node() throws UnsupportedOperationException { return this.getLeastSignificantBits() & 0x0000FFFFFFFFFFFFL; } - // Object Inherited Methods - /** * 返回此{@code UUID} 的字符串表现形式。 - * - *

        * UUID 的字符串表示形式由此 BNF 描述: * *

        @@ -363,8 +347,6 @@ public String toString() {
         
             /**
              * 返回此{@code UUID} 的字符串表现形式。
        -     *
        -     * 

        * UUID 的字符串表示形式由此 BNF 描述: * *

        @@ -427,7 +409,6 @@ public int hashCode() {
         
             /**
              * 将此对象与指定对象比较。
        -     * 

        * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。 * * @param obj 要与之比较的对象 @@ -445,12 +426,8 @@ public boolean equals(final Object obj) { return (mostSigBits == id.getMostSignificantBits() && leastSigBits == id.getLeastSignificantBits()); } - // Comparison Operations - /** * 将此 UUID 与指定的 UUID 比较。 - * - *

        * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。 * * @param val 与此 UUID 比较的 UUID diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/FastStringReader.java b/bus-core/src/main/java/org/miaixz/bus/core/io/FastStringReader.java index 745bcdc4a5..2526263722 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/FastStringReader.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/FastStringReader.java @@ -101,9 +101,9 @@ public int read(final char[] charBuffer, final int off, final int len) throws IO /** * 跳过指定长度,返回跳过的字符数。 * - *

        {@code ns} 参数可能为负数, 负数表示向前跳过,跳到开头则停止 + * {@code ns} 参数可能为负数, 负数表示向前跳过,跳到开头则停止 * - *

        如果字符串所有字符被读取或跳过, 此方法无效,始终返回0. + * 如果字符串所有字符被读取或跳过, 此方法无效,始终返回0. * * @throws IOException IO异常 */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/SectionBuffer.java b/bus-core/src/main/java/org/miaixz/bus/core/io/SectionBuffer.java index c5651632e9..453a89175c 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/SectionBuffer.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/SectionBuffer.java @@ -149,7 +149,7 @@ public final SectionBuffer push(SectionBuffer segment) { * segment contains the data in {@code [pos+byteCount..limit)}. This can be * useful when moving partial segments from one buffer to another. * - *

        Returns the new head of the circularly-linked list. + * Returns the new head of the circularly-linked list. */ public final SectionBuffer split(int byteCount) { if (byteCount <= 0 || byteCount > limit - pos) throw new IllegalArgumentException(); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/buffer/Buffer.java b/bus-core/src/main/java/org/miaixz/bus/core/io/buffer/Buffer.java index 26a33d065b..e0a122b8b0 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/buffer/Buffer.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/buffer/Buffer.java @@ -2118,12 +2118,12 @@ public int seek(long offset) { * capacity at the end or truncating the buffer at the end. Newly added capacity may span * multiple segments. * - *

        As a side-effect this cursor will {@link #seek seek}. If the buffer is being enlarged it + * As a side-effect this cursor will {@link #seek seek}. If the buffer is being enlarged it * will move {@link #offset} to the first byte of newly-added capacity. This is the size of the * buffer prior to the {@code resizeBuffer()} call. If the buffer is being shrunk it will move * {@link #offset} to the end of the buffer. * - *

        Warning: it is the caller’s responsibility to write new data to every byte of the + * Warning: it is the caller’s responsibility to write new data to every byte of the * newly-allocated capacity. Failure to do so may cause serious security problems as the data * in the returned buffers is not zero filled. Buffers may contain dirty pooled segments that * hold very sensitive data from other parts of the current process. @@ -2193,15 +2193,15 @@ public long resizeBuffer(long newSize) { * segment. This adds at least {@code minByteCount} bytes but may add up to a full segment of * additional capacity. * - *

        As a side-effect this cursor will {@link #seek seek}. It will move {@link #offset} to the + * As a side-effect this cursor will {@link #seek seek}. It will move {@link #offset} to the * first byte of newly-added capacity. This is the size of the buffer prior to the {@code * expandBuffer()} call. * - *

        If {@code minByteCount} bytes are available in the buffer's current tail segment that will + * If {@code minByteCount} bytes are available in the buffer's current tail segment that will * be used; otherwise another segment will be allocated and appended. In either case this * returns the number of bytes of capacity added to this buffer. * - *

        Warning: it is the caller’s responsibility to either write new data to every byte of the + * Warning: it is the caller’s responsibility to either write new data to every byte of the * newly-allocated capacity, or to {@link #resizeBuffer shrink} the buffer to the data written. * Failure to do so may cause serious security problems as the data in the returned buffers is * not zero filled. Buffers may contain dirty pooled segments that hold very sensitive data from diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/file/FileTailer.java b/bus-core/src/main/java/org/miaixz/bus/core/io/file/FileTailer.java index 0c8aecfae9..6391d6ce02 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/file/FileTailer.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/file/FileTailer.java @@ -101,7 +101,7 @@ public FileTailer(final File file, final ConsumerX lineHandler) { * * @param file 文件 * @param lineHandler 行处理器 - * @param initReadLine 启动时预读取的行数 + * @param initReadLine 启动时预读取的行数,1表示一行 */ public FileTailer(final File file, final ConsumerX lineHandler, final int initReadLine) { this(file, Charset.UTF_8, lineHandler, initReadLine, Units.SECOND.getMillis()); @@ -124,7 +124,7 @@ public FileTailer(final File file, final java.nio.charset.Charset charset, final * @param file 文件 * @param charset 编码 * @param lineHandler 行处理器 - * @param initReadLine 启动时预读取的行数 + * @param initReadLine 启动时预读取的行数,1表示一行 * @param period 检查间隔 */ public FileTailer(final File file, final java.nio.charset.Charset charset, final ConsumerX lineHandler, final int initReadLine, final long period) { @@ -183,9 +183,9 @@ public void start(final boolean async) { final LineWatcher lineWatcher = new LineWatcher(this.randomAccessFile, this.charset, this.lineHandler); final ScheduledFuture scheduledFuture = this.executorService.scheduleAtFixedRate(// - lineWatcher, // - 0, // - this.period, TimeUnit.MILLISECONDS// + lineWatcher, + 0, + this.period, TimeUnit.MILLISECONDS ); // 监听删除 @@ -246,7 +246,9 @@ private void readTail() throws IOException { int currentLine = 0; while (nextEnd > start) { // 满 - if (currentLine > initReadLine) { + if (currentLine >= initReadLine) { + // initReadLine是行数,从1开始,currentLine是行号,从0开始 + // 因此行号0表示一行,所以currentLine == initReadLine表示读取完毕 break; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/file/PathMover.java b/bus-core/src/main/java/org/miaixz/bus/core/io/file/PathMover.java index 9001a890c0..a6598f956a 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/file/PathMover.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/file/PathMover.java @@ -127,7 +127,7 @@ public Path move() throws IllegalArgumentException { final CopyOption[] options = this.options; if (PathResolve.isSub(src, target)) { - if (Files.exists(target) && PathResolve.equals(src, target)) { + if(PathResolve.equals(src, target)){ // 当用户传入目标路径与源路径一致时,直接返回,否则会导致删除风险。 return target; } @@ -174,15 +174,11 @@ public Path move() throws IllegalArgumentException { */ public Path moveContent() { final Path src = this.src; - if (PathResolve.isExistsAndNotDirectory(target, false)) { - // 文件移动调用move方法 - return move(); - } - final Path target = this.target; + + // 文件移动调用move方法 if (PathResolve.isExistsAndNotDirectory(target, false)) { - // 目标不能为文件 - throw new IllegalArgumentException("Can not move dir content to a file"); + return move(); } // target 不存在导致NoSuchFileException diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/file/PathResolve.java b/bus-core/src/main/java/org/miaixz/bus/core/io/file/PathResolve.java index 51957148e8..67a28f7da5 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/file/PathResolve.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/file/PathResolve.java @@ -34,6 +34,7 @@ import org.miaixz.bus.core.lang.exception.InternalException; import org.miaixz.bus.core.xyz.ArrayKit; import org.miaixz.bus.core.xyz.IoKit; +import org.miaixz.bus.core.xyz.ObjectKit; import java.io.*; import java.nio.file.*; @@ -608,6 +609,33 @@ public static Path moveContent(final Path src, final Path target, final boolean * @see Files#isSameFile(Path, Path) */ public static boolean equals(final Path file1, final Path file2) throws InternalException { + // 两者都为null判定为相同 + if (null == file1 || null == file2) { + return null == file1 && null == file2; + } + + final boolean exists1 = exists(file1, false); + final boolean exists2 = exists(file2, false); + + + if (exists1 && exists2) { + return isSameFile(file1, file2); + } + + return ObjectKit.equals(file1, file2); + } + + /** + * 检查两个文件是否是同一个文件 + * 所谓文件相同,是指Path对象是否指向同一个文件或文件夹 + * + * @param file1 文件1,必须存在 + * @param file2 文件2,必须存在 + * @return 是否相同 + * @throws InternalException IO异常 + * @see Files#isSameFile(Path, Path) + */ + public static boolean isSameFile(final Path file1, final Path file2) throws InternalException { try { return Files.isSameFile(file1, file2); } catch (final IOException e) { diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/resource/VfsResource.java b/bus-core/src/main/java/org/miaixz/bus/core/io/resource/VfsResource.java index 175f2fdc75..e6b6c8ed4c 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/resource/VfsResource.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/resource/VfsResource.java @@ -40,8 +40,6 @@ * VFS资源封装 * 支持VFS 3.x on JBoss AS 6+,JBoss AS 7 and WildFly 8+ * 参考:org.springframework.core.io.VfsUtils - *

        - * , Spring * * @author Kimi Liu * @since Java 17+ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/source/BufferSource.java b/bus-core/src/main/java/org/miaixz/bus/core/io/source/BufferSource.java index c74d058e6e..87689def30 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/source/BufferSource.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/source/BufferSource.java @@ -47,36 +47,51 @@ public interface BufferSource extends Source, ReadableByteChannel { /** - * This source's internal buffer. + * 该源的内部缓冲区 + * + * @return {@link Buffer} */ Buffer getBuffer(); /** - * Returns true if there are no more bytes in this source. This will block until there are bytes - * to read or the source is definitely exhausted. + * 如果此源中没有更多字节,则返回 true。 + * 这将阻塞,直到有字节可读取或源确实已耗尽 + * + * @return the true/false + * @throws IOException 异常 */ boolean exhausted() throws IOException; /** - * Returns when the buffer contains at least {@code byteCount} bytes. Throws an - * {@link java.io.EOFException} if the source is exhausted before the required bytes can be read. + * 当缓冲区至少包含 {@code byteCount} 个字节时返回。 + * 如果在读取所需字节之前源已耗尽,则抛出 {@link java.io.EOFException}。 + * + * @param byteCount 字节数 + * @throws IOException 异常 */ void require(long byteCount) throws IOException; /** - * Returns true when the buffer contains at least {@code byteCount} bytes, expanding it as - * necessary. Returns false if the source is exhausted before the requested bytes can be read. + * 如果缓冲区至少包含 {@code byteCount} 个字节,则返回 true,并根据需要对其进行扩展。 + * 如果在读取请求的字节之前源已耗尽,则返回 false。 + * + * @param byteCount 字节数 + * @return the true/false + * @throws IOException 异常 */ boolean request(long byteCount) throws IOException; /** - * Removes a byte from this source and returns it. + * 从该源中删除一个字节并返回它 + * + * @return the true/false + * @throws IOException 异常 */ byte readByte() throws IOException; /** - * Removes two bytes from this source and returns a big-endian short.

        {@code
        -     *
        +     * 从此源中删除两个字节并返回一个短整型
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeByte(0x7f)
              *       .writeByte(0xff)
        @@ -90,12 +105,15 @@ public interface BufferSource extends Source, ReadableByteChannel {
              *   assertEquals(15, buffer.readShort());
              *   assertEquals(0, buffer.size());
              * }
        + * + * @return the short + * @throws IOException 异常 */ short readShort() throws IOException; /** - * Removes two bytes from this source and returns a little-endian short.
        {@code
        -     *
        +     * 从此源中删除两个字节并返回一个整型
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeByte(0xff)
              *       .writeByte(0x7f)
        @@ -109,12 +127,15 @@ public interface BufferSource extends Source, ReadableByteChannel {
              *   assertEquals(15, buffer.readShortLe());
              *   assertEquals(0, buffer.size());
              * }
        + * + * @return the short + * @throws IOException 异常 */ short readShortLe() throws IOException; /** - * Removes four bytes from this source and returns a big-endian int.
        {@code
        -     *
        +     * 从此源中删除四个字节并返回一个大整数
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeByte(0x7f)
              *       .writeByte(0xff)
        @@ -138,8 +159,8 @@ public interface BufferSource extends Source, ReadableByteChannel {
             int readInt() throws IOException;
         
             /**
        -     * Removes four bytes from this source and returns a little-endian int. 
        {@code
        -     *
        +     * 从该源中删除四个字节并返回一个小整数
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeByte(0xff)
              *       .writeByte(0xff)
        @@ -163,8 +184,8 @@ public interface BufferSource extends Source, ReadableByteChannel {
             int readIntLe() throws IOException;
         
             /**
        -     * Removes eight bytes from this source and returns a big-endian long. 
        {@code
        -     *
        +     * 该源中删除八个字节并返回一个大长整型
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeByte(0x7f)
              *       .writeByte(0xff)
        @@ -196,8 +217,8 @@ public interface BufferSource extends Source, ReadableByteChannel {
             long readLong() throws IOException;
         
             /**
        -     * Removes eight bytes from this source and returns a little-endian long. 
        {@code
        -     *
        +     * 从此源中删除八个字节并返回一个小长整型
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeByte(0xff)
              *       .writeByte(0xff)
        @@ -229,9 +250,8 @@ public interface BufferSource extends Source, ReadableByteChannel {
             long readLongLe() throws IOException;
         
             /**
        -     * Reads a long from this source in signed decimal form (i.e., as a string in base 10 with
        -     * optional leading '-'). This will iterate until a non-digit character is found. 
        {@code
        -     *
        +     * 以有符号十进制形式从此源读取一个长整型值(即以十进制为基数的字符串,前导字符可选为“-”)。此操作将不断迭代,直到找到非数字字符。
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeUtf8("8675309 -123 00001");
              *
        @@ -243,15 +263,13 @@ public interface BufferSource extends Source, ReadableByteChannel {
              * }
        * * @return the long - * @throws NumberFormatException if the found digits do not fit into a {@code long} or a decimal - * number was not present. + * @throws NumberFormatException 如果找到的数字不适合 {@code long} 或不存在十进制数。 */ long readDecimalLong() throws IOException; /** - * Reads a long form this source in hexadecimal form (i.e., as a string in base 16). This will - * iterate until a non-hexadecimal character is found.
        {@code
        -     *
        +     * 以十六进制形式(即以 16 进制表示的字符串)读取此源的长格式。此过程将不断迭代,直到找到非十六进制字符
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeUtf8("ffff CAFEBABE 10");
              *
        @@ -263,40 +281,40 @@ public interface BufferSource extends Source, ReadableByteChannel {
              * }
        * * @return the long - * @throws NumberFormatException if the found hexadecimal does not fit into a {@code long} or - * hexadecimal was not found. + * @throws NumberFormatException 如果找到的十六进制数不适合 {@code long} 或未找到十六进制数。 */ long readHexadecimalUnsignedLong() throws IOException; /** - * Reads and discards {@code byteCount} bytes from this source. Throws an - * {@link java.io.EOFException} if the source is exhausted before the - * requested bytes can be skipped. + * 从此源读取并丢弃 {@code byteCount} 个字节 + * + * @param byteCount 字节数 + * @throws IOException 如果在跳过请求的字节之前源已耗尽,则抛出。 */ void skip(long byteCount) throws IOException; /** - * Removes all bytes bytes from this and returns them as a byte string. + * 从中删除所有字节并将它们作为字节字符串返回 * * @return the {@link ByteString} + * @throws IOException 异常 */ ByteString readByteString() throws IOException; /** - * Removes {@code byteCount} bytes from this and returns them as a byte string. + * 从中删除 {@code byteCount} 个字节并将其作为字节字符串返回。 * * @return the {@link ByteString} + * @throws IOException 异常 */ ByteString readByteString(long byteCount) throws IOException; /** - * Finds the first string in {@code options} that is a prefix of this buffer, consumes it from - * this buffer, and returns its index. If no byte string in {@code options} is a prefix of this - * buffer this returns -1 and no bytes are consumed. - * - *

        This can be used as an alternative to {@link #readByteString} or even {@link #readUtf8} if - * the set of expected values is known in advance.

        {@code
        +     * 在{@code options} 中查找第一个作为此缓冲区前缀的字符串,从此缓冲区中使用它,并返回其索引。
        +     * 如果 {@code options} 中没有字节字符串是此缓冲区的前缀,则返回 -1,并且不消耗任何字节。
              *
        +     * 如果事先知道预期值集,则可以将其用作 {@link #readByteString} 甚至 {@link #readUtf8} 的替代。
        +     * 
        {@code
              *   Options FIELDS = Options.of(
              *       ByteString.encodeUtf8("depth="),
              *       ByteString.encodeUtf8("height="),
        @@ -314,58 +332,81 @@ public interface BufferSource extends Source, ReadableByteChannel {
              *   assertEquals('\n', buffer.readByte());
              * }
        * + * @param segmentBuffer 索引值 * @return the int + * @throws IOException 异常 */ int select(SegmentBuffer segmentBuffer) throws IOException; /** - * Removes all bytes from this and returns them as a byte array. + * 从中删除所有字节并将它们作为字节数组返回。 * * @return the byte + * @throws IOException 异常 */ byte[] readByteArray() throws IOException; /** - * Removes {@code byteCount} bytes from this and returns them as a byte array. + * 从中删除 {@code byteCount} 个字节并将其作为字节数组返回。 * * @return the byte + * @throws IOException 异常 */ byte[] readByteArray(long byteCount) throws IOException; /** - * Removes up to {@code sink.length} bytes from this and copies them into {@code sink}. Returns - * the number of bytes read, or -1 if this source is exhausted. + * 从中移除最多 {@code sink.length} 个字节并将其复制到 {@code sink}。 + * 返回读取的字节数,如果此源已耗尽,则返回 -1。 + * + * @param sink 字节集合 + * @return the int + * @throws IOException 异常 */ int read(byte[] sink) throws IOException; /** - * Removes exactly {@code sink.length} bytes from this and copies them into {@code sink}. Throws - * an {@link java.io.EOFException} if the requested number of bytes cannot be read. + * 从中删除恰好 {@code sink.length} 个字节并将其复制到 {@code sink}。 + * 如果无法读取请求的字节数,则抛出 {@link java.io.EOFException}。 + * + * @param sink 字节集合 + * @throws IOException 异常 */ void readFully(byte[] sink) throws IOException; /** - * Removes up to {@code byteCount} bytes from this and copies them into {@code sink} at {@code - * offset}. Returns the number of bytes read, or -1 if this source is exhausted. + * 从此处删除最多 {@code byteCount} 个字节并将其复制到 {@code offset} 处的 {@code sink}。 + * 返回读取的字节数,如果此源已耗尽,则返回 -1。 + * + * @param sink 字节集合 + * @param offset 偏移位 + * @param byteCount 字节数 + * @return the int + * @throws IOException 异常 */ int read(byte[] sink, int offset, int byteCount) throws IOException; /** - * Removes exactly {@code byteCount} bytes from this and appends them to {@code sink}. Throws an - * {@link java.io.EOFException} if the requested number of bytes cannot be read. + * 从中删除精确的 {@code byteCount} 个字节并将其附加到 {@code sink}。 + * 如果无法读取请求的字节数,则抛出 {@link java.io.EOFException}。 + * + * @param sink 字节集合 + * @param byteCount 字节数 + * @throws IOException 异常 */ void readFully(Buffer sink, long byteCount) throws IOException; /** - * Removes all bytes from this and appends them to {@code sink}. Returns the total number of bytes - * written to {@code sink} which will be 0 if this is exhausted. + * 从中删除所有字节并将其附加到 {@code sink}。返回写入 {@code sink} 的总字节数,如果已用尽,则为 0。 + * + * @param sink 字节集合 + * @return the long + * @throws IOException 异常 */ long readAll(Sink sink) throws IOException; /** - * Removes all bytes from this, decodes them as UTF-8, and returns the string. Returns the empty - * string if this source is empty.
        {@code
        -     *
        +     * 从中删除所有字节,将其解码为 UTF-8,然后返回字符串。如果此源为空,则返回空字符串。
        +     * 
        {@code
              *   Buffer buffer = new Buffer()
              *       .writeUtf8("Uh uh uh!")
              *       .writeByte(' ')
        @@ -377,13 +418,15 @@ public interface BufferSource extends Source, ReadableByteChannel {
              *   assertEquals("", buffer.readUtf8());
              *   assertEquals(0, buffer.size());
              * }
        + * + * @return the string + * @throws IOException 异常 */ String readUtf8() throws IOException; /** - * Removes {@code byteCount} bytes from this, decodes them as UTF-8, and returns the string. + * 从中删除 {@code byteCount} 个字节,将其解码为 UTF-8,并返回字符串。 *
        {@code
        -     *
              *   Buffer buffer = new Buffer()
              *       .writeUtf8("Uh uh uh!")
              *       .writeByte(' ')
        @@ -399,14 +442,17 @@ public interface BufferSource extends Source, ReadableByteChannel {
              *   assertEquals(" magic word!", buffer.readUtf8(12));
              *   assertEquals(0, buffer.size());
              * }
        + * + * @param byteCount 字节数 + * @return the string + * @throws IOException 异常 */ String readUtf8(long byteCount) throws IOException; /** - * Removes and returns characters up to but not including the next line break. A line break is - * either {@code "\n"} or {@code "\r\n"}; these characters are not included in the result. + * 删除并返回直到下一个换行符(但不包括该换行符)的字符。 + * 换行符为 {@code "\n"} 或 {@code "\r\n"};这些字符不包含在结果中。 *
        {@code
        -     *
              *   Buffer buffer = new Buffer()
              *       .writeUtf8("I'm a hacker!\n")
              *       .writeUtf8("That's what I said: you're a nerd.\n")
        @@ -426,36 +472,27 @@ public interface BufferSource extends Source, ReadableByteChannel {
              *   assertEquals(0, buffer.size());
              * }
        * - *

        On the end of the stream this method returns null, just like {@link - * java.io.BufferedReader}. If the source doesn't end with a line break then an implicit line - * break is assumed. Null is returned once the source is exhausted. Use this for human-generated - * data, where a trailing line break is optional. + * 在流的末尾,此方法返回 null, 就像 {@link java.io.BufferedReader} 一样。 + * 如果源未以换行符结尾,则假定为隐式换行符。一旦源耗尽,将返回 Null。将此方法用于人工生成的数据,其中尾随换行符是可选的。 + * + * @return the string + * @throws IOException 异常 */ String readUtf8Line() throws IOException; /** - * Removes and returns characters up to but not including the next line break. A line break is - * either {@code "\n"} or {@code "\r\n"}; these characters are not included in the result. + * 删除并返回直到下一个换行符(但不包括该换行符)的字符。 + * 换行符为 {@code "\n"} 或 {@code "\r\n"};这些字符不包含在结果中 * - *

        On the end of the stream this method throws. Every call must consume either - * '\r\n' or '\n'. If these characters are absent in the stream, an {@link java.io.EOFException} - * is thrown. Use this for machine-generated data where a missing line break implies truncated - * input. + * @return the string + * @throws IOException 异常 */ String readUtf8LineStrict() throws IOException; /** - * Like {@link #readUtf8LineStrict()}, except this allows the caller to specify the longest - * allowed match. Use this to protect against streams that may not include - * {@code "\n"} or {@code "\r\n"}. - * - *

        The returned string will have at most {@code limit} UTF-8 bytes, and the maximum number - * of bytes scanned is {@code limit + 2}. If {@code limit == 0} this will always throw - * an {@code EOFException} because no bytes will be scanned. - * - *

        This method is safe. No bytes are discarded if the match fails, and the caller is free - * to try another match:

        {@code
        -     *
        +     * 与 {@link #readUtf8LineStrict()} 类似,不同之处在于它允许调用者指定允许的最长匹配。
        +     * 使用它来防止可能不包含 {@code "\n"} 或 {@code "\r\n"} 的流。
        +     * 
        {@code
              *   Buffer buffer = new Buffer();
              *   buffer.writeUtf8("12345\r\n");
              *
        @@ -465,45 +502,56 @@ public interface BufferSource extends Source, ReadableByteChannel {
              *   // No bytes have been consumed so the caller can retry.
              *   assertEquals("12345", buffer.readUtf8LineStrict(5));
              * }
        + * + * @param limit 限制 + * @return the string + * @throws IOException 异常 */ String readUtf8LineStrict(long limit) throws IOException; /** - * Removes and returns a single UTF-8 code point, reading between 1 and 4 bytes as necessary. - * - *

        If this source is exhausted before a complete code point can be read, this throws an {@link - * java.io.EOFException} and consumes no input. + * 删除并返回单个 UTF-8 代码点,根据需要读取 1 到 4 个字节。 + * 如果此源不是以正确编码的 UTF-8 代码点开头,则此方法将删除 1 个或多个非 UTF-8 字节并返回替换字符 ({@code U+FFFD})。 + * 这包括编码问题(输入不是正确编码的 UTF-8)、字符超出范围(超出 Unicode 的 0x10ffff 限制)、UTF-16 代理的代码 + * 点 (U+d800..U+dfff) 和过长编码(例如,修改版 UTF-8 中的 NUL 字符为 {@code 0xc080}) * - *

        If this source doesn't start with a properly-encoded UTF-8 code point, this method will - * remove 1 or more non-UTF-8 bytes and return the replacement character ({@code U+FFFD}). This - * covers encoding problems (the input is not properly-encoded UTF-8), characters out of range - * (beyond the 0x10ffff limit of Unicode), code points for UTF-16 surrogates (U+d800..U+dfff) and - * overlong encodings (such as {@code 0xc080} for the NUL character in modified UTF-8). + * @return the int + * @throws IOException 异常 */ int readUtf8CodePoint() throws IOException; /** - * Removes all bytes from this, decodes them as {@code charset}, and returns the string. + * 从中删除所有字节,将其解码为{@code charset},并返回字符串。 + * + * @param charset 字符编码 + * @return the string + * @throws IOException 异常 */ String readString(Charset charset) throws IOException; /** - * Removes {@code byteCount} bytes from this, decodes them as {@code charset}, and returns the - * string. + * 从中删除 {@code byteCount} 个字节,将其解码为 {@code charset},并返回字符串。 + * + * @param byteCount 字节数 + * @param charset 字符编码 + * @return the string + * @throws IOException 异常 */ String readString(long byteCount, Charset charset) throws IOException; /** * Equivalent to {@link #indexOf(byte, long) indexOf(b, 0)}. + * + * @param b + * @return the long + * @throws IOException 异常 */ long indexOf(byte b) throws IOException; /** - * Returns the index of the first {@code b} in the buffer at or after {@code fromIndex}. This - * expands the buffer as necessary until {@code b} is found. This reads an unbounded number of - * bytes into the buffer. Returns -1 if the stream is exhausted before the requested byte is - * found.

        {@code
        -     *
        +     * 返回缓冲区中第一个 {@code b} 的索引,位于 {@code fromIndex} 处或之后。
        +     * 这会根据需要扩展缓冲区,直到找到 {@code b}。这会将无限数量的字节读入缓冲区。如果在找到请求的字节之前流已耗尽,则返回 -1。
        +     * 
        {@code
              *   Buffer buffer = new Buffer();
              *   buffer.writeUtf8("Don't move! He can't see us if we don't move.");
              *
        @@ -511,112 +559,137 @@ public interface BufferSource extends Source, ReadableByteChannel {
              *   assertEquals(6,  buffer.indexOf(m));
              *   assertEquals(40, buffer.indexOf(m, 12));
              * }
        + * + * @param b + * @param fromIndex + * @return the long + * @throws IOException 异常 */ long indexOf(byte b, long fromIndex) throws IOException; /** - * Returns the index of {@code b} if it is found in the range of {@code fromIndex} inclusive - * to {@code toIndex} exclusive. If {@code b} isn't found, or if {@code fromIndex == toIndex}, - * then -1 is returned. + * 如果在 {@code fromIndex} 到 {@code toIndex} 范围内找到 {@code b},则返回其索引。 + * 如果未找到 {@code b},或者 {@code fromIndex == toIndex},则返回 -1。 * - *

        The scan terminates at either {@code toIndex} or the end of the buffer, whichever comes - * first. The maximum number of bytes scanned is {@code toIndex-fromIndex}. + * @param b 字节 + * @param fromIndex 开始索引 + * @param toIndex 目标索引 + * @return the long + * @throws IOException 异常 */ long indexOf(byte b, long fromIndex, long toIndex) throws IOException; /** - * Equivalent to {@link #indexOf(ByteString, long) indexOf(bytes, 0)}. + * 相当于{@link #indexOf(ByteString, long) indexOf(bytes, 0)}。 + * + * @param bytes 字节 + * @return the long + * @throws IOException 异常 */ long indexOf(ByteString bytes) throws IOException; /** - * Returns the index of the first match for {@code bytes} in the buffer at or after {@code - * fromIndex}. This expands the buffer as necessary until {@code bytes} is found. This reads an - * unbounded number of bytes into the buffer. Returns -1 if the stream is exhausted before the - * requested bytes are found.

        {@code
        -     *
        +     * 返回缓冲区中 {@code bytes} 的第一个匹配项的索引,位于 {@code fromIndex} 处或之后。
        +     * 这会根据需要扩展缓冲区,直到找到 {@code bytes}。这会将无限数量的字节读入缓冲区。如果在找到请求的字节之前流已耗尽,则返回 -1。
        +     * 
        {@code
              *   ByteString MOVE = ByteString.encodeUtf8("move");
        -     *
              *   Buffer buffer = new Buffer();
              *   buffer.writeUtf8("Don't move! He can't see us if we don't move.");
              *
              *   assertEquals(6,  buffer.indexOf(MOVE));
              *   assertEquals(40, buffer.indexOf(MOVE, 12));
              * }
        + * + * @param bytes 字节 + * @param fromIndex 字节索引 + * @return the long + * @throws IOException 异常 */ long indexOf(ByteString bytes, long fromIndex) throws IOException; /** - * Equivalent to {@link #indexOfElement(ByteString, long) indexOfElement(targetBytes, 0)}. + * 相当于{@link #indexOfElement(ByteString, long) indexOfElement(targetBytes, 0)}。 + * + * @param targetBytes 目标字节 + * @return the long + * @throws IOException 异常 */ long indexOfElement(ByteString targetBytes) throws IOException; /** - * Returns the first index in this buffer that is at or after {@code fromIndex} and that contains - * any of the bytes in {@code targetBytes}. This expands the buffer as necessary until a target - * byte is found. This reads an unbounded number of bytes into the buffer. Returns -1 if the - * stream is exhausted before the requested byte is found.
        {@code
        -     *
        +     * 返回此缓冲区中位于 {@code fromIndex} 或之后且包含 {@code targetBytes} 中任意字节的第一个索引。
        +     * 这会根据需要扩展缓冲区,直到找到目标字节。这会将无限数量的字节读入缓冲区。如果在找到请求的字节之前流已耗尽,则返回 -1。
        +     * 
        {@code
              *   ByteString ANY_VOWEL = ByteString.encodeUtf8("AEOIUaeoiu");
        -     *
              *   Buffer buffer = new Buffer();
              *   buffer.writeUtf8("Dr. Alan Grant");
              *
              *   assertEquals(4,  buffer.indexOfElement(ANY_VOWEL));    // 'A' in 'Alan'.
              *   assertEquals(11, buffer.indexOfElement(ANY_VOWEL, 9)); // 'a' in 'Grant'.
              * }
        + * + * @param targetBytes 目标字节 + * @param fromIndex 开始索引 + * @return the long + * @throws IOException 异常 */ long indexOfElement(ByteString targetBytes, long fromIndex) throws IOException; /** - * Returns true if the bytes at {@code offset} in this source equal {@code bytes}. This expands - * the buffer as necessary until a byte does not match, all bytes are matched, or if the stream - * is exhausted before enough bytes could determine a match.
        {@code
        -     *
        +     * 如果此源中 {@code offset} 处的字节等于 {@code bytes},则返回 true。
        +     * 这会根据需要扩展缓冲区,直到某个字节不匹配、所有字节都匹配,或者在足够的字节确定匹配之前流已耗尽。
        +     * 
        {@code
              *   ByteString simonSays = ByteString.encodeUtf8("Simon says:");
        -     *
              *   Buffer standOnOneLeg = new Buffer().writeUtf8("Simon says: Stand on one leg.");
              *   assertTrue(standOnOneLeg.rangeEquals(0, simonSays));
              *
              *   Buffer payMeMoney = new Buffer().writeUtf8("Pay me $1,000,000.");
              *   assertFalse(payMeMoney.rangeEquals(0, simonSays));
              * }
        + * + * @param offset 偏移量 + * @param bytes 字节 + * @return + * @throws IOException 异常 */ boolean rangeEquals(long offset, ByteString bytes) throws IOException; /** - * Returns true if {@code byteCount} bytes at {@code offset} in this source equal {@code bytes} - * at {@code bytesOffset}. This expands the buffer as necessary until a byte does not match, all - * bytes are matched, or if the stream is exhausted before enough bytes could determine a match. + * 如果此源中 {@code offset} 处的 {@code byteCount} 个字节等于 {@code bytesOffset} 处的 {@code bytes},则返回 true。 + * 这会根据需要扩展缓冲区,直到某个字节不匹配、所有字节都匹配,或者在足够的字节确定匹配之前流已耗尽。 + * + * @param offset 偏移量 + * @param bytes 字节 + * @param bytesOffset 字节偏移量 + * @param byteCount 字节数 + * @return the true/false + * @throws IOException 异常 */ boolean rangeEquals(long offset, ByteString bytes, int bytesOffset, int byteCount) throws IOException; /** - * Returns a new {@code BufferedSource} that can read data from this {@code BufferedSource} - * without consuming it. The returned source becomes invalid once this source is next read or - * closed. - *

        - * For example, we can use {@code peek()} to lookahead and read the same data multiple times. - * + * 返回一个新的 {@code BufferedSource},可从此 {@code BufferedSource}读取数据但不使用它。 + * 一旦下次读取或关闭此源,返回的源将变为无效。 *

         {@code
        -     *
              *   Buffer buffer = new Buffer();
              *   buffer.writeUtf8("abcdefghi");
        -     *
              *   buffer.readUtf8(3) // returns "abc", buffer contains "defghi"
              *
              *   BufferedSource peek = buffer.peek();
              *   peek.readUtf8(3); // returns "def", buffer contains "defghi"
              *   peek.readUtf8(3); // returns "ghi", buffer contains "defghi"
        -     *
              *   buffer.readUtf8(3); // returns "def", buffer contains "ghi"
              * }
        + * + * @return {@link BufferSource} */ BufferSource peek(); /** - * Returns an input stream that reads from this source. + * 返回从该源读取的输入流 + * + * @return {@link InputStream} */ InputStream inputStream(); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/source/GzipSource.java b/bus-core/src/main/java/org/miaixz/bus/core/io/source/GzipSource.java index fa66d64739..22e64259ff 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/source/GzipSource.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/source/GzipSource.java @@ -56,26 +56,24 @@ public class GzipSource implements Source { private static final byte SECTION_DONE = 3; /** - * Our source should yield a GZIP header (which we consume directly), followed - * by deflated bytes (which we consume via an InflaterSource), followed by a - * GZIP trailer (which we also consume directly). + * + * 源压缩字节 */ private final BufferSource source; /** - * The inflater used to decompress the deflated body. + * 用于进行解压的缓冲区 */ private final Inflater inflater; /** - * The inflater source takes care of moving data between compressed source and - * decompressed sink buffers. + * 负责在压缩源缓冲区和解压缩接收缓冲区之间交换数据 */ private final InflaterSource inflaterSource; /** - * Checksum used to check both the GZIP header and decompressed body. + * 用于检查 GZIP 标头和解压缩主体的校验 */ private final CRC32 crc = new CRC32(); /** - * The current section. Always progresses forward. + * 当前部分 */ private int section = SECTION_HEADER; @@ -91,7 +89,7 @@ public long read(Buffer sink, long byteCount) throws IOException { if (byteCount < 0) throw new IllegalArgumentException("byteCount < 0: " + byteCount); if (byteCount == 0) return 0; - // If we haven't consumed the header, we must consume it before anything else. + // 如果还没有使用标题,必须在做其他事情之前使用它。 if (section == SECTION_HEADER) { consumeHeader(); section = SECTION_BODY; @@ -107,17 +105,15 @@ public long read(Buffer sink, long byteCount) throws IOException { section = SECTION_TRAILER; } - // The body is exhausted; time to read the trailer. We always consume the - // trailer before returning a -1 exhausted result; that way if you read to - // the end of a GzipSource you guarantee that the CRC has been checked. + // 主体已耗尽;读取尾部了。总是在返回 -1 耗尽结果之前使用 + // 尾部;这样,如果您读到 GzipSource 的末尾,就可以保证 CRC 已经过检查。 if (section == SECTION_TRAILER) { consumeTrailer(); section = SECTION_DONE; - // Gzip streams self-terminate: they return -1 before their underlying - // source returns -1. Here we attempt to force the underlying stream to - // return -1 which may trigger it to release its resources. If it doesn't - // return -1, then our Gzip data finished prematurely! + // Gzip 流会自行终止:在底层源返回 -1 之前返回 -1。 + // 在这里,尝试强制底层流返回 -1,这可能会触发它释放其资源。 + // 如果它不返回 -1,那么我们的 Gzip 数据就会过早结束! if (!source.exhausted()) { throw new IOException("gzip finished without exhausting source"); } @@ -127,9 +123,8 @@ public long read(Buffer sink, long byteCount) throws IOException { } private void consumeHeader() throws IOException { - // Read the 10-byte header. We peek at the flags byte first so we know if we - // need to CRC the entire header. Then we read the magic ID1ID2 sequence. - // We can skip everything else in the first 10 bytes. + // 读取 10 字节的标头。首先查看标志字节,以便知道是否需要对整个标头进行 CRC 校验。 + // 然后读取神奇的 ID1 ID2 序列。可以跳过前 10 个字节中的所有其他内容。 // +---+---+---+---+---+---+---+---+---+---+ // |ID1|ID2|CM |FLG| MTIME |XFL|OS | (more-->) // +---+---+---+---+---+---+---+---+---+---+ @@ -142,10 +137,6 @@ private void consumeHeader() throws IOException { checkEqual("ID1ID2", (short) 0x1f8b, id1id2); source.skip(8); - // Skip optional extra fields. - // +---+---+=================================+ - // | XLEN |...XLEN bytes of "extra field"...| (more-->) - // +---+---+=================================+ if (((flags >> FEXTRA) & 1) == 1) { source.require(2); if (fhcrc) updateCrc(source.getBuffer(), 0, 2); @@ -155,10 +146,6 @@ private void consumeHeader() throws IOException { source.skip(xlen); } - // Skip an optional 0-terminated name. - // +=========================================+ - // |...original file name, zero-terminated...| (more-->) - // +=========================================+ if (((flags >> FNAME) & 1) == 1) { long index = source.indexOf((byte) 0); if (index == -1) throw new EOFException(); @@ -166,10 +153,6 @@ private void consumeHeader() throws IOException { source.skip(index + 1); } - // Skip an optional 0-terminated comment. - // +===================================+ - // |...file comment, zero-terminated...| (more-->) - // +===================================+ if (((flags >> FCOMMENT) & 1) == 1) { long index = source.indexOf((byte) 0); if (index == -1) throw new EOFException(); @@ -177,10 +160,6 @@ private void consumeHeader() throws IOException { source.skip(index + 1); } - // Confirm the optional header CRC. - // +---+---+ - // | CRC16 | - // +---+---+ if (fhcrc) { checkEqual("FHCRC", source.readShortLe(), (short) crc.getValue()); crc.reset(); @@ -188,10 +167,6 @@ private void consumeHeader() throws IOException { } private void consumeTrailer() throws IOException { - // Read the eight-byte trailer. Confirm the body's CRC and size. - // +---+---+---+---+---+---+---+---+ - // | CRC32 | ISIZE | - // +---+---+---+---+---+---+---+---+ checkEqual("CRC", source.readIntLe(), (int) crc.getValue()); checkEqual("ISIZE", source.readIntLe(), (int) inflater.getBytesWritten()); } @@ -207,16 +182,16 @@ public void close() throws IOException { } /** - * Updates the CRC with the given bytes. + * 使用给定的字节更新 CRC */ private void updateCrc(Buffer buffer, long offset, long byteCount) { - // Skip segments that we aren't checksumming. + // 跳过我们未进行校验的 SectionBuffer s = buffer.head; for (; offset >= (s.limit - s.pos); s = s.next) { offset -= (s.limit - s.pos); } - // Checksum one segment at a time. + // 每次对一个段进行校验 for (; byteCount > 0; s = s.next) { int pos = (int) (s.pos + offset); int toUpdate = (int) Math.min(s.limit - pos, byteCount); @@ -228,8 +203,7 @@ private void updateCrc(Buffer buffer, long offset, long byteCount) { private void checkEqual(String name, int expected, int actual) throws IOException { if (actual != expected) { - throw new IOException(String.format( - "%s: actual 0x%08x != expected 0x%08x", name, actual, expected)); + throw new IOException(String.format("%s: actual 0x%08x != expected 0x%08x", name, actual, expected)); } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/source/InflaterSource.java b/bus-core/src/main/java/org/miaixz/bus/core/io/source/InflaterSource.java index 04d31160f6..af5179a2ae 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/source/InflaterSource.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/source/InflaterSource.java @@ -39,8 +39,7 @@ import java.util.zip.Inflater; /** - * A source that uses DEFLATE - * to decompress data read from another source. + * 使用DEFLATE 解压缩从另一个源读取的数据的源。 * * @author Kimi Liu * @since Java 17+ @@ -51,9 +50,7 @@ public final class InflaterSource implements Source { private final Inflater inflater; /** - * When we call Inflater.setInput(), the inflater keeps our byte array until - * it needs input again. This tracks how many bytes the inflater is currently - * holding on to. + * 当调用 Inflater.setInput() 时,inflater 会保留字节数组,直到再次需要输入。 */ private int bufferBytesHeldByInflater; private boolean closed; @@ -63,9 +60,11 @@ public InflaterSource(Source source, Inflater inflater) { } /** - * This package-private constructor shares a buffer with its trusted caller. - * In general we can't share a BufferedSource because the inflater holds input - * bytes until they are inflated. + * 此包私有构造函数与其受信任的调用者共享一个缓冲区。 + * 一般来说,我们不能共享 BufferedSource,因为 inflater 会保留输入字节,直到它们被溢出为止。 + * + * @param source 缓冲源 + * @param inflater 缓冲区 */ InflaterSource(BufferSource source, Inflater inflater) { if (source == null) throw new IllegalArgumentException("source == null"); @@ -84,7 +83,7 @@ public long read( while (true) { boolean sourceExhausted = refill(); - // Decompress the inflater's compressed data into the sink. + // 将缓冲区的压缩数据解压到接收器中 try { SectionBuffer tail = sink.writableSegment(1); int toRead = (int) Math.min(byteCount, SectionBuffer.SIZE - tail.limit); @@ -97,7 +96,7 @@ public long read( if (inflater.finished() || inflater.needsDictionary()) { releaseInflatedBytes(); if (tail.pos == tail.limit) { - // We allocated a tail segment, but didn't end up needing it. Recycle! + // 分配了一个尾段,但最终并不需要它。回收! sink.head = tail.pop(); LifeCycle.recycle(tail); } @@ -111,9 +110,8 @@ public long read( } /** - * Refills the inflater with compressed data if it needs input. (And only if - * it needs input). Returns true if the inflater required input but the source - * was exhausted. + * 如果需要输入,则用压缩数据重新填充缓冲区。(并且仅在需要输入时才有效) + * 如果缓冲区需要输入但源已耗尽,则返回 true。 */ public boolean refill() throws IOException { if (!inflater.needsInput()) return false; @@ -121,10 +119,12 @@ public boolean refill() throws IOException { releaseInflatedBytes(); if (inflater.getRemaining() != 0) throw new IllegalStateException("?"); - // If there are compressed bytes in the source, assign them to the inflater. - if (source.exhausted()) return true; + // 如果源中有压缩字节,则将它们分配给缓冲区 + if (source.exhausted()) { + return true; + } - // Assign buffer bytes to the inflater. + // 将缓冲区字节分配给缓冲区 SectionBuffer head = source.getBuffer().head; bufferBytesHeldByInflater = head.limit - head.pos; inflater.setInput(head.data, head.pos, bufferBytesHeldByInflater); @@ -132,7 +132,7 @@ public boolean refill() throws IOException { } /** - * When the inflater has processed compressed data, remove it from the buffer. + * 当缓冲区处理完压缩数据后,将其从缓冲区中移除。 */ private void releaseInflatedBytes() throws IOException { if (bufferBytesHeldByInflater == 0) return; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/source/PeekSource.java b/bus-core/src/main/java/org/miaixz/bus/core/io/source/PeekSource.java index 9fd7c53cf5..f8413cb311 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/source/PeekSource.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/source/PeekSource.java @@ -66,8 +66,7 @@ public long read(Buffer sink, long byteCount) throws IOException { if (byteCount < 0) throw new IllegalArgumentException("byteCount < 0: " + byteCount); if (closed) throw new IllegalStateException("closed"); - // Source becomes invalid if there is an expected SectionBuffer and it and the expected position - // do not match the current head and head position of the upstream buffer + // 如果存在 SectionBuffer,并且它的位置与缓冲区的位置不匹配,则源将变为无效 if (expectedSegment != null && (expectedSegment != buffer.head || expectedPos != buffer.head.pos)) { throw new IllegalStateException("Peek source is invalid because upstream source was used"); @@ -76,9 +75,7 @@ public long read(Buffer sink, long byteCount) throws IOException { if (!upstream.request(pos + 1)) return -1L; if (expectedSegment == null && buffer.head != null) { - // Only once the buffer actually holds data should an expected SectionBuffer and position be - // recorded. This allows reads from the peek source to repeatedly return -1 and for data to be - // added later. Unit tests depend on this behavior. + // 只有当缓冲区实际保存数据时,才应记录预期的 SectionBuffer 和位置。 expectedSegment = buffer.head; expectedPos = buffer.head.pos; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/source/RealSource.java b/bus-core/src/main/java/org/miaixz/bus/core/io/source/RealSource.java index 89193b1439..b561fcacef 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/source/RealSource.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/source/RealSource.java @@ -139,10 +139,8 @@ public int select(SegmentBuffer segmentBuffer) throws IOException { int index = buffer.selectPrefix(segmentBuffer, true); if (index == -1) return -1; if (index == -2) { - // We need to grow the buffer. Do that, then try it all again. if (source.read(buffer, SectionBuffer.SIZE) == -1L) return -1; } else { - // We matched a full byte string: consume it and return it. int selectedSize = segmentBuffer.byteStrings[index].size(); buffer.skip(selectedSize); return index; @@ -172,7 +170,6 @@ public void readFully(byte[] sink) throws IOException { try { require(sink.length); } catch (EOFException e) { - // The underlying source is exhausted. Copy the bytes we got before rethrowing. int offset = 0; while (buffer.size > 0) { int read = buffer.read(sink, offset, (int) buffer.size); diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/source/Source.java b/bus-core/src/main/java/org/miaixz/bus/core/io/source/Source.java index 6b886848fa..a216b0442b 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/source/Source.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/source/Source.java @@ -50,7 +50,7 @@ public interface Source extends Closeable { * @param sink 缓冲 * @param byteCount 长度大小 * @return the long - * @throws IOException {@link IOException} IOException. + * @throws IOException 异常 */ long read(Buffer sink, long byteCount) throws IOException; @@ -65,7 +65,7 @@ public interface Source extends Closeable { * 关闭此源并释放此源持有的资源. * 读取闭源是一个错误。多次关闭源是安全的. * - * @throws IOException {@link IOException} IOException. + * @throws IOException 异常 */ @Override void close() throws IOException; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/stream/FastByteArrayOutputStream.java b/bus-core/src/main/java/org/miaixz/bus/core/io/stream/FastByteArrayOutputStream.java index 3e6d1895ff..03c494265a 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/stream/FastByteArrayOutputStream.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/stream/FastByteArrayOutputStream.java @@ -37,14 +37,9 @@ /** * 基于快速缓冲FastByteBuffer的OutputStream,随着数据的增长自动扩充缓冲区 - *

        * 可以通过{@link #toByteArray()}和 {@link #toString()}来获取数据 - *

        * {@link #close()}方法无任何效果,当流被关闭后不会抛出IOException - *

        * 这种设计避免重新分配内存块而是分配新增的缓冲区,缓冲区不会被GC,数据也不会被拷贝到其他缓冲区。 - *

        - * biezhi * * @author Kimi Liu * @since Java 17+ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/stream/StrInputStream.java b/bus-core/src/main/java/org/miaixz/bus/core/io/stream/StringInputStream.java similarity index 87% rename from bus-core/src/main/java/org/miaixz/bus/core/io/stream/StrInputStream.java rename to bus-core/src/main/java/org/miaixz/bus/core/io/stream/StringInputStream.java index f3ce7e6215..8dc976ca76 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/stream/StrInputStream.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/stream/StringInputStream.java @@ -38,7 +38,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class StrInputStream extends ByteArrayInputStream { +public class StringInputStream extends ByteArrayInputStream { /** * 构造 @@ -46,7 +46,7 @@ public class StrInputStream extends ByteArrayInputStream { * @param text 字符串 * @param charset 编码 */ - public StrInputStream(final CharSequence text, final java.nio.charset.Charset charset) { + public StringInputStream(final CharSequence text, final java.nio.charset.Charset charset) { super(ByteKit.toBytes(text, charset)); } @@ -56,7 +56,7 @@ public StrInputStream(final CharSequence text, final java.nio.charset.Charset ch * @param text 字符串 * @return StrInputStream */ - public static StrInputStream of(final CharSequence text) { + public static StringInputStream of(final CharSequence text) { return of(text, Charset.UTF_8); } @@ -67,8 +67,8 @@ public static StrInputStream of(final CharSequence text) { * @param charset 编码 * @return StrInputStream */ - public static StrInputStream of(final CharSequence text, final java.nio.charset.Charset charset) { - return new StrInputStream(text, charset); + public static StringInputStream of(final CharSequence text, final java.nio.charset.Charset charset) { + return new StringInputStream(text, charset); } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/timout/AssignTimeout.java b/bus-core/src/main/java/org/miaixz/bus/core/io/timout/AssignTimeout.java index a1c9617d24..f49b8120d4 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/timout/AssignTimeout.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/timout/AssignTimeout.java @@ -48,7 +48,7 @@ public AssignTimeout(Timeout delegate) { } /** - * {@link Timeout} instance to which this instance is currently delegating. + * {@link Timeout} 此实例当前正在委托给的实例 */ public final Timeout delegate() { return delegate; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/timout/AsyncTimeout.java b/bus-core/src/main/java/org/miaixz/bus/core/io/timout/AsyncTimeout.java index 34b637c1d5..4c8f078d29 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/timout/AsyncTimeout.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/timout/AsyncTimeout.java @@ -48,46 +48,41 @@ public class AsyncTimeout extends Timeout { /** - * Don't write more than 64 KiB of data at a time, give or take a segment. Otherwise slow - * connections may suffer timeouts even when they're making (slow) progress. Without this, writing - * a single 1 MiB buffer may never succeed on a sufficiently slow connection. + * 每次写入的数据不得超过 64 KiB,无论大小。 + * 否则,慢速连接即使正在(缓慢)进行,也可能会超时。 + * 如果不这样做,在速度足够慢的连接上,写入单个 1 MiB 缓冲区可能永远不会成功。 */ private static final int TIMEOUT_WRITE_SIZE = 64 * 1024; /** - * Duration for the watchdog thread to be idle before it shuts itself down. + * 守护线程在关闭之前处于空闲状态的持续时间 */ private static final long IDLE_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(60); private static final long IDLE_TIMEOUT_NANOS = TimeUnit.MILLISECONDS.toNanos(IDLE_TIMEOUT_MILLIS); /** - * The watchdog thread processes a linked list of pending timeouts, sorted in the order to be - * triggered. This class synchronizes on AsyncTimeout.class. This lock guards the queue. - * - *

        Head's 'next' points to the first element of the linked list. The first element is the next - * node to time out, or null if the queue is empty. The head is null until the watchdog thread is - * started and also after being idle for {@link #IDLE_TIMEOUT_MILLIS}. + * 守护线程处理待处理超时的链接列表,按触发顺序排序。 */ static AsyncTimeout head; /** - * True if this node is currently in the queue. + * 如果此节点当前在队列中,则为 True。 */ private boolean inQueue; /** - * The next node in the linked list. + * 链接列表中的下一个节点。 */ private AsyncTimeout next; /** - * If scheduled, this is the time that the watchdog should time this out. + * 如果已安排好,这是守护线程应该超时的时间。 */ private long timeoutAt; private static synchronized void scheduleTimeout( AsyncTimeout node, long timeoutNanos, boolean hasDeadline) { - // Start the watchdog thread and create the head node when the first timeout is scheduled. + // 在第一次超时安排时启动守护线程并创建头节点 if (head == null) { head = new AsyncTimeout(); new Watchdog().start(); @@ -95,8 +90,7 @@ private static synchronized void scheduleTimeout( long now = System.nanoTime(); if (timeoutNanos != 0 && hasDeadline) { - // Compute the earliest event; either timeout or deadline. Because nanoTime can wrap around, - // Math.min() is undefined for absolute values, but meaningful for relative ones. + // 计算最早的事件;超时或截止时间。由于 nanoTime 可以循环,因此 Math.min() 对于绝对值是未定义的,但对于相对值是有意义的。 node.timeoutAt = now + Math.min(timeoutNanos, node.deadlineNanoTime() - now); } else if (timeoutNanos != 0) { node.timeoutAt = now + timeoutNanos; @@ -106,14 +100,15 @@ private static synchronized void scheduleTimeout( throw new AssertionError(); } - // Insert the node in sorted order. + // 按排序顺序插入节点 long remainingNanos = node.remainingNanos(now); for (AsyncTimeout prev = head; true; prev = prev.next) { if (prev.next == null || remainingNanos < prev.next.remainingNanos(now)) { node.next = prev.next; prev.next = node; if (prev == head) { - AsyncTimeout.class.notify(); // Wake up the watchdog when inserting at the front. + // 前端插入时唤醒守护线程 + AsyncTimeout.class.notify(); } break; } @@ -121,10 +116,13 @@ private static synchronized void scheduleTimeout( } /** - * Returns true if the timeout occurred. + * 如果发生超时则返回 true + * + * @param node + * @return the true/false */ private static synchronized boolean cancelScheduledTimeout(AsyncTimeout node) { - // Remove the node from the linked list. + // 从链接列表中删除该节点 for (AsyncTimeout prev = head; prev != null; prev = prev.next) { if (prev.next == node) { prev.next = node.next; @@ -132,44 +130,40 @@ private static synchronized boolean cancelScheduledTimeout(AsyncTimeout node) { return false; } } - - // The node wasn't found in the linked list: it must have timed out! + // 链接列表中未找到该节点:一定是超时了! return true; } /** - * Removes and returns the node at the head of the list, waiting for it to time out if necessary. - * This returns {@link #head} if there was no node at the head of the list when starting, and - * there continues to be no node after waiting {@code IDLE_TIMEOUT_NANOS}. It returns null if a - * new node was inserted while waiting. Otherwise this returns the node being waited on that has - * been removed. + * 删除并返回列表头部的节点,必要时等待其超时。 + * 如果启动时列表头部没有节点,则返回 {@link #head},并且在等待 {@code IDLE_TIMEOUT_NANOS} 后仍然没有节点。 + * 如果在等待期间插入了新节点,则返回 null。否则,返回正在等待的已被删除的节点。 */ static AsyncTimeout awaitTimeout() throws InterruptedException { - // Get the next eligible node. + // 获取下一个合格节点 AsyncTimeout node = head.next; - // The queue is empty. Wait until either something is enqueued or the idle timeout elapses. + // 队列为空。等待,直到有内容入队或空闲超时结束。 if (node == null) { long startNanos = System.nanoTime(); AsyncTimeout.class.wait(IDLE_TIMEOUT_MILLIS); return head.next == null && (System.nanoTime() - startNanos) >= IDLE_TIMEOUT_NANOS - ? head // The idle timeout elapsed. - : null; // The situation has changed. + ? head // 空闲超时已过 + : null; // 情况已经发生了变化 } long waitNanos = node.remainingNanos(System.nanoTime()); - // The head of the queue hasn't timed out yet. Await that. + // 队头尚未超时。请等待 if (waitNanos > 0) { - // Waiting is made complicated by the fact that we work in nanoseconds, - // but the API wants (millis, nanos) in two arguments. + // 由于我们以纳秒为单位进行工作,因此等待变得复杂,但 API 需要两个参数(毫秒,纳秒)。 long waitMillis = waitNanos / 1000000L; waitNanos -= (waitMillis * 1000000L); AsyncTimeout.class.wait(waitMillis, (int) waitNanos); return null; } - // The head of the queue has timed out. Remove it. + // 队列头部已超时。请将其移除 head.next = node.next; node.next = null; return node; @@ -180,14 +174,17 @@ public final void enter() { long timeoutNanos = timeoutNanos(); boolean hasDeadline = hasDeadline(); if (timeoutNanos == 0 && !hasDeadline) { - return; // No timeout and no deadline? Don't bother with the queue. + // 没有超时和截止期限?不用排队 + return; } inQueue = true; scheduleTimeout(this, timeoutNanos, hasDeadline); } /** - * Returns true if the timeout occurred. + * 如果发生超时则返回 true + * + * @return the true/false */ public final boolean exit() { if (!inQueue) return false; @@ -196,32 +193,29 @@ public final boolean exit() { } /** - * Returns the amount of time left until the time out. This will be negative if the timeout has - * elapsed and the timeout should occur immediately. + * 返回距离超时还剩多少时间。如果超时已过且超时应立即发生,则该值为负数。 */ private long remainingNanos(long now) { return timeoutAt - now; } /** - * Invoked by the watchdog thread when the time between calls to {@link #enter()} and {@link - * #exit()} has exceeded the timeout. + * 当调用 {@link #enter()} 和 {@link #exit()} 之间的时间超出超时时,由守护线程调用。 */ protected void timedOut() { } /** - * Returns a new sink that delegates to {@code sink}, using this to implement timeouts. This works - * best if {@link #timedOut} is overridden to interrupt {@code sink}'s current operation. + * 返回一个委托给 {@code sink} 的新接收器,使用它来实现超时。 + * 如果覆盖 {@link #timedOut} 以中断 {@code sink} 的当前操作,则效果最佳。 */ public final Sink sink(final Sink sink) { return new Sink() { @Override public void write(Buffer source, long byteCount) throws IOException { IoKit.checkOffsetAndCount(source.size, 0, byteCount); - while (byteCount > 0L) { - // Count how many bytes to write. This loop guarantees we split on a segment boundary. + // 计算要写入的字节数。此循环保证我们在段边界上进行分割。 long toWrite = 0L; for (SectionBuffer s = source.head; toWrite < TIMEOUT_WRITE_SIZE; s = s.next) { int segmentSize = s.limit - s.pos; @@ -232,7 +226,7 @@ public void write(Buffer source, long byteCount) throws IOException { } } - // Emit one write. Only this section is subject to the timeout. + // 发出一次写入。只有此部分受超时限制。 boolean throwOnTimeout = false; enter(); try { @@ -288,8 +282,8 @@ public String toString() { } /** - * Returns a new source that delegates to {@code source}, using this to implement timeouts. This - * works best if {@link #timedOut} is overridden to interrupt {@code sink}'s current operation. + * 返回一个委托给 {@code source} 的新源,使用它来实现超时。 + * 如果覆盖 {@link #timedOut} 以中断 {@code sink} 的当前操作,则效果最佳。 */ public final Source source(final Source source) { return new Source() { @@ -335,8 +329,8 @@ public String toString() { } /** - * Throws an IOException if {@code throwOnTimeout} is {@code true} and a timeout occurred. See - * {@link #newTimeoutException(IOException)} for the type of exception thrown. + * 如果 {@code throwOnTimeout} 为 {@code true} 且发生超时,则抛出 IOException。 + * 请参阅 {@link #newTimeoutException(IOException)} 以了解抛出的异常类型。 */ final void exit(boolean throwOnTimeout) throws IOException { boolean timedOut = exit(); @@ -344,9 +338,8 @@ final void exit(boolean throwOnTimeout) throws IOException { } /** - * Returns either {@code cause} or an IOException that's caused by {@code cause} if a timeout - * occurred. See {@link #newTimeoutException(IOException)} for the type of exception - * returned. + * 如果发生超时,则返回 {@code cause} 或由 {@code cause} 引起的 IOException。 + * 有关返回的异常类型,请参阅 {@link #newTimeoutException(IOException)}。 */ final IOException exit(IOException cause) throws IOException { if (!exit()) return cause; @@ -354,9 +347,8 @@ final IOException exit(IOException cause) throws IOException { } /** - * Returns an {@link IOException} to represent a timeout. By default this method returns {@link - * InterruptedIOException}. If {@code cause} is non-null it is set as the cause of the - * returned exception. + * 返回一个 {@link IOException} 来表示超时。默认情况下,此方法返回 {@link InterruptedIOException}。 + * 如果 {@code cause} 非空,则将其设置为返回异常的原因。 */ protected IOException newTimeoutException(IOException cause) { InterruptedIOException e = new InterruptedIOException("timeout"); @@ -368,7 +360,7 @@ protected IOException newTimeoutException(IOException cause) { private static final class Watchdog extends Thread { Watchdog() { - super("Okio Watchdog"); + super("Watchdog"); setDaemon(true); } @@ -379,18 +371,17 @@ public void run() { synchronized (AsyncTimeout.class) { timedOut = awaitTimeout(); - // Didn't find a node to interrupt. Try again. + // 未找到要中断的节点。请重试 if (timedOut == null) continue; - // The queue is completely empty. Let this thread exit and let another watchdog thread - // get created on the next call to scheduleTimeout(). + // 队列完全为空。让此线程退出,并在下次调用 scheduleTimeout() 时创建另一个守护线程。 if (timedOut == head) { head = null; return; } } - // Close the timed out node. + // 关闭超时节点 timedOut.timedOut(); } catch (InterruptedException ignored) { } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/timout/Timeout.java b/bus-core/src/main/java/org/miaixz/bus/core/io/timout/Timeout.java index 48f5de04fa..4755fc9804 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/timout/Timeout.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/timout/Timeout.java @@ -45,7 +45,7 @@ public class Timeout { /** * 既不跟踪也不检测超时的空超时。在不需要超时 - * 的情况下使用它,例如在操作不会阻塞的实现中. + * 的情况下使用它,例如在操作不会阻塞的实现中 */ public static final Timeout NONE = new Timeout() { @Override @@ -61,34 +61,36 @@ public Timeout deadlineNanoTime(long deadlineNanoTime) { @Override public void throwIfReached() { } - }; /** - * True if {@code deadlineNanoTime} is defined. There is no equivalent to null - * or 0 for {@link System#nanoTime}. + * 如果定义了 {@code deadlineNanoTime},则为 True。 + * 对于 {@link System#nanoTime},没有与 null 或 0 等价的值 */ private boolean hasDeadline; + /** + * 截止时间 + */ private long deadlineNanoTime; + /** + * 超时时间 + */ private long timeoutNanos; + /** + * 构建 + */ public Timeout() { - } - static long minTimeout(long aNanos, long bNanos) { - if (aNanos == 0L) return bNanos; - if (bNanos == 0L) return aNanos; - if (aNanos < bNanos) return aNanos; - return bNanos; } /** - * Wait at most {@code timeout} time before aborting an operation. Using a - * per-operation timeout means that as long as forward progress is being made, - * no sequence of operations will fail. + * 最多等待 {@code timeout} 时间,然后中止操作。 + * 使用每个操作超时意味着只要向前推进,任何操作序列都不会失败。 * - *

        If {@code timeout == 0}, operations will run indefinitely. (Operating - * system timeouts may still apply.) + * @param timeout 超时时间 + * @param unit 时间单位 + * @return {@link Timeout} */ public Timeout timeout(long timeout, TimeUnit unit) { if (timeout < 0) throw new IllegalArgumentException("timeout < 0: " + timeout); @@ -98,24 +100,23 @@ public Timeout timeout(long timeout, TimeUnit unit) { } /** - * Returns the timeout in nanoseconds, or {@code 0} for no timeout. + * 返回以纳秒为单位的超时时间,或 {@code 0} 表示无超时。 */ public long timeoutNanos() { return timeoutNanos; } /** - * Returns true if a deadline is enabled. + * 如果启用了截止期限,则返回 true */ public boolean hasDeadline() { return hasDeadline; } /** - * Returns the {@linkplain System#nanoTime() nano time} when the deadline will - * be reached. + * 返回截止期限的 {@linkplain System#nanoTime()} * - * @throws IllegalStateException if no deadline is set. + * @throws IllegalStateException 如果没有设定截止时间 */ public long deadlineNanoTime() { if (!hasDeadline) throw new IllegalStateException("No deadline"); @@ -123,9 +124,8 @@ public long deadlineNanoTime() { } /** - * Sets the {@linkplain System#nanoTime() nano time} when the deadline will be - * reached. All operations must complete before this time. Use a deadline to - * set a maximum bound on the time spent on a sequence of operations. + * 设置达到截止期限的 {@linkplain System#nanoTime()} + * 所有操作必须在此时间之前完成。使用截止期限来设置一系列操作所花费时间的最大限度。 */ public Timeout deadlineNanoTime(long deadlineNanoTime) { this.hasDeadline = true; @@ -134,7 +134,11 @@ public Timeout deadlineNanoTime(long deadlineNanoTime) { } /** - * Set a deadline of now plus {@code duration} time. + * 设定现在加上{@code duration} 时间的截止时间 + * + * @param duration 期间 + * @param unit 时间单位 + * @return {@link Timeout} */ public final Timeout deadline(long duration, TimeUnit unit) { if (duration <= 0) throw new IllegalArgumentException("duration <= 0: " + duration); @@ -143,7 +147,7 @@ public final Timeout deadline(long duration, TimeUnit unit) { } /** - * Clears the timeout. Operating system timeouts may still apply. + * 清除超时 */ public Timeout clearTimeout() { this.timeoutNanos = 0; @@ -151,7 +155,7 @@ public Timeout clearTimeout() { } /** - * Clears the deadline. + * 清除最后期限 */ public Timeout clearDeadline() { this.hasDeadline = false; @@ -159,13 +163,13 @@ public Timeout clearDeadline() { } /** - * Throws an {@link InterruptedIOException} if the deadline has been reached or if the current - * thread has been interrupted. This method doesn't detect timeouts; that should be implemented to - * asynchronously abort an in-progress operation. + * 如果已达到截止时间或当前线程已中断,则抛出 {@link InterruptedIOException}。 + * 此方法不检测超时;应实施超时以异步中止正在进行的操作 */ public void throwIfReached() throws IOException { if (Thread.interrupted()) { - Thread.currentThread().interrupt(); // Retain interrupted status. + // 保留中断状态 + Thread.currentThread().interrupt(); throw new InterruptedIOException("interrupted"); } @@ -175,40 +179,12 @@ public void throwIfReached() throws IOException { } /** - * Waits on {@code monitor} until it is notified. Throws {@link InterruptedIOException} if either - * the thread is interrupted or if this timeout elapses before {@code monitor} is notified. The - * caller must be synchronized on {@code monitor}. - * - *

        Here's a sample class that uses {@code waitUntilNotified()} to await a specific state. Note - * that the call is made within a loop to avoid unnecessary waiting and to mitigate spurious - * notifications.

        {@code
        -     *
        -     *   class Dice {
        -     *     Random random = new Random();
        -     *     int latestTotal;
        -     *
        -     *     public synchronized void roll() {
        -     *       latestTotal = 2 + random.nextInt(6) + random.nextInt(6);
        -     *       System.out.println("Rolled " + latestTotal);
        -     *       notifyAll();
        -     *     }
        -     *
        -     *     public void rollAtFixedRate(int period, TimeUnit timeUnit) {
        -     *       Executors.newScheduledThreadPool(0).scheduleAtFixedRate(new Runnable() {
        -     *         public void run() {
        -     *           roll();
        -     *          }
        -     *       }, 0, period, timeUnit);
        -     *     }
        +     * 等待 {@code monitor} 直到收到通知。
        +     * 如果线程中断或在 {@code monitor} 收到通知之前超时,则抛出 {@link InterruptedIOException}。
        +     * 调用者必须在 {@code monitor} 上同步。
              *
        -     *     public synchronized void awaitTotal(Timeout timeout, int total)
        -     *         throws InterruptedIOException {
        -     *       while (latestTotal != total) {
        -     *         timeout.waitUntilNotified(this);
        -     *       }
        -     *     }
        -     *   }
        -     * }
        + * @param monitor 监视器 + * @throws InterruptedIOException 异常 */ public final void waitUntilNotified(Object monitor) throws InterruptedIOException { try { @@ -216,11 +192,12 @@ public final void waitUntilNotified(Object monitor) throws InterruptedIOExceptio long timeoutNanos = timeoutNanos(); if (!hasDeadline && timeoutNanos == 0L) { - monitor.wait(); // There is no timeout: wait forever. + // 没有超时:永远等待 + monitor.wait(); return; } - // Compute how long we'll wait. + // 计算一下要等待多久 long waitNanos; long start = System.nanoTime(); if (hasDeadline && timeoutNanos != 0) { @@ -232,7 +209,7 @@ public final void waitUntilNotified(Object monitor) throws InterruptedIOExceptio waitNanos = timeoutNanos; } - // Attempt to wait that long. This will break out early if the monitor is notified. + // 尝试等待那么长时间。如果监视器收到通知,这将提前触发 long elapsedNanos = 0L; if (waitNanos > 0L) { long waitMillis = waitNanos / 1000000L; @@ -240,7 +217,7 @@ public final void waitUntilNotified(Object monitor) throws InterruptedIOExceptio elapsedNanos = System.nanoTime() - start; } - // Throw if the timeout elapsed before the monitor was notified. + // 如果在监视器收到通知之前已经超时,则抛出 if (elapsedNanos >= waitNanos) { throw new InterruptedIOException("timeout"); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/unit/DataSize.java b/bus-core/src/main/java/org/miaixz/bus/core/io/unit/DataSize.java index 99bc151e3d..f481ea267d 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/io/unit/DataSize.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/unit/DataSize.java @@ -176,7 +176,6 @@ public static DataSize of(final BigDecimal amount, DataUnit unit) { /** * 获取指定数据大小文本对应的DataSize对象,如果无单位指定,默认获取{@link DataUnit#BYTES} - *

        * 例如: *

              * "12KB" -- parses as "12 kilobytes"
        @@ -194,7 +193,6 @@ public static long parse(final String text) {
         
             /**
              * 获取指定数据大小文本对应的DataSize对象,如果无单位指定,默认获取{@link DataUnit#BYTES}
        -     * 

        * 例如: *

              * "12KB" -- parses as "12 kilobytes"
        @@ -213,10 +211,8 @@ public static DataSize parse(final CharSequence text) {
             /**
              * Obtain a DataSize from a text string such as {@code 12MB} using
              * the specified default {@link DataUnit} if no unit is specified.
        -     * 

        * The string starts with a number followed optionally by a unit matching one of the * supported {@linkplain DataUnit suffixes}. - *

        * Examples: *

              * "12KB" -- parses as "12 kilobytes"
        diff --git a/bus-core/src/main/java/org/miaixz/bus/core/io/watch/WatchMonitor.java b/bus-core/src/main/java/org/miaixz/bus/core/io/watch/WatchMonitor.java
        index d3bbe15007..564814b14d 100644
        --- a/bus-core/src/main/java/org/miaixz/bus/core/io/watch/WatchMonitor.java
        +++ b/bus-core/src/main/java/org/miaixz/bus/core/io/watch/WatchMonitor.java
        @@ -40,7 +40,6 @@
         
         /**
          * 路径监听器
        - * 

        * 监听器可监听目录或文件 * 如果监听的Path不存在,则递归创建空目录然后监听此空目录 * 递归监听目录时,并不会监听新创建的目录 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/Algorithm.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/Algorithm.java index 07163be5cf..459f6197af 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/Algorithm.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/Algorithm.java @@ -59,6 +59,10 @@ public enum Algorithm { /** * RSA算法,此算法用了RSA/None/NoPadding */ + RSA_NONE("RSA/None/NoPadding"), + /** + * EC算法 + */ EC("EC"), /** * ECDSA @@ -268,6 +272,16 @@ public enum Algorithm { /******************************* 其他算法 *******************************/ + /** + * 祖冲之算法-ZUC算法 + * ZUC-128 + */ + ZUC_128("ZUC-128"), + /** + * 祖冲之算法-ZUC算法 + * ZUC-256 + */ + ZUC_256("ZUC-256"), /** * ECIES(集成加密方案,elliptic curve integrate encrypt scheme) */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/Header.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/Header.java deleted file mode 100755 index bb8e34e96b..0000000000 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/Header.java +++ /dev/null @@ -1,279 +0,0 @@ -/* - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - ~ ~ - ~ The MIT License (MIT) ~ - ~ ~ - ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ - ~ ~ - ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ - ~ of this software and associated documentation files (the "Software"), to deal ~ - ~ in the Software without restriction, including without limitation the rights ~ - ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ - ~ copies of the Software, and to permit persons to whom the Software is ~ - ~ furnished to do so, subject to the following conditions: ~ - ~ ~ - ~ The above copyright notice and this permission notice shall be included in ~ - ~ all copies or substantial portions of the Software. ~ - ~ ~ - ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ - ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ - ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ - ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ - ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ - ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ - ~ THE SOFTWARE. ~ - ~ ~ - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - */ -package org.miaixz.bus.core.lang; - -/** - * Header 常量 - * - * @author Kimi Liu - * @since Java 17+ - */ -public class Header { - - /** - * The header Host - */ - public static final String HOST = "Host"; - /** - * The header Server - */ - public static final String SERVER = "Server"; - /** - * The header Age - */ - public static final String AGE = "Age"; - /** - * The header Allow - */ - public static final String ALLOW = "Allow"; - /** - * The header Expires - */ - public static final String EXPIRES = "Expires"; - /** - * The header Cookie - */ - public static final String COOKIE = "Cookie"; - /** - * The header Set-Cookie - */ - public static final String SET_COOKIE = "Set-Cookie"; - /** - * The header Encoding - */ - public static final String ENCODING = "Encoding"; - /** - * The header Upgrade - */ - public static final String UPGRADE = "Upgrade"; - /** - * The header Trailers - */ - public static final String TRAILERS = "Trailers"; - /** - * The header Location - */ - public static final String LOCATION = "Location"; - /** - * The header Connection - */ - public static final String CONNECTION = "Connection"; - /** - * The header Date - */ - public static final String DATE = "Date"; - /** - * The header Etag - */ - public static final String ETAG = "Etag"; - /** - * The header Expect - */ - public static final String EXPECT = "Expect"; - /** - * The header From - */ - public static final String FROM = "From"; - /** - * The header Link - */ - public static final String LINK = "Link"; - /** - * The header Vary - */ - public static final String VARY = "Vary"; - /** - * The header Via - */ - public static final String VIA = "Via"; - /** - * The header Range - */ - public static final String RANGE = "Range"; - /** - * The header Referer - */ - public static final String REFERER = "Referer"; - /** - * The header Refresh - */ - public static final String REFRESH = "Refresh"; - /** - * The header te - */ - public static final String TE = "te"; - /** - * The header If-Match - */ - public static final String IF_MATCH = "If-Match"; - /** - * The header If-Range - */ - public static final String IF_RANGE = "If-Range"; - /** - * The header Accept - */ - public static final String ACCEPT = "Accept"; - /** - * The header Accept-Charset - */ - public static final String ACCEPT_CHARSET = "Accept-Charset"; - /** - * The header Accept-Encoding - */ - public static final String ACCEPT_ENCODING = "Accept-Encoding"; - /** - * The header Accept-Language - */ - public static final String ACCEPT_LANGUAGE = "Accept-Language"; - /** - * The header Accept-Ranges - */ - public static final String ACCEPT_RANGES = "Accept-Ranges"; - /** - * The header Content-Encoding - */ - public static final String CONTENT_ENCODING = "Content-Encoding"; - /** - * The header Content-Language - */ - public static final String CONTENT_LANGUAGE = "Content-Language"; - /** - * The header Content-Length - */ - public static final String CONTENT_LENGTH = "Content-Length"; - /** - * The header Content-Location - */ - public static final String CONTENT_LOCATION = "Content-Location"; - /** - * The header Content-MD5 - */ - public static final String CONTENT_MD5 = "Content-MD5"; - /** - * The header Content-Range - */ - public static final String CONTENT_RANGE = "Content-Range"; - /** - * The header Content-Type - */ - public static final String CONTENT_TYPE = "Content-Type"; - /** - * The header Content-Disposition - */ - public static final String CONTENT_DISPOSITION = "Content-Disposition"; - /** - * The header Transfer-Encoding - */ - public static final String TRANSFER_ENCODING = "Transfer-Encoding"; - /** - * The header Cache-Control - */ - public static final String CACHE_CONTROL = "Cache-Control"; - /** - * The header User-Agent - */ - public static final String USER_AGENT = "User-Agent"; - /** - * The header Retry-After - */ - public static final String RETRY_AFTER = "Retry-After"; - /** - * The header Max-Forwards - */ - public static final String MAX_FORWARDS = "Max-Forwards"; - /** - * The header Keep-Alive - */ - public static final String KEEP_ALIVE = "Keep-Alive"; - /** - * The header Authorization - */ - public static final String AUTHORIZATION = "Authorization"; - /** - * The header Proxy-Authorization - */ - public static final String PROXY_AUTHORIZATION = "Proxy-Authorization"; - /** - * The header Proxy-Connection - */ - public static final String PROXY_CONNECTION = "Proxy-Connection"; - /** - * The header WWW-Authenticate - */ - public static final String WWW_AUTHENTICATE = "WWW-Authenticate"; - /** - * The header Proxy-Authenticate - */ - public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate"; - /** - * The header Httpd-Preemptive - */ - public static final String HTTPD_PREEMPTIVE = "Httpd-Preemptive"; - /** - * The header Last-Modified - */ - public static final String LAST_MODIFIED = "Last-Modified"; - /** - * The header If-Unmodified-Since - */ - public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; - /** - * The header If-Modified-Since - */ - public static final String IF_MODIFIED_SINCE = "If-Modified-Since"; - /** - * The header If-None-Match - */ - public static final String IF_NONE_MATCH = "If-None-Match"; - /** - * The header Sec-WebSocket-Key - */ - public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key"; - /** - * The header Sec-WebSocket-Accept - */ - public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept"; - /** - * The header Sec-WebSocket-Version - */ - public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version"; - /** - * The header Sec-WebSocket-Version - */ - public static final String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; - /** - * The header Sec-WebSocket-Version - */ - public static final String STRICT_TRANSPORT_SECURITY = "Strict-Transport-Security"; - /** - * The header SOAPAction - */ - public static final String SOAPACTION = "SOAPAction"; - -} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/Http.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/Http.java deleted file mode 100644 index 266a5a3a1f..0000000000 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/Http.java +++ /dev/null @@ -1,517 +0,0 @@ -package org.miaixz.bus.core.lang; - - -import org.miaixz.bus.core.xyz.StringKit; - -/** - * HTTP 相关常量 - * - * @author Kimi Liu - * @since Java 17+ - */ -public class Http { - - /** - * The http - */ - public static final String HTTP = "http"; - /** - * The https - */ - public static final String HTTPS = "https"; - /** - * The https - */ - public static final String WS = "ws"; - /** - * The https - */ - public static final String WSS = "wss"; - /** - * The prefix http - */ - public static final String HTTP_PREFIX = HTTP + Symbol.COLON + Symbol.FORWARDSLASH; - /** - * The prefix https - */ - public static final String HTTPS_PREFIX = HTTPS + Symbol.COLON + Symbol.FORWARDSLASH; - /** - * The prefix ws - */ - public static final String WS_PREFIX = WS + Symbol.COLON + Symbol.FORWARDSLASH; - /** - * The prefix wss - */ - public static final String WSS_PREFIX = WSS + Symbol.COLON + Symbol.FORWARDSLASH; - /** - * HTTP Method GET - */ - public static final String GET = "GET"; - /** - * HTTP Method POST - */ - public static final String POST = "POST"; - /** - * HTTP Method PUT - */ - public static final String PUT = "PUT"; - /** - * HTTP Method PATCH - */ - public static final String PATCH = "PATCH"; - /** - * HTTP Method DELETE - */ - public static final String DELETE = "DELETE"; - /** - * HTTP Method HEAD - */ - public static final String HEAD = "HEAD"; - /** - * HTTP Method TRACE - */ - public static final String TRACE = "TRACE"; - /** - * HTTP Method CONNECT - */ - public static final String CONNECT = "CONNECT"; - /** - * HTTP Method OPTIONS - */ - public static final String OPTIONS = "OPTIONS"; - /** - * HTTP Method BEFORE - */ - public static final String BEFORE = "BEFORE"; - /** - * HTTP Method AFTER - */ - public static final String AFTER = "AFTER"; - /** - * HTTP Method MOVE - */ - public static final String MOVE = "MOVE"; - /** - * HTTP Method PROPPATCH - */ - public static final String PROPPATCH = "PROPPATCH"; - /** - * HTTP Method REPORT - */ - public static final String REPORT = "REPORT"; - /** - * HTTP Method PROPFIND - */ - public static final String PROPFIND = "PROPFIND"; - /** - * HTTP Method ALL - */ - public static final String ALL = "ALL"; - /** - * HTTP Method NONE - */ - public static final String NONE = "NONE"; - /** - * HTTP/1.0 - */ - public static final String HTTP_1_0 = "HTTP/1.0"; - /** - * HTTP/1.1 - */ - public static final String HTTP_1_1 = "HTTP/1.1"; - /** - * HTTP/2.0 - */ - public static final String HTTP_2_0 = "HTTP/2.0"; - /** - * SPDY/3.1 - */ - public static final String SPDY_3_1 = "SPDY/3.1"; - /** - * SOAP 1.1 - */ - public static final String SOAP_1_1 = "SOAP 1.1 Protocol"; - /** - * SOAP 1.2 - */ - public static final String SOAP_1_2 = "SOAP 1.2 Protocol"; - /** - * QUIC - */ - public static final String QUIC = "QUIC"; - /** - * 明文HTTP/2,没有"upgrade"往返。此选项要求客户端事先知道服务器支持明文HTTP/2 - */ - public static final String H2_PRIOR_KNOWLEDGE = "H2_PRIOR_KNOWLEDGE"; - /** - * Supports some version of SSL; may support other versions - */ - public static final String SSL = "SSL"; - /** - * Supports some version of TLS; may support other versions - */ - public static final String TLS = "TLS"; - /** - * Supports RFC 2246: TLS version 1.0 ; may support other versions - */ - public static final String TLS_V_10 = "TLSv1"; - /** - * Supports RFC 4346: TLS version 1.1 ; may support other versions - */ - public static final String TLS_V_11 = "TLSv1.1"; - /** - * Supports RFC 5246: TLS version 1.2 ; may support other versions - */ - public static final String TLS_V_12 = "TLSv1.2"; - /** - * Supports RFC 5246: TLS version 1.3 ; may support other versions - */ - public static final String TLS_V_13 = "TLSv1.3"; - /** - * Supports SSL version 2 or later; may support other versions - */ - public static final String SSL_V_20 = "SSLv2"; - /** - * Supports SSL version 3; may support other versions - */ - public static final String SSL_V_30 = "SSLv3"; - /** - * The use status - */ - public static final String RESPONSE_STATUS_UTF8 = ":status"; - /** - * The use method - */ - public static final String TARGET_METHOD_UTF8 = ":method"; - /** - * The use path - */ - public static final String TARGET_PATH_UTF8 = ":path"; - /** - * The use scheme - */ - public static final String TARGET_SCHEME_UTF8 = ":scheme"; - /** - * The use authority - */ - public static final String TARGET_AUTHORITY_UTF8 = ":authority"; - /** - * The IPV4 127.0.0.1 - */ - public static final String HOST_IPV4 = "127.0.0.1"; - /** - * The localhost - */ - public static final String HOST_LOCAL = "localhost"; - /** - * HTTP Status-Code 100: Continue. - */ - public static final int HTTP_CONTINUE = 100; - /** - * HTTP Status-Code 101: Switching Protocols. - */ - public static final int HTTP_SWITCHING_PROTOCOL = 101; - /** - * HTTP Status-Code 200: OK. - */ - public static final int HTTP_OK = 200; - /** - * HTTP Status-Code 201: Created. - */ - public static final int HTTP_CREATED = 201; - /** - * HTTP Status-Code 202: Accepted. - */ - public static final int HTTP_ACCEPTED = 202; - /** - * HTTP Status-Code 203: Non-Authoritative Information. - */ - public static final int HTTP_NOT_AUTHORITATIVE = 203; - /** - * HTTP Status-Code 204: No Content. - */ - public static final int HTTP_NO_CONTENT = 204; - /** - * HTTP Status-Code 205: Reset Content. - */ - public static final int HTTP_RESET = 205; - /** - * HTTP Status-Code 206: Partial Content. - */ - public static final int HTTP_PARTIAL = 206; - /** - * HTTP Status-Code 300: Multiple Choices. - */ - public static final int HTTP_MULT_CHOICE = 300; - /** - * HTTP Status-Code 301: Moved Permanently. - */ - public static final int HTTP_MOVED_PERM = 301; - /** - * HTTP Status-Code 302: Temporary Redirect. - */ - public static final int HTTP_MOVED_TEMP = 302; - /** - * HTTP Status-Code 303: See Other. - */ - public static final int HTTP_SEE_OTHER = 303; - /** - * HTTP Status-Code 304: Not Modified. - */ - public static final int HTTP_NOT_MODIFIED = 304; - /** - * HTTP Status-Code 305: Use Proxy. - */ - public static final int HTTP_USE_PROXY = 305; - /** - * HTTP Status-Code 307: Temporary Redirect. - */ - public static final int HTTP_TEMP_REDIRECT = 307; - /** - * HTTP Status-Code 308: Use perm Redirect. - */ - public static final int HTTP_PERM_REDIRECT = 308; - /** - * HTTP Status-Code 400: Bad Request. - */ - public static final int HTTP_BAD_REQUEST = 400; - /** - * HTTP Status-Code 401: Unauthorized. - */ - public static final int HTTP_UNAUTHORIZED = 401; - /** - * HTTP Status-Code 402: Payment Required. - */ - public static final int HTTP_PAYMENT_REQUIRED = 402; - /** - * HTTP Status-Code 403: Forbidden. - */ - public static final int HTTP_FORBIDDEN = 403; - /** - * HTTP Status-Code 404: Not Found. - */ - public static final int HTTP_NOT_FOUND = 404; - /** - * HTTP Status-Code 405: Method Not Allowed. - */ - public static final int HTTP_BAD_METHOD = 405; - /** - * HTTP Status-Code 406: Not Acceptable. - */ - public static final int HTTP_NOT_ACCEPTABLE = 406; - /** - * HTTP Status-Code 407: Proxy Authentication Required. - */ - public static final int HTTP_PROXY_AUTH = 407; - /** - * HTTP Status-Code 408: Request Time-Out. - */ - public static final int HTTP_CLIENT_TIMEOUT = 408; - /** - * HTTP Status-Code 409: Conflict. - */ - public static final int HTTP_CONFLICT = 409; - /** - * HTTP Status-Code 410: Gone. - */ - public static final int HTTP_GONE = 410; - /** - * HTTP Status-Code 411: Length Required. - */ - public static final int HTTP_LENGTH_REQUIRED = 411; - /** - * HTTP Status-Code 412: Precondition Failed. - */ - public static final int HTTP_PRECON_FAILED = 412; - /** - * HTTP Status-Code 413: Request Entity Too Large. - */ - public static final int HTTP_ENTITY_TOO_LARGE = 413; - /** - * HTTP Status-Code 414: Request-URI Too Large. - */ - public static final int HTTP_REQ_TOO_LONG = 414; - /** - * HTTP Status-Code 415: Unsupported Media Type. - */ - public static final int HTTP_UNSUPPORTED_TYPE = 415; - /** - * HTTP Status-Code 500: Internal Server Error. - */ - public static final int HTTP_INTERNAL_ERROR = 500; - /** - * HTTP Status-Code 501: Not Implemented. - */ - public static final int HTTP_NOT_IMPLEMENTED = 501; - /** - * HTTP Status-Code 502: Bad Gateway. - */ - public static final int HTTP_BAD_GATEWAY = 502; - /** - * HTTP Status-Code 503: Service Unavailable. - */ - public static final int HTTP_UNAVAILABLE = 503; - /** - * HTTP Status-Code 504: Gateway Timeout. - */ - public static final int HTTP_GATEWAY_TIMEOUT = 504; - /** - * HTTP Status-Code 505: HTTP Version Not Supported. - */ - public static final int HTTP_VERSION = 505; - /** - * From the HTTP/2 specs, the default initial window size for all streams is 64 KiB. (Chrome 25 - * uses 10 MiB). - */ - public static final int DEFAULT_INITIAL_WINDOW_SIZE = 65535; - /** - * HTTP/2: Size in bytes of the table used to decode the sender's header blocks. - */ - public static final int HEADER_TABLE_SIZE = 1; - /** - * HTTP/2: The peer must not send a PUSH_PROMISE frame when this is 0. - */ - public static final int ENABLE_PUSH = 2; - /** - * Sender's maximum number of concurrent streams. - */ - public static final int MAX_CONCURRENT_STREAMS = 4; - /** - * HTTP/2: Size in bytes of the largest frame payload the sender will accept. - */ - public static final int MAX_FRAME_SIZE = 5; - /** - * HTTP/2: Advisory only. Size in bytes of the largest header list the sender will accept. - */ - public static final int MAX_HEADER_LIST_SIZE = 6; - /** - * Window size in bytes. - */ - public static final int INITIAL_WINDOW_SIZE = 7; - /** - * The form data - */ - public static final String FORM = "form"; - /** - * The json data - */ - public static final String JSON = "json"; - /** - * The xml data - */ - public static final String XML = "xml"; - /** - * The protobuf data - */ - public static final String PROTOBUF = "protobuf"; - - /** - * 是否为http协议 - * - * @param url 待验证的url - * @return true: http协议, false: 非http协议 - */ - public static boolean isHttp(String url) { - if (StringKit.isEmpty(url)) { - return false; - } - return url.startsWith(Http.HTTP_PREFIX) || url.startsWith("http%3A%2F%2F"); - } - - /** - * 是否为https协议 - * - * @param url 待验证的url - * @return true: https协议, false: 非https协议 - */ - public static boolean isHttps(String url) { - if (StringKit.isEmpty(url)) { - return false; - } - return url.startsWith(Http.HTTPS_PREFIX) || url.startsWith("https%3A%2F%2F"); - } - - /** - * 是否为本地主机(域名) - * - * @param url 待验证的url - * @return true: 本地主机(域名), false: 非本地主机(域名) - */ - public static boolean isLocalHost(String url) { - return StringKit.isEmpty(url) || url.contains(Http.HOST_IPV4) || url.contains(Http.HOST_LOCAL); - } - - - /** - * 是否为https协议或本地主机(域名) - * - * @param url 待验证的url - * @return true: https协议或本地主机 false: 非https协议或本机主机 - */ - public static boolean isHttpsOrLocalHost(String url) { - if (StringKit.isEmpty(url)) { - return false; - } - return isHttps(url) || isLocalHost(url); - } - - /** - * WebDAV - * - * @param method 请求方式 - * @return the boolean - */ - public static boolean invalidatesCache(String method) { - return POST.equals(method) - || PUT.equals(method) - || PATCH.equals(method) - || DELETE.equals(method) - || MOVE.equals(method); - } - - /** - * WebDAV - * CalDAV/CardDAV(在WebDAV版本中定义) - * - * @param method 请求方式 - * @return the boolean - */ - public static boolean requiresRequestBody(String method) { - return POST.equals(method) - || PUT.equals(method) - || PATCH.equals(method) - || PROPPATCH.equals(method) - || REPORT.equals(method); - } - - /** - * 许可维护请求体 - * - * @param method 请求方式 - * @return the boolean - */ - public static boolean permitsRequestBody(String method) { - return !GET.equals(method) || HEAD.equals(method); - } - - /** - * (WebDAV)重定向也应该维护请求体 - * - * @param method 请求方式 - * @return the boolean - */ - public static boolean redirectsWithBody(String method) { - return PROPFIND.equals(method); - } - - /** - * 除了PROPFIND之外的所有请求都应该重定向到GET请求 - * - * @param method 请求方式 - * @return the boolean - */ - public static boolean redirectsToGet(String method) { - return !PROPFIND.equals(method); - } - -} \ No newline at end of file diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/Symbol.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/Symbol.java index 635899c1c5..02e925fb30 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/Symbol.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/Symbol.java @@ -141,6 +141,12 @@ public class Symbol { public static final char C_U_TEN = '拾'; public static final String U_TEN = Normal.EMPTY + C_U_TEN; + /** + * 符号: X + */ + public static final char C_X = 'X'; + public static final String X = Normal.EMPTY + C_X; + /** * 符号: 逗号 */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinCallable.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KCallable.java similarity index 93% rename from bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinCallable.java rename to bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KCallable.java index c651561130..faf08824aa 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinCallable.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KCallable.java @@ -40,7 +40,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class KotlinCallable { +public class KCallable { private static final Method METHOD_GET_PARAMETERS; private static final Method METHOD_CALL; @@ -57,11 +57,11 @@ public class KotlinCallable { * @param kCallable kotlin的类、方法或构造 * @return 参数列表 */ - public static List getParameters(final Object kCallable) { + public static List getParameters(final Object kCallable) { final List parameters = MethodKit.invoke(kCallable, METHOD_GET_PARAMETERS); - final List result = new ArrayList<>(parameters.size()); + final List result = new ArrayList<>(parameters.size()); for (final Object parameter : parameters) { - result.add(new KotlinParameter(parameter)); + result.add(new KParameter(parameter)); } return result; } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinClassImpl.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KClassImpl.java similarity index 99% rename from bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinClassImpl.java rename to bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KClassImpl.java index 33c5a5b862..fc82808e5b 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinClassImpl.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KClassImpl.java @@ -40,7 +40,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class KotlinClassImpl { +public class KClassImpl { private static final Class KCLASS_IMPL_CLASS; private static final Method METHOD_GET_CONSTRUCTORS; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinParameter.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KParameter.java similarity index 96% rename from bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinParameter.java rename to bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KParameter.java index ea7fe93703..dd8d6fc432 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KotlinParameter.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/reflect/kotlin/KParameter.java @@ -40,7 +40,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class KotlinParameter { +public class KParameter { private static final Method METHOD_GET_NAME; private static final Method METHOD_GET_TYPE; @@ -63,7 +63,7 @@ public class KotlinParameter { * * @param kParameterInstance kotlin.reflect.KParameter实例对象 */ - public KotlinParameter(final Object kParameterInstance) { + public KParameter(final Object kParameterInstance) { this.name = MethodKit.invoke(kParameterInstance, METHOD_GET_NAME); final Object kType = MethodKit.invoke(kParameterInstance, METHOD_GET_TYPE); this.type = MethodKit.invoke(kType, METHOD_GET_JAVA_TYPE); @@ -95,7 +95,7 @@ public boolean equals(final Object o) { if (o == null || getClass() != o.getClass()) { return false; } - final KotlinParameter that = (KotlinParameter) o; + final KParameter that = (KParameter) o; return Objects.equals(name, that.name) && Objects.equals(type, that.type); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/selector/Selector.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/selector/Selector.java index e153408e1e..0ea8800b80 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/selector/Selector.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/selector/Selector.java @@ -29,11 +29,13 @@ /** * 选择器接口 + * 用于抽象负载均衡策略中的选择方式 * * @param 选择对象类型 * @author Kimi Liu * @since Java 17+ */ +@FunctionalInterface public interface Selector { /** diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/BlockPolicy.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/BlockPolicy.java index f9d9383caf..aa3addd8a2 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/BlockPolicy.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/BlockPolicy.java @@ -78,7 +78,6 @@ public void rejectedExecution(final Runnable r, final ThreadPoolExecutor e) { // 当设置了关闭时候的处理 handlerwhenshutdown.accept(r); } - // 线程池关闭后,丢弃任务 } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ConcurrencyTester.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ConcurrencyTester.java index 8c03239bbb..1976fd5d1d 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ConcurrencyTester.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ConcurrencyTester.java @@ -36,13 +36,11 @@ * 高并发测试工具类 * *

        - * ps:
        - * //模拟1000个线程并发
        + * 模拟1000个线程并发
          * ConcurrencyTester ct = new ConcurrencyTester(1000);
          * ct.test(() -> {
          *      // 需要并发测试的业务代码
          * });
        - *
          * Console.logger(ct.getInterval());
          * ct.close();
          * 
        @@ -51,6 +49,7 @@ * @since Java 17+ */ public class ConcurrencyTester implements Closeable { + private final SyncFinisher sf; private final StopWatch timeInterval; private long interval; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ExecutorBuilder.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ExecutorBuilder.java index 8a32df1c1c..8bb9364cb8 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ExecutorBuilder.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ExecutorBuilder.java @@ -47,11 +47,11 @@ */ public class ExecutorBuilder implements Builder { + private static final long serialVersionUID = -1L; /** * 默认的等待队列容量 */ public static final int DEFAULT_QUEUE_CAPACITY = Integer.MAX_VALUE; - private static final long serialVersionUID = -1L; /** * 初始池大小 */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/NamedThreadFactory.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/NamedThreadFactory.java index 4d71ab2957..406b4e7f86 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/NamedThreadFactory.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/NamedThreadFactory.java @@ -27,16 +27,19 @@ */ package org.miaixz.bus.core.lang.thread; +import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.lang.thread.threadlocal.SpecificThread; +import org.miaixz.bus.core.xyz.ClassKit; +import org.miaixz.bus.core.xyz.ObjectKit; import org.miaixz.bus.core.xyz.StringKit; -import org.miaixz.bus.core.xyz.ThreadKit; import java.lang.Thread.UncaughtExceptionHandler; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicInteger; /** - * 线程创建工厂类,此工厂可选配置: - * + * 线程创建工厂类 + * 此工厂可选配置: *
          * 1. 自定义线程命名前缀
          * 2. 自定义是否守护线程
        @@ -48,25 +51,40 @@
         public class NamedThreadFactory implements ThreadFactory {
         
             /**
        -     * 命名前缀
        +     * 线程名称前缀
              */
        -    private final String prefix;
        +    protected final String prefix;
             /**
              * 线程组
              */
        -    private final ThreadGroup group;
        +    protected final ThreadGroup group;
             /**
        -     * 线程组
        +     * 是否守护线程
              */
        -    private final AtomicInteger threadNumber = new AtomicInteger(1);
        +    protected final boolean daemon;
             /**
        -     * 是否守护线程
        +     * 线程的优先级
              */
        -    private final boolean isDaemon;
        +    protected final int priority;
        +    /**
        +     * 线程池中的线程ID
        +     */
        +    protected final AtomicInteger nextId = new AtomicInteger(1);
             /**
              * 无法捕获的异常统一处理
              */
        -    private final UncaughtExceptionHandler handler;
        +    protected final UncaughtExceptionHandler handler;
        +
        +    /**
        +     * 构造
        +     */
        +    public NamedThreadFactory() {
        +        this(null, null, Thread.NORM_PRIORITY);
        +    }
        +
        +    public NamedThreadFactory(Class clazz) {
        +        this(clazz, null, Thread.NORM_PRIORITY);
        +    }
         
             /**
              * 构造
        @@ -74,72 +92,147 @@ public class NamedThreadFactory implements ThreadFactory {
              * @param prefix 线程名前缀
              */
             public NamedThreadFactory(String prefix) {
        -        this(prefix, true);
        +        this(null, prefix, Thread.NORM_PRIORITY);
        +    }
        +
        +    /**
        +     * 构造
        +     *
        +     * @param prefix   线程名前缀
        +     * @param priority 优先级
        +     */
        +    public NamedThreadFactory(final Class clazz, String prefix, int priority) {
        +        this(clazz, prefix, true, priority);
        +    }
        +
        +    /**
        +     * 构造
        +     *
        +     * @param prefix 线程名前缀
        +     * @param daemon 是否守护线程
        +     */
        +    public NamedThreadFactory(final String prefix, final boolean daemon) {
        +        this(null, prefix, null, daemon, Thread.NORM_PRIORITY);
             }
         
             /**
              * 构造
              *
              * @param prefix   线程名前缀
        -     * @param isDaemon 是否守护线程
        +     * @param daemon   是否守护线程
        +     * @param priority 优先级
              */
        -    public NamedThreadFactory(final String prefix, final boolean isDaemon) {
        -        this(prefix, null, isDaemon);
        +    public NamedThreadFactory(final Class clazz, final String prefix, final boolean daemon, int priority) {
        +        this(clazz, prefix, null, daemon, priority);
             }
         
             /**
              * 构造
              *
        -     * @param prefix      线程名前缀
        -     * @param threadGroup 线程组,可以为null
        -     * @param isDaemon    是否守护线程
        +     * @param prefix 线程名前缀
        +     * @param group  线程组,可以为null
        +     * @param daemon 是否守护线程
              */
        -    public NamedThreadFactory(final String prefix, final ThreadGroup threadGroup, final boolean isDaemon) {
        -        this(prefix, threadGroup, isDaemon, null);
        +    public NamedThreadFactory(final String prefix, final ThreadGroup group, final boolean daemon) {
        +        this(null, prefix, group, daemon, Thread.NORM_PRIORITY, null);
             }
         
             /**
              * 构造
              *
        -     * @param prefix      线程名前缀
        -     * @param threadGroup 线程组,可以为null
        -     * @param isDaemon    是否守护线程
        -     * @param handler     未捕获异常处理
        -     */
        -    public NamedThreadFactory(final String prefix, ThreadGroup threadGroup, final boolean isDaemon, final UncaughtExceptionHandler handler) {
        -        this.prefix = StringKit.isBlank(prefix) ? "X" : prefix;
        -        if (null == threadGroup) {
        -            threadGroup = ThreadKit.currentThreadGroup();
        +     * @param prefix   线程名前缀
        +     * @param group    线程组,可以为null
        +     * @param daemon   是否守护线程
        +     * @param priority 优先级
        +     */
        +    public NamedThreadFactory(final Class clazz, final String prefix, final ThreadGroup group, final boolean daemon, int priority) {
        +        this(clazz, prefix, group, daemon, priority, null);
        +    }
        +
        +    /**
        +     * 构造
        +     *
        +     * @param prefix  线程名前缀
        +     * @param group   线程组,可以为null
        +     * @param daemon  是否守护线程
        +     * @param handler 未捕获异常处理
        +     */
        +    public NamedThreadFactory(final String prefix, ThreadGroup group, final boolean daemon, final UncaughtExceptionHandler handler) {
        +        this(null, prefix, group, daemon, Thread.NORM_PRIORITY, handler);
        +    }
        +
        +    /**
        +     * 构造
        +     *
        +     * @param prefix   线程名前缀
        +     * @param group    线程组,可以为null
        +     * @param daemon   是否守护线程
        +     * @param priority 优先级
        +     * @param handler  未捕获异常处理
        +     */
        +    public NamedThreadFactory(final Class clazz, final String prefix, ThreadGroup group, final boolean daemon, int priority, final UncaughtExceptionHandler handler) {
        +        if (priority < Thread.MIN_PRIORITY || priority > Thread.MAX_PRIORITY) {
        +            throw new IllegalArgumentException(
        +                    "priority: " + priority + " (expected: Thread.MIN_PRIORITY <= priority <= Thread.MAX_PRIORITY)");
        +        }
        +
        +        if (ObjectKit.isEmpty(clazz) && StringKit.isEmpty(prefix)) {
        +            // 线程前缀,两者都为空使用默认值
        +            this.prefix = Symbol.X;
        +        } else {
        +            // 线程前缀,默认使用prefix,反之使用clazz
        +            this.prefix = StringKit.isBlank(prefix) ? ClassKit.getClassName(clazz, true) : prefix;
                 }
        -        this.group = threadGroup;
        -        this.isDaemon = isDaemon;
        +
        +        if (null == group) {
        +            // 当前线程组
        +            group = Thread.currentThread().getThreadGroup();
        +        }
        +        this.group = group;
        +        this.daemon = daemon;
        +        this.priority = priority;
                 this.handler = handler;
             }
         
        +    /**
        +     * 构造一个新的未启动线程来运行给定的可运行对象
        +     *
        +     * @param r 由新线程实例执行的可运行对象
        +     * @return 新新线程信息
        +     */
             @Override
             public Thread newThread(final Runnable r) {
        -        final Thread t = new Thread(this.group, r, StringKit.format("{}{}", prefix, threadNumber.getAndIncrement()));
        -
        -        //守护线程
        +        final Thread t = this.newThread(r, StringKit.format("{}{}", this.prefix, this.nextId.getAndIncrement()));
        +        // 守护线程
                 if (!t.isDaemon()) {
        -            if (isDaemon) {
        +            if (this.daemon) {
                         // 原线程为非守护则设置为守护
                         t.setDaemon(true);
                     }
        -        } else if (!isDaemon) {
        +        } else if (!this.daemon) {
                     // 原线程为守护则还原为非守护
                     t.setDaemon(false);
                 }
        -        //异常处理
        -        if (null != this.handler) {
        -            t.setUncaughtExceptionHandler(handler);
        +        if (t.getPriority() != this.priority) {
        +            t.setPriority(this.priority);
                 }
        -        //优先级
        -        if (Thread.NORM_PRIORITY != t.getPriority()) {
        -            // 标准优先级
        -            t.setPriority(Thread.NORM_PRIORITY);
        +
        +        // 异常处理
        +        if (null != this.handler) {
        +            t.setUncaughtExceptionHandler(this.handler);
                 }
                 return t;
             }
         
        +    /**
        +     * 构造一个新的未启动线程来运行给定的可运行对象
        +     *
        +     * @param r    由新线程实例执行的可运行对象
        +     * @param name 线程名称
        +     * @return 新新线程信息
        +     */
        +    protected Thread newThread(Runnable r, String name) {
        +        return new SpecificThread(this.group, r, name);
        +    }
        +
         }
        diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/SemaphoreRunnable.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/SemaphoreRunnable.java
        index 41f8aa758c..ddb648b434 100644
        --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/SemaphoreRunnable.java
        +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/SemaphoreRunnable.java
        @@ -31,7 +31,6 @@
         
         /**
          * 带有信号量控制的{@link Runnable} 接口抽象实现
        - *
          * 

        * 通过设置信号量,可以限制可以访问某些资源(物理或逻辑的)线程数目。 * 例如:设置信号量为2,表示最多有两个线程可以同时执行方法逻辑,其余线程等待,直到此线程逻辑执行完毕 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ThreadExecutorBuilder.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ThreadExecutorBuilder.java new file mode 100644 index 0000000000..f5cb58a4c4 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ThreadExecutorBuilder.java @@ -0,0 +1,92 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.lang.thread; + +import java.util.concurrent.*; + +/** + * 类比 {@link java.util.concurrent.Executors} + * + * @author Kimi Liu + * @since Java 17+ + */ +public class ThreadExecutorBuilder { + + /** + * 创建一个线程数固定(corePoolSize==maximumPoolSize)的线程池 + * 核心线程会一直存在,不被回收 + * 如果一个核心线程由于异常跪了,会新创建一个线程 + * 无界队列LinkedBlockingQueue + * + * @param corePoolSize 要保留在池中的线程数,即使它们是空闲的 + * @param prefix 线程名前缀 + */ + public static Executor newFixedFastThread(final int corePoolSize, final String prefix) { + return new ThreadPoolExecutor(corePoolSize, corePoolSize, 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<>(), new NamedThreadFactory(prefix)); + } + + /** + * corePoolSize==0 + * maximumPoolSize==Integer.MAX_VALUE + * 队列:SynchronousQueue + * 创建一个线程池:当池中的线程都处于忙碌状态时,会立即新建一个线程来处理新来的任务 + * 这种池将会在执行许多耗时短的异步任务的时候提高程序的性能 + * 60秒钟内没有使用的线程将会被中止,并且从线程池中移除,因此几乎不必担心耗费资源 + * + * @param prefix 线程名前缀 + */ + public static Executor newCachedFastThread(final String prefix) { + return new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<>(), + new NamedThreadFactory(prefix)); + } + + /** + * 用给定的初始参数创建一个新的Executor + * + * @param corePoolSize 要保留在池中的线程数,即使它们是空闲的 + * @param maximumPoolSize 池中允许的最大线程数 + * @param keepAliveTime 当线程数大于核心时,这是多余空闲线程在终止前等待新任务的最大时间。 + * @param unit keepAliveTime参数的时间单位 + * @param workQueue 任务执行之前用于保存任务的队列。此队列将仅保存由execute方法提交的可运行任务。 + * @param prefix 线程名前缀 + * @param handler 由于达到线程边界和队列容量而阻塞执行时使用的处理程序 + * @return {@link Executor} + */ + public static Executor newLimitedFastThread(final int corePoolSize, + final int maximumPoolSize, + final long keepAliveTime, + final TimeUnit unit, + final BlockingQueue workQueue, + final String prefix, + final RejectedExecutionHandler handler) { + return new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue, + new NamedThreadFactory(prefix), handler); + } + +} \ No newline at end of file diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ThreadFactoryBuilder.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ThreadFactoryBuilder.java index a6c5fff3b4..bd20c6e095 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ThreadFactoryBuilder.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/ThreadFactoryBuilder.java @@ -83,8 +83,8 @@ public static ThreadFactoryBuilder of() { * @return {@link ThreadFactory} */ private static ThreadFactory build(final ThreadFactoryBuilder builder) { - final ThreadFactory backingThreadFactory = (null != builder.backingThreadFactory)// - ? builder.backingThreadFactory // + final ThreadFactory backingThreadFactory = (null != builder.backingThreadFactory) + ? builder.backingThreadFactory : Executors.defaultThreadFactory(); final String namePrefix = builder.namePrefix; final Boolean daemon = builder.daemon; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/FastThreadLocal.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/FastThreadLocal.java new file mode 100644 index 0000000000..8dc89f5c7e --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/FastThreadLocal.java @@ -0,0 +1,251 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.lang.thread.threadlocal; + +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Set; + +/** + * {@link ThreadLocal} 的一个特殊变体 + * 当从 {@link SpecificThread} 访问时,可产生更高的访问性能。 + * {@link SpecificThread} 使用数组中的常量索引(而不是使用哈希码和哈希表)来查找变量。 + * 虽然看似非常微妙,但它比使用哈希表具有轻微的性能优势,并且在频繁访问时很有用。 + * + * @author Kimi Liu + * @since Java 17+ + */ +public class FastThreadLocal { + + /** + * 索引 + */ + private final int index; + + /** + * 构造 + */ + public FastThreadLocal() { + this.index = ThreadLocalMap.nextVariableIndex(); + } + + /** + * 返回绑定到当前线程的线程局部变量的数量 + */ + public static int size() { + ThreadLocalMap threadLocalMap = ThreadLocalMap.getIfSet(); + if (threadLocalMap == null) { + return 0; + } else { + return threadLocalMap.size(); + } + } + + /** + * 删除与当前线程绑定的所有 {@link FastThreadLocal} 变量。 + * 当处于容器环境中,并且不想将线程局部变量留在未管理的线程中时,此操作非常有用 + */ + public static void removeAll() { + // 1. 获取当前线程的ThreadLocalMap,如果当前的ThreadLocalMap为null,则直接返回 + ThreadLocalMap threadLocalMap = ThreadLocalMap.getIfSet(); + if (threadLocalMap == null) { + return; + } + + try { + // 2. 从indexedVariable[VARIABLES_TO_REMOVE_INDEX]获取目前ThreadLocalMap存储的有效的FastThreadLocal的值,之后遍历Set,进行remove操作 + // 注意:这也是为什么会将有效的FastThreadLocal存储在一个Set中的原因(另外,如果没有Set>这个集合的话,我们需要直接去遍历整个indexedVariables数组,可能其中有效的并不多,影响效率) + Object v = threadLocalMap.indexedVariable(ThreadLocalMap.VARIABLES_TO_REMOVE_INDEX); + if (v != null && v != ThreadLocalMap.UNSET) { + Set> variablesToRemove = (Set>) v; + // 这里为什么需要将set先转换为数组? + // 因为set的for-remove模式会报并发修改异常,array不会 + FastThreadLocal[] variablesToRemoveArray = + variablesToRemove.toArray(new FastThreadLocal[variablesToRemove.size()]); + for (FastThreadLocal tlv : variablesToRemoveArray) { + tlv.remove(threadLocalMap); + } + } + } finally { + // 3. 删除当前线程的 ThreadLocalMap + ThreadLocalMap.remove(); + } + } + + /** + * 销毁保存所有从非 {@link SpecificThread} 访问的 {@link FastThreadLocal} 变量的数据结构 + * 当处于容器环境中,并且不想将线程局部变量留在未管理的线程中时,此操作非常有用。 + * 当应用程序从容器中卸载时,请调用此方法。 + */ + public static void destroy() { + ThreadLocalMap.destroy(); + } + + /** + * 将当前的FastThreadLocal添加到indexedVariable[variableToRemoveIndex]位置上的Set>中 + * + * @param threadLocalMap 内部数据结构 + * @param variable 环境变量 + */ + private static void addToVariablesToRemove(ThreadLocalMap threadLocalMap, FastThreadLocal variable) { + // 1、首先从InternalThreadLocalMap获取Set,如果存在,直接往Set里添加值FastThreadLocal; + // 如果不存在,则先创建一个Set,然后将创建的Set添加到InternalThreadLocalMap中,最后将FastThreadLocal添加到这个Set中 + Object v = threadLocalMap.indexedVariable(ThreadLocalMap.VARIABLES_TO_REMOVE_INDEX); + // Set中的FastThreadLocal可能有多个类型,所以此处的泛型使用?,而不是用指定的V + Set> variablesToRemove; + if (v == ThreadLocalMap.UNSET || v == null) { + variablesToRemove = Collections.newSetFromMap(new IdentityHashMap<>()); + threadLocalMap.setIndexedVariable(ThreadLocalMap.VARIABLES_TO_REMOVE_INDEX, variablesToRemove); + } else { + variablesToRemove = (Set>) v; + } + + variablesToRemove.add(variable); + } + + /** + * 从要移除的变量中删除数据 + * + * @param threadLocalMap 内部数据结构 + * @param variable 环境变量 + */ + private static void removeFromVariablesToRemove(ThreadLocalMap threadLocalMap, FastThreadLocal variable) { + Object v = threadLocalMap.indexedVariable(ThreadLocalMap.VARIABLES_TO_REMOVE_INDEX); + + if (v == ThreadLocalMap.UNSET || v == null) { + return; + } + + Set> variablesToRemove = (Set>) v; + variablesToRemove.remove(variable); + } + + /** + * 获取当前线程的ThreadLocalMap中的当前线程的value + */ + public final V get() { + // 1. 获取ThreadLocalMap + ThreadLocalMap threadLocalMap = ThreadLocalMap.get(); + // 2. 从ThreadLocalMap获取索引为index的value,如果该索引处的value是有效值,不是占位值,则直接返回 + Object v = threadLocalMap.indexedVariable(index); + if (v != ThreadLocalMap.UNSET) { + return (V) v; + } + // 3. indexedVariable[index]没有设置有效值,执行初始化操作,获取初始值 + return initialize(threadLocalMap); + } + + /** + * 设置当前线程的值 + * + * @param value 线程值 + */ + public final void set(V value) { + // 如果value是UNSET,表示删除当前的ThreadLocal对应的value; + // 如果不是UNSET,则可能是修改,也可能是新增; + // 如果是修改,修改value结束后返回, + // 如果是新增,则先新增value,然后新增ThreadLocal到Set中,最后注册Cleaner清除线程 + if (value == null || value == ThreadLocalMap.UNSET) { + // 如果设置的值是UNSET,表示清除该FastThreadLocal的value + remove(); + } else { + ThreadLocalMap threadLocalMap = ThreadLocalMap.get(); + if (threadLocalMap.setIndexedVariable(index, value)) { + addToVariablesToRemove(threadLocalMap, this); + } + } + } + + /** + * 清除当前的ThreadLocal + */ + public final void remove() { + remove(ThreadLocalMap.getIfSet()); + } + + /** + * 将指定线程本地映射的值设置为未初始化 + * 对 get() 的继续调用将触发对 initialValue() 的调用 + * 指定的线程本地映射必须适用于当前线程。 + */ + public final void remove(ThreadLocalMap threadLocalMap) { + if (threadLocalMap == null) { + return; + } + // 1. 从 ThreadLocalMap 中删除当前的FastThreadLocal对应的value + Object v = threadLocalMap.removeIndexedVariable(index); + // 2. 从 ThreadLocalMap 中的Set>中删除当前的FastThreadLocal + removeFromVariablesToRemove(threadLocalMap, this); + // 3. 如果删除的是有效值,则进行onRemove方法的回调 + if (v != ThreadLocalMap.UNSET) { + try { + onRemoval((V) v); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * 初始化参数 + * 由子类重写 + */ + protected V initialValue() { + return null; + } + + /** + * 当此线程局部变量被{@link #remove()}删除时的回调 + * 由子类重写 + */ + protected void onRemoval(V value) { + + } + + /** + * 初始化 + * + * @param threadLocalMap 内部数据结构 + * @return 当前线程的值 + */ + private V initialize(ThreadLocalMap threadLocalMap) { + V v; + try { + // 1. 获取初始值 + v = initialValue(); + } catch (Exception e) { + throw new RuntimeException(e); + } + // 2. 设置value到InternalThreadLocalMap中 + threadLocalMap.setIndexedVariable(index, v); + // 3. 添加当前的FastThreadLocal到ThreadLocalMap的Set>中 + addToVariablesToRemove(threadLocalMap, this); + return v; + } + +} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/SpecificThread.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/SpecificThread.java new file mode 100644 index 0000000000..4b1a57ee74 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/SpecificThread.java @@ -0,0 +1,138 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.lang.thread.threadlocal; + +/** + * 特殊的 {@link Thread},提供对 {@link FastThreadLocal} 变量的快速访问。 + * + * @author Kimi Liu + * @since Java 17+ + */ +public class SpecificThread extends Thread { + + /** + * 变量数据结构 + */ + private ThreadLocalMap threadLocalMap; + + /** + * 构造 + */ + public SpecificThread() { + } + + /** + * 构造 + * + * @param name 线程名称 + */ + public SpecificThread(String name) { + super(name); + } + + /** + * 构造 + * + * @param r 由新线程实例执行的可运行对象 + */ + public SpecificThread(Runnable r) { + super(r); + } + + /** + * 构造 + * + * @param r 由新线程实例执行的可运行对象 + * @param name 线程名称 + */ + public SpecificThread(Runnable r, String name) { + super(r, name); + } + + /** + * 构造 + * + * @param group 线程组 + * @param name 线程名称 + */ + public SpecificThread(ThreadGroup group, String name) { + super(group, name); + } + + /** + * 构造 + * + * @param group 线程组 + * @param r 由新线程实例执行的可运行对象 + */ + public SpecificThread(ThreadGroup group, Runnable r) { + super(group, r); + } + + /** + * 构造 + * + * @param group 线程组 + * @param r 由新线程实例执行的可运行对象 + * @param name 线程名称 + */ + public SpecificThread(ThreadGroup group, Runnable r, String name) { + super(group, r, name); + } + + /** + * 构造 + * + * @param group 线程组 + * @param r 由新线程实例执行的可运行对象 + * @param name 线程名称 + * @param stackSize 线程所需的堆栈大小 + */ + public SpecificThread(ThreadGroup group, Runnable r, String name, long stackSize) { + super(group, r, name, stackSize); + } + + /** + * 返回将线程局部变量绑定到此线程的内部数据结构。 + * 请注意,此方法仅供内部使用,因此随时可能发生变化。 + */ + public final ThreadLocalMap getThreadLocalMap() { + return threadLocalMap; + } + + /** + * 设置将线程局部变量绑定到此线程的内部数据结构。 + * 请注意,此方法仅供内部使用,因此随时可能发生变化。 + * + * @param threadLocalMap 变量数据结构 + */ + public final void setThreadLocalMap(ThreadLocalMap threadLocalMap) { + this.threadLocalMap = threadLocalMap; + } + +} \ No newline at end of file diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/ThreadLocalMap.java b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/ThreadLocalMap.java new file mode 100644 index 0000000000..d46b1265c3 --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/lang/thread/threadlocal/ThreadLocalMap.java @@ -0,0 +1,305 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.lang.thread.threadlocal; + +import org.miaixz.bus.core.lang.Normal; + +import java.util.Arrays; +import java.util.BitSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicInteger; + +/** + * 存储所有 {@link SpecificThread} 的 {@link ThreadLocal} 变量的内部数据结构。 + * 请注意,此类仅供内部使用。除非知道自己在做什么,否则请使用 {@link SpecificThread} + * + * @author Kimi Liu + * @since Java 17+ + */ +public final class ThreadLocalMap { + + /** + * 无效的value值(占位符),不使用null做无效值的原因是因为netty认为null也是一个有效值, + * 例如:假设没有重写FastThreadLocal的initialValue()方法,则该方法返回为null,会将null作为有效值直接存储起来 + */ + public static final Object UNSET = new Object(); + /** + * 线程缓存 + */ + private static final ThreadLocal SLOW_THREAD_LOCAL_MAP = new ThreadLocal<>(); + /** + * 下一索引 + */ + private static final AtomicInteger NEXT_INDEX = new AtomicInteger(); + /** + * 要删除的变量索引 + */ + public static final int VARIABLES_TO_REMOVE_INDEX = nextVariableIndex(); + /** + * 索引变量 {@link FastThreadLocal} + * index就是FastThreadLocal的唯一索引index + * value是相对应的FastThreadLocal所要存储的值 + */ + private Object[] indexedVariables; + /** + * BitSet简要原理: + * BitSet默认底层数据结构是一个long[]数组,开始时长度为1,即只有long[0],而一个long有64bit。 + * 当BitSet.set(1)的时候,表示将long[0]的第二位设置为true,即0000 0000 ... 0010(64bit),则long[0]==2 + * 当BitSet.get(1)的时候,第二位为1,则表示true;如果是0,则表示false + * 当BitSet.set(64)的时候,表示设置第65位,此时long[0]已经不够用了,扩容处long[1]来,进行存储 + *

        + * 存储类似 {index:boolean} 键值对,用于防止一个FastThreadLocal多次启动清理线程 + * 将index位置的bit设为true,表示该InternalThreadLocalMap中对该FastThreadLocal已经启动了清理线程 + */ + private BitSet cleanerFlags; + + /** + * 构造 + * 创建indexedVariables数组,并将每一个元素初始化为UNSET + */ + private ThreadLocalMap() { + indexedVariables = newIndexedVariableTable(); + } + + /** + * 获取ThreadLocalMap实例 + * + * @return {@link ThreadLocalMap} + */ + public static ThreadLocalMap get() { + Thread thread = Thread.currentThread(); + if (thread instanceof SpecificThread) { + return fastGet((SpecificThread) thread); + } else { + return slowGet(); + } + } + + /** + * 获取hreadLocalMap实例,如果为null会创建新的;如果不为null,也直接返回 + * + * @param thread 快速访问变量 + * @return {@link ThreadLocalMap} + */ + private static ThreadLocalMap fastGet(SpecificThread thread) { + ThreadLocalMap threadLocalMap = thread.getThreadLocalMap(); + if (threadLocalMap == null) { + thread.setThreadLocalMap(threadLocalMap = new ThreadLocalMap()); + } + return threadLocalMap; + } + + /** + * 获取当前线程信息 + * + * @return {@link ThreadLocalMap} + */ + private static ThreadLocalMap slowGet() { + ThreadLocalMap ret = SLOW_THREAD_LOCAL_MAP.get(); + if (ret == null) { + ret = new ThreadLocalMap(); + SLOW_THREAD_LOCAL_MAP.set(ret); + } + return ret; + } + + /** + * 获取当前线程信息 + * + * @return {@link ThreadLocalMap} + */ + public static ThreadLocalMap getIfSet() { + Thread thread = Thread.currentThread(); + if (thread instanceof SpecificThread) { + return ((SpecificThread) thread).getThreadLocalMap(); + } + return SLOW_THREAD_LOCAL_MAP.get(); + } + + /** + * 删除当前线程的ThreadLocalMap + */ + public static void remove() { + Thread thread = Thread.currentThread(); + if (thread instanceof SpecificThread) { + ((SpecificThread) thread).setThreadLocalMap(null); + } else { + SLOW_THREAD_LOCAL_MAP.remove(); + } + } + + /** + * 销毁线程信息 + */ + public static void destroy() { + SLOW_THREAD_LOCAL_MAP.remove(); + } + + /** + * 获取FastThreadLocal的唯一索引 + * + * @return the int + */ + public static int nextVariableIndex() { + int index = NEXT_INDEX.getAndIncrement(); + if (index < 0) { + NEXT_INDEX.decrementAndGet(); + throw new IllegalStateException("too many thread-local indexed variables"); + } + return index; + } + + /** + * 新的索引变量表 + * + * @return the object + */ + private static Object[] newIndexedVariableTable() { + Object[] array = new Object[Normal._32]; + Arrays.fill(array, UNSET); + return array; + } + + /** + * 当前线程大小 + * + * @return the int + */ + public int size() { + int count = 0; + Object v = indexedVariable(VARIABLES_TO_REMOVE_INDEX); + if (v != null && v != UNSET) { + Set> variablesToRemove = (Set>) v; + count += variablesToRemove.size(); + } + return count; + } + + /** + * 是否索引变量集 + * + * @param index 索引 + * @return the true/false + */ + public boolean isIndexedVariableSet(int index) { + Object[] lookup = indexedVariables; + return index < lookup.length && lookup[index] != UNSET; + } + + /** + * 获取指定位置的元素 + * + * @param index 索引 + * @return the object + */ + public Object indexedVariable(int index) { + Object[] lookup = indexedVariables; + return index < lookup.length ? lookup[index] : UNSET; + } + + /** + * 设置索引变量 + * + * @param index 索引 + * @param value 变量值 + * @return @code true} 当且仅当创建了新的线程局部变量时 + */ + public boolean setIndexedVariable(int index, Object value) { + Object[] lookup = indexedVariables; + if (index < lookup.length) { + Object oldValue = lookup[index]; + lookup[index] = value; + return oldValue == UNSET; + } else { + expandIndexedVariableTableAndSet(index, value); + return true; + } + } + + /** + * 删除指定位置的对象 + * + * @param index 索引 + * @return the object + */ + public Object removeIndexedVariable(int index) { + Object[] lookup = indexedVariables; + if (index < lookup.length) { + Object v = lookup[index]; + lookup[index] = UNSET; + return v; + } else { + return UNSET; + } + } + + /** + * 设置当前索引位置index(FastThreadLocal)的bit为1 + */ + public void setCleanerFlags(int index) { + if (cleanerFlags == null) { + cleanerFlags = new BitSet(); + } + cleanerFlags.set(index); + } + + /** + * 获取 当前index的bit值,1表示true,0表示false(默认值) + */ + public boolean isCleanerFlags(int index) { + return cleanerFlags != null && cleanerFlags.get(index); + } + + /** + * 展开索引变量表和集合 + * + * @param index 索引 + * @param value 索引值 + */ + private void expandIndexedVariableTableAndSet(int index, Object value) { + Object[] oldArray = indexedVariables; + final int oldCapacity = oldArray.length; + int newCapacity = index; + newCapacity |= newCapacity >>> 1; + newCapacity |= newCapacity >>> 2; + newCapacity |= newCapacity >>> 4; + newCapacity |= newCapacity >>> 8; + newCapacity |= newCapacity >>> 16; + newCapacity++; + + // 创建新数组并拷贝旧数组的元素到新数组 + Object[] newArray = Arrays.copyOf(oldArray, newCapacity); + // 初始化扩容出来的部分的元素 + Arrays.fill(newArray, oldCapacity, newArray.length, UNSET); + // 设置变量 + newArray[index] = value; + // 将新数组设置给成员变量 + indexedVariables = newArray; + } + +} \ No newline at end of file diff --git a/bus-core/src/main/java/org/miaixz/bus/core/lang/Protocol.java b/bus-core/src/main/java/org/miaixz/bus/core/net/HTTP.java old mode 100755 new mode 100644 similarity index 66% rename from bus-core/src/main/java/org/miaixz/bus/core/lang/Protocol.java rename to bus-core/src/main/java/org/miaixz/bus/core/net/HTTP.java index f5e944e4df..29608adde4 --- a/bus-core/src/main/java/org/miaixz/bus/core/lang/Protocol.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/net/HTTP.java @@ -25,9 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.core.lang; - -import org.miaixz.bus.core.xyz.StringKit; +package org.miaixz.bus.core.net; /** * HTTP 相关常量 @@ -35,40 +33,16 @@ * @author Kimi Liu * @since Java 17+ */ -public class Protocol { +public class HTTP { /** - * The http - */ - public static final String HTTP = "http"; - /** - * The https - */ - public static final String HTTPS = "https"; - /** - * The https - */ - public static final String WS = "ws"; - /** - * The https - */ - public static final String WSS = "wss"; - /** - * The prefix http - */ - public static final String HTTP_PREFIX = HTTP + Symbol.COLON + Symbol.FORWARDSLASH; - /** - * The prefix https - */ - public static final String HTTPS_PREFIX = HTTPS + Symbol.COLON + Symbol.FORWARDSLASH; - /** - * The prefix ws + * HTTP Method ALL */ - public static final String WS_PREFIX = WS + Symbol.COLON + Symbol.FORWARDSLASH; + public static final String ALL = "ALL"; /** - * The prefix wss + * HTTP Method NONE */ - public static final String WSS_PREFIX = WSS + Symbol.COLON + Symbol.FORWARDSLASH; + public static final String NONE = "NONE"; /** * HTTP Method GET */ @@ -129,122 +103,8 @@ public class Protocol { * HTTP Method PROPFIND */ public static final String PROPFIND = "PROPFIND"; - /** - * HTTP Method ALL - */ - public static final String ALL = "ALL"; - /** - * HTTP Method NONE - */ - public static final String NONE = "NONE"; - /** - * HTTP/1.0 - */ - public static final String HTTP_1_0 = "HTTP/1.0"; - /** - * HTTP/1.1 - */ - public static final String HTTP_1_1 = "HTTP/1.1"; - /** - * HTTP/2.0 - */ - public static final String HTTP_2_0 = "HTTP/2.0"; - /** - * SPDY/3.1 - */ - public static final String SPDY_3_1 = "SPDY/3.1"; - /** - * SOAP 1.1 - */ - public static final String SOAP_1_1 = "SOAP 1.1 Protocol"; - /** - * SOAP 1.2 - */ - public static final String SOAP_1_2 = "SOAP 1.2 Protocol"; - /** - * QUIC - */ - public static final String QUIC = "QUIC"; - /** - * 明文HTTP/2,没有"upgrade"往返。此选项要求客户端事先知道服务器支持明文HTTP/2 - */ - public static final String H2_PRIOR_KNOWLEDGE = "H2_PRIOR_KNOWLEDGE"; - /** - * Supports some version of SSL; may support other versions - */ - public static final String SSL = "SSL"; - /** - * Supports some version of TLS; may support other versions - */ - public static final String TLS = "TLS"; - /** - * Supports RFC 2246: TLS version 1.0 ; may support other versions - */ - public static final String TLS_V_10 = "TLSv1"; - /** - * Supports RFC 4346: TLS version 1.1 ; may support other versions - */ - public static final String TLS_V_11 = "TLSv1.1"; - /** - * Supports RFC 5246: TLS version 1.2 ; may support other versions - */ - public static final String TLS_V_12 = "TLSv1.2"; - /** - * Supports RFC 5246: TLS version 1.3 ; may support other versions - */ - public static final String TLS_V_13 = "TLSv1.3"; - /** - * Supports SSL version 2 or later; may support other versions - */ - public static final String SSL_V_20 = "SSLv2"; - /** - * Supports SSL version 3; may support other versions - */ - public static final String SSL_V_30 = "SSLv3"; - /** - * The use status - */ - public static final String RESPONSE_STATUS_UTF8 = ":status"; - /** - * The use method - */ - public static final String TARGET_METHOD_UTF8 = ":method"; - /** - * The use path - */ - public static final String TARGET_PATH_UTF8 = ":path"; - /** - * The use scheme - */ - public static final String TARGET_SCHEME_UTF8 = ":scheme"; - /** - * The use authority - */ - public static final String TARGET_AUTHORITY_UTF8 = ":authority"; - /** - * The IPV4 127.0.0.1 - */ - public static final String HOST_IPV4 = "127.0.0.1"; - /** - * The localhost - */ - public static final String HOST_LOCAL = "localhost"; - /** - * Ipv4地址最小值字符串形式 - */ - public static final String IPV4_STR_MIN = "0.0.0.0"; - /** - * Ipv4地址最大值字符串形式 - */ - public static final String IPV4_STR_MAX = "255.255.255.255"; - /** - * Ipv4最大值数值形式 - */ - public static final long IPV4_NUM_MAX = 0xffffffffL; - /** - * Ipv4未使用地址最大值字符串形式 - */ - public static final String IPV4_UNUSED_STR_MAX = "0.255.255.255"; + + /** * HTTP Status-Code 100: Continue. */ @@ -430,72 +290,287 @@ public class Protocol { * Window size in bytes. */ public static final int INITIAL_WINDOW_SIZE = 7; + + /** - * The form data + * The header Host */ - public static final String FORM = "form"; + public static final String HOST = "Host"; /** - * The json data + * The header Server */ - public static final String JSON = "json"; + public static final String SERVER = "Server"; /** - * The xml data + * The header Age */ - public static final String XML = "xml"; + public static final String AGE = "Age"; /** - * The protobuf data + * The header Allow */ - public static final String PROTOBUF = "protobuf"; - + public static final String ALLOW = "Allow"; /** - * 是否为http协议 - * - * @param url 待验证的url - * @return true: http协议, false: 非http协议 - */ - public static boolean isHttp(String url) { - if (StringKit.isEmpty(url)) { - return false; - } - return url.startsWith(Protocol.HTTP_PREFIX) || url.startsWith("http%3A%2F%2F"); - } - + * The header Expires + */ + public static final String EXPIRES = "Expires"; /** - * 是否为https协议 - * - * @param url 待验证的url - * @return true: https协议, false: 非https协议 - */ - public static boolean isHttps(String url) { - if (StringKit.isEmpty(url)) { - return false; - } - return url.startsWith(Protocol.HTTPS_PREFIX) || url.startsWith("https%3A%2F%2F"); - } - + * The header Cookie + */ + public static final String COOKIE = "Cookie"; /** - * 是否为本地主机(域名) - * - * @param url 待验证的url - * @return true: 本地主机(域名), false: 非本地主机(域名) + * The header Set-Cookie */ - public static boolean isLocalHost(String url) { - return StringKit.isEmpty(url) || url.contains(Protocol.HOST_IPV4) || url.contains(Protocol.HOST_LOCAL); - } + public static final String SET_COOKIE = "Set-Cookie"; + /** + * The header Encoding + */ + public static final String ENCODING = "Encoding"; + /** + * The header Upgrade + */ + public static final String UPGRADE = "Upgrade"; + /** + * The header Trailers + */ + public static final String TRAILERS = "Trailers"; + /** + * The header Location + */ + public static final String LOCATION = "Location"; + /** + * The header Connection + */ + public static final String CONNECTION = "Connection"; + /** + * The header Date + */ + public static final String DATE = "Date"; + /** + * The header Etag + */ + public static final String ETAG = "Etag"; + /** + * The header Expect + */ + public static final String EXPECT = "Expect"; + /** + * The header From + */ + public static final String FROM = "From"; + /** + * The header Link + */ + public static final String LINK = "Link"; + /** + * The header Vary + */ + public static final String VARY = "Vary"; + /** + * The header Via + */ + public static final String VIA = "Via"; + /** + * The header Range + */ + public static final String RANGE = "Range"; + /** + * The header Referer + */ + public static final String REFERER = "Referer"; + /** + * The header Refresh + */ + public static final String REFRESH = "Refresh"; + /** + * The header te + */ + public static final String TE = "te"; + /** + * The header If-Match + */ + public static final String IF_MATCH = "If-Match"; + /** + * The header If-Range + */ + public static final String IF_RANGE = "If-Range"; + /** + * The header Accept + */ + public static final String ACCEPT = "Accept"; + /** + * The header Accept-Charset + */ + public static final String ACCEPT_CHARSET = "Accept-Charset"; + /** + * The header Accept-Encoding + */ + public static final String ACCEPT_ENCODING = "Accept-Encoding"; + /** + * The header Accept-Language + */ + public static final String ACCEPT_LANGUAGE = "Accept-Language"; + /** + * The header Accept-Ranges + */ + public static final String ACCEPT_RANGES = "Accept-Ranges"; + /** + * The header Content-Encoding + */ + public static final String CONTENT_ENCODING = "Content-Encoding"; + /** + * The header Content-Language + */ + public static final String CONTENT_LANGUAGE = "Content-Language"; + /** + * The header Content-Length + */ + public static final String CONTENT_LENGTH = "Content-Length"; + /** + * The header Content-Location + */ + public static final String CONTENT_LOCATION = "Content-Location"; + /** + * The header Content-MD5 + */ + public static final String CONTENT_MD5 = "Content-MD5"; + /** + * The header Content-Range + */ + public static final String CONTENT_RANGE = "Content-Range"; + /** + * The header Content-Type + */ + public static final String CONTENT_TYPE = "Content-Type"; + /** + * The header Content-Disposition + */ + public static final String CONTENT_DISPOSITION = "Content-Disposition"; + /** + * The header Transfer-Encoding + */ + public static final String TRANSFER_ENCODING = "Transfer-Encoding"; + /** + * The header Cache-Control + */ + public static final String CACHE_CONTROL = "Cache-Control"; + /** + * The header User-Agent + */ + public static final String USER_AGENT = "User-Agent"; + /** + * The header Retry-After + */ + public static final String RETRY_AFTER = "Retry-After"; + /** + * The header Max-Forwards + */ + public static final String MAX_FORWARDS = "Max-Forwards"; + /** + * The header Keep-Alive + */ + public static final String KEEP_ALIVE = "Keep-Alive"; + /** + * The header Authorization + */ + public static final String AUTHORIZATION = "Authorization"; + /** + * The header Proxy-Authorization + */ + public static final String PROXY_AUTHORIZATION = "Proxy-Authorization"; + /** + * The header Proxy-Connection + */ + public static final String PROXY_CONNECTION = "Proxy-Connection"; + /** + * The header WWW-Authenticate + */ + public static final String WWW_AUTHENTICATE = "WWW-Authenticate"; + /** + * The header Proxy-Authenticate + */ + public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate"; + /** + * The header Httpd-Preemptive + */ + public static final String HTTPD_PREEMPTIVE = "Httpd-Preemptive"; + /** + * The header Last-Modified + */ + public static final String LAST_MODIFIED = "Last-Modified"; + /** + * The header If-Unmodified-Since + */ + public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since"; + /** + * The header If-Modified-Since + */ + public static final String IF_MODIFIED_SINCE = "If-Modified-Since"; + /** + * The header If-None-Match + */ + public static final String IF_NONE_MATCH = "If-None-Match"; + /** + * The header Sec-WebSocket-Key + */ + public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key"; + /** + * The header Sec-WebSocket-Accept + */ + public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept"; + /** + * The header Sec-WebSocket-Version + */ + public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version"; + /** + * The header Sec-WebSocket-Version + */ + public static final String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin"; + /** + * The header Sec-WebSocket-Version + */ + public static final String STRICT_TRANSPORT_SECURITY = "Strict-Transport-Security"; + /** + * The header SOAPAction + */ + public static final String SOAPACTION = "SOAPAction"; /** - * 是否为https协议或本地主机(域名) - * - * @param url 待验证的url - * @return true: https协议或本地主机 false: 非https协议或本机主机 - */ - public static boolean isHttpsOrLocalHost(String url) { - if (StringKit.isEmpty(url)) { - return false; - } - return isHttps(url) || isLocalHost(url); - } + * The use method + */ + public static final String TARGET_METHOD_UTF8 = ":method"; + /** + * The use status + */ + public static final String RESPONSE_STATUS_UTF8 = ":status"; + /** + * The use path + */ + public static final String TARGET_PATH_UTF8 = ":path"; + /** + * The use scheme + */ + public static final String TARGET_SCHEME_UTF8 = ":scheme"; + /** + * The use authority + */ + public static final String TARGET_AUTHORITY_UTF8 = ":authority"; + + /** + * The use form data + */ + public static final String FORM = "form"; + /** + * The use json data + */ + public static final String JSON = "json"; + /** + * The use xml data + */ + public static final String XML = "xml"; + /** + * The use protobuf data + */ + public static final String PROTOBUF = "protobuf"; /** * WebDAV @@ -556,4 +631,4 @@ public static boolean redirectsToGet(String method) { return !PROPFIND.equals(method); } -} +} \ No newline at end of file diff --git a/bus-core/src/main/java/org/miaixz/bus/core/net/MaskBit.java b/bus-core/src/main/java/org/miaixz/bus/core/net/MaskBit.java index cdedd75459..e6c7d99909 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/net/MaskBit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/net/MaskBit.java @@ -29,7 +29,6 @@ import org.miaixz.bus.core.center.map.BiMap; import org.miaixz.bus.core.lang.Assert; -import org.miaixz.bus.core.lang.Protocol; import org.miaixz.bus.core.net.ip.IPv4; import java.util.HashMap; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/net/Protocol.java b/bus-core/src/main/java/org/miaixz/bus/core/net/Protocol.java new file mode 100644 index 0000000000..d955a0df5e --- /dev/null +++ b/bus-core/src/main/java/org/miaixz/bus/core/net/Protocol.java @@ -0,0 +1,295 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.core.net; + +import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.xyz.StringKit; + +import java.io.IOException; + +/** + * 协议vs计划 它的名字是:{@link java.net.URL#getProtocol()} + * 返回{@linkplain java.net.URI#getScheme() scheme} (http, https, etc.), + * 而不是协议(http/1.1, spdy/3.1,等等) 请使用这个协议来识别它是如何被分割的 + * Httpd使用协议这个词来标识HTTP消息是如何构造的 + * + * @author Kimi Liu + * @since Java 17+ + */ +public enum Protocol { + + /** + * TCP协议 + */ + TCP("tcp"), + /** + * + */ + UDP("udp"), + /** + * http协议 + */ + HTTP("http"), + /** + * 过时的plaintext,默认情况下不使用持久套接字 + */ + HTTP_1_0("HTTP/1.0"), + /** + * 包含持久连接的plaintext + * 此版本的Httpd实现了RFC 7230,并跟踪对该规范的修订 + */ + HTTP_1_1("HTTP/1.1"), + /** + * IETF的二进制框架协议,包括头压缩、在同一个套接字上多路复用多个请求和服务器推送 + * HTTP/1.1语义是在HTTP/2上分层的 + */ + HTTP_2("h2"), + /** + * HTTP/3 是用于交换信息的超文本传输协议的第三个主要版本 + * HTTP/3 在 QUIC 上运行,QUIC 以 RFC 9000 的形式发布。 + */ + HTTP_3("h3"), + /** + * Chromium的二进制框架协议,包括标头压缩、在同一个套接字上多路复用多个请求和服务器推送 + * HTTP/1.1语义在SPDY/3上分层. + */ + SPDY_3("spdy/3.1"), + /** + * 明文HTTP/2,没有"upgrade"往返。此选项要求客户端事先知道服务器支持明文HTTP/2 + */ + H2_PRIOR_KNOWLEDGE("h2_prior_knowledge"), + /** + * QUIC(快速UDP互联网连接)是一个新的多路复用和UDP之上的安全传输, + * 从底层设计和优化的HTTP/2语义。HTTP/1.1语义是在HTTP/2上分层的 + */ + QUIC("quic"), + /** + * SOAP 1.1协议 + */ + SOAP_1_1("soap 1.1 protocol"), + /** + * SOAP 1.2协议 + */ + SOAP_1_2("SOAP 1.2 Protocol"), + /** + *the ws + */ + WS("ws"), + /** + * the wss + */ + WSS("wss"), + /** + * https协议 + */ + HTTPS("https"), + /** + * Supports some version of SSL + */ + SSL("ssl"), + /** + * Supports SSL version 2 + */ + SSLv2("SSLv2"), + /** + * Supports SSL version 3 + */ + SSLv3("SSLv3"), + /** + * Supports some version of TLS + */ + TLS("tls"), + /** + * Supports RFC 2246: TLS version 1.0 + */ + TLSv1("TLSv1"), + /** + * Supports RFC 4346: TLS version 1.1 + */ + TLSv1_1("TLSv1.1"), + /** + * Supports RFC 5246: TLS version 1.2 + */ + TLSv1_2("TLSv1.2"), + /** + * Supports RFC 5246: TLS version 1.3 + */ + TLSv1_3("TLSv1.3"), + /** + * + */ + DICOM("dicom"), + /** + * + */ + HL7("hl7"); + + /** + * The prefix http + */ + public static final String HTTP_PREFIX = HTTP.name + Symbol.COLON + Symbol.FORWARDSLASH; + /** + * The prefix https + */ + public static final String HTTPS_PREFIX = HTTPS.name + Symbol.COLON + Symbol.FORWARDSLASH; + /** + * The prefix ws + */ + public static final String WS_PREFIX = WS.name + Symbol.COLON + Symbol.FORWARDSLASH; + /** + * The prefix wss + */ + public static final String WSS_PREFIX = WSS.name + Symbol.COLON + Symbol.FORWARDSLASH; + + /** + * The IPV4 127.0.0.1 + */ + public static final String HOST_IPV4 = "127.0.0.1"; + /** + * The localhost + */ + public static final String HOST_LOCAL = "localhost"; + /** + * Ipv4地址最小值字符串形式 + */ + public static final String IPV4_STR_MIN = "0.0.0.0"; + /** + * Ipv4地址最大值字符串形式 + */ + public static final String IPV4_STR_MAX = "255.255.255.255"; + /** + * Ipv4最大值数值形式 + */ + public static final long IPV4_NUM_MAX = 0xffffffffL; + /** + * Ipv4未使用地址最大值字符串形式 + */ + public static final String IPV4_UNUSED_STR_MAX = "0.255.255.255"; + + public final String name; + + Protocol(String name) { + this.name = name; + } + + /** + * @param protocol 协议标示 + * @return 返回由{@code protocol}标识的协议 + * @throws IOException if {@code protocol} is unknown. + */ + public static Protocol get(String protocol) throws IOException { + if (protocol.equals(HTTP_1_0.name)) { + return HTTP_1_0; + } + if (protocol.equals(HTTP_1_1.name)) { + return HTTP_1_1; + } + if (protocol.equals(H2_PRIOR_KNOWLEDGE.name)) { + return H2_PRIOR_KNOWLEDGE; + } + if (protocol.equals(HTTP_2.name)) { + return HTTP_2; + } + if (protocol.equals(SPDY_3.name)) { + return SPDY_3; + } + if (protocol.equals(QUIC.name)) { + return QUIC; + } + if (protocol.equals(SOAP_1_1.name)) { + return SOAP_1_1; + } + if (protocol.equals(SOAP_1_2.name)) { + return SOAP_1_2; + } + throw new IOException("Unexpected protocol: " + protocol); + } + + /** + * 是否为http协议 + * + * @param url 待验证的url + * @return true: http协议, false: 非http协议 + */ + public static boolean isHttp(String url) { + if (StringKit.isEmpty(url)) { + return false; + } + return url.startsWith(HTTP_PREFIX) || url.startsWith("http%3A%2F%2F"); + } + + /** + * 是否为https协议 + * + * @param url 待验证的url + * @return true: https协议, false: 非https协议 + */ + public static boolean isHttps(String url) { + if (StringKit.isEmpty(url)) { + return false; + } + return url.startsWith(HTTPS_PREFIX) || url.startsWith("https%3A%2F%2F"); + } + + /** + * 是否为本地主机(域名) + * + * @param url 待验证的url + * @return true: 本地主机(域名), false: 非本地主机(域名) + */ + public static boolean isLocalHost(String url) { + return StringKit.isEmpty(url) || url.contains(HOST_IPV4) || url.contains(HOST_LOCAL); + } + + + /** + * 是否为https协议或本地主机(域名) + * + * @param url 待验证的url + * @return true: https协议或本地主机 false: 非https协议或本机主机 + */ + public static boolean isHttpsOrLocalHost(String url) { + if (StringKit.isEmpty(url)) { + return false; + } + return isHttps(url) || isLocalHost(url); + } + + public boolean isTcp() { + return this != UDP; + } + + /** + * 返回用于识别ALPN协议的字符串,如“http/1.1”、“spdy/3.1”或“http/2.0”. + */ + @Override + public String toString() { + return name; + } + +} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/net/ip/IPv4.java b/bus-core/src/main/java/org/miaixz/bus/core/net/ip/IPv4.java index 9266afbd06..e3abee6f40 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/net/ip/IPv4.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/net/ip/IPv4.java @@ -30,9 +30,9 @@ import org.miaixz.bus.core.center.regex.Pattern; import org.miaixz.bus.core.instance.Instances; import org.miaixz.bus.core.lang.Assert; -import org.miaixz.bus.core.lang.Protocol; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.net.MaskBit; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.text.CharsBacker; import org.miaixz.bus.core.xyz.*; @@ -448,7 +448,7 @@ public static byte[] getLocalHardwareAddress() { * *

        * 此方法不会抛出异常,获取失败将返回{@code null} - *

        + *

        * * @return 本机网卡IP地址,获取失败返回{@code null} */ @@ -467,7 +467,7 @@ public static InetAddress getLocalhost() { * *

        * 此方法不会抛出异常,获取失败将返回{@code null} - *

        + *

        * * @return 本机网卡IP地址,获取失败返回{@code null} */ @@ -486,7 +486,7 @@ public static InetAddress getLocalhostDirectly() { * *

        * 此方法不会抛出异常,获取失败将返回{@code null} - *

        + *

        * * @param includeSiteLocal 是否包含局域网地址,如10.0.0.0 ~ 10.255.255.255、172.16.0.0 ~ 172.31.255.255、192.168.0.0 ~ 192.168.255.255 * @return 本机网卡IP地址,获取失败返回{@code null} @@ -866,7 +866,6 @@ public static boolean isInnerIP(final long ipNum) { /** * 是否为公网地址 - *

        * 公网IP: *

              * A类 1.0.0.0-9.255.255.255,11.0.0.0-126.255.255.255
        diff --git a/bus-core/src/main/java/org/miaixz/bus/core/net/ip/IPv6.java b/bus-core/src/main/java/org/miaixz/bus/core/net/ip/IPv6.java
        index 81d2f0b0af..56cd8d5944 100644
        --- a/bus-core/src/main/java/org/miaixz/bus/core/net/ip/IPv6.java
        +++ b/bus-core/src/main/java/org/miaixz/bus/core/net/ip/IPv6.java
        @@ -159,7 +159,7 @@ public static InetAddress getLocalhost() {
              *
              * 

        * 此方法不会抛出异常,获取失败将返回{@code null} - *

        + *

        * * @return 本机网卡IP地址,获取失败返回{@code null} */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/net/tls/SSLContextBuilder.java b/bus-core/src/main/java/org/miaixz/bus/core/net/tls/SSLContextBuilder.java index 1312f51c52..d181681ba1 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/net/tls/SSLContextBuilder.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/net/tls/SSLContextBuilder.java @@ -28,9 +28,8 @@ package org.miaixz.bus.core.net.tls; import org.miaixz.bus.core.Builder; -import org.miaixz.bus.core.lang.Http; -import org.miaixz.bus.core.lang.Protocol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.ArrayKit; import org.miaixz.bus.core.xyz.StringKit; @@ -46,7 +45,6 @@ *
      • {@link TrustManager},默认{@link TrustAnyTrustManager},即信任全部
      • *
      • {@link SecureRandom}
      • *
      - *

      * 构建后可获得{@link SSLContext},通过调用{@link SSLContext#getSocketFactory()}获取{@link javax.net.ssl.SSLSocketFactory} * * @author Kimi Liu @@ -56,7 +54,7 @@ public class SSLContextBuilder implements Builder { private static final long serialVersionUID = -1L; - private String protocol = Protocol.TLS; + private String protocol = Protocol.TLS.name; private KeyManager[] keyManagers; private TrustManager[] trustManagers = TrustAnyTrustManager.TRUST_ANYS; private SecureRandom secureRandom = new SecureRandom(); @@ -175,10 +173,10 @@ public static X509TrustManager newTrustManager() { public static SSLContext getSSLContext() { try { - return SSLContext.getInstance(Http.TLS_V_13); + return SSLContext.getInstance(Protocol.TLSv1_3.name); } catch (NoSuchAlgorithmException e) { try { - return SSLContext.getInstance(Http.TLS); + return SSLContext.getInstance(Protocol.TLS.name); } catch (NoSuchAlgorithmException e2) { throw new IllegalStateException("No TLS provider", e); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/net/tls/TlsVersion.java b/bus-core/src/main/java/org/miaixz/bus/core/net/tls/TlsVersion.java index a6fbb1a2b5..afbd9da8cf 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/net/tls/TlsVersion.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/net/tls/TlsVersion.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.core.net.tls; -import org.miaixz.bus.core.lang.Protocol; +import org.miaixz.bus.core.net.Protocol; import java.util.ArrayList; import java.util.Collections; @@ -45,23 +45,23 @@ public enum TlsVersion { /** * 2016年版本 */ - TLS_1_3(Protocol.TLS_V_13), + TLSv1_3(Protocol.TLSv1_3.name), /** * 2008年版本 */ - TLS_1_2(Protocol.TLS_V_12), + TLSv1_2(Protocol.TLSv1_2.name), /** * 2006年版本 */ - TLS_1_1(Protocol.TLS_V_11), + TLSv1_1(Protocol.TLSv1_1.name), /** * 1999年版本 */ - TLS_1_0(Protocol.TLS_V_10), + TLSv1(Protocol.TLSv1.name), /** * 1996年版本 */ - SSL_3_0(Protocol.SSL_V_30); + SSLv3(Protocol.SSLv3.name); public final String javaName; @@ -70,17 +70,20 @@ public enum TlsVersion { } public static TlsVersion forJavaName(String javaName) { - switch (javaName) { - case Protocol.TLS_V_13: - return TLS_1_3; - case Protocol.TLS_V_12: - return TLS_1_2; - case Protocol.TLS_V_11: - return TLS_1_1; - case Protocol.TLS_V_10: - return TLS_1_0; - case Protocol.SSL_V_30: - return SSL_3_0; + if (Protocol.TLSv1_3.name.equals(javaName)) { + return TLSv1_3; + } + if (Protocol.TLSv1_2.name.equals(javaName)) { + return TLSv1_2; + } + if (Protocol.TLSv1_1.name.equals(javaName)) { + return TLSv1_1; + } + if (Protocol.TLSv1.name.equals(javaName)) { + return TLSv1; + } + if (Protocol.SSLv3.name.equals(javaName)) { + return SSLv3; } throw new IllegalArgumentException("Unexpected TLS version: " + javaName); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/net/url/UrlBuilder.java b/bus-core/src/main/java/org/miaixz/bus/core/net/url/UrlBuilder.java index 34a409e553..9a2f75380c 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/net/url/UrlBuilder.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/net/url/UrlBuilder.java @@ -30,8 +30,9 @@ import org.miaixz.bus.core.Builder; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.Charset; -import org.miaixz.bus.core.lang.Protocol; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.core.xyz.UrlKit; @@ -283,7 +284,7 @@ public UrlBuilder setScheme(final String scheme) { * @return 协议,例如http */ public String getSchemeWithDefault() { - return StringKit.defaultIfEmpty(this.scheme, Protocol.HTTP); + return StringKit.defaultIfEmpty(this.scheme, Protocol.HTTP.name); } /** @@ -568,7 +569,7 @@ public URL toURL(final URLStreamHandler handler) { try { return new URL(getSchemeWithDefault(), host, port, fileBuilder.toString(), handler); } catch (final MalformedURLException e) { - return null; + throw new InternalException(e); } } @@ -581,7 +582,7 @@ public URI toURI() { try { return toURL().toURI(); } catch (final URISyntaxException e) { - return null; + throw new InternalException(e); } } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/text/CharsBacker.java b/bus-core/src/main/java/org/miaixz/bus/core/text/CharsBacker.java index 87047014d7..13db731f5f 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/text/CharsBacker.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/text/CharsBacker.java @@ -55,7 +55,7 @@ import java.util.regex.Matcher; /** - * {@link CharSequence} 相关工具类封装,包括但不限于: + * {@link CharSequence} 相关类封装,包括但不限于: *

        *
      • 字符串补充前缀或后缀:addXXX
      • *
      • 字符串补充长度:padXXX
      • @@ -441,7 +441,7 @@ public static boolean startWith(final CharSequence text, final CharSequence pref * @return 是否以指定字符串开头 */ public static boolean startWith(final CharSequence text, final CharSequence prefix, final boolean ignoreCase, final boolean ignoreEquals) { - return new StringMatcher(ignoreCase, ignoreEquals, true) + return new OffsetMatcher(ignoreCase, ignoreEquals, true) .test(text, prefix); } @@ -547,7 +547,7 @@ public static boolean endWith(final CharSequence text, final CharSequence suffix * @return 是否以指定字符串结尾 */ public static boolean endWith(final CharSequence text, final CharSequence suffix, final boolean ignoreCase, final boolean ignoreEquals) { - return new StringMatcher(ignoreCase, ignoreEquals, false) + return new OffsetMatcher(ignoreCase, ignoreEquals, false) .test(text, suffix); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/text/StringMatcher.java b/bus-core/src/main/java/org/miaixz/bus/core/text/OffsetMatcher.java similarity index 95% rename from bus-core/src/main/java/org/miaixz/bus/core/text/StringMatcher.java rename to bus-core/src/main/java/org/miaixz/bus/core/text/OffsetMatcher.java index 638722440d..ff4b7f423a 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/text/StringMatcher.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/text/OffsetMatcher.java @@ -44,7 +44,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class StringMatcher implements BiPredicate, Serializable { +public class OffsetMatcher implements BiPredicate, Serializable { private static final long serialVersionUID = -1L; @@ -62,7 +62,7 @@ public class StringMatcher implements BiPredicate, S * @param ignoreEquals 是否忽略字符串相等的情况 * @param isPrefix {@code true}表示检查开头匹配,{@code false}检查末尾匹配 */ - public StringMatcher(final boolean ignoreCase, final boolean ignoreEquals, final boolean isPrefix) { + public OffsetMatcher(final boolean ignoreCase, final boolean ignoreEquals, final boolean isPrefix) { this(ignoreCase, ignoreEquals, isPrefix ? 0 : -1); } @@ -73,7 +73,7 @@ public StringMatcher(final boolean ignoreCase, final boolean ignoreEquals, final * @param ignoreEquals 是否忽略字符串相等的情况 * @param offset 匹配位置,正数表示从开始偏移,负数表示从后偏移 */ - public StringMatcher(final boolean ignoreCase, final boolean ignoreEquals, final int offset) { + public OffsetMatcher(final boolean ignoreCase, final boolean ignoreEquals, final int offset) { this.ignoreCase = ignoreCase; this.ignoreEquals = ignoreEquals; this.offset = offset; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/tree/NodeConfig.java b/bus-core/src/main/java/org/miaixz/bus/core/tree/NodeConfig.java index 2a5639e5cb..aaa54e014f 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/tree/NodeConfig.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/tree/NodeConfig.java @@ -37,11 +37,12 @@ */ public class NodeConfig implements Serializable { + private static final long serialVersionUID = -1L; + /** * 默认属性配置对象 */ public static final NodeConfig DEFAULT_CONFIG = new NodeConfig(); - private static final long serialVersionUID = -1L; /** * 属性名配置字段 */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/tree/parser/DefaultNodeParser.java b/bus-core/src/main/java/org/miaixz/bus/core/tree/parser/DefaultNodeParser.java index 7814536d76..06edf52b45 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/tree/parser/DefaultNodeParser.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/tree/parser/DefaultNodeParser.java @@ -37,7 +37,6 @@ * 默认的简单转换器 * * @param ID类型 - * liangbaikai * @author Kimi Liu * @since Java 17+ */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xml/UniversalNamespaceCache.java b/bus-core/src/main/java/org/miaixz/bus/core/xml/UniversalNamespace.java similarity index 72% rename from bus-core/src/main/java/org/miaixz/bus/core/xml/UniversalNamespaceCache.java rename to bus-core/src/main/java/org/miaixz/bus/core/xml/UniversalNamespace.java index 054ed230a7..12c478549b 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/xml/UniversalNamespaceCache.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xml/UniversalNamespace.java @@ -44,27 +44,27 @@ * @author Kimi Liu * @since Java 17+ */ -public class UniversalNamespaceCache implements NamespaceContext { +public class UniversalNamespace implements NamespaceContext { private static final String DEFAULT_NS = "DEFAULT"; private final BiMap prefixUri = new BiMap<>(new HashMap<>()); /** - * This constructor parses the document and stores all namespaces it can - * find. If toplevelOnly is true, only namespaces in the root are used. + * 此构造函数解析文档并存储其能找到的所有命名空间。 + * 如果 toplevelOnly 为 true,则仅使用根目录中的命名空间。 * - * @param node source Node - * @param toplevelOnly restriction of the search to enhance performance + * @param node 源节点 + * @param toplevelOnly 限制搜索以提高性能 */ - public UniversalNamespaceCache(final Node node, final boolean toplevelOnly) { + public UniversalNamespace(final Node node, final boolean toplevelOnly) { examineNode(node.getFirstChild(), toplevelOnly); } /** - * A single node is read, the namespace attributes are extracted and stored. + *取单个节点,提取并存储命名空间属性。 * - * @param node to examine - * @param attributesOnly, if true no recursion happens + * @param node 检查节点 + * @param attributesOnly 如果为真,则不发生递归 */ private void examineNode(final Node node, final boolean attributesOnly) { final NamedNodeMap attributes = node.getAttributes(); @@ -78,7 +78,6 @@ private void examineNode(final Node node, final boolean attributesOnly) { if (!attributesOnly) { final NodeList childNodes = node.getChildNodes(); - //noinspection ConstantConditions if (null != childNodes) { Node item; final int childLength = childNodes.getLength(); @@ -92,34 +91,32 @@ private void examineNode(final Node node, final boolean attributesOnly) { } /** - * This method looks at an attribute and stores it, if it is a namespace - * attribute. + * 如果它是命名空间属性,则此方法查看该属性并将其存储。 * - * @param attribute to examine + * @param node 检查节点 */ - private void storeAttribute(final Node attribute) { - if (null == attribute) { + private void storeAttribute(final Node node) { + if (null == node) { return; } - // examine the attributes in namespace xmlns - if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attribute.getNamespaceURI())) { - // Default namespace xmlns="uri goes here" - if (XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getNodeName())) { - prefixUri.put(DEFAULT_NS, attribute.getNodeValue()); + // 检查命名空间 xmlns 中的属性 + if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(node.getNamespaceURI())) { + // 默认命名空间 xmlns="uri goes here" + if (XMLConstants.XMLNS_ATTRIBUTE.equals(node.getNodeName())) { + prefixUri.put(DEFAULT_NS, node.getNodeValue()); } else { - // The defined prefixes are stored here - prefixUri.put(attribute.getLocalName(), attribute.getNodeValue()); + // 定义的前缀存储在这里 + prefixUri.put(node.getLocalName(), node.getNodeValue()); } } } /** - * This method is called by XPath. It returns the default namespace, if the - * prefix is null or "". + * 此方法由 XPath 调用。如果前缀为 null 或“”,则返回默认命名空间。 * - * @param prefix to search for - * @return uri + * @param prefix 前缀 + * @return 命名空间URI */ @Override public String getNamespaceURI(final String prefix) { @@ -131,8 +128,7 @@ public String getNamespaceURI(final String prefix) { } /** - * This method is not needed in this context, but can be implemented in a - * similar way. + * 在这种情况下不需要这种方法,但可以用类似的方式实现。 */ @Override public String getPrefix(final String namespaceURI) { diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xml/XPath.java b/bus-core/src/main/java/org/miaixz/bus/core/xml/XPath.java index 77098d82d7..de35b4ad5c 100755 --- a/bus-core/src/main/java/org/miaixz/bus/core/xml/XPath.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xml/XPath.java @@ -105,7 +105,7 @@ public static Node getNodeByXPath(final String expression, final Object source) public static Object getByXPath(final String expression, final Object source, final QName returnType) { NamespaceContext nsContext = null; if (source instanceof Node) { - nsContext = new UniversalNamespaceCache((Node) source, false); + nsContext = new UniversalNamespace((Node) source, false); } return getByXPath(expression, source, returnType, nsContext); } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ArrayKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ArrayKit.java index 0dfa9b2b54..f98a27320e 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ArrayKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ArrayKit.java @@ -113,9 +113,6 @@ public static T[] ofArray(final Iterable iterable, final Class compone /** *

        指定字符串数组中,是否包含空字符串。

        *

        如果指定的字符串数组的长度为 0,或者其中的任意一个元素是空字符串,则返回 true。

        - * - * - *

        例:

        *
          *
        • {@code hasBlank() // true}
        • *
        • {@code hasBlank("", null, " ") // true}
        • @@ -158,9 +155,6 @@ public static boolean isAllNotBlank(final CharSequence... args) { /** *

          指定字符串数组中的元素,是否全部为空字符串。

          *

          如果指定的字符串数组的长度为 0,或者所有元素都是空字符串,则返回 true。

          - * - * - *

          例:

          *
            *
          • {@code isAllBlank() // true}
          • *
          • {@code isAllBlank("", null, " ") // true}
          • @@ -310,7 +304,7 @@ public static boolean hasEmptyVarargs(final T... args) { /** * 是否所有元素都为{@code null}或空对象,通过{@link ObjectKit#isEmpty(Object)} 判断元素 - *

            如果提供的数组本身为空,则返回{@code true}

            + * 如果提供的数组本身为空,则返回{@code true} * * @param 元素类型 * @param args 被检查的对象,一个或者多个 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CharKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CharKit.java index 1444ab3e51..db82b53735 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CharKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CharKit.java @@ -121,9 +121,7 @@ public static boolean isLetter(final char ch) { } /** - *

            * 判断是否为大写字母,大写字母包括A~Z - *

            * *
                  *   CharKit.isLetterUpper('a')  = false
            @@ -364,7 +362,6 @@ public static int digit16(final int b) {
                  *     'A' - 'Ⓐ'
                  *     'a' - 'ⓐ'
                  * 
            - *

            * 获取带圈数字 /封闭式字母数字 ,从1-20,超过1-20报错 * * @param c 被转换的字符,如果字符不支持转换,返回原字符 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CitizenIdKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CitizenIdKit.java index b8bf7fedad..123309011d 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CitizenIdKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CitizenIdKit.java @@ -115,7 +115,7 @@ public static boolean isValidCard(final String idCard) { return false; } - //idCard = idCard.trim(); + // idCard = idCard.trim(); final int length = idCard.length(); switch (length) { case 18:// 18位身份证 @@ -136,24 +136,19 @@ public static boolean isValidCard(final String idCard) { } /** - *

            * 判断18位身份证的合法性 - *

            * 根据〖中华人民共和国国家标准GB11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。 * 排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。 - *

            * 顺序码: 表示在同一地址码所标识的区域范围内,对同年、同月、同 日出生的人编定的顺序号,顺序码的奇数分配给男性,偶数分配 给女性。 - *

            *
              - *
            1. 第1、2位数字表示:所在省份的代码
            2. - *
            3. 第3、4位数字表示:所在城市的代码
            4. - *
            5. 第5、6位数字表示:所在区县的代码
            6. - *
            7. 第7~14位数字表示:出生年、月、日
            8. - *
            9. 第15、16位数字表示:所在地的派出所的代码
            10. - *
            11. 第17位数字表示性别:奇数表示男性,偶数表示女性
            12. - *
            13. 第18位数字是校检码,用来检验身份证的正确性。校检码可以是0~9的数字,有时也用x表示
            14. + *
            15. 第1、2位数字表示:所在省份的代码
            16. + *
            17. 第3、4位数字表示:所在城市的代码
            18. + *
            19. 第5、6位数字表示:所在区县的代码
            20. + *
            21. 第7~14位数字表示:出生年、月、日
            22. + *
            23. 第15、16位数字表示:所在地的派出所的代码
            24. + *
            25. 第17位数字表示性别:奇数表示男性,偶数表示女性
            26. + *
            27. 第18位数字是校检码,用来检验身份证的正确性。校检码可以是0~9的数字,有时也用x表示
            28. *
            - *

            * 第十八位数字(校验码)的计算方法为: *

              *
            1. 将前面的身份证号码17位数分别乘以不同的系数。从第一位到第十七位的系数分别为:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
            2. @@ -163,19 +158,19 @@ public static boolean isValidCard(final String idCard) { *
            3. 通过上面得知如果余数是2,就会在身份证的第18位数字上出现罗马数字的Ⅹ。如果余数是10,身份证的最后一位号码就是2
            4. *
            *
              - *
            1. 香港人在大陆的身份证,【810000】开头;同样可以直接获取到 性别、出生日期
            2. - *
            3. 81000019980902013X: 文绎循 男 1998-09-02
            4. - *
            5. 810000201011210153: 辛烨 男 2010-11-21
            6. - *
            - *
              - *
            1. 澳门人在大陆的身份证,【820000】开头;同样可以直接获取到 性别、出生日期
            2. - *
            3. 820000200009100032: 黄敬杰 男 2000-09-10
            4. - *
            - *
              - *
            1. 台湾人在大陆的身份证,【830000】开头;同样可以直接获取到 性别、出生日期
            2. - *
            3. 830000200209060065: 王宜妃 女 2002-09-06
            4. - *
            5. 830000194609150010: 苏建文 男 1946-09-14
            6. - *
            7. 83000019810715006X: 刁婉琇 女 1981-07-15
            8. + *
            9. 香港人在大陆的身份证,【810000】开头;同样可以直接获取到 性别、出生日期
            10. + *
            11. 81000019980902013X: 文绎循 男 1998-09-02
            12. + *
            13. 810000201011210153: 辛烨 男 2010-11-21
            14. + *
            + *
              + *
            1. 澳门人在大陆的身份证,【820000】开头;同样可以直接获取到 性别、出生日期
            2. + *
            3. 820000200009100032: 黄敬杰 男 2000-09-10
            4. + *
            + *
              + *
            1. 台湾人在大陆的身份证,【830000】开头;同样可以直接获取到 性别、出生日期
            2. + *
            3. 830000200209060065: 王宜妃 女 2002-09-06
            4. + *
            5. 830000194609150010: 苏建文 男 1946-09-14
            6. + *
            7. 83000019810715006X: 刁婉琇 女 1981-07-15
            8. *
            * * @param idcard 待验证的身份证 @@ -186,31 +181,26 @@ public static boolean isValidCard18(final String idcard) { } /** - *

            * 判断18位身份证的合法性 - *

            * 根据〖中华人民共和国国家标准GB11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。 * 排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。 - *

            * 顺序码: 表示在同一地址码所标识的区域范围内,对同年、同月、同 日出生的人编定的顺序号,顺序码的奇数分配给男性,偶数分配 给女性。 - *

            *
              - *
            1. 第1、2位数字表示:所在省份的代码
            2. - *
            3. 第3、4位数字表示:所在城市的代码
            4. - *
            5. 第5、6位数字表示:所在区县的代码
            6. - *
            7. 第7~14位数字表示:出生年、月、日
            8. - *
            9. 第15、16位数字表示:所在地的派出所的代码
            10. - *
            11. 第17位数字表示性别:奇数表示男性,偶数表示女性
            12. - *
            13. 第18位数字是校检码,用来检验身份证的正确性。校检码可以是0~9的数字,有时也用x表示
            14. + *
            15. 第1、2位数字表示:所在省份的代码
            16. + *
            17. 第3、4位数字表示:所在城市的代码
            18. + *
            19. 第5、6位数字表示:所在区县的代码
            20. + *
            21. 第7~14位数字表示:出生年、月、日
            22. + *
            23. 第15、16位数字表示:所在地的派出所的代码
            24. + *
            25. 第17位数字表示性别:奇数表示男性,偶数表示女性
            26. + *
            27. 第18位数字是校检码,用来检验身份证的正确性。校检码可以是0~9的数字,有时也用x表示
            28. *
            - *

            * 第十八位数字(校验码)的计算方法为: *

              - *
            1. 将前面的身份证号码17位数分别乘以不同的系数。从第一位到第十七位的系数分别为:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
            2. - *
            3. 将这17位数字和系数相乘的结果相加
            4. - *
            5. 用加出来和除以11,看余数是多少
            6. - *
            7. 余数只可能有0 1 2 3 4 5 6 7 8 9 10这11个数字。其分别对应的最后一位身份证的号码为1 0 X 9 8 7 6 5 4 3 2
            8. - *
            9. 通过上面得知如果余数是2,就会在身份证的第18位数字上出现罗马数字的Ⅹ。如果余数是10,身份证的最后一位号码就是2
            10. + *
            11. 将前面的身份证号码17位数分别乘以不同的系数。从第一位到第十七位的系数分别为:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2
            12. + *
            13. 将这17位数字和系数相乘的结果相加
            14. + *
            15. 用加出来和除以11,看余数是多少
            16. + *
            17. 余数只可能有0 1 2 3 4 5 6 7 8 9 10这11个数字。其分别对应的最后一位身份证的号码为1 0 X 9 8 7 6 5 4 3 2
            18. + *
            19. 通过上面得知如果余数是2,就会在身份证的第18位数字上出现罗马数字的Ⅹ。如果余数是10,身份证的最后一位号码就是2
            20. *
            * * @param idcard 待验证的身份证 @@ -227,7 +217,7 @@ public static boolean isValidCard18(final String idcard, final boolean ignoreCas * @param idcard 身份编码 * @return 身份证信息数组 *

            - * [0] - 台湾、澳门、香港 [1] - 性别(男M,女F,未知N) [2] - 是否合法(合法true,不合法false) 若不是身份证件号码则返回null + * [0] - 台湾、澳门、香港 [1] - 性别(男M,女F,未知N) [2] - 是否合法(合法true,不合法false) 若不是身份证件号码则返回null *

            */ public static String[] isValidCard10(final String idcard) { diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ClassKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ClassKit.java index 51ac146ee6..f5c4545e18 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ClassKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ClassKit.java @@ -146,7 +146,7 @@ public static String getClassName(final Object obj, final boolean isSimple) { * 例如:ClassKit这个类 * *
            -     * isSimple为false: "reflect.core.org.miaixz.bus.ClassKit"
            +     * isSimple为false: "org.miaixz.bus.ClassKit"
                  * isSimple为true: "ClassKit"
                  * 
            * @@ -808,7 +808,7 @@ public static void traverseTypeHierarchyWhile( } /** - *

            按广度优先遍历包括{@code root}在内,其层级结构中的所有类和接口。 + * 按广度优先遍历包括{@code root}在内,其层级结构中的所有类和接口。 * 类遍历顺序如下: *

              *
            • 离{@code type}距离越近,则顺序越靠前;
            • diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CollKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CollKit.java index 9661f0ba3f..d75bd200d3 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CollKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CollKit.java @@ -1412,7 +1412,6 @@ public static TreeSet toTreeSet(final Collection collection, final Com /** * Iterator转换为Enumeration - *

              * Adapt the specified {@link Iterator} to the {@link Enumeration} interface. * * @param 集合元素类型 @@ -1449,9 +1448,7 @@ public static Collection toCollection(final Iterable iterable) { * {a: 4} * ] * - *

              * 结果是: - * *

                    * {
                    *   a: [1,2,3,4]
              @@ -1482,9 +1479,7 @@ public static  Map> toListMap(final Iterable
              -     * 

              * 结果是: - * *

                    * [
                    *  {a: 1, b: 1, c: 1}
              @@ -2209,27 +2204,60 @@ public static int size(final Object object) {
                       }
                   }
               
              +    /**
              +     * 判断subCollection是否为collection的子集合,不考虑顺序,只考虑元素数量。
              +     * 
                + *
              • 如果两个集合为同一集合或,则返回true
              • + *
              • 如果两个集合元素都相同,则返回true(无论顺序相同与否)
              • + *
              + * + * @param subCollection 第一个Iterable对象,即子集合。 + * @param collection 第二个Iterable对象,可以为任何实现了Iterable接口的集合。 + * @return 如果subCollection是collection的子集合,则返回true;否则返回false。 + */ + public static boolean isSub(final Collection subCollection, final Collection collection) { + if (size(subCollection) > size(collection)) { + return false; + } + return IteratorKit.isSub(subCollection, collection); + } + /** * 判断两个{@link Collection} 是否元素和顺序相同,返回{@code true}的条件是: *
                *
              • 两个{@link Collection}必须长度相同
              • *
              • 两个{@link Collection}元素相同index的对象必须equals,满足{@link Objects#equals(Object, Object)}
              • *
              - * 此方法来自Apache-Commons-Collections4。 * * @param list1 列表1 * @param list2 列表2 * @return 是否相同 */ public static boolean isEqualList(final Collection list1, final Collection list2) { - if (list1 == list2) { - return true; - } - if (list1 == null || list2 == null || list1.size() != list2.size()) { + return equals(list1, list2, false); + } + + /** + * 判断两个{@link Iterable}中的元素是否相同,可选是否判断顺序 + * 当满足下列情况时返回{@code true}: + *
                + *
              • 两个{@link Iterable}都为{@code null};
              • + *
              • 两个{@link Iterable}满足{@code coll1 == coll2};
              • + *
              • 如果忽略顺序,则计算两个集合中元素和数量是否相同
              • + *
              • 如果不忽略顺序,两个{@link Iterable}所有具有相同下标的元素皆满足{@link Objects#equals(Object, Object)};
              • + *
              + * + * @param coll1 集合1 + * @param coll2 集合2 + * @param ignoreOrder 是否忽略顺序 + * @return 是否相同 + */ + public static boolean equals(final Collection coll1, final Collection coll2, final boolean ignoreOrder) { + if (size(coll1) != size(coll2)) { return false; } - return IteratorKit.isEqualList(list1, list2); + return IteratorKit.equals(coll1, coll2, ignoreOrder); } /** @@ -2303,7 +2331,6 @@ public static List flat(final Collection collection) { /** * 解构多层集合 * 例如:{@code List>> 解构成 List} - *

              * skipNull如果为true, 则解构后的集合里不包含null值,为false则会包含null值。 * * @param 元素类型 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CollectorKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CollectorKit.java index db131b2a0c..7e65d0ccaf 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CollectorKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CollectorKit.java @@ -455,7 +455,7 @@ public static Collector, R> transform(final Function, } /** - *

              过滤

              + * 过滤 * * @param predicate 断言 * @param downstream 下游操作 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ColorKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ColorKit.java index 50a3b84322..d79b1c45e0 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ColorKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ColorKit.java @@ -146,8 +146,6 @@ public static String toHex(final int r, final int g, final int b) { * 3. RGB形式,例如:13,148,252 * 4. RGBA形式,例如:13,148,252,1 *
              - *

              - * 方法来自:com.lnwazg.kit * * @param colorName 颜色的英文名,16进制表示或RGB表示 * @return {@link Color} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CompareKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CompareKit.java index 9a54183ab3..034e8637db 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/CompareKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/CompareKit.java @@ -166,8 +166,6 @@ public static > Comparator reverse(final Comp /** * 对象比较,比较结果取决于comparator,如果被比较对象为null,传入的comparator对象应处理此情况 * 如果传入comparator为null,则使用默认规则比较(此时被比较对象必须实现Comparable接口) - * - *

              * 一般而言,如果c1 < c2,返回数小于0,c1==c2返回0,c1 > c2 大于0 * * @param 被比较对象类型 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/DateKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/DateKit.java index 9065605716..1c5e63f7fe 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/DateKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/DateKit.java @@ -1627,6 +1627,17 @@ public static String getZodiac(final int year) { return Zodiac.getName(year); } + /** + * {@code null}安全的日期比较,{@code null}对象排在末尾 + * + * @param date1 日期1 + * @param date2 日期2 + * @return 比较结果,如果date1 < date2,返回数小于0,date1==date2返回0,date1 > date2 大于0 + */ + public static int compare(final Date date1, final Date date2) { + return CompareKit.compare(date1, date2); + } + /** * {@code null}安全的日期比较,并只比较指定格式; {@code null}对象排在末尾, 并指定日期格式; * diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ExceptionKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ExceptionKit.java index fca770283e..bcd06038ad 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ExceptionKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ExceptionKit.java @@ -74,7 +74,6 @@ public static String getSimpleMessage(final Throwable e) { /** * 使用运行时异常包装编译异常 - *

              * 如果传入参数已经是运行时异常,则直接返回,不再额外包装 * * @param throwable 异常 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/FieldKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/FieldKit.java index d68860de8e..3bc9de84d4 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/FieldKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/FieldKit.java @@ -35,6 +35,7 @@ import org.miaixz.bus.core.lang.reflect.field.FieldReflect; import java.lang.reflect.Field; +import java.lang.reflect.Modifier; import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; @@ -172,27 +173,27 @@ public static Field[] getFields(final Class beanClass) throws SecurityExcepti * 获得一个类中所有满足条件的字段列表,包括其父类中的字段 * 如果子类与父类中存在同名字段,则这两个字段同时存在,子类字段在前,父类字段在后。 * - * @param beanClass 类 - * @param fieldPredicate field过滤器,过滤掉不需要的field,{@link Predicate#test(Object)}为{@code true}保留,null表示全部保留 + * @param beanClass 类 + * @param filter field过滤器,过滤掉不需要的field,{@link Predicate#test(Object)}为{@code true}保留,null表示全部保留 * @return 字段列表 * @throws SecurityException 安全检查异常 */ - public static Field[] getFields(final Class beanClass, final Predicate fieldPredicate) throws SecurityException { + public static Field[] getFields(final Class beanClass, final Predicate filter) throws SecurityException { Assert.notNull(beanClass); - return FIELDS_CACHE.computeIfAbsent(beanClass, FieldReflect::of).getAllFields(fieldPredicate); + return FIELDS_CACHE.computeIfAbsent(beanClass, FieldReflect::of).getAllFields(filter); } /** * 获得当前类声明的所有字段(包括非public字段),但不包括父类的字段 * - * @param beanClass 类 - * @param fieldPredicate field过滤器,过滤掉不需要的field,{@link Predicate#test(Object)}为{@code true}保留,null表示全部保留 + * @param beanClass 类 + * @param filter field过滤器,过滤掉不需要的field,{@link Predicate#test(Object)}为{@code true}保留,null表示全部保留 * @return 字段列表 * @throws SecurityException 安全检查异常 */ - public static Field[] getDeclaredFields(final Class beanClass, final Predicate fieldPredicate) throws SecurityException { + public static Field[] getDeclaredFields(final Class beanClass, final Predicate filter) throws SecurityException { Assert.notNull(beanClass); - return FIELDS_CACHE.computeIfAbsent(beanClass, FieldReflect::of).getDeclaredFields(fieldPredicate); + return FIELDS_CACHE.computeIfAbsent(beanClass, FieldReflect::of).getDeclaredFields(filter); } /** @@ -288,6 +289,53 @@ public static Object[] getFieldsValue(final Object obj, final Predicate f return null; } + /** + * 获取所有字段及对应值 + * + * @param obj bean对象,如果是static字段,此处为类class + * @return 字段值数组 + */ + public static Object getFieldsAndValue(final Object obj) { + if (null != obj) { + final Field[] fields = getFields(obj instanceof Class ? (Class) obj : obj.getClass()); + if (null != fields) { + Map map = new HashMap<>(); + for (Field field : fields) { + Object object = getFieldValue(obj, field); + if (ObjectKit.isNotEmpty(object) && !isSerialVersionUID(field)) { + map.put(field.getName(), getFieldValue(obj, field)); + } + } + return map; + } + } + return null; + } + + /** + * 获取所有字段及对应值 + * + * @param obj bean对象,如果是static字段,此处为类class + * @param filter 字段过滤器,{@code null}返回原集合 + * @return 字段值数组 + */ + public static Object getFieldsAndValue(final Object obj, final Predicate filter) { + if (null != obj) { + final Field[] fields = getFields(obj instanceof Class ? (Class) obj : obj.getClass(), filter); + if (null != fields) { + Map map = new HashMap<>(); + for (Field field : fields) { + Object object = getFieldValue(obj, field); + if (ObjectKit.isNotEmpty(object) && !isSerialVersionUID(field)) { + map.put(field.getName(), getFieldValue(obj, field)); + } + } + return map; + } + } + return null; + } + /** * 设置字段值 * @@ -362,4 +410,16 @@ public static void setFieldValueExact(final Object obj, final Field field, final } } + /** + * 给定类是否存在serialVersionUID字段 + * + * @param field 字段 + * @return 是否存在serialVersionUID字段 + */ + public static boolean isSerialVersionUID(Field field) { + return "serialVersionUID".equals(field.getName()) + && (Long.class.equals(field.getType()) || long.class.equals(field.getType())) + && field.getModifiers() == (Modifier.PRIVATE + Modifier.STATIC + Modifier.FINAL); + } + } diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/FileKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/FileKit.java index b2e8194d37..087f6702f9 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/FileKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/FileKit.java @@ -336,7 +336,6 @@ public static File file(final File directory, final String... names) { /** * 通过多层目录创建文件 - *

              * 元素名(多层目录名) * * @param names 多层文件的文件名,由外到内依次传入 @@ -1044,8 +1043,6 @@ public static File rename(final File file, final String newName, final boolean i *

                    * FileKit.rename(file, "aaa", true) xx/xx.png = xx/aaa.png
                    * 
              - * - *

              * 2、isRetainExt为false时,不保留原扩展名,需要在newName中 * *

              @@ -1219,23 +1216,37 @@ public static boolean isFile(final File file) {
               
                   /**
                    * 检查两个文件是否是同一个文件
              -     * 所谓文件相同,是指File对象是否指向同一个文件或文件夹
              +     * 所谓文件相同,是指File对象是否指向同一个文件或文件夹,规则为:
              +     * 
                + *
              • 当两个文件都为{@code null}时,返回{@code true}
              • + *
              • 当两个文件都存在时,检查是否为同一个文件
              • + *
              • 当两个文件都不存在时,检查路径是否一致
              • + *
              * - * @param file1 文件1 - * @param file2 文件2 + * @param file1 文件1,可以为{@code null} + * @param file2 文件2,可以为{@code null} * @return 是否相同 - * @throws InternalException IO异常 */ - public static boolean equals(final File file1, final File file2) throws InternalException { - Assert.notNull(file1); - Assert.notNull(file2); - if (!file1.exists() || !file2.exists()) { - // 两个文件都不存在判断其路径是否相同, 对于一个存在一个不存在的情况,一定不相同 - return !file1.exists()// - && !file2.exists()// - && pathEquals(file1, file2); + public static boolean equals(final File file1, final File file2) { + // 两者都为null判定为相同 + if (null == file1 || null == file2) { + return null == file1 && null == file2; } - return equals(file1.toPath(), file2.toPath()); + + final boolean exists1 = file1.exists(); + final boolean exists2 = file2.exists(); + + // 当两个文件都存在时,检查是否为同一个文件 + if (exists1 && exists2) { + return PathResolve.isSameFile(file1.toPath(), file2.toPath()); + } + + // 都不存在时,检查路径是否相同 + if (!exists1 && !exists2) { + return pathEquals(file1, file2); + } + + return false; } /** @@ -2532,7 +2543,6 @@ public static File getParent(final File file, final int level) { /** * 检查父完整路径是否为自路径的前半部分,如果不是说明不是子路径,可能存在slip注入。 - *

              * 见http://blog.nsfocus.net/zip-slip-2/ * * @param parentFile 父文件或目录 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/HexKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/HexKit.java index c0603e32f0..6e1ffff250 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/HexKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/HexKit.java @@ -39,7 +39,6 @@ * 十六进制(简写为hex或下标16)在数学中是一种逢16进1的进位制,一般用数字0到9和字母A到F表示(其中:A~F即10~15)。 * 例如十进制数57,在二进制写作111001,在16进制写作39。 * 像java,c这样的语言为了区分十六进制和十进制数值,会在十六进制数的前面加上 0x,比如0x20是十进制的32,而不是十进制的20 - *

              * 此工具类为16进制组合工具类,除了继承{@link Hex}实现编码解码外,提供其它转换类和识别类工具。 * * @author Kimi Liu diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/IoKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/IoKit.java index 5c5bda22f9..364223aa38 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/IoKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/IoKit.java @@ -865,6 +865,18 @@ public static void flush(final Flushable flushable) { } } + /** + * 尝试关闭指定对象 + * 判断对象如果实现了{@link AutoCloseable},则调用之 + * + * @param obj 可关闭对象 + */ + public static void close(final Object obj) { + if (obj instanceof AutoCloseable) { + closeQuietly((AutoCloseable) obj); + } + } + /** * 关闭 * 关闭失败不会抛出异常 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/IteratorKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/IteratorKit.java index 090637d102..2abdfa279b 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/IteratorKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/IteratorKit.java @@ -465,7 +465,6 @@ public static Map toMap(final Iterable iterable, final Functi /** * Enumeration转换为Iterator - *

              * Adapt the specified {@code Enumeration} to the {@code Iterator} interface * * @param 集合元素类型 @@ -720,7 +719,44 @@ public static int size(final Iterator iterator) { } /** - *

              判断两个{@link Iterable}中的元素与其顺序是否相同 + * 判断subIter是否为iter的子集合,不考虑顺序,只考虑元素数量。 + *

                + *
              • 如果两个集合为同一集合或,则返回true
              • + *
              • 如果两个集合元素都相同,则返回true(无论顺序相同与否)
              • + *
              + * + * @param subIter 第一个Iterable对象,即子集合。 + * @param iter 第二个Iterable对象,可以为任何实现了Iterable接口的集合。 + * @return 如果subIter是iter的子集合,则返回true;否则返回false。 + */ + public static boolean isSub(final Iterable subIter, final Iterable iter) { + // 如果两个Iterable对象引用相同,则肯定是一个的子集合 + if (subIter == iter) { + return true; + } + // 如果有任何一个Iterable对象为null,则不是子集合关系 + if (subIter == null || iter == null) { + return false; + } + + // 使用Map记录每个Iterable中每个元素出现的次数 + final Map countMap1 = countMap(subIter.iterator()); + final Map countMap2 = countMap(iter.iterator()); + + // 遍历第一个Iterable中的每个元素 + for (final Object obj : subIter) { + // 比较第一个Iterable中元素的出现次数和第二个Iterable中元素的出现次数 + // 如果第一个Iterable中元素的出现次数大于第二个Iterable中元素的出现次数,则不是子集合关系 + if (MathKit.nullToZero(countMap1.get(obj)) > MathKit.nullToZero(countMap2.get(obj))) { + return false; + } + } + // 如果所有元素的出现次数比较都满足子集合关系,则返回true + return true; + } + + /** + * 判断两个{@link Iterable}中的元素与其顺序是否相同 * 当满足下列情况时返回{@code true}: *
                *
              • 两个{@link Iterable}都为{@code null};
              • @@ -734,25 +770,66 @@ public static int size(final Iterator iterator) { * @return 是否相同 */ public static boolean isEqualList(final Iterable iterable1, final Iterable iterable2) { + return equals(iterable1, iterable2, false); + } + + /** + * 判断两个{@link Iterable}中的元素是否相同,可选是否判断顺序 + * 当满足下列情况时返回{@code true}: + *
                  + *
                • 两个{@link Iterable}都为{@code null};
                • + *
                • 两个{@link Iterable}满足{@code iterable1 == iterable2};
                • + *
                • 如果忽略顺序,则计算两个集合中元素和数量是否相同
                • + *
                • 如果不忽略顺序,两个{@link Iterable}所有具有相同下标的元素皆满足{@link Objects#equals(Object, Object)};
                • + *
                + * + * @param iterable1 集合1 + * @param iterable2 集合2 + * @param ignoreOrder 是否忽略顺序 + * @return 是否相同 + */ + public static boolean equals(final Iterable iterable1, final Iterable iterable2, final boolean ignoreOrder) { + // 如果两个Iterable对象引用相同,则肯定相等 if (iterable1 == iterable2) { return true; } + // 如果有任何一个Iterable对象为null,则不是子集合关系 if (iterable1 == null || iterable2 == null) { return false; } - final Iterator iter1 = iterable1.iterator(); - final Iterator iter2 = iterable2.iterator(); - Object obj1; - Object obj2; - while (iter1.hasNext() && iter2.hasNext()) { - obj1 = iter1.next(); - obj2 = iter2.next(); - if (!Objects.equals(obj1, obj2)) { + + if (ignoreOrder) { + final Map countMap1 = countMap(iterable1.iterator()); + final Map countMap2 = countMap(iterable2.iterator()); + + if (countMap1.size() != countMap2.size()) { + // 如果两个Iterable中元素种类不同,则肯定不等 return false; } + + for (final Object obj : iterable1) { + // 比较第一个Iterable中元素的出现次数和第二个Iterable中元素的出现次数 + if (MathKit.nullToZero(countMap1.get(obj)) != MathKit.nullToZero(countMap2.get(obj))) { + return false; + } + } + // 如果所有元素的出现次数比较都满足子集合关系,则返回true + return true; + } else { + final Iterator iter1 = iterable1.iterator(); + final Iterator iter2 = iterable2.iterator(); + Object obj1; + Object obj2; + while (iter1.hasNext() && iter2.hasNext()) { + obj1 = iter1.next(); + obj2 = iter2.next(); + if (!Objects.equals(obj1, obj2)) { + return false; + } + } + // 当两个Iterable长度不一致时返回false + return !(iter1.hasNext() || iter2.hasNext()); } - // 当两个Iterable长度不一致时返回false - return !(iter1.hasNext() || iter2.hasNext()); } /** diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/KotlinKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/KotlinKit.java index 69012c5756..5eda856e08 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/KotlinKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/KotlinKit.java @@ -30,9 +30,9 @@ import org.miaixz.bus.core.beans.copier.ValueProvider; import org.miaixz.bus.core.beans.copier.provider.MapValueProvider; import org.miaixz.bus.core.lang.Optional; -import org.miaixz.bus.core.lang.reflect.kotlin.KotlinCallable; -import org.miaixz.bus.core.lang.reflect.kotlin.KotlinClassImpl; -import org.miaixz.bus.core.lang.reflect.kotlin.KotlinParameter; +import org.miaixz.bus.core.lang.reflect.kotlin.KCallable; +import org.miaixz.bus.core.lang.reflect.kotlin.KClassImpl; +import org.miaixz.bus.core.lang.reflect.kotlin.KParameter; import java.lang.annotation.Annotation; import java.util.List; @@ -72,7 +72,7 @@ public static boolean isKotlinClass(final Class clazz) { * @return 构造列表 */ public static List getConstructors(final Class targetType) { - return KotlinClassImpl.getConstructors(targetType); + return KClassImpl.getConstructors(targetType); } /** @@ -81,8 +81,8 @@ public static List getConstructors(final Class targetType) { * @param kCallable kotlin的类、方法或构造 * @return 参数列表 */ - public static List getParameters(final Object kCallable) { - return KotlinCallable.getParameters(kCallable); + public static List getParameters(final Object kCallable) { + return KCallable.getParameters(kCallable); } /** @@ -93,9 +93,9 @@ public static List getParameters(final Object kCallable) { * @return 参数数组 */ public static Object[] getParameterValues(final Object kCallable, final ValueProvider valueProvider) { - final List parameters = getParameters(kCallable); + final List parameters = getParameters(kCallable); final Object[] args = new Object[parameters.size()]; - KotlinParameter kParameter; + KParameter kParameter; for (int i = 0; i < parameters.size(); i++) { kParameter = parameters.get(i); args[i] = valueProvider.value(kParameter.getName(), kParameter.getType()); @@ -129,7 +129,7 @@ public static T newInstance(final Class targetType, final ValueProvider *

                * 表示的不是0.1而是0.1000000000000000055511151231257827021181583404541015625 + *

                * *

                * 这是因为0.1无法准确的表示为double。因此应该使用new BigDecimal(String)。 diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/NetKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/NetKit.java index 7a4dbdf2da..9136eb284b 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/NetKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/NetKit.java @@ -383,7 +383,6 @@ public static LinkedHashSet localAddressList(final Predicate * 参考: * http://stackoverflow.com/questions/9481865/getting-the-ip-address-of-the-current-machine-using-java * @@ -408,7 +407,7 @@ public static String getLocalhostStringV4() { * *

                * 此方法不会抛出异常,获取失败将返回{@code null} - *

                + *

                * * @return 本机网卡IP地址,获取失败返回{@code null} */ diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ObjectKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ObjectKit.java index d77717bc74..aff5277836 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ObjectKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ObjectKit.java @@ -42,7 +42,6 @@ /** * 对象工具类,包括判空、克隆、序列化等操作 - *

                * 原数组相关操作见:{@link ArrayKit#hasBlank(CharSequence...)}、{@link ArrayKit#isAllBlank(CharSequence...)}等等 * * @author Kimi Liu diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/RandomKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/RandomKit.java index c2771ccf95..5bdd6532e2 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/RandomKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/RandomKit.java @@ -100,6 +100,7 @@ public static SecureRandom getSecureRandom() { * *

                * 相关说明见:how-to-solve-slow-java-securerandom + *

                * * @param seed 随机数种子 * @return {@link SecureRandom} @@ -116,6 +117,7 @@ public static SecureRandom getSecureRandom(final byte[] seed) { * *

                * 相关说明见:how-to-solve-slow-java-securerandom + *

                * * @param seed 随机数种子 * @return {@link SecureRandom} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ReflectKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ReflectKit.java index 0971576a79..d5e5c52e1d 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ReflectKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ReflectKit.java @@ -56,7 +56,6 @@ *
              • 移除final属性
              • *
              • {@code ReflectKit.removeFinalModify(Field)} --p {@link ModifierKit#removeFinalModify(Field)}
              • *
              - *

              * 在字节码中,类型表示如下: *

                *
              • byte = B
              • diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/RuntimeKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/RuntimeKit.java index 1c396d849f..58a4e803a4 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/RuntimeKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/RuntimeKit.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.core.xyz; -import org.miaixz.bus.core.data.Pid; +import org.miaixz.bus.core.data.id.Pid; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/SPIKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/SPIKit.java index 202bac8ed9..eff2891b46 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/SPIKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/SPIKit.java @@ -36,7 +36,6 @@ /** * 服务提供接口SPI(Service Provider interface)相关类 - *

                * SPI机制中的服务加载工具类,流程如下 * *

                diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/StreamKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/StreamKit.java
                index face0b6b7e..d1785874a4 100644
                --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/StreamKit.java
                +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/StreamKit.java
                @@ -234,7 +234,7 @@ public static  Stream iterate(final T seed, final Predicate has
                     }
                 
                     /**
                -     * 

                指定一个层级结构的根节点(通常是树或图), + * 指定一个层级结构的根节点(通常是树或图), * 然后获取包含根节点在内,根节点所有层级结构中的节点组成的流。 * 该方法用于以平铺的方式按广度优先对图或树节点进行访问,可以使用并行流提高效率。 * @@ -261,7 +261,7 @@ public static Stream iterateHierarchies( } /** - *

                指定一个层级结构的根节点(通常是树或图), + * 指定一个层级结构的根节点(通常是树或图), * 然后获取包含根节点在内,根节点所有层级结构中的节点组成的流。 * 该方法用于以平铺的方式按广度优先对图或树节点进行访问,可以使用并行流提高效率。 * diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ThreadKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ThreadKit.java index 40ba271aeb..6c18b78524 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/ThreadKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/ThreadKit.java @@ -127,8 +127,10 @@ public static ExecutorService newExecutor(final int corePoolSize, final int maxi * 传入阻塞系数,线程池的大小计算公式为:CPU可用核心数 / (1 - 阻塞因子) * Blocking Coefficient(阻塞系数) = 阻塞时间/(阻塞时间+使用CPU的时间) * 计算密集型任务的阻塞系数为0,而IO密集型任务的阻塞系数则接近于1。 + * *

                * see: http://blog.csdn.net/partner4java/article/details/9417663 + *

                * * @param blockingCoefficient 阻塞系数,阻塞因子介于0~1之间的数,阻塞因子越大,线程池中的线程数越多。 * @return {@link ThreadPoolExecutor} @@ -297,7 +299,6 @@ public static CompletionService newCompletionService(final ExecutorServic * System.out.println("【主线程】所有同学都离开了教室,开始锁教室大门了。"); * } *
                - *

                * 该示例,也可以用:{@link Phaser} 移相器 进行实现 * * @param taskCount 任务数量 @@ -655,8 +656,7 @@ public static Thread getMainThread() { * @return 线程组 */ public static ThreadGroup currentThreadGroup() { - final SecurityManager s = System.getSecurityManager(); - return (null != s) ? s.getThreadGroup() : Thread.currentThread().getThreadGroup(); + return Thread.currentThread().getThreadGroup(); } /** diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/TreeKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/TreeKit.java index 8f97603527..2886405e72 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/TreeKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/TreeKit.java @@ -221,8 +221,6 @@ public static MapTree getNode(final MapTree node, final T id) { /** * 获取所有父节点名称列表 - * - *

                * 比如有个人在研发1部,他上面有研发部,接着上面有技术中心 * 返回结果就是:[研发一部, 研发中心, 技术中心] * @@ -237,8 +235,6 @@ public static List getParentsName(final MapTree node, final /** * 获取所有父节点ID列表 - * - *

                * 比如有个人在研发1部,他上面有研发部,接着上面有技术中心 * 返回结果就是:[研发部, 技术中心] * diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/TypeKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/TypeKit.java index bd175252a5..bf5e6ee8d5 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/TypeKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/TypeKit.java @@ -528,12 +528,10 @@ public static Type getTypeArgument(final Type type, final int index) { /** * 获得指定类型中所有泛型参数类型,例如: - * *

                      * class A<T>
                      * class B extends A<String>
                      * 
                - *

                * 通过此方法,传入B.class即可得到String * * @param type 指定类型 @@ -716,12 +714,10 @@ public static Type getClosestParentType(final Class cls, final Class super * 将{@link Type} 转换为{@link ParameterizedType} * {@link ParameterizedType}用于获取当前类或父类中泛型参数化后的类型 * 一般用于获取泛型参数具体的参数类型,例如: - * *

                      * class A<T>
                      * class B extends A<String>
                      * 
                - *

                * 通过此方法,传入B.class即可得到B{@link ParameterizedType},从而获取到String * * @param type {@link Type} diff --git a/bus-core/src/main/java/org/miaixz/bus/core/xyz/UrlKit.java b/bus-core/src/main/java/org/miaixz/bus/core/xyz/UrlKit.java index 3eedaf9b54..369b89a319 100644 --- a/bus-core/src/main/java/org/miaixz/bus/core/xyz/UrlKit.java +++ b/bus-core/src/main/java/org/miaixz/bus/core/xyz/UrlKit.java @@ -521,8 +521,6 @@ public static String buildQuery(final Map paramMap, final java.nio.ch /** * Data URI Scheme封装,数据格式为Base64。data URI scheme 允许我们使用内联(inline-code)的方式在网页中包含数据, * 目的是将一些小的数据,直接嵌入到网页中,从而不用再从外部文件载入。常用于将图片嵌入网页。 - * - *

                * Data URI的格式规范: *

                      *     data:[<mime type>][;charset=<charset>][;<encoding>],<encoded data>
                @@ -539,8 +537,6 @@ public static String getDataUriBase64(final String mimeType, final String data)
                     /**
                      * Data URI Scheme封装。data URI scheme 允许我们使用内联(inline-code)的方式在网页中包含数据,
                      * 目的是将一些小的数据,直接嵌入到网页中,从而不用再从外部文件载入。常用于将图片嵌入网页。
                -     *
                -     * 

                * Data URI的格式规范: *

                      *     data:[<mime type>][;charset=<charset>][;<encoding>],<encoded data>
                @@ -558,8 +554,6 @@ public static String getDataUri(final String mimeType, final String encoding, fi
                     /**
                      * Data URI Scheme封装。data URI scheme 允许我们使用内联(inline-code)的方式在网页中包含数据,
                      * 目的是将一些小的数据,直接嵌入到网页中,从而不用再从外部文件载入。常用于将图片嵌入网页。
                -     *
                -     * 

                * Data URI的格式规范: *

                      *     data:[<mime type>][;charset=<charset>][;<encoding>],<encoded data>
                diff --git a/bus-cron/pom.xml b/bus-cron/pom.xml
                index 6c070f4653..59c877dc51 100755
                --- a/bus-cron/pom.xml
                +++ b/bus-cron/pom.xml
                @@ -33,7 +33,7 @@
                 
                     org.miaixz
                     bus-cron
                -    8.0.2
                +    8.0.5
                     jar
                 
                     ${project.artifactId}
                @@ -105,54 +105,44 @@
                                     
                                 
                             
                +            
                +                org.apache.maven.plugins
                +                maven-source-plugin
                +                3.3.1
                +                
                +                    
                +                        attach-sources
                +                        
                +                            jar-no-fork
                +                        
                +                    
                +                
                +            
                +            
                +                org.apache.maven.plugins
                +                maven-gpg-plugin
                +                3.2.3
                +                
                +                    
                +                        sonatype-nexus-staging
                +                        verify
                +                        
                +                            sign
                +                        
                +                    
                +                
                +            
                +            
                +                org.sonatype.central
                +                central-publishing-maven-plugin
                +                0.5.0
                +                true
                +                
                +                    central
                +                    true
                +                
                +            
                         
                     
                 
                -    
                -        
                -            release
                -            
                -                
                -                    
                -                        org.apache.maven.plugins
                -                        maven-source-plugin
                -                        3.3.1
                -                        
                -                            
                -                                attach-sources
                -                                
                -                                    jar-no-fork
                -                                
                -                            
                -                        
                -                    
                -                    
                -                        org.apache.maven.plugins
                -                        maven-gpg-plugin
                -                        3.2.3
                -                        
                -                            
                -                                sonatype-nexus-staging
                -                                verify
                -                                
                -                                    sign
                -                                
                -                            
                -                        
                -                    
                -                    
                -                        org.sonatype.central
                -                        central-publishing-maven-plugin
                -                        0.4.0
                -                        true
                -                        
                -                            central
                -                            true
                -                        
                -                    
                -                
                -            
                -        
                -    
                -
                 
                diff --git a/bus-cron/src/main/java/org/miaixz/bus/cron/Scheduler.java b/bus-cron/src/main/java/org/miaixz/bus/cron/Scheduler.java
                index 6f9ed1395f..d3c76c68c3 100644
                --- a/bus-cron/src/main/java/org/miaixz/bus/cron/Scheduler.java
                +++ b/bus-cron/src/main/java/org/miaixz/bus/cron/Scheduler.java
                @@ -27,7 +27,7 @@
                  */
                 package org.miaixz.bus.cron;
                 
                -import org.miaixz.bus.core.data.ID;
                +import org.miaixz.bus.core.data.id.ID;
                 import org.miaixz.bus.core.lang.Symbol;
                 import org.miaixz.bus.core.lang.exception.CrontabException;
                 import org.miaixz.bus.core.lang.thread.ExecutorBuilder;
                @@ -273,7 +273,7 @@ public String schedule(final String pattern, final Runnable task) {
                      * @return ID
                      */
                     public String schedule(final String pattern, final Crontab crontab) {
                -        final String id = ID.fastUUID();
                +        final String id = ID.objectId();
                         schedule(id, pattern, crontab);
                         return id;
                     }
                diff --git a/bus-crypto/pom.xml b/bus-crypto/pom.xml
                index 86ebc4a6c5..04313e2e13 100755
                --- a/bus-crypto/pom.xml
                +++ b/bus-crypto/pom.xml
                @@ -33,7 +33,7 @@
                 
                     org.miaixz
                     bus-crypto
                -    8.0.2
                +    8.0.5
                     jar
                 
                     ${project.artifactId}
                @@ -119,54 +119,44 @@
                                     
                                 
                             
                +            
                +                org.apache.maven.plugins
                +                maven-source-plugin
                +                3.3.1
                +                
                +                    
                +                        attach-sources
                +                        
                +                            jar-no-fork
                +                        
                +                    
                +                
                +            
                +            
                +                org.apache.maven.plugins
                +                maven-gpg-plugin
                +                3.2.3
                +                
                +                    
                +                        sonatype-nexus-staging
                +                        verify
                +                        
                +                            sign
                +                        
                +                    
                +                
                +            
                +            
                +                org.sonatype.central
                +                central-publishing-maven-plugin
                +                0.5.0
                +                true
                +                
                +                    central
                +                    true
                +                
                +            
                         
                     
                 
                -    
                -        
                -            release
                -            
                -                
                -                    
                -                        org.apache.maven.plugins
                -                        maven-source-plugin
                -                        3.3.1
                -                        
                -                            
                -                                attach-sources
                -                                
                -                                    jar-no-fork
                -                                
                -                            
                -                        
                -                    
                -                    
                -                        org.apache.maven.plugins
                -                        maven-gpg-plugin
                -                        3.2.3
                -                        
                -                            
                -                                sonatype-nexus-staging
                -                                verify
                -                                
                -                                    sign
                -                                
                -                            
                -                        
                -                    
                -                    
                -                        org.sonatype.central
                -                        central-publishing-maven-plugin
                -                        0.4.0
                -                        true
                -                        
                -                            central
                -                            true
                -                        
                -                    
                -                
                -            
                -        
                -    
                -
                 
                diff --git a/bus-crypto/src/main/java/org/miaixz/bus/crypto/Builder.java b/bus-crypto/src/main/java/org/miaixz/bus/crypto/Builder.java
                index 0e4fa9923c..a77a369039 100644
                --- a/bus-crypto/src/main/java/org/miaixz/bus/crypto/Builder.java
                +++ b/bus-crypto/src/main/java/org/miaixz/bus/crypto/Builder.java
                @@ -174,33 +174,35 @@ public static DES des(final byte[] key) {
                     }
                 
                     /**
                -     * DESede加密(又名3DES、TripleDES),生成随机KEY。注意解密时必须使用相同 {@link TDEA}对象或者使用相同KEY
                +     * 三重数据加密算法,缩写为TDEA(又名3DES、TripleDES),生成随机KEY。
                +     * 注意解密时必须使用相同 {@link TDEA}对象或者使用相同KEY
                      * Java中默认实现为:DESede/ECB/PKCS5Padding
                      * 例:
                      * 
                -     * DESede加密:desede().encrypt(data)
                -     * DESede解密:desede().decrypt(data)
                +     * DESede加密:tdea().encrypt(data)
                +     * DESede解密:tdea().decrypt(data)
                      * 
                * * @return {@link TDEA} */ - public static TDEA desede() { + public static TDEA tdea() { return new TDEA(); } /** - * DESede加密(又名3DES、TripleDES) + * 三重数据加密算法,缩写为TDEA(又名3DES、TripleDES),生成随机KEY。 + * 注意解密时必须使用相同 {@link TDEA}对象或者使用相同KEY * Java中默认实现为:DESede/ECB/PKCS5Padding * 例: *
                -     * DESede加密:desede(data).encrypt(data)
                -     * DESede解密:desede(data).decrypt(data)
                +     * DESede加密:tdea(data).encrypt(data)
                +     * DESede解密:tdea(data).decrypt(data)
                      * 
                * * @param key 密钥 * @return {@link TDEA} */ - public static TDEA desede(final byte[] key) { + public static TDEA tdea(final byte[] key) { return new TDEA(key); } @@ -679,7 +681,7 @@ public static FPE fpe(final FPE.FPEMode mode, final byte[] key, final AlphabetMa * @return {@link ZUC} */ public static ZUC zuc128(final byte[] key, final byte[] iv) { - return new ZUC(ZUC.ZUCAlgorithm.ZUC_128, key, iv); + return new ZUC(Algorithm.ZUC_128, key, iv); } /** @@ -690,7 +692,7 @@ public static ZUC zuc128(final byte[] key, final byte[] iv) { * @return {@link ZUC} */ public static ZUC zuc256(final byte[] key, final byte[] iv) { - return new ZUC(ZUC.ZUCAlgorithm.ZUC_256, key, iv); + return new ZUC(Algorithm.ZUC_256, key, iv); } /** diff --git a/bus-crypto/src/main/java/org/miaixz/bus/crypto/builtin/Certificate.java b/bus-crypto/src/main/java/org/miaixz/bus/crypto/builtin/Certificate.java index 98ea7d873a..d12901c8fa 100644 --- a/bus-crypto/src/main/java/org/miaixz/bus/crypto/builtin/Certificate.java +++ b/bus-crypto/src/main/java/org/miaixz/bus/crypto/builtin/Certificate.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.crypto.builtin; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.bouncycastle.asn1.ASN1EncodableVector; import org.bouncycastle.asn1.DERSequence; import org.bouncycastle.asn1.x500.X500NameBuilder; @@ -60,7 +64,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Certificate implements Serializable { diff --git a/bus-crypto/src/main/java/org/miaixz/bus/crypto/center/XXTEA.java b/bus-crypto/src/main/java/org/miaixz/bus/crypto/center/TEA.java similarity index 97% rename from bus-crypto/src/main/java/org/miaixz/bus/crypto/center/XXTEA.java rename to bus-crypto/src/main/java/org/miaixz/bus/crypto/center/TEA.java index df53014a54..9274e30f7c 100644 --- a/bus-crypto/src/main/java/org/miaixz/bus/crypto/center/XXTEA.java +++ b/bus-crypto/src/main/java/org/miaixz/bus/crypto/center/TEA.java @@ -36,13 +36,13 @@ import java.io.Serializable; /** - * XXTEA(Corrected Block Tiny Encryption Algorithm)算法实现 + * TEA(Corrected Block Tiny Encryption Algorithm)算法实现 * 来自:https://github.com/xxtea/xxtea-java * * @author Kimi Liu * @since Java 17+ */ -public class XXTEA implements Encryptor, Decryptor, Serializable { +public class TEA implements Encryptor, Decryptor, Serializable { private static final long serialVersionUID = -1L; @@ -61,7 +61,7 @@ public class XXTEA implements Encryptor, Decryptor, Serializable { * * @param key 密钥,16位 */ - public XXTEA(final byte[] key) { + public TEA(final byte[] key) { this.key = key; } diff --git a/bus-crypto/src/main/java/org/miaixz/bus/crypto/center/ZUC.java b/bus-crypto/src/main/java/org/miaixz/bus/crypto/center/ZUC.java index b0672e8da7..fd4b217e68 100644 --- a/bus-crypto/src/main/java/org/miaixz/bus/crypto/center/ZUC.java +++ b/bus-crypto/src/main/java/org/miaixz/bus/crypto/center/ZUC.java @@ -27,6 +27,7 @@ */ package org.miaixz.bus.crypto.center; +import org.miaixz.bus.core.lang.Algorithm; import org.miaixz.bus.core.xyz.RandomKit; import org.miaixz.bus.crypto.Keeper; import org.miaixz.bus.crypto.builtin.symmetric.Crypto; @@ -50,9 +51,9 @@ public class ZUC extends Crypto { * @param key 密钥 * @param iv 加盐,128位加盐是16bytes,256位是25bytes,{@code null}是随机加盐 */ - public ZUC(final ZUCAlgorithm algorithm, final byte[] key, final byte[] iv) { - super(algorithm.value, - Keeper.generateKey(algorithm.value, key), + public ZUC(final Algorithm algorithm, final byte[] key, final byte[] iv) { + super(algorithm.getValue(), + Keeper.generateKey(algorithm.getValue(), key), generateIvParam(algorithm, iv)); } @@ -63,8 +64,8 @@ public ZUC(final ZUCAlgorithm algorithm, final byte[] key, final byte[] iv) { * @return 密钥 * @see Keeper#generateKey(String) */ - public static byte[] generateKey(final ZUCAlgorithm algorithm) { - return Keeper.generateKey(algorithm.value).getEncoded(); + public static byte[] generateKey(final Algorithm algorithm) { + return Keeper.generateKey(algorithm.getValue()).getEncoded(); } /** @@ -74,7 +75,7 @@ public static byte[] generateKey(final ZUCAlgorithm algorithm) { * @param iv 加盐,128位加盐是16bytes,256位是25bytes,{@code null}是随机加盐 * @return {@link IvParameterSpec} */ - private static IvParameterSpec generateIvParam(final ZUCAlgorithm algorithm, byte[] iv) { + private static IvParameterSpec generateIvParam(final Algorithm algorithm, byte[] iv) { if (null == iv) { switch (algorithm) { case ZUC_128: @@ -88,38 +89,4 @@ private static IvParameterSpec generateIvParam(final ZUCAlgorithm algorithm, byt return new IvParameterSpec(iv); } - /** - * ZUC类型,包括128位和256位 - */ - public enum ZUCAlgorithm { - /** - * ZUC-128 - */ - ZUC_128("ZUC-128"), - /** - * ZUC-256 - */ - ZUC_256("ZUC-256"); - - private final String value; - - /** - * 构造 - * - * @param value 算法的字符串表示,区分大小写 - */ - ZUCAlgorithm(final String value) { - this.value = value; - } - - /** - * 获得算法的字符串表示形式 - * - * @return 算法字符串 - */ - public String getValue() { - return this.value; - } - } - } diff --git a/bus-extra/pom.xml b/bus-extra/pom.xml index 2c0157f342..2e3f8e75a6 100644 --- a/bus-extra/pom.xml +++ b/bus-extra/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-extra - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -404,54 +404,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/captcha/CaptchaBuilder.java b/bus-extra/src/main/java/org/miaixz/bus/extra/captcha/CaptchaBuilder.java index 7691f806b1..53fdec8fa0 100644 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/captcha/CaptchaBuilder.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/captcha/CaptchaBuilder.java @@ -47,7 +47,7 @@ public class CaptchaBuilder { * @param height 图片高 * @return {@link LineProvider} */ - public static LineProvider ofLineCaptcha(final int width, final int height) { + public static LineProvider ofLine(final int width, final int height) { return new LineProvider(width, height); } @@ -60,7 +60,7 @@ public static LineProvider ofLineCaptcha(final int width, final int height) { * @param lineCount 干扰线条数 * @return {@link LineProvider} */ - public static LineProvider ofLineCaptcha(final int width, final int height, final int codeCount, final int lineCount) { + public static LineProvider ofLine(final int width, final int height, final int codeCount, final int lineCount) { return new LineProvider(width, height, codeCount, lineCount); } @@ -74,8 +74,8 @@ public static LineProvider ofLineCaptcha(final int width, final int height, fina * @param sizeBaseHeight 字体的大小 高度的倍数 * @return {@link LineProvider} */ - public static LineProvider ofLineCaptcha(final int width, final int height, final int codeCount, - final int lineCount, final float sizeBaseHeight) { + public static LineProvider ofLine(final int width, final int height, final int codeCount, + final int lineCount, final float sizeBaseHeight) { return new LineProvider(width, height, codeCount, lineCount, sizeBaseHeight); } @@ -86,7 +86,7 @@ public static LineProvider ofLineCaptcha(final int width, final int height, fina * @param height 图片高 * @return {@link CircleProvider} */ - public static CircleProvider ofCircleCaptcha(final int width, final int height) { + public static CircleProvider ofCircle(final int width, final int height) { return new CircleProvider(width, height); } @@ -99,7 +99,7 @@ public static CircleProvider ofCircleCaptcha(final int width, final int height) * @param circleCount 干扰圆圈条数 * @return {@link CircleProvider} */ - public static CircleProvider ofCircleCaptcha(final int width, final int height, final int codeCount, final int circleCount) { + public static CircleProvider ofCircle(final int width, final int height, final int codeCount, final int circleCount) { return new CircleProvider(width, height, codeCount, circleCount); } @@ -113,8 +113,8 @@ public static CircleProvider ofCircleCaptcha(final int width, final int height, * @param size 字体的大小 高度的倍数 * @return {@link CircleProvider} */ - public static CircleProvider ofCircleCaptcha(final int width, final int height, final int codeCount, - final int circleCount, final float size) { + public static CircleProvider ofCircle(final int width, final int height, final int codeCount, + final int circleCount, final float size) { return new CircleProvider(width, height, codeCount, circleCount, size); } @@ -125,7 +125,7 @@ public static CircleProvider ofCircleCaptcha(final int width, final int height, * @param height 图片高 * @return {@link ShearProvider} */ - public static ShearProvider ofShearCaptcha(final int width, final int height) { + public static ShearProvider ofShear(final int width, final int height) { return new ShearProvider(width, height); } @@ -138,7 +138,7 @@ public static ShearProvider ofShearCaptcha(final int width, final int height) { * @param thickness 干扰线宽度 * @return {@link ShearProvider} */ - public static ShearProvider ofShearCaptcha(final int width, final int height, final int codeCount, final int thickness) { + public static ShearProvider ofShear(final int width, final int height, final int codeCount, final int thickness) { return new ShearProvider(width, height, codeCount, thickness); } @@ -152,7 +152,7 @@ public static ShearProvider ofShearCaptcha(final int width, final int height, fi * @param sizeBaseHeight 字体的大小 高度的倍数 * @return {@link ShearProvider} */ - public static ShearProvider ofShearCaptcha(final int width, final int height, final int codeCount, final int thickness, final float sizeBaseHeight) { + public static ShearProvider ofShear(final int width, final int height, final int codeCount, final int thickness, final float sizeBaseHeight) { return new ShearProvider(width, height, codeCount, thickness, sizeBaseHeight); } @@ -163,7 +163,7 @@ public static ShearProvider ofShearCaptcha(final int width, final int height, fi * @param height 高 * @return {@link GifProvider} */ - public static GifProvider ofGifCaptcha(final int width, final int height) { + public static GifProvider ofGif(final int width, final int height) { return new GifProvider(width, height); } @@ -175,7 +175,7 @@ public static GifProvider ofGifCaptcha(final int width, final int height) { * @param codeCount 字符个数 * @return {@link GifProvider} */ - public static GifProvider ofGifCaptcha(final int width, final int height, final int codeCount) { + public static GifProvider ofGif(final int width, final int height, final int codeCount) { return new GifProvider(width, height, codeCount); } @@ -189,8 +189,8 @@ public static GifProvider ofGifCaptcha(final int width, final int height, final * @param sizeBaseHeight 字体的大小 高度的倍数 * @return {@link GifProvider} */ - public static GifProvider ofGifCaptcha(final int width, final int height, final int codeCount, - final int thickness, final float sizeBaseHeight) { + public static GifProvider ofGif(final int width, final int height, final int codeCount, + final int thickness, final float sizeBaseHeight) { return new GifProvider(width, height, codeCount, thickness, sizeBaseHeight); } diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/pinyin/PinyinFactory.java b/bus-extra/src/main/java/org/miaixz/bus/extra/pinyin/PinyinFactory.java index 62edbb12ab..3c3f457839 100644 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/pinyin/PinyinFactory.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/pinyin/PinyinFactory.java @@ -44,13 +44,13 @@ public class PinyinFactory { /** - * 获得单例的PinyinEngine + * 获得单例 * - * @return 单例的PinyinEngine + * @return 单例 */ - public static PinyinProvider getEngine() { - final PinyinProvider engine = Instances.get(PinyinProvider.class.getName(), PinyinFactory::createEngine); - Logger.debug("Use [{}] Pinyin Engine As Default.", StringKit.removeSuffix(engine.getClass().getSimpleName(), "Engine")); + public static PinyinProvider get() { + final PinyinProvider engine = Instances.get(PinyinProvider.class.getName(), PinyinFactory::create); + Logger.debug("Use [{}] Pinyin Provider As Default.", StringKit.removeSuffix(engine.getClass().getSimpleName(), "Engine")); return engine; } @@ -60,28 +60,28 @@ public static PinyinProvider getEngine() { * * @return {@link PinyinProvider} */ - public static PinyinProvider createEngine() { - return doCreateEngine(); + public static PinyinProvider create() { + return doCreate(); } /** * 创建自定义引擎 * - * @param engineName 引擎名称,忽略大小写,如`Bopomofo4j`、`Houbb`、`JPinyin`、`Pinyin4j`、`TinyPinyin` + * @param name 引擎名称,忽略大小写,如`Bopomofo4j`、`Houbb`、`JPinyin`、`Pinyin4j`、`TinyPinyin` * @return 引擎 * @throws InternalException 无对应名称的引擎 */ - public static PinyinProvider createEngine(String engineName) throws InternalException { - if (!StringKit.endWithIgnoreCase(engineName, "Engine")) { - engineName = engineName + "Engine"; + public static PinyinProvider create(String name) throws InternalException { + if (!StringKit.endWithIgnoreCase(name, "Provider")) { + name = name + "Provider"; } final ServiceLoader list = SPIKit.loadList(PinyinProvider.class); for (final String serviceName : list.getServiceNames()) { - if (StringKit.endWithIgnoreCase(serviceName, engineName)) { + if (StringKit.endWithIgnoreCase(serviceName, name)) { return list.getService(serviceName); } } - throw new InternalException("No such engine named: " + engineName); + throw new InternalException("No such engine named: " + name); } /** @@ -90,7 +90,7 @@ public static PinyinProvider createEngine(String engineName) throws InternalExce * * @return {@link PinyinProvider} */ - private static PinyinProvider doCreateEngine() { + private static PinyinProvider doCreate() { final PinyinProvider engine = SPIKit.loadFirstAvailable(PinyinProvider.class); if (null != engine) { return engine; diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/pinyin/PinyinKit.java b/bus-extra/src/main/java/org/miaixz/bus/extra/pinyin/PinyinKit.java index c448e95513..674fdd69a0 100644 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/pinyin/PinyinKit.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/pinyin/PinyinKit.java @@ -46,7 +46,7 @@ public class PinyinKit { * @return {@link PinyinProvider} */ public static PinyinProvider createEngine(final String engineName) { - return PinyinFactory.createEngine(engineName); + return PinyinFactory.create(engineName); } /** @@ -55,7 +55,7 @@ public static PinyinProvider createEngine(final String engineName) { * @return 全局单例的拼音引擎 */ public static PinyinProvider getEngine() { - return PinyinFactory.getEngine(); + return PinyinFactory.get(); } /** diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateConfig.java b/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateConfig.java index 9b9e5094c1..65a8d3687d 100644 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateConfig.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateConfig.java @@ -61,7 +61,7 @@ public class TemplateConfig implements Serializable { /** * 自定义引擎,当多个jar包引入时,可以自定使用的默认引擎 */ - private Class customEngine; + private Class provider; /** * 默认构造,使用UTF8编码,默认从ClassPath获取模板 @@ -173,19 +173,19 @@ public void setResourceMode(final ResourceMode resourceMode) { * * @return 自定义引擎,null表示系统自动判断 */ - public Class getCustomEngine() { - return customEngine; + public Class getProvider() { + return provider; } /** * 设置自定义引擎,null表示系统自动判断 * - * @param customEngine 自定义引擎,null表示系统自动判断 + * @param provider 自定义引擎,null表示系统自动判断 * @return this */ - public TemplateConfig setCustomEngine(final Class customEngine) { - this.customEngine = customEngine; + public TemplateConfig setProvider(final Class provider) { + this.provider = provider; return this; } @@ -201,12 +201,12 @@ public boolean equals(final Object o) { return Objects.equals(charset, that.charset) && Objects.equals(path, that.path) && resourceMode == that.resourceMode && - Objects.equals(customEngine, that.customEngine); + Objects.equals(provider, that.provider); } @Override public int hashCode() { - return Objects.hash(charset, path, resourceMode, customEngine); + return Objects.hash(charset, path, resourceMode, provider); } /** diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateFactory.java b/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateFactory.java index b17c862628..38efe2e83f 100644 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateFactory.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateFactory.java @@ -45,12 +45,12 @@ public class TemplateFactory { /** * 根据用户引入的模板引擎jar,自动创建对应的模板引擎对象 - * 获得的是单例的TemplateEngine + * 获得的是单例 * - * @return 单例的TemplateEngine + * @return 单例 */ - public static TemplateProvider getEngine() { - final TemplateProvider engine = Instances.get(TemplateProvider.class.getName(), TemplateFactory::createEngine); + public static TemplateProvider get() { + final TemplateProvider engine = Instances.get(TemplateProvider.class.getName(), TemplateFactory::create); Logger.debug("Use [{}] Template Engine As Default.", StringKit.removeSuffix(engine.getClass().getSimpleName(), "Engine")); return engine; } @@ -61,8 +61,8 @@ public static TemplateProvider getEngine() { * * @return {@link TemplateProvider} */ - public static TemplateProvider createEngine() { - return createEngine(TemplateConfig.DEFAULT); + public static TemplateProvider create() { + return create(TemplateConfig.DEFAULT); } /** @@ -72,8 +72,8 @@ public static TemplateProvider createEngine() { * @param config 模板配置,包括编码、模板文件path等信息 * @return {@link TemplateProvider} */ - public static TemplateProvider createEngine(final TemplateConfig config) { - return doCreateEngine(config); + public static TemplateProvider create(final TemplateConfig config) { + return doCreate(config); } /** @@ -83,8 +83,8 @@ public static TemplateProvider createEngine(final TemplateConfig config) { * @param config 模板配置,包括编码、模板文件path等信息 * @return {@link TemplateProvider} */ - private static TemplateProvider doCreateEngine(final TemplateConfig config) { - final Class customEngineClass = config.getCustomEngine(); + private static TemplateProvider doCreate(final TemplateConfig config) { + final Class customEngineClass = config.getProvider(); final TemplateProvider engine; if (null != customEngineClass) { // 自定义模板引擎 @@ -99,4 +99,5 @@ private static TemplateProvider doCreateEngine(final TemplateConfig config) { throw new InternalException("No template found! Please add one of template jar to your project !"); } + } diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateKit.java b/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateKit.java index 9abcaf1ce2..588bb6d4e3 100755 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateKit.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/template/TemplateKit.java @@ -44,7 +44,7 @@ public class TemplateKit { * @return {@link TemplateProvider} */ public static TemplateProvider getEngine() { - return TemplateFactory.getEngine(); + return TemplateFactory.get(); } /** diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/beetl/BeetlProvider.java b/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/beetl/BeetlProvider.java index 0766ec7cc5..43ef272e3c 100644 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/beetl/BeetlProvider.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/beetl/BeetlProvider.java @@ -78,7 +78,7 @@ public BeetlProvider(final GroupTemplate engine) { * @param config 模板配置 * @return {@link GroupTemplate} */ - private static GroupTemplate createEngine(TemplateConfig config) { + private static GroupTemplate create(TemplateConfig config) { if (null == config) { config = TemplateConfig.DEFAULT; } @@ -128,7 +128,7 @@ private static GroupTemplate createGroupTemplate(final ResourceLoader loader, @Override public TemplateProvider init(final TemplateConfig config) { - init(createEngine(config)); + init(create(config)); return this; } diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/freemarker/FreemarkerProvider.java b/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/freemarker/FreemarkerProvider.java index 65a7f9724b..f4ea1f66a5 100644 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/freemarker/FreemarkerProvider.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/freemarker/FreemarkerProvider.java @@ -80,7 +80,7 @@ public FreemarkerProvider(final Configuration freemarkerCfg) { * @param config 模板配置 * @return {@link Configuration } */ - private static Configuration createCfg(TemplateConfig config) { + private static Configuration create(TemplateConfig config) { if (null == config) { config = new TemplateConfig(); } @@ -122,7 +122,7 @@ public TemplateProvider init(TemplateConfig config) { if (null == config) { config = TemplateConfig.DEFAULT; } - init(createCfg(config)); + init(create(config)); return this; } diff --git a/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/thymeleaf/ThymeleafProvider.java b/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/thymeleaf/ThymeleafProvider.java index 3a8d4151e0..88861ba2b6 100644 --- a/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/thymeleaf/ThymeleafProvider.java +++ b/bus-extra/src/main/java/org/miaixz/bus/extra/template/provider/thymeleaf/ThymeleafProvider.java @@ -32,6 +32,7 @@ import org.miaixz.bus.extra.template.Template; import org.miaixz.bus.extra.template.TemplateConfig; import org.miaixz.bus.extra.template.TemplateProvider; +import org.thymeleaf.TemplateEngine; import org.thymeleaf.templatemode.TemplateMode; import org.thymeleaf.templateresolver.*; @@ -43,7 +44,7 @@ */ public class ThymeleafProvider implements TemplateProvider { - org.thymeleaf.TemplateEngine engine; + TemplateEngine engine; TemplateConfig config; /** @@ -64,9 +65,9 @@ public ThymeleafProvider(final TemplateConfig config) { /** * 构造 * - * @param engine {@link org.thymeleaf.TemplateEngine} + * @param engine {@link TemplateEngine} */ - public ThymeleafProvider(final org.thymeleaf.TemplateEngine engine) { + public ThymeleafProvider(final TemplateEngine engine) { init(engine); } @@ -76,7 +77,7 @@ public ThymeleafProvider(final org.thymeleaf.TemplateEngine engine) { * @param config 模板配置 * @return {@link TemplateProvider} */ - private static org.thymeleaf.TemplateEngine createEngine(TemplateConfig config) { + private static TemplateEngine create(TemplateConfig config) { if (null == config) { config = new TemplateConfig(); } @@ -112,7 +113,7 @@ private static org.thymeleaf.TemplateEngine createEngine(TemplateConfig config) break; } - final org.thymeleaf.TemplateEngine engine = new org.thymeleaf.TemplateEngine(); + final TemplateEngine engine = new TemplateEngine(); engine.setTemplateResolver(resolver); return engine; } @@ -123,7 +124,7 @@ public TemplateProvider init(TemplateConfig config) { config = TemplateConfig.DEFAULT; } this.config = config; - init(createEngine(config)); + init(create(config)); return this; } @@ -132,7 +133,7 @@ public TemplateProvider init(TemplateConfig config) { * * @param engine 引擎 */ - private void init(final org.thymeleaf.TemplateEngine engine) { + private void init(final TemplateEngine engine) { this.engine = engine; } @@ -147,10 +148,11 @@ public Template getTemplate(final String resource) { /** * 获取原始引擎的钩子方法,用于自定义特殊属性,如插件等 * - * @return {@link org.thymeleaf.TemplateEngine} + * @return {@link TemplateEngine} */ @Override - public org.thymeleaf.TemplateEngine getRaw() { + public TemplateEngine getRaw() { return this.engine; } + } diff --git a/bus-gitlab/pom.xml b/bus-gitlab/pom.xml index 6bcfd91bd6..96f3329907 100755 --- a/bus-gitlab/pom.xml +++ b/bus-gitlab/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-gitlab - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -133,54 +133,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - \ No newline at end of file diff --git a/bus-gitlab/src/main/java/org/miaixz/bus/gitlab/models/ApprovedBy.java b/bus-gitlab/src/main/java/org/miaixz/bus/gitlab/models/ApprovedBy.java index bc3996c00e..b55e33432b 100644 --- a/bus-gitlab/src/main/java/org/miaixz/bus/gitlab/models/ApprovedBy.java +++ b/bus-gitlab/src/main/java/org/miaixz/bus/gitlab/models/ApprovedBy.java @@ -35,8 +35,6 @@ /** * This class is used by various models to represent the approved_by property, * which can contain a User or Group instance. - * - * @since 4.19.0 */ public class ApprovedBy implements Serializable { private static final long serialVersionUID = 1L; diff --git a/bus-gitlab/src/main/java/org/miaixz/bus/gitlab/models/Setting.java b/bus-gitlab/src/main/java/org/miaixz/bus/gitlab/models/Setting.java index e778943eb0..60531265d7 100644 --- a/bus-gitlab/src/main/java/org/miaixz/bus/gitlab/models/Setting.java +++ b/bus-gitlab/src/main/java/org/miaixz/bus/gitlab/models/Setting.java @@ -542,7 +542,6 @@ public enum Setting { /** * NOT DOCUMENTED: but it's returned by a call to /api/v4/application/settings * Was added with this commit https://gitlab.com/gitlab-org/gitlab/commit/30e7f01877fd436e21efdf0974d42d8fc83f4883 - * @since 2019-07-18 */ LOGIN_RECAPTCHA_PROTECTION_ENABLED(Boolean.class), diff --git a/bus-goalie/pom.xml b/bus-goalie/pom.xml index 48aa718998..2b9dafb1f5 100644 --- a/bus-goalie/pom.xml +++ b/bus-goalie/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-goalie - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -70,18 +70,12 @@ UTF-8 21 21 - 3.3.0 + 3.3.1 1.18.32 33.2.1-jre - - ${project.groupId} - bus-base - ${project.version} - true - ${project.groupId} bus-crypto @@ -148,54 +142,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/Handler.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/Handler.java index a1c05495d4..e4c1eef797 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/Handler.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/Handler.java @@ -34,7 +34,7 @@ * 拦截器,原理同spring拦截器 * * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public interface Handler { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/Provider.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/Provider.java index b6074f875d..872589fbc7 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/Provider.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/Provider.java @@ -31,7 +31,7 @@ * 数据序列化 * * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public interface Provider { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/ApiVersion.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/ApiVersion.java index 451eb7703a..05b4e663cd 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/ApiVersion.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/ApiVersion.java @@ -37,7 +37,7 @@ * 规则,自动放置于路径开始部分;不做method做版本,避免难以维护 * * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/ClientVersion.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/ClientVersion.java index db2e959b31..6802d178e3 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/ClientVersion.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/ClientVersion.java @@ -31,7 +31,7 @@ /** * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ @Target({ElementType.METHOD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/TerminalVersion.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/TerminalVersion.java index 74f4f317b8..942c36b5f5 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/TerminalVersion.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/annotation/TerminalVersion.java @@ -35,7 +35,7 @@ /** * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ @Retention(RetentionPolicy.RUNTIME) public @interface TerminalVersion { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/AuthorizeFilter.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/AuthorizeFilter.java index 53f4f0af04..00b31ced22 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/AuthorizeFilter.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/AuthorizeFilter.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.goalie.filter; -import org.miaixz.bus.base.entity.OAuth2; -import org.miaixz.bus.base.normal.ErrorCode; +import org.miaixz.bus.core.basics.entity.OAuth2; +import org.miaixz.bus.core.basics.normal.ErrorCode; import org.miaixz.bus.core.beans.copier.CopyOptions; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.BusinessException; diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/EncryptFilter.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/EncryptFilter.java index 108f3c3bbe..e6d6d3b4aa 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/EncryptFilter.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/EncryptFilter.java @@ -28,7 +28,7 @@ package org.miaixz.bus.goalie.filter; import jakarta.annotation.PostConstruct; -import org.miaixz.bus.base.entity.Message; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Algorithm; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.xyz.ObjectKit; diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/FormatFilter.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/FormatFilter.java index acd5f8eb67..f8a8c7fe68 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/FormatFilter.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/FormatFilter.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.goalie.filter; -import org.miaixz.bus.base.entity.Message; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.goalie.Context; import org.miaixz.bus.logger.Logger; diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/PrimaryFilter.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/PrimaryFilter.java index f5c5b2587f..973db2af1e 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/PrimaryFilter.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/filter/PrimaryFilter.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.goalie.filter; -import org.miaixz.bus.base.normal.ErrorCode; +import org.miaixz.bus.core.basics.normal.ErrorCode; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.exception.BusinessException; import org.miaixz.bus.core.xyz.StringKit; diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/AbstractApiHandler.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/AbstractApiHandler.java index ad68b9ca6c..7b47843aac 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/AbstractApiHandler.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/AbstractApiHandler.java @@ -31,7 +31,7 @@ /** * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public class AbstractApiHandler implements Handler { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiPermissionHandler.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiPermissionHandler.java index 0d379cc23a..e2781bee5c 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiPermissionHandler.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiPermissionHandler.java @@ -32,7 +32,7 @@ /** * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public class ApiPermissionHandler extends AbstractApiHandler { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiRequestMappingHandlerMapping.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiRequestMappingHandlerMapping.java index 24140da073..49acdf0867 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiRequestMappingHandlerMapping.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiRequestMappingHandlerMapping.java @@ -39,7 +39,7 @@ /** * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public class ApiRequestMappingHandlerMapping extends RequestMappingHandlerMapping { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiVersionRequestCondition.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiVersionRequestCondition.java index ae8d47ccfc..2e61d01cde 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiVersionRequestCondition.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiVersionRequestCondition.java @@ -41,7 +41,7 @@ /** * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public class ApiVersionRequestCondition extends AbstractRequestCondition { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiWebMvcRegistrations.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiWebMvcRegistrations.java index 9b336367ee..1d3a43dbf1 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiWebMvcRegistrations.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/ApiWebMvcRegistrations.java @@ -36,7 +36,7 @@ * spring boot专用,避免继承webconfigurationsupport对spring的自动配置侵入和破坏 * * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public class ApiWebMvcRegistrations implements WebMvcRegistrations { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/GlobalExceptionHandler.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/GlobalExceptionHandler.java index 3c545c24bf..fac201ed48 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/GlobalExceptionHandler.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/handler/GlobalExceptionHandler.java @@ -28,7 +28,7 @@ package org.miaixz.bus.goalie.handler; import io.netty.handler.timeout.ReadTimeoutException; -import org.miaixz.bus.base.spring.Controller; +import org.miaixz.bus.core.basics.spring.Controller; import org.miaixz.bus.core.lang.exception.BusinessException; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.goalie.Config; diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/metric/Delegate.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/metric/Delegate.java index 346ff196bf..e4fdd7c172 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/metric/Delegate.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/metric/Delegate.java @@ -29,9 +29,9 @@ import lombok.Getter; import lombok.Setter; -import org.miaixz.bus.base.entity.Message; -import org.miaixz.bus.base.entity.OAuth2; -import org.miaixz.bus.base.normal.Consts; +import org.miaixz.bus.core.basics.entity.Message; +import org.miaixz.bus.core.basics.entity.OAuth2; +import org.miaixz.bus.core.basics.normal.Consts; /** * 认证及委托处理 diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/metric/ErrorCode.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/metric/ErrorCode.java index 2f3e04e997..05a9d774b6 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/metric/ErrorCode.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/metric/ErrorCode.java @@ -30,9 +30,9 @@ /** * 自定义错误码 * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ -public class ErrorCode extends org.miaixz.bus.base.normal.ErrorCode { +public class ErrorCode extends org.miaixz.bus.core.basics.normal.ErrorCode { /** * 没有API权限 diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/registry/InterceptorRegistry.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/registry/InterceptorRegistry.java index 948a151d3a..e3023222be 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/registry/InterceptorRegistry.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/registry/InterceptorRegistry.java @@ -33,7 +33,7 @@ * 数据序列化 * * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public interface InterceptorRegistry extends Registry { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/support/JsonProvider.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/support/JsonProvider.java index 466e8ea45a..9fed68ed57 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/support/JsonProvider.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/support/JsonProvider.java @@ -34,7 +34,7 @@ * Json序列化 * * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public class JsonProvider implements Provider { diff --git a/bus-goalie/src/main/java/org/miaixz/bus/goalie/support/XmlProvider.java b/bus-goalie/src/main/java/org/miaixz/bus/goalie/support/XmlProvider.java index d22cf03e59..e398153375 100644 --- a/bus-goalie/src/main/java/org/miaixz/bus/goalie/support/XmlProvider.java +++ b/bus-goalie/src/main/java/org/miaixz/bus/goalie/support/XmlProvider.java @@ -38,7 +38,7 @@ * Xml序列化 * * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ public class XmlProvider implements Provider { diff --git a/bus-health/pom.xml b/bus-health/pom.xml index 454aa69344..dc325d6c05 100755 --- a/bus-health/pom.xml +++ b/bus-health/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-health - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -112,54 +112,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-http/pom.xml b/bus-http/pom.xml index 99e03f4177..1ae7b09985 100755 --- a/bus-http/pom.xml +++ b/bus-http/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-http - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -119,54 +119,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Address.java b/bus-http/src/main/java/org/miaixz/bus/http/Address.java index e79f923472..a84a5fc07b 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/Address.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/Address.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.http; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.http.accord.Connection; import org.miaixz.bus.http.accord.ConnectionSuite; import org.miaixz.bus.http.secure.Authenticator; @@ -101,7 +101,7 @@ public Address(String uriHost, int uriPort, DnsX dns, SocketFactory socketFactor Proxy proxy, List protocols, List connectionSuites, ProxySelector proxySelector) { this.url = new UnoUrl.Builder() - .scheme(null != sslSocketFactory ? Http.HTTPS : Http.HTTP) + .scheme(null != sslSocketFactory ? Protocol.HTTPS.name : Protocol.HTTP.name) .host(uriHost) .port(uriPort) .build(); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Builder.java b/bus-http/src/main/java/org/miaixz/bus/http/Builder.java index 19fa6f6be1..467cd639d6 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/Builder.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/Builder.java @@ -37,6 +37,7 @@ import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.http.bodys.ResponseBody; import org.miaixz.bus.http.metric.Internal; +import org.miaixz.bus.http.metric.http.Http2Header; import java.io.IOException; import java.io.InterruptedIOException; @@ -597,18 +598,18 @@ private static String inet6AddressToAscii(byte[] address) { return result.readUtf8(); } - public static Headers toHeaders(List headerBlock) { + public static Headers toHeaders(List headerBlock) { Headers.Builder builder = new Headers.Builder(); - for (Headers.Header header : headerBlock) { + for (Http2Header header : headerBlock) { Internal.instance.addLenient(builder, header.name.utf8(), header.value.utf8()); } return builder.build(); } - public static List toHeaderBlock(Headers headers) { - List result = new ArrayList<>(); + public static List toHeaderBlock(Headers headers) { + List result = new ArrayList<>(); for (int i = 0; i < headers.size(); i++) { - result.add(new Headers.Header(headers.name(i), headers.value(i))); + result.add(new Http2Header(headers.name(i), headers.value(i))); } return result; } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Headers.java b/bus-http/src/main/java/org/miaixz/bus/http/Headers.java index 7696853d5a..28eb1f2d91 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/Headers.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/Headers.java @@ -27,11 +27,10 @@ */ package org.miaixz.bus.http; -import org.miaixz.bus.core.io.ByteString; import org.miaixz.bus.core.io.buffer.Buffer; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.metric.CookieJar; import org.miaixz.bus.http.secure.Challenge; @@ -425,9 +424,9 @@ public static boolean hasBody(Response response) { } int responseCode = response.code(); - if ((responseCode < Http.HTTP_CONTINUE || responseCode >= 200) - && responseCode != Http.HTTP_NO_CONTENT - && responseCode != Http.HTTP_NOT_MODIFIED) { + if ((responseCode < HTTP.HTTP_CONTINUE || responseCode >= 200) + && responseCode != HTTP.HTTP_NO_CONTENT + && responseCode != HTTP.HTTP_NOT_MODIFIED) { return true; } @@ -789,67 +788,4 @@ public Headers build() { } } - /** - * HTTP header: the name is an ASCII string, but the value can be UTF-8. - */ - public static class Header { - - // Special header names defined in HTTP/2 spec. - public static final ByteString PSEUDO_PREFIX = ByteString.encodeUtf8(Symbol.COLON); - public static final ByteString RESPONSE_STATUS = ByteString.encodeUtf8(Http.RESPONSE_STATUS_UTF8); - public static final ByteString TARGET_METHOD = ByteString.encodeUtf8(Http.TARGET_METHOD_UTF8); - public static final ByteString TARGET_PATH = ByteString.encodeUtf8(Http.TARGET_PATH_UTF8); - public static final ByteString TARGET_SCHEME = ByteString.encodeUtf8(Http.TARGET_SCHEME_UTF8); - public static final ByteString TARGET_AUTHORITY = ByteString.encodeUtf8(Http.TARGET_AUTHORITY_UTF8); - - - /** - * Name in case-insensitive ASCII encoding. - */ - public final ByteString name; - /** - * Value in UTF-8 encoding. - */ - public final ByteString value; - public final int hpackSize; - - // TODO: search for toLowerCase and consider moving logic here. - public Header(String name, String value) { - this(ByteString.encodeUtf8(name), ByteString.encodeUtf8(value)); - } - - public Header(ByteString name, String value) { - this(name, ByteString.encodeUtf8(value)); - } - - public Header(ByteString name, ByteString value) { - this.name = name; - this.value = value; - this.hpackSize = 32 + name.size() + value.size(); - } - - @Override - public boolean equals(Object other) { - if (other instanceof Header) { - Header that = (Header) other; - return this.name.equals(that.name) - && this.value.equals(that.value); - } - return false; - } - - @Override - public int hashCode() { - int result = 17; - result = 31 * result + name.hashCode(); - result = 31 * result + value.hashCode(); - return result; - } - - @Override - public String toString() { - return String.format("%s: %s", name.utf8(), value.utf8()); - } - } - } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Httpd.java b/bus-http/src/main/java/org/miaixz/bus/http/Httpd.java index 8b401ec4bc..0a9f575197 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/Httpd.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/Httpd.java @@ -29,6 +29,7 @@ import org.miaixz.bus.core.io.sink.Sink; import org.miaixz.bus.core.io.source.Source; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.net.tls.SSLContextBuilder; import org.miaixz.bus.core.net.tls.TrustAnyHostnameVerifier; import org.miaixz.bus.http.accord.ConnectionPool; @@ -141,7 +142,7 @@ public Exchange exchange(Response response) { final List interceptors; /** * 返回观察单个网络请求和响应的不可变拦截器列表。这些拦截器必须 - * 调用{@link Interceptor.Chain#proceed} 只执行一次:网络拦截器短路或重复网络请求是错误的 + * 调用{@link NewChain#proceed} 只执行一次:网络拦截器短路或重复网络请求是错误的 */ final List networkInterceptors; final EventListener.Factory eventListenerFactory; @@ -897,7 +898,7 @@ public Builder addInterceptor(Interceptor interceptor) { /** * 返回观察单个网络请求和响应的可修改的拦截器列表。 - * 这些拦截器必须调用{@link Interceptor.Chain#proceed} + * 这些拦截器必须调用{@link NewChain#proceed} * 只执行一次:网络拦截器短路或重复网络请求是错误的 * * @return 构造器 diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Httpv.java b/bus-http/src/main/java/org/miaixz/bus/http/Httpv.java index 50da544801..97fa068b26 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/Httpv.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/Httpv.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.http; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.http.bodys.ResponseBody; import org.miaixz.bus.http.plugin.httpv.*; import org.miaixz.bus.http.socket.WebSocket; @@ -252,10 +252,10 @@ private String urlPath(String urlPath, boolean websocket) { throw new InternalException("Before setting BaseUrl, you must specify a specific path to initiate a request!"); } } else { - boolean isFullPath = urlPath.startsWith(Http.HTTPS_PREFIX) - || urlPath.startsWith(Http.HTTP_PREFIX) - || urlPath.startsWith(Http.WSS_PREFIX) - || urlPath.startsWith(Http.WS_PREFIX); + boolean isFullPath = urlPath.startsWith(Protocol.HTTPS_PREFIX) + || urlPath.startsWith(Protocol.HTTP_PREFIX) + || urlPath.startsWith(Protocol.WSS_PREFIX) + || urlPath.startsWith(Protocol.WS_PREFIX); if (isFullPath) { fullUrl = urlPath; } else if (null != baseUrl) { @@ -264,11 +264,11 @@ private String urlPath(String urlPath, boolean websocket) { throw new InternalException("Before setting BaseUrl, you must use the full path URL to initiate the request. The current URL is:" + urlPath); } } - if (websocket && fullUrl.startsWith(Http.HTTP)) { - return fullUrl.replaceFirst(Http.HTTP, Http.WS); + if (websocket && fullUrl.startsWith(Protocol.HTTP.name)) { + return fullUrl.replaceFirst(Protocol.HTTP.name, Protocol.WS.name); } - if (!websocket && fullUrl.startsWith(Http.WS)) { - return fullUrl.replaceFirst(Http.WS, Http.HTTP); + if (!websocket && fullUrl.startsWith(Protocol.WS.name)) { + return fullUrl.replaceFirst(Protocol.WS.name, Protocol.HTTP.name); } return fullUrl; } @@ -392,7 +392,7 @@ public static class Builder { private Charset charset = org.miaixz.bus.core.lang.Charset.UTF_8; - private String bodyType = Http.FORM; + private String bodyType = HTTP.FORM; public Builder() { mediaTypes = new HashMap<>(); @@ -437,7 +437,7 @@ private static void addCopyInterceptor(Httpd.Builder builder) { Request request = chain.request(); Response response = chain.proceed(request); ResponseBody body = response.body(); - String type = response.header(Header.CONTENT_TYPE); + String type = response.header(HTTP.CONTENT_TYPE); if (null == body || null != type && (type.contains("octet-stream") || type.contains("image") || type.contains("video") || type.contains("archive") || type.contains("word") diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Httpx.java b/bus-http/src/main/java/org/miaixz/bus/http/Httpx.java index 95bd437082..b8e5cb32ae 100755 --- a/bus-http/src/main/java/org/miaixz/bus/http/Httpx.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/Httpx.java @@ -27,8 +27,12 @@ */ package org.miaixz.bus.http; -import org.miaixz.bus.core.lang.*; +import org.miaixz.bus.core.lang.Charset; +import org.miaixz.bus.core.lang.MediaType; +import org.miaixz.bus.core.lang.Normal; +import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.net.tls.SSLContextBuilder; import org.miaixz.bus.core.xyz.ArrayKit; import org.miaixz.bus.core.xyz.MapKit; @@ -251,7 +255,7 @@ public static String get(final String url, final String charset) { */ public static String get(final String url, final boolean isAsync) { if (isAsync) { - return enqueue(Builder.builder().url(url).method(Http.GET).build()); + return enqueue(Builder.builder().url(url).method(HTTP.GET).build()); } return get(url); } @@ -400,12 +404,12 @@ public static String post(final String url, final Map formMap, f * @return the {@link String} */ public static String post(final String url, final String data, final String mediaType, final String charset) { - return execute(Builder.builder().url(url).method(Http.POST).data(data).mediaType(mediaType) + return execute(Builder.builder().url(url).method(HTTP.POST).data(data).mediaType(mediaType) .requestCharset(charset).responseCharset(charset).build()); } public static String post(final String url, final String data, final Map headerMap, final String mediaType) { - return execute(Builder.builder().url(url).method(Http.POST).data(data).headerMap(headerMap).mediaType(mediaType) + return execute(Builder.builder().url(url).method(HTTP.POST).data(data).headerMap(headerMap).mediaType(mediaType) .requestCharset(Charset.DEFAULT_UTF_8).responseCharset(Charset.DEFAULT_UTF_8).build()); } @@ -419,7 +423,7 @@ public static String post(final String url, final String data, final Map formMap, final String mediaType, final String charset) { - return execute(Builder.builder().url(url).method(Http.POST).formMap(formMap).mediaType(mediaType) + return execute(Builder.builder().url(url).method(HTTP.POST).formMap(formMap).mediaType(mediaType) .requestCharset(charset).responseCharset(charset).build()); } @@ -447,7 +451,7 @@ public static String post(final String url, final Map formMap, f * @return the {@link String} */ public static String post(final String url, final Map formMap, final Map headerMap, final String mediaType, final String charset) { - return execute(Builder.builder().url(url).method(Http.POST).headerMap(headerMap).formMap(formMap) + return execute(Builder.builder().url(url).method(HTTP.POST).headerMap(headerMap).formMap(formMap) .mediaType(mediaType).requestCharset(charset).responseCharset(charset).build()); } @@ -499,7 +503,7 @@ private static Request.Builder builder(final Builder builder) { builder.responseCharset = Charset.DEFAULT_UTF_8; } if (StringKit.isBlank(builder.method)) { - builder.method = Http.GET; + builder.method = HTTP.GET; } if (StringKit.isBlank(builder.mediaType)) { builder.mediaType = MediaType.APPLICATION_FORM_URLENCODED; @@ -515,7 +519,7 @@ private static Request.Builder builder(final Builder builder) { } String method = builder.method.toUpperCase(); String mediaType = String.format("%s;charset=%s", builder.mediaType, builder.requestCharset); - if (StringKit.equals(method, Http.GET)) { + if (StringKit.equals(method, HTTP.GET)) { if (MapKit.isNotEmpty(builder.formMap)) { String form = builder.formMap.entrySet().stream() .map(entry -> String.format("%s=%s", entry.getKey(), entry.getValue())) @@ -523,7 +527,7 @@ private static Request.Builder builder(final Builder builder) { builder.url = String.format("%s%s%s", builder.url, builder.url.contains(Symbol.QUESTION_MARK) ? Symbol.AND : Symbol.QUESTION_MARK, form); } request.get(); - } else if (ArrayKit.contains(new String[]{Http.POST, Http.PUT, Http.DELETE, Http.PATCH}, method)) { + } else if (ArrayKit.contains(new String[]{HTTP.POST, HTTP.PUT, HTTP.DELETE, HTTP.PATCH}, method)) { if (StringKit.isNotEmpty(builder.data)) { RequestBody requestBody = RequestBody.create(MediaType.valueOf(mediaType), builder.data); request.method(method, requestBody); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Protocol.java b/bus-http/src/main/java/org/miaixz/bus/http/Protocol.java deleted file mode 100644 index 585c79aea8..0000000000 --- a/bus-http/src/main/java/org/miaixz/bus/http/Protocol.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - ~ ~ - ~ The MIT License (MIT) ~ - ~ ~ - ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ - ~ ~ - ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ - ~ of this software and associated documentation files (the "Software"), to deal ~ - ~ in the Software without restriction, including without limitation the rights ~ - ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ - ~ copies of the Software, and to permit persons to whom the Software is ~ - ~ furnished to do so, subject to the following conditions: ~ - ~ ~ - ~ The above copyright notice and this permission notice shall be included in ~ - ~ all copies or substantial portions of the Software. ~ - ~ ~ - ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ - ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ - ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ - ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ - ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ - ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ - ~ THE SOFTWARE. ~ - ~ ~ - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - */ -package org.miaixz.bus.http; - -import org.miaixz.bus.core.lang.Http; - -import java.io.IOException; - -/** - * 协议vs计划 它的名字是:{@link java.net.URL#getProtocol()} - * 返回{@linkplain java.net.URI#getScheme() scheme} (http, https, etc.), - * 而不是协议(http/1.1, spdy/3.1,等等) 请使用这个协议来识别它是如何被分割的 - * Httpd使用协议这个词来标识HTTP消息是如何构造的 - * - * @author Kimi Liu - * @since Java 17+ - */ -public enum Protocol { - - /** - * 一种过时的plaintext,默认情况下不使用持久套接字 - */ - HTTP_1_0(Http.HTTP_1_0), - - /** - * 包含持久连接的plaintext - * 此版本的Httpd实现了RFC 7230,并跟踪对该规范的修订 - */ - HTTP_1_1(Http.HTTP_1_1), - - /** - * IETF的二进制框架协议,包括头压缩、在同一个套接字上多路复用多个请求和服务器推送 - * HTTP/1.1语义是在HTTP/2上分层的 - */ - HTTP_2("h2"), - - /** - * Chromium的二进制框架协议,包括标头压缩、在同一个套接字上多路复用多个请求和服务器推送 - * HTTP/1.1语义在SPDY/3上分层. - */ - SPDY_3(Http.SPDY_3_1), - - /** - * 明文HTTP/2,没有"upgrade"往返。此选项要求客户端事先知道服务器支持明文HTTP/2 - */ - H2_PRIOR_KNOWLEDGE(Http.H2_PRIOR_KNOWLEDGE), - - /** - * QUIC(快速UDP互联网连接)是一个新的多路复用和UDP之上的安全传输, - * 从底层设计和优化的HTTP/2语义。HTTP/1.1语义是在HTTP/2上分层的 - */ - QUIC(Http.QUIC), - - /** - * SOAP 1.1协议 - */ - SOAP_1_1(Http.SOAP_1_1), - /** - * SOAP 1.2协议 - */ - SOAP_1_2(Http.SOAP_1_2); - - private final String protocol; - - Protocol(String protocol) { - this.protocol = protocol; - } - - /** - * @param protocol 协议标示 - * @return 返回由{@code protocol}标识的协议 - * @throws IOException if {@code protocol} is unknown. - */ - public static Protocol get(String protocol) throws IOException { - if (protocol.equals(HTTP_1_0.protocol)) return HTTP_1_0; - if (protocol.equals(HTTP_1_1.protocol)) return HTTP_1_1; - if (protocol.equals(H2_PRIOR_KNOWLEDGE.protocol)) return H2_PRIOR_KNOWLEDGE; - if (protocol.equals(HTTP_2.protocol)) return HTTP_2; - if (protocol.equals(SPDY_3.protocol)) return SPDY_3; - if (protocol.equals(QUIC.protocol)) return QUIC; - if (protocol.equals(SOAP_1_1.protocol)) return SOAP_1_1; - if (protocol.equals(SOAP_1_2.protocol)) return SOAP_1_2; - throw new IOException("Unexpected protocol: " + protocol); - } - - /** - * 返回用于识别ALPN协议的字符串,如“http/1.1”、“spdy/3.1”或“http/2.0”. - */ - @Override - public String toString() { - return protocol; - } - -} diff --git a/bus-http/src/main/java/org/miaixz/bus/http/RealCall.java b/bus-http/src/main/java/org/miaixz/bus/http/RealCall.java index a0158fc100..571f3d4b68 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/RealCall.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/RealCall.java @@ -35,6 +35,7 @@ import org.miaixz.bus.http.cache.CacheInterceptor; import org.miaixz.bus.http.metric.Interceptor; import org.miaixz.bus.http.metric.NamedRunnable; +import org.miaixz.bus.http.metric.NewChain; import org.miaixz.bus.http.metric.http.BridgeInterceptor; import org.miaixz.bus.http.metric.http.CallServerInterceptor; import org.miaixz.bus.http.metric.http.RealInterceptorChain; @@ -172,7 +173,7 @@ public Response getResponseWithInterceptorChain() throws IOException { } interceptors.add(new CallServerInterceptor(forWebSocket)); - Interceptor.Chain chain = new RealInterceptorChain(interceptors, transmitter, null, 0, + NewChain chain = new RealInterceptorChain(interceptors, transmitter, null, 0, originalRequest, this, client.connectTimeoutMillis(), client.readTimeoutMillis(), client.writeTimeoutMillis()); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Request.java b/bus-http/src/main/java/org/miaixz/bus/http/Request.java index 1fe6bbfd8d..4de05e7c8b 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/Request.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/Request.java @@ -27,10 +27,9 @@ */ package org.miaixz.bus.http; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.bodys.RequestBody; import org.miaixz.bus.http.cache.CacheControl; @@ -233,24 +232,24 @@ public Builder headers(Headers headers) { */ public Builder cacheControl(CacheControl cacheControl) { String value = cacheControl.toString(); - if (value.isEmpty()) return removeHeader(Header.CACHE_CONTROL); - return header(Header.CACHE_CONTROL, value); + if (value.isEmpty()) return removeHeader(HTTP.CACHE_CONTROL); + return header(HTTP.CACHE_CONTROL, value); } public Builder get() { - return method(Http.GET, null); + return method(HTTP.GET, null); } public Builder head() { - return method(Http.HEAD, null); + return method(HTTP.HEAD, null); } public Builder post(RequestBody body) { - return method(Http.POST, body); + return method(HTTP.POST, body); } public Builder delete(RequestBody body) { - return method(Http.DELETE, body); + return method(HTTP.DELETE, body); } public Builder delete() { @@ -258,20 +257,20 @@ public Builder delete() { } public Builder put(RequestBody body) { - return method(Http.PUT, body); + return method(HTTP.PUT, body); } public Builder patch(RequestBody body) { - return method(Http.PATCH, body); + return method(HTTP.PATCH, body); } public Builder method(String method, RequestBody body) { if (null == method) throw new NullPointerException("method == null"); if (method.length() == 0) throw new IllegalArgumentException("method.length() == 0"); - if (body != null && !Http.permitsRequestBody(method)) { + if (body != null && !HTTP.permitsRequestBody(method)) { throw new IllegalArgumentException("method " + method + " must not have a request body."); } - if (body == null && Http.requiresRequestBody(method)) { + if (body == null && HTTP.requiresRequestBody(method)) { throw new IllegalArgumentException("method " + method + " must have a request body."); } this.method = method; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Response.java b/bus-http/src/main/java/org/miaixz/bus/http/Response.java index 8a25ccd122..11e8a2c01b 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/Response.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/Response.java @@ -29,9 +29,9 @@ import org.miaixz.bus.core.io.buffer.Buffer; import org.miaixz.bus.core.io.source.BufferSource; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.http.accord.Exchange; import org.miaixz.bus.http.bodys.ResponseBody; import org.miaixz.bus.http.cache.CacheControl; @@ -202,12 +202,12 @@ public Builder newBuilder() { */ public boolean isRedirect() { switch (code) { - case Http.HTTP_PERM_REDIRECT: - case Http.HTTP_TEMP_REDIRECT: - case Http.HTTP_MULT_CHOICE: - case Http.HTTP_MOVED_PERM: - case Http.HTTP_MOVED_TEMP: - case Http.HTTP_SEE_OTHER: + case HTTP.HTTP_PERM_REDIRECT: + case HTTP.HTTP_TEMP_REDIRECT: + case HTTP.HTTP_MULT_CHOICE: + case HTTP.HTTP_MOVED_PERM: + case HTTP.HTTP_MOVED_TEMP: + case HTTP.HTTP_SEE_OTHER: return true; default: return false; @@ -255,10 +255,10 @@ public Response priorResponse() { */ public List challenges() { String responseField; - if (code == Http.HTTP_UNAUTHORIZED) { - responseField = Header.WWW_AUTHENTICATE; - } else if (code == Http.HTTP_PROXY_AUTH) { - responseField = Header.PROXY_AUTHENTICATE; + if (code == HTTP.HTTP_UNAUTHORIZED) { + responseField = HTTP.WWW_AUTHENTICATE; + } else if (code == HTTP.HTTP_PROXY_AUTH) { + responseField = HTTP.PROXY_AUTHENTICATE; } else { return Collections.emptyList(); } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/UnoUrl.java b/bus-http/src/main/java/org/miaixz/bus/http/UnoUrl.java index 876e397c8b..4d8a29a7cf 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/UnoUrl.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/UnoUrl.java @@ -29,9 +29,9 @@ import org.miaixz.bus.core.io.buffer.Buffer; import org.miaixz.bus.core.lang.Charset; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.Protocol; import java.net.MalformedURLException; import java.net.URI; @@ -124,9 +124,9 @@ public class UnoUrl { * otherwise. */ public static int defaultPort(String scheme) { - if (Http.HTTP.equals(scheme)) { + if (Protocol.HTTP.name.equals(scheme)) { return 80; - } else if (Http.HTTPS.equals(scheme)) { + } else if (Protocol.HTTPS.name.equals(scheme)) { return 443; } else { return -1; @@ -394,7 +394,7 @@ public String scheme() { } public boolean isHttps() { - return scheme.equals("https"); + return Protocol.isHttps(scheme); } /** @@ -950,10 +950,10 @@ private static int parsePort(String input, int pos, int limit) { public Builder scheme(String scheme) { if (null == scheme) { throw new NullPointerException("scheme == null"); - } else if (scheme.equalsIgnoreCase(Http.HTTP)) { - this.scheme = Http.HTTP; - } else if (scheme.equalsIgnoreCase(Http.HTTPS)) { - this.scheme = Http.HTTPS; + } else if (scheme.equalsIgnoreCase(Protocol.HTTP.name)) { + this.scheme = Protocol.HTTP.name; + } else if (scheme.equalsIgnoreCase(Protocol.HTTPS.name)) { + this.scheme = Protocol.HTTPS.name; } else { throw new IllegalArgumentException("unexpected scheme: " + scheme); } @@ -1287,12 +1287,12 @@ Builder parse(UnoUrl base, String input) { int schemeDelimiterOffset = schemeDelimiterOffset(input, pos, limit); if (schemeDelimiterOffset != -1) { - if (input.regionMatches(true, pos, Http.HTTPS + Symbol.COLON, 0, 6)) { - this.scheme = Http.HTTPS; - pos += (Http.HTTPS + Symbol.COLON).length(); - } else if (input.regionMatches(true, pos, Http.HTTP + Symbol.COLON, 0, 5)) { - this.scheme = Http.HTTP; - pos += (Http.HTTP + Symbol.COLON).length(); + if (input.regionMatches(true, pos, Protocol.HTTPS.name + Symbol.COLON, 0, 6)) { + this.scheme = Protocol.HTTPS.name; + pos += (Protocol.HTTPS.name + Symbol.COLON).length(); + } else if (input.regionMatches(true, pos, Protocol.HTTP.name + Symbol.COLON, 0, 5)) { + this.scheme = Protocol.HTTP.name; + pos += (Protocol.HTTP.name + Symbol.COLON).length(); } else { throw new IllegalArgumentException("Expected URL scheme 'http' or 'https' but was '" + input.substring(0, schemeDelimiterOffset) + Symbol.SINGLE_QUOTE); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/accord/ConnectInterceptor.java b/bus-http/src/main/java/org/miaixz/bus/http/accord/ConnectInterceptor.java index 90ef973f60..bf3bfb6d04 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/accord/ConnectInterceptor.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/accord/ConnectInterceptor.java @@ -27,11 +27,12 @@ */ package org.miaixz.bus.http.accord; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Httpd; import org.miaixz.bus.http.Request; import org.miaixz.bus.http.Response; import org.miaixz.bus.http.metric.Interceptor; +import org.miaixz.bus.http.metric.NewChain; import org.miaixz.bus.http.metric.http.RealInterceptorChain; import java.io.IOException; @@ -51,13 +52,13 @@ public ConnectInterceptor(Httpd httpd) { } @Override - public Response intercept(Chain chain) throws IOException { + public Response intercept(NewChain chain) throws IOException { RealInterceptorChain realChain = (RealInterceptorChain) chain; Request request = realChain.request(); Transmitter transmitter = realChain.transmitter(); // 我们需要网络来满足这个要求。可能用于验证条件GET - boolean doExtensiveHealthChecks = !Http.GET.equals(request.method()); + boolean doExtensiveHealthChecks = !HTTP.GET.equals(request.method()); Exchange exchange = transmitter.newExchange(chain, doExtensiveHealthChecks); return realChain.proceed(request, transmitter, exchange); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/accord/Connection.java b/bus-http/src/main/java/org/miaixz/bus/http/accord/Connection.java index 3fe971349a..0278df2c1e 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/accord/Connection.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/accord/Connection.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.http.accord; -import org.miaixz.bus.http.Protocol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.http.Route; import org.miaixz.bus.http.socket.Handshake; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/accord/ConnectionSuite.java b/bus-http/src/main/java/org/miaixz/bus/http/accord/ConnectionSuite.java index 2365231da3..c7d3539a86 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/accord/ConnectionSuite.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/accord/ConnectionSuite.java @@ -86,7 +86,7 @@ public class ConnectionSuite { */ public static final ConnectionSuite MODERN_TLS = new Builder(true) .cipherSuites(APPROVED_CIPHER_SUITES) - .tlsVersions(TlsVersion.TLS_1_3, TlsVersion.TLS_1_2) + .tlsVersions(TlsVersion.TLSv1_3, TlsVersion.TLSv1_2) .supportsTlsExtensions(true) .build(); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/accord/ExchangeFinder.java b/bus-http/src/main/java/org/miaixz/bus/http/accord/ExchangeFinder.java index f49b1f06f0..b63d7140b6 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/accord/ExchangeFinder.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/accord/ExchangeFinder.java @@ -30,7 +30,7 @@ import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.http.*; import org.miaixz.bus.http.metric.EventListener; -import org.miaixz.bus.http.metric.Interceptor; +import org.miaixz.bus.http.metric.NewChain; import org.miaixz.bus.http.metric.http.HttpCodec; import java.io.IOException; @@ -83,7 +83,7 @@ final class ExchangeFinder { } public HttpCodec find( - Httpd client, Interceptor.Chain chain, boolean doExtensiveHealthChecks) { + Httpd client, NewChain chain, boolean doExtensiveHealthChecks) { int connectTimeout = chain.connectTimeoutMillis(); int readTimeout = chain.readTimeoutMillis(); int writeTimeout = chain.writeTimeoutMillis(); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/accord/RealConnection.java b/bus-http/src/main/java/org/miaixz/bus/http/accord/RealConnection.java index 52936f878c..758ca21c86 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/accord/RealConnection.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/accord/RealConnection.java @@ -30,17 +30,17 @@ import org.miaixz.bus.core.Version; import org.miaixz.bus.core.io.sink.BufferSink; import org.miaixz.bus.core.io.source.BufferSource; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.RevisedException; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.net.tls.TrustAnyHostnameVerifier; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.http.*; import org.miaixz.bus.http.accord.platform.Platform; import org.miaixz.bus.http.metric.EventListener; -import org.miaixz.bus.http.metric.Interceptor; import org.miaixz.bus.http.metric.Internal; +import org.miaixz.bus.http.metric.NewChain; import org.miaixz.bus.http.metric.http.*; import org.miaixz.bus.http.secure.CertificatePinner; import org.miaixz.bus.http.socket.Handshake; @@ -421,19 +421,19 @@ private Request createTunnel(int readTimeout, int writeTimeout, Request tunnelRe tunnelCodec.skipConnectBody(response); switch (response.code()) { - case Http.HTTP_OK: + case HTTP.HTTP_OK: if (!source.getBuffer().exhausted() || !sink.buffer().exhausted()) { throw new IOException("TLS tunnel buffered too many bytes!"); } return null; - case Http.HTTP_PROXY_AUTH: + case HTTP.HTTP_PROXY_AUTH: tunnelRequest = route.address().proxyAuthenticator().authenticate(route, response); if (null == tunnelRequest) { throw new IOException("Failed to authenticate with proxy"); } - if ("close".equalsIgnoreCase(response.header(Header.CONNECTION))) { + if ("close".equalsIgnoreCase(response.header(HTTP.CONNECTION))) { return tunnelRequest; } break; @@ -455,21 +455,21 @@ private Request createTunnel(int readTimeout, int writeTimeout, Request tunnelRe private Request createTunnelRequest() throws IOException { Request proxyConnectRequest = new Request.Builder() .url(route.address().url()) - .method(Http.CONNECT, null) - .header(Header.HOST, Builder.hostHeader(route.address().url(), true)) - .header(Header.PROXY_CONNECTION, Header.KEEP_ALIVE) - .header(Header.USER_AGENT, "Httpd/" + Version.all()) + .method(HTTP.CONNECT, null) + .header(HTTP.HOST, Builder.hostHeader(route.address().url(), true)) + .header(HTTP.PROXY_CONNECTION, HTTP.KEEP_ALIVE) + .header(HTTP.USER_AGENT, "Httpd/" + Version.all()) .build(); Response fakeAuthChallengeResponse = new Response.Builder() .request(proxyConnectRequest) .protocol(Protocol.HTTP_1_1) - .code(Http.HTTP_PROXY_AUTH) + .code(HTTP.HTTP_PROXY_AUTH) .message("Preemptive Authenticate") .body(Builder.EMPTY_RESPONSE) .sentRequestAtMillis(-1L) .receivedResponseAtMillis(-1L) - .header(Header.PROXY_AUTHENTICATE, Header.HTTPD_PREEMPTIVE) + .header(HTTP.PROXY_AUTHENTICATE, HTTP.HTTPD_PREEMPTIVE) .build(); Request authenticatedRequest = route.address().proxyAuthenticator() @@ -555,7 +555,7 @@ public boolean supportsUrl(UnoUrl url) { return true; } - HttpCodec newCodec(Httpd client, Interceptor.Chain chain) throws SocketException { + HttpCodec newCodec(Httpd client, NewChain chain) throws SocketException { if (http2Connection != null) { return new Http2Codec(client, this, chain, http2Connection); } else { @@ -634,7 +634,7 @@ public boolean isHealthy(boolean doExtensiveChecks) { */ @Override public void onStream(Http2Stream stream) throws IOException { - stream.close(ErrorCode.REFUSED_STREAM, null); + stream.close(Http2ErrorCode.REFUSED_STREAM, null); } /** @@ -668,15 +668,15 @@ void trackFailure(IOException e) { assert (!Thread.holdsLock(connectionPool)); synchronized (connectionPool) { if (e instanceof StreamException) { - ErrorCode errorCode = ((StreamException) e).errorCode; - if (errorCode == ErrorCode.REFUSED_STREAM) { + Http2ErrorCode errorCode = ((StreamException) e).errorCode; + if (errorCode == Http2ErrorCode.REFUSED_STREAM) { // Retry REFUSED_STREAM errors once on the same connection. refusedStreamCount++; if (refusedStreamCount > 1) { noNewExchanges = true; routeFailureCount++; } - } else if (errorCode != ErrorCode.CANCEL) { + } else if (errorCode != Http2ErrorCode.CANCEL) { // Keep the connection for CANCEL errors. Everything else wants a fresh connection. noNewExchanges = true; routeFailureCount++; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/accord/Transmitter.java b/bus-http/src/main/java/org/miaixz/bus/http/accord/Transmitter.java index d5cd0adc2e..f6252ecdbb 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/accord/Transmitter.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/accord/Transmitter.java @@ -33,8 +33,8 @@ import org.miaixz.bus.http.*; import org.miaixz.bus.http.accord.platform.Platform; import org.miaixz.bus.http.metric.EventListener; -import org.miaixz.bus.http.metric.Interceptor; import org.miaixz.bus.http.metric.Internal; +import org.miaixz.bus.http.metric.NewChain; import org.miaixz.bus.http.metric.http.HttpCodec; import org.miaixz.bus.http.secure.CertificatePinner; @@ -162,7 +162,7 @@ private Address createAddress(UnoUrl url) { /** * Returns a new exchange to carry a new request and response. */ - Exchange newExchange(Interceptor.Chain chain, boolean doExtensiveHealthChecks) { + Exchange newExchange(NewChain chain, boolean doExtensiveHealthChecks) { synchronized (connectionPool) { if (noMoreExchanges) { throw new IllegalStateException("released"); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/accord/platform/JdkPlatform.java b/bus-http/src/main/java/org/miaixz/bus/http/accord/platform/JdkPlatform.java index 8ff21b8dbc..19f8825de5 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/accord/platform/JdkPlatform.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/accord/platform/JdkPlatform.java @@ -28,7 +28,7 @@ package org.miaixz.bus.http.accord.platform; import org.miaixz.bus.core.lang.Normal; -import org.miaixz.bus.http.Protocol; +import org.miaixz.bus.core.net.Protocol; import javax.net.ssl.SSLParameters; import javax.net.ssl.SSLSocket; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/accord/platform/Platform.java b/bus-http/src/main/java/org/miaixz/bus/http/accord/platform/Platform.java index f34321776c..b6428aa9f9 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/accord/platform/Platform.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/accord/platform/Platform.java @@ -28,7 +28,7 @@ package org.miaixz.bus.http.accord.platform; import org.miaixz.bus.core.io.buffer.Buffer; -import org.miaixz.bus.http.Protocol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.http.secure.BasicCertificateChainCleaner; import org.miaixz.bus.http.secure.BasicTrustRootIndex; import org.miaixz.bus.http.secure.CertificateChainCleaner; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/bodys/MultipartBody.java b/bus-http/src/main/java/org/miaixz/bus/http/bodys/MultipartBody.java index 263289f8ad..e9497b778d 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/bodys/MultipartBody.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/bodys/MultipartBody.java @@ -30,9 +30,9 @@ import org.miaixz.bus.core.io.ByteString; import org.miaixz.bus.core.io.buffer.Buffer; import org.miaixz.bus.core.io.sink.BufferSink; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Headers; import java.io.IOException; @@ -178,7 +178,7 @@ private long writeOrCountBytes(BufferSink sink, boolean countBytes) throws IOExc MediaType mediaType = body.mediaType(); if (null != mediaType) { - sink.writeUtf8(Header.CONTENT_TYPE + ": ") + sink.writeUtf8(HTTP.CONTENT_TYPE + ": ") .writeUtf8(mediaType.toString()) .write(CRLF); } @@ -235,10 +235,10 @@ public static Part create(Headers headers, RequestBody body) { if (null == body) { throw new NullPointerException("body == null"); } - if (null != headers && null != headers.get(Header.CONTENT_TYPE)) { + if (null != headers && null != headers.get(HTTP.CONTENT_TYPE)) { throw new IllegalArgumentException("Unexpected header: Content-Type"); } - if (null != headers && null != headers.get(Header.CONTENT_LENGTH)) { + if (null != headers && null != headers.get(HTTP.CONTENT_LENGTH)) { throw new IllegalArgumentException("Unexpected header: Content-Length"); } return new Part(headers, body); @@ -261,7 +261,7 @@ public static Part createFormData(String name, String filename, RequestBody body } Headers headers = new Headers.Builder() - .addUnsafeNonAscii(Header.CONTENT_DISPOSITION, disposition.toString()) + .addUnsafeNonAscii(HTTP.CONTENT_DISPOSITION, disposition.toString()) .build(); return create(headers, body); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/cache/Cache.java b/bus-http/src/main/java/org/miaixz/bus/http/cache/Cache.java index 34079ae9d4..6c27727915 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/cache/Cache.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/cache/Cache.java @@ -35,13 +35,16 @@ import org.miaixz.bus.core.io.source.AssignSource; import org.miaixz.bus.core.io.source.BufferSource; import org.miaixz.bus.core.io.source.Source; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.net.tls.TlsVersion; import org.miaixz.bus.core.xyz.IoKit; -import org.miaixz.bus.http.*; +import org.miaixz.bus.http.Headers; +import org.miaixz.bus.http.Request; +import org.miaixz.bus.http.Response; +import org.miaixz.bus.http.UnoUrl; import org.miaixz.bus.http.accord.platform.Platform; import org.miaixz.bus.http.bodys.ResponseBody; import org.miaixz.bus.http.metric.http.StatusLine; @@ -175,7 +178,7 @@ Response get(Request request) { CacheRequest put(Response response) { String requestMethod = response.request().method(); - if (Http.invalidatesCache(response.request().method())) { + if (HTTP.invalidatesCache(response.request().method())) { try { remove(response.request()); } catch (IOException ignored) { @@ -183,7 +186,7 @@ CacheRequest put(Response response) { } return null; } - if (!Http.GET.equals(requestMethod)) { + if (!HTTP.GET.equals(requestMethod)) { // 不要缓存非get响应。从技术上讲,我们可以缓存HEAD请求和POST请求,但是这样做的复杂性很高,好处很少 return null; } @@ -485,7 +488,7 @@ private static class Entry { List localCertificates = readCertificateList(source); TlsVersion tlsVersion = !source.exhausted() ? TlsVersion.forJavaName(source.readUtf8LineStrict()) - : TlsVersion.SSL_3_0; + : TlsVersion.SSLv3; handshake = Handshake.get(tlsVersion, cipherSuite, peerCertificates, localCertificates); } else { handshake = null; @@ -555,7 +558,7 @@ public void writeTo(DiskLruCache.Editor editor) throws IOException { } private boolean isHttps() { - return url.startsWith(Http.HTTPS_PREFIX); + return url.startsWith(Protocol.HTTPS_PREFIX); } private List readCertificateList(BufferSource source) throws IOException { @@ -600,8 +603,8 @@ public boolean matches(Request request, Response response) { } public Response response(DiskLruCache.Snapshot snapshot) { - String mediaType = responseHeaders.get(Header.CONTENT_TYPE); - String length = responseHeaders.get(Header.CONTENT_LENGTH); + String mediaType = responseHeaders.get(HTTP.CONTENT_TYPE); + String length = responseHeaders.get(HTTP.CONTENT_LENGTH); Request request = new Request.Builder() .url(url) .method(requestMethod, null) diff --git a/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheControl.java b/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheControl.java index f3cb725ce2..8afe0e3f7c 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheControl.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheControl.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.http.cache; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Headers; import java.util.concurrent.TimeUnit; @@ -152,7 +152,7 @@ public static CacheControl parse(Headers headers) { String name = headers.name(i); String value = headers.value(i); - if (name.equalsIgnoreCase(Header.CACHE_CONTROL)) { + if (name.equalsIgnoreCase(HTTP.CACHE_CONTROL)) { if (null != headerValue) { // 多个cache-control头文件意味着不能使用原始值 canUseHeaderValue = false; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheInterceptor.java b/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheInterceptor.java index 742e8e885e..e2b7cb60ec 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheInterceptor.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheInterceptor.java @@ -33,14 +33,18 @@ import org.miaixz.bus.core.io.source.BufferSource; import org.miaixz.bus.core.io.source.Source; import org.miaixz.bus.core.io.timout.Timeout; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.IoKit; -import org.miaixz.bus.http.*; +import org.miaixz.bus.http.Builder; +import org.miaixz.bus.http.Headers; +import org.miaixz.bus.http.Request; +import org.miaixz.bus.http.Response; import org.miaixz.bus.http.bodys.RealResponseBody; import org.miaixz.bus.http.metric.Interceptor; import org.miaixz.bus.http.metric.Internal; +import org.miaixz.bus.http.metric.NewChain; import org.miaixz.bus.http.metric.http.HttpCodec; import java.io.IOException; @@ -106,14 +110,14 @@ private static Headers combine(Headers cachedHeaders, Headers networkHeaders) { * @return the true/false */ static boolean isEndToEnd(String fieldName) { - return !Header.CONNECTION.equalsIgnoreCase(fieldName) - && !Header.KEEP_ALIVE.equalsIgnoreCase(fieldName) - && !Header.PROXY_AUTHENTICATE.equalsIgnoreCase(fieldName) - && !Header.PROXY_AUTHORIZATION.equalsIgnoreCase(fieldName) - && !Header.TE.equalsIgnoreCase(fieldName) - && !Header.TRAILERS.equalsIgnoreCase(fieldName) - && !Header.TRANSFER_ENCODING.equalsIgnoreCase(fieldName) - && !Header.UPGRADE.equalsIgnoreCase(fieldName); + return !HTTP.CONNECTION.equalsIgnoreCase(fieldName) + && !HTTP.KEEP_ALIVE.equalsIgnoreCase(fieldName) + && !HTTP.PROXY_AUTHENTICATE.equalsIgnoreCase(fieldName) + && !HTTP.PROXY_AUTHORIZATION.equalsIgnoreCase(fieldName) + && !HTTP.TE.equalsIgnoreCase(fieldName) + && !HTTP.TRAILERS.equalsIgnoreCase(fieldName) + && !HTTP.TRANSFER_ENCODING.equalsIgnoreCase(fieldName) + && !HTTP.UPGRADE.equalsIgnoreCase(fieldName); } /** @@ -123,13 +127,13 @@ static boolean isEndToEnd(String fieldName) { * @return the true/false */ static boolean isContentSpecificHeader(String fieldName) { - return Header.CONTENT_LENGTH.equalsIgnoreCase(fieldName) - || Header.CONTENT_ENCODING.equalsIgnoreCase(fieldName) - || Header.CONTENT_TYPE.equalsIgnoreCase(fieldName); + return HTTP.CONTENT_LENGTH.equalsIgnoreCase(fieldName) + || HTTP.CONTENT_ENCODING.equalsIgnoreCase(fieldName) + || HTTP.CONTENT_TYPE.equalsIgnoreCase(fieldName); } @Override - public Response intercept(Chain chain) throws IOException { + public Response intercept(NewChain chain) throws IOException { Response cacheCandidate = null != cache ? cache.get(chain.request()) : null; @@ -181,7 +185,7 @@ public Response intercept(Chain chain) throws IOException { // 如果我们也有缓存响应,那么在做一个条件get if (null != cacheResponse) { - if (networkResponse.code() == Http.HTTP_NOT_MODIFIED) { + if (networkResponse.code() == HTTP.HTTP_NOT_MODIFIED) { Response response = cacheResponse.newBuilder() .headers(combine(cacheResponse.headers(), networkResponse.headers())) .sentRequestAtMillis(networkResponse.sentRequestAtMillis()) @@ -212,7 +216,7 @@ public Response intercept(Chain chain) throws IOException { return cacheWritingResponse(cacheRequest, response); } - if (Http.invalidatesCache(networkRequest.method())) { + if (HTTP.invalidatesCache(networkRequest.method())) { try { cache.remove(networkRequest); } catch (IOException ignored) { @@ -294,7 +298,7 @@ public void close() throws IOException { } }; - String mediaType = response.header(Header.CONTENT_TYPE); + String mediaType = response.header(HTTP.CONTENT_TYPE); long contentLength = response.body().length(); return response.newBuilder() .body(new RealResponseBody(mediaType, contentLength, IoKit.buffer(cacheWritingSource))) diff --git a/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheStrategy.java b/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheStrategy.java index 1f3ad81d2f..886e41ad26 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheStrategy.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/cache/CacheStrategy.java @@ -27,8 +27,7 @@ */ package org.miaixz.bus.http.cache; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Builder; import org.miaixz.bus.http.Headers; import org.miaixz.bus.http.Request; @@ -73,22 +72,22 @@ public class CacheStrategy { public static boolean isCacheable(Response response, Request request) { // 总是去网络获取非缓存的响应代码(RFC 7231 section 6.1),这个实现不支持缓存部分内容 switch (response.code()) { - case Http.HTTP_OK: - case Http.HTTP_NOT_AUTHORITATIVE: - case Http.HTTP_NO_CONTENT: - case Http.HTTP_MULT_CHOICE: - case Http.HTTP_MOVED_PERM: - case Http.HTTP_NOT_FOUND: - case Http.HTTP_BAD_METHOD: - case Http.HTTP_GONE: - case Http.HTTP_REQ_TOO_LONG: - case Http.HTTP_NOT_IMPLEMENTED: - case Http.HTTP_PERM_REDIRECT: + case HTTP.HTTP_OK: + case HTTP.HTTP_NOT_AUTHORITATIVE: + case HTTP.HTTP_NO_CONTENT: + case HTTP.HTTP_MULT_CHOICE: + case HTTP.HTTP_MOVED_PERM: + case HTTP.HTTP_NOT_FOUND: + case HTTP.HTTP_BAD_METHOD: + case HTTP.HTTP_GONE: + case HTTP.HTTP_REQ_TOO_LONG: + case HTTP.HTTP_NOT_IMPLEMENTED: + case HTTP.HTTP_PERM_REDIRECT: // 这些代码可以被缓存,除非标头禁止 break; - case Http.HTTP_MOVED_TEMP: - case Http.HTTP_TEMP_REDIRECT: - if (null != response.header(Header.EXPIRES) + case HTTP.HTTP_MOVED_TEMP: + case HTTP.HTTP_TEMP_REDIRECT: + if (null != response.header(HTTP.EXPIRES) || response.cacheControl().maxAgeSeconds() != -1 || response.cacheControl().isPublic() || response.cacheControl().isPrivate()) { @@ -183,7 +182,7 @@ public Factory(long nowMillis, Request request, Response cacheResponse) { * @return the true/false */ private static boolean hasConditions(Request request) { - return null != request.header(Header.IF_MODIFIED_SINCE) || null != request.header(Header.IF_NONE_MATCH); + return null != request.header(HTTP.IF_MODIFIED_SINCE) || null != request.header(HTTP.IF_NONE_MATCH); } /** diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/EventListener.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/EventListener.java index c813a80f93..e616aadf79 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/EventListener.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/EventListener.java @@ -27,6 +27,7 @@ */ package org.miaixz.bus.http.metric; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.http.*; import org.miaixz.bus.http.accord.Connection; import org.miaixz.bus.http.accord.ConnectionPool; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/Interceptor.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/Interceptor.java index 1989bd4f9c..a9b929b76d 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/Interceptor.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/Interceptor.java @@ -27,13 +27,9 @@ */ package org.miaixz.bus.http.metric; -import org.miaixz.bus.http.NewCall; -import org.miaixz.bus.http.Request; import org.miaixz.bus.http.Response; -import org.miaixz.bus.http.accord.Connection; import java.io.IOException; -import java.util.concurrent.TimeUnit; /** * 观察、修改和潜在的短路请求,并返回相应的响应 @@ -44,38 +40,21 @@ */ public interface Interceptor { - Response intercept(Chain chain) throws IOException; + /** + * 网络请求拦截 + * + * @param chain 网络调用链 + * @return {@link Response} + * @throws IOException 异常 + */ + Response intercept(NewChain chain) throws IOException; + + /** + * 说明该拦截器实现的作用 + * 方便其他业务场景或者服务使用,例如链路追踪等 + */ + default void instructions() { - interface Chain { - - /** - * @return 网络请求 - */ - Request request(); - - Response proceed(Request request) throws IOException; - - /** - * 返回将执行请求的连接。这只在网络拦截器链中可用; - * 对于应用程序拦截器,这总是null - * - * @return 连接信息 - */ - Connection connection(); - - NewCall call(); - - int connectTimeoutMillis(); - - Chain withConnectTimeout(int timeout, TimeUnit unit); - - int readTimeoutMillis(); - - Chain withReadTimeout(int timeout, TimeUnit unit); - - int writeTimeoutMillis(); - - Chain withWriteTimeout(int timeout, TimeUnit unit); } } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/NewChain.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/NewChain.java new file mode 100644 index 0000000000..d8230a2d94 --- /dev/null +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/NewChain.java @@ -0,0 +1,121 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.http.metric; + +import org.miaixz.bus.http.NewCall; +import org.miaixz.bus.http.Request; +import org.miaixz.bus.http.Response; +import org.miaixz.bus.http.accord.Connection; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +/** + * 网络调用链 + * + * @author Kimi Liu + * @since Java 17+ + */ +public interface NewChain { + + /** + * @return 网络请求 + */ + Request request(); + + /** + * @param request 网络请求 + * @return {@link Response} + * @throws IOException 异常 + */ + Response proceed(Request request) throws IOException; + + /** + * 返回将执行请求的连接。这只在网络拦截器链中可用; + * 对于应用程序拦截器,这总是null + * + * @return 连接信息 + */ + Connection connection(); + + /** + * 实际调用准备执行的请求 + * + * @return {@link NewCall} + */ + NewCall call(); + + /** + * 连接超时时间 + * + * @return the int + */ + int connectTimeoutMillis(); + + /** + * 设置连接超时时间 + * + * @param timeout 超时时间 + * @param unit 单位 + * @return {@link NewChain} + */ + NewChain withConnectTimeout(int timeout, TimeUnit unit); + + /** + * 读操作超时时间 + * + * @return the int + */ + int readTimeoutMillis(); + + /** + * 配置读操作超时时间 + * + * @param timeout 超时时间 + * @param unit 单位 + * @return {@link NewChain} + */ + NewChain withReadTimeout(int timeout, TimeUnit unit); + + /** + * 写操作超时时间 + * + * @return the int + */ + int writeTimeoutMillis(); + + /** + * 配置写操作超时时间 + * + * @param timeout 超时时间 + * @param unit 单位 + * @return {@link NewChain} + */ + NewChain withWriteTimeout(int timeout, TimeUnit unit); + +} diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Browser.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Browser.java index a8946177cf..93cfe9948c 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Browser.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Browser.java @@ -59,11 +59,11 @@ public class Browser extends UserAgent { // 企业微信 企业微信使用微信浏览器内核,会包含 MicroMessenger 所以要放在前面 new Browser("wxwork", "wxwork", "wxwork\\/([\\d\\w\\.\\-]+)"), // 微信 - new Browser("MicroMessenger", "MicroMessenger", "MicroMessenger\\/([\\d\\w\\.\\-]+)"), + new Browser("MicroMessenger", "MicroMessenger", OTHER_VERSION), // 微信小程序 - new Browser("miniProgram", "miniProgram", "miniProgram\\/([\\d\\w\\.\\-]+)"), + new Browser("miniProgram", "miniProgram", OTHER_VERSION), // QQ浏览器 - new Browser("QQBrowser", "MQQBrowser", "MQQBrowser\\/([\\d\\w\\.\\-]+)"), + new Browser("QQBrowser", "QQBrowser", "QQBrowser\\/([\\d\\w\\.\\-]+)"), // 钉钉PC端浏览器 new Browser("DingTalk-win", "dingtalk-win", "DingTalk\\(([\\d\\w\\.\\-]+)\\)"), // 钉钉内置浏览器 @@ -73,13 +73,17 @@ public class Browser extends UserAgent { // 淘宝内置浏览器 new Browser("Taobao", "taobao", "AliApp\\(TB\\/([\\d\\w\\.\\-]+)\\)"), // UC浏览器 - new Browser("UCBrowser", "UCBrowser", "UCBrowser\\/([\\d\\w\\.\\-]+)"), - // Quark浏览器 - new Browser("Quark", "Quark", "Quark\\/([\\d\\w\\.\\-]+)"), - // Lenovo浏览器 + new Browser("UCBrowser", "UC?Browser", "UC?Browser\\/([\\d\\w\\.\\-]+)"), + // XiaoMi 浏览器 + new Browser("MiuiBrowser", "MiuiBrowser|mibrowser", "MiuiBrowser\\/([\\d\\w\\.\\-]+)"), + // 夸克浏览器 + new Browser("Quark", "Quark", OTHER_VERSION), + // 联想浏览器 new Browser("Lenovo", "SLBrowser", "SLBrowser/([\\d\\w\\.\\-]+)"), new Browser("MSEdge", "Edge|Edg", "(?:edge|Edg|EdgA)\\/([\\d\\w\\.\\-]+)"), - new Browser("Chrome", "chrome", OTHER_VERSION), + // issues I7OTCU + new Browser("Chrome", "chrome|(iphone.*crios.*safari)", "(?:Chrome|CriOS)\\/([\\d\\w\\.\\-]+)"), + //new Browser("Chrome", "chrome", Other_Version), new Browser("Firefox", "firefox", OTHER_VERSION), new Browser("IEMobile", "iemobile", OTHER_VERSION), new Browser("Android Browser", "android", "version\\/([\\d\\w\\.\\-]+)"), @@ -96,43 +100,60 @@ public class Browser extends UserAgent { new Browser("Evolution", "evolution", OTHER_VERSION), new Browser("MSIE", "msie", "msie ([\\d\\w\\.\\-]+)"), new Browser("MSIE11", "rv:11", "rv:([\\d\\w\\.\\-]+)"), - new Browser("Gabble", "Gabble", "Gabble\\/([\\d\\w\\.\\-]+)"), + new Browser("Gabble", "Gabble", OTHER_VERSION), new Browser("Yammer Desktop", "AdobeAir", "([\\d\\w\\.\\-]+)\\/Yammer"), new Browser("Yammer Mobile", "Yammer[\\s]+([\\d\\w\\.\\-]+)", "Yammer[\\s]+([\\d\\w\\.\\-]+)"), new Browser("Apache HTTP Client", "Apache\\\\-HttpClient", "Apache\\-HttpClient\\/([\\d\\w\\.\\-]+)"), new Browser("BlackBerry", "BlackBerry", "BlackBerry[\\d]+\\/([\\d\\w\\.\\-]+)"), - // 小米浏览器 - new Browser("MiuiBrowser", "MiuiBrowser|mibrowser", "MiuiBrowser\\/([\\d\\w\\.\\-]+)") - + // issue#I847JY 百度浏览器 + new Browser("Baidu", "Baidu", "baiduboxapp\\/([\\d\\w\\.\\-]+)") ); - private Pattern versionPattern; + /** + * 匹配正则 + */ + private Pattern pattern; /** * 构造 * - * @param name 浏览器名称 - * @param regex 关键字或表达式 - * @param versionRegex 匹配版本的正则 + * @param name 浏览器名称 + * @param rule 关键字或表达式 + * @param regex 匹配版本的正则 */ - public Browser(String name, String regex, String versionRegex) { - super(name, regex); - if (OTHER_VERSION.equals(versionRegex)) { - versionRegex = name + versionRegex; + public Browser(final String name, final String rule, String regex) { + super(name, rule); + if (OTHER_VERSION.equals(regex)) { + regex = name + regex; } - if (null != versionRegex) { - this.versionPattern = Pattern.compile(versionRegex, Pattern.CASE_INSENSITIVE); + if (null != regex) { + this.pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); } } + + /** + * 添加自定义的浏览器类型 + * + * @param name 浏览器名称 + * @param rule 关键字或表达式 + * @param regex 匹配版本的正则 + */ + synchronized public static void addCustomBrowser(final String name, final String rule, final String regex) { + BROWERS.add(new Browser(name, rule, regex)); + } + /** * 获取浏览器版本 * - * @param agentString User-Agent字符串 + * @param text User-Agent字符串 * @return 版本 */ - public String getVersion(String agentString) { - return PatternKit.getGroup1(this.versionPattern, agentString); + public String getVersion(final String text) { + if (isUnknown()) { + return null; + } + return PatternKit.getGroup1(this.pattern, text); } /** @@ -141,7 +162,14 @@ public String getVersion(String agentString) { * @return 是否移动浏览器 */ public boolean isMobile() { - return "PSP".equals(this.getName()); + final String name = this.getName(); + return "PSP".equals(name) || + "Yammer Mobile".equals(name) || + "Android Browser".equals(name) || + "IEMobile".equals(name) || + "MicroMessenger".equals(name) || + "miniProgram".equals(name) || + "DingTalk".equals(name); } } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Divice.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Device.java similarity index 69% rename from bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Divice.java rename to bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Device.java index 1636fb1e32..5003c0bdaa 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Divice.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Device.java @@ -28,9 +28,9 @@ package org.miaixz.bus.http.metric.anget; import org.miaixz.bus.core.lang.Normal; +import org.miaixz.bus.core.xyz.CollKit; import org.miaixz.bus.core.xyz.ListKit; -import java.util.ArrayList; import java.util.List; /** @@ -39,87 +39,81 @@ * @author Kimi Liu * @since Java 17+ */ -public class Divice extends UserAgent { +public class Device extends UserAgent { /** * 未知 */ - public static final Divice UNKNOWN = new Divice(Normal.UNKNOWN, null); + public static final Device UNKNOWN = new Device(Normal.UNKNOWN, null); /** - * iPhone + * Iphone */ - public static final Divice IPHONE = new Divice("iPhone", "iphone"); + public static final Device IPHONE = new Device("iPhone", "iphone"); /** - * iPod + * ipod */ - public static final Divice IPOD = new Divice("iPod", "ipod"); + public static final Device IPOD = new Device("iPod", "ipod"); /** - * iPad + * ipad */ - public static final Divice IPAD = new Divice("iPad", "ipad"); + public static final Device IPAD = new Device("iPad", "ipad"); /** - * Android + * android */ - public static final Divice ANDROID = new Divice("Android", "android"); + public static final Device ANDROID = new Device("Android", "android"); /** - * Android + * android */ - public static final Divice GOOGLE_TV = new Divice("GoogleTV", "googletv"); + public static final Device GOOGLE_TV = new Device("GoogleTV", "googletv"); /** * Windows Phone */ - public static final Divice WINDOWS_PHONE = new Divice("Windows Phone", "windows (ce|phone|mobile)( os)?"); + public static final Device WINDOWS_PHONE = new Device("Windows Phone", "windows (ce|phone|mobile)( os)?"); /** * 支持的移动平台类型 */ - public static final List MOBILE_DIVICES = ListKit.of( + public static final List MOBILE_DEVICE = ListKit.of( WINDOWS_PHONE, IPAD, IPOD, IPHONE, + new Device("Android", "XiaoMi|MI\\s+"), ANDROID, GOOGLE_TV, - new Divice("htcFlyer", "htc_flyer"), - new Divice("Symbian", "symbian(os)?"), - new Divice("Blackberry", "blackberry"), - new Divice("Android", "XiaoMi|MI\\s+") + new Device("htcFlyer", "htc_flyer"), + new Device("Symbian", "symbian(os)?"), + new Device("Blackberry", "blackberry") ); /** * 支持的桌面平台类型 */ - public static final List DESKTOP_DIVICES = ListKit.of( - new Divice("Windows", "windows"), - new Divice("Mac", "(macintosh|darwin)"), - new Divice("Linux", "linux"), - new Divice("Wii", "wii"), - new Divice("Playstation", "playstation"), - new Divice("Java", "java") + public static final List DESKTOP_DEVICE = ListKit.of( + new Device("Windows", "windows"), + new Device("Mac", "(macintosh|darwin)"), + new Device("Linux", "linux"), + new Device("Wii", "wii"), + new Device("Playstation", "playstation"), + new Device("Java", "java") ); /** * 支持的平台类型 */ - public static final List DIVICES; - - static { - DIVICES = new ArrayList<>(13); - DIVICES.addAll(MOBILE_DIVICES); - DIVICES.addAll(DESKTOP_DIVICES); - } + public static final List ALL_DEVICE = (List) CollKit.union(MOBILE_DEVICE, DESKTOP_DEVICE); /** * 构造 * * @param name 平台名称 - * @param regex 关键字或表达式 + * @param rule 关键字或表达式 */ - public Divice(String name, String regex) { - super(name, regex); + public Device(final String name, final String rule) { + super(name, rule); } /** @@ -128,7 +122,7 @@ public Divice(String name, String regex) { * @return 是否为移动平台 */ public boolean isMobile() { - return MOBILE_DIVICES.contains(this); + return MOBILE_DEVICE.contains(this); } /** @@ -137,7 +131,7 @@ public boolean isMobile() { * @return 是否为Iphone或者iPod设备 */ public boolean isIPhoneOrIPod() { - return IPHONE.equals(this) || IPOD.equals(this); + return this.equals(IPHONE) || this.equals(IPOD); } /** @@ -146,7 +140,7 @@ public boolean isIPhoneOrIPod() { * @return 是否为Iphone或者iPod设备 */ public boolean isIPad() { - return IPAD.equals(this); + return this.equals(IPAD); } /** @@ -164,7 +158,7 @@ public boolean isIos() { * @return 是否为Android平台,包括Android和Google TV */ public boolean isAndroid() { - return ANDROID.equals(this) || GOOGLE_TV.equals(this); + return this.equals(ANDROID) || this.equals(GOOGLE_TV); } } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Engine.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Engine.java index 47889938ad..2015f861f7 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Engine.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/Engine.java @@ -29,8 +29,10 @@ import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.xyz.ListKit; +import org.miaixz.bus.core.xyz.PatternKit; import java.util.List; +import java.util.regex.Pattern; /** * 浏览器解析引擎 @@ -48,7 +50,7 @@ public class Engine extends UserAgent { /** * 支持的引擎类型 */ - public static final List ENGINES = ListKit.of( + public static final List ENGINES = ListKit.view( new Engine("Trident", "trident"), new Engine("Webkit", "webkit"), new Engine("Chrome", "chrome"), @@ -56,18 +58,37 @@ public class Engine extends UserAgent { new Engine("Presto", "presto"), new Engine("Gecko", "gecko"), new Engine("KHTML", "khtml"), - new Engine("Konqeror", "konqueror"), + new Engine("Konqueror", "konqueror"), new Engine("MIDP", "MIDP") ); + /** + * 匹配正则 + */ + private final Pattern pattern; + /** * 构造 * * @param name 引擎名称 - * @param regex 关键字或表达式 + * @param rule 关键字或表达式 + */ + public Engine(String name, String rule) { + super(name, rule); + this.pattern = Pattern.compile(name + "[/\\- ]([\\w.\\-]+)", Pattern.CASE_INSENSITIVE); + } + + /** + * 获取引擎版本 + * + * @param userAgentString User-Agent字符串 + * @return 版本 */ - public Engine(String name, String regex) { - super(name, regex); + public String getVersion(final String userAgentString) { + if (isUnknown()) { + return null; + } + return PatternKit.getGroup1(this.pattern, userAgentString); } } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/NOS.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/NOS.java index 2c609ec710..df9d575512 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/NOS.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/NOS.java @@ -49,7 +49,7 @@ public class NOS extends UserAgent { /** * 支持的引擎类型 */ - public static final List OSES = ListKit.of( + public static final List NOS = ListKit.of( new NOS("Windows 10 or Windows Server 2016", "windows nt 10\\.0", "windows nt (10\\.0)"), new NOS("Windows 8.1 or Windows Server 2012R2", "windows nt 6\\.3", "windows nt (6\\.3)"), new NOS("Windows 8 or Windows Server 2012", "windows nt 6\\.2", "windows nt (6\\.2)"), @@ -78,7 +78,7 @@ public class NOS extends UserAgent { new NOS("Java", "Java[\\s]+([\\d\\w\\.\\-]+)", "Java[\\s]+([\\d\\w\\.\\-]+)") ); /** - * 版本规则 + * 匹配正则 */ private Pattern pattern; @@ -86,21 +86,21 @@ public class NOS extends UserAgent { * 构造 * * @param name 系统名称 - * @param regex 关键字或表达式 + * @param rule 关键字或表达式 */ - public NOS(String name, String regex) { - this(name, regex, null); + public NOS(String name, String rule) { + this(name, rule, null); } /** * 构造 * * @param name 系统名称 - * @param regex 关键字或表达式 + * @param rule 关键字或表达式 * @param versionRegex 版本正则表达式 */ - public NOS(String name, String regex, String versionRegex) { - super(name, regex); + public NOS(String name, String rule, String versionRegex) { + super(name, rule); if (null != versionRegex) { this.pattern = Pattern.compile(versionRegex, Pattern.CASE_INSENSITIVE); } @@ -110,11 +110,11 @@ public NOS(String name, String regex, String versionRegex) { * 添加自定义的系统类型 * * @param name 浏览器名称 - * @param regex 关键字或表达式 + * @param rule 关键字或表达式 * @param versionRegex 匹配版本的正则 */ - synchronized public static void addOs(String name, String regex, String versionRegex) { - OSES.add(new NOS(name, regex, versionRegex)); + synchronized public static void addOs(String name, String rule, String versionRegex) { + NOS.add(new NOS(name, rule, versionRegex)); } /** @@ -131,4 +131,13 @@ public String getVersion(String userAgent) { return PatternKit.getGroup1(this.pattern, userAgent); } + /** + * 是否为MacOS + * + * @return 是否为MacOS + */ + public boolean isMacOS() { + return "OSX".equals(getName()); + } + } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/UserAgent.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/UserAgent.java index 5d361f3cb9..f17163fdbe 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/UserAgent.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/anget/UserAgent.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.http.metric.anget; +import lombok.Getter; +import lombok.Setter; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.xyz.PatternKit; +import org.miaixz.bus.core.xyz.StringKit; import java.util.regex.Pattern; @@ -38,6 +41,8 @@ * @author Kimi Liu * @since Java 17+ */ +@Getter +@Setter public class UserAgent { /** @@ -51,11 +56,11 @@ public class UserAgent { /** * 平台类型 */ - private Divice divice; + private Device device; /** * 系统类型 */ - private NOS NOS; + private NOS nos; /** * 引擎类型 */ @@ -81,6 +86,7 @@ public class UserAgent { * 构造 */ public UserAgent() { + } /** @@ -105,147 +111,44 @@ public UserAgent(String name, Pattern pattern) { } /** - * 是否为移动平台 - * - * @return 是否为移动平台 - */ - public boolean isMobile() { - return mobile; - } - - /** - * 设置是否为移动平台 + * 解析User-Agent * - * @param mobile 是否为移动平台 + * @param text User-Agent字符串 + * @return {@link UserAgent} */ - public void setMobile(boolean mobile) { - this.mobile = mobile; - } - - /** - * 获取浏览器类型 - * - * @return 浏览器类型 - */ - public Browser getBrowser() { - return browser; - } - - /** - * 设置浏览器类型 - * - * @param browser 浏览器类型 - */ - public void setBrowser(Browser browser) { - this.browser = browser; - } - - /** - * 获取平台类型 - * - * @return 平台类型 - */ - public Divice getDivice() { - return divice; - } - - /** - * 设置平台类型 - * - * @param divice 平台类型 - */ - public void setDivice(Divice divice) { - this.divice = divice; - } + public static UserAgent parse(final String text) { + if (StringKit.isBlank(text)) { + return null; + } + final UserAgent userAgent = new UserAgent(); - /** - * 获取系统类型 - * - * @return 系统类型 - */ - public NOS getNOS() { - return NOS; - } + // 浏览器 + final Browser browser = parseBrowser(text); + userAgent.setBrowser(browser); + userAgent.setVersion(browser.getVersion(text)); - /** - * 设置系统类型 - * - * @param NOS 系统类型 - */ - public void setNOS(NOS NOS) { - this.NOS = NOS; - } + // 浏览器引擎 + final Engine engine = parseEngine(text); + userAgent.setEngine(engine); + userAgent.setEngineVersion(engine.getVersion(text)); - /** - * 获取引擎类型 - * - * @return 引擎类型 - */ - public Engine getEngine() { - return engine; - } + // 操作系统 + final NOS os = parseNOS(text); + userAgent.setNos(os); + userAgent.setVersion(os.getVersion(text)); - /** - * 设置引擎类型 - * - * @param engine 引擎类型 - */ - public void setEngine(Engine engine) { - this.engine = engine; - } + // 设备信息 + final Device device = parseDevice(text); + userAgent.setDevice(device); - /** - * 获取浏览器版本 - * - * @return 浏览器版本 - */ - public String getVersion() { - return version; - } - - /** - * 设置浏览器版本 - * - * @param version 浏览器版本 - */ - public void setVersion(String version) { - this.version = version; - } - - /** - * 获取引擎版本 - * - * @return 引擎版本 - */ - public String getEngineVersion() { - return engineVersion; - } - - /** - * 设置引擎版本 - * - * @param engineVersion 引擎版本 - */ - public void setEngineVersion(String engineVersion) { - this.engineVersion = engineVersion; - } - - /** - * 获取信息名称 - * - * @return 信息名称 - */ - public String getName() { - return name; - } + // MacOS 下的微信不属于移动平台 + if (device.isMobile() || browser.isMobile()) { + if (false == os.isMacOS()) { + userAgent.setMobile(true); + } + } - /** - * 获取匹配模式 - * - * @return 匹配模式 - */ - public Pattern getPattern() { - return pattern; + return userAgent; } /** @@ -297,4 +200,64 @@ public String toString() { return this.name; } + /** + * 解析浏览器类型 + * + * @param text User-Agent字符串 + * @return 浏览器类型 + */ + private static Browser parseBrowser(final String text) { + for (final Browser browser : Browser.BROWERS) { + if (browser.isMatch(text)) { + return browser; + } + } + return Browser.UNKNOWN; + } + + /** + * 解析引擎类型 + * + * @param text User-Agent字符串 + * @return 引擎类型 + */ + private static Engine parseEngine(final String text) { + for (final Engine engine : Engine.ENGINES) { + if (engine.isMatch(text)) { + return engine; + } + } + return Engine.UNKNOWN; + } + + /** + * 解析系统类型 + * + * @param text User-Agent字符串 + * @return 系统类型 + */ + private static NOS parseNOS(final String text) { + for (final NOS os : NOS.NOS) { + if (os.isMatch(text)) { + return os; + } + } + return NOS.UNKNOWN; + } + + /** + * 解析平台类型 + * + * @param text User-Agent字符串 + * @return 平台类型 + */ + private static Device parseDevice(final String text) { + for (final Device platform : Device.ALL_DEVICE) { + if (platform.isMatch(text)) { + return platform; + } + } + return Device.UNKNOWN; + } + } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/BridgeInterceptor.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/BridgeInterceptor.java index 88b32209e0..93018651e0 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/BridgeInterceptor.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/BridgeInterceptor.java @@ -29,15 +29,16 @@ import org.miaixz.bus.core.Version; import org.miaixz.bus.core.io.source.GzipSource; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.http.*; import org.miaixz.bus.http.bodys.RealResponseBody; import org.miaixz.bus.http.bodys.RequestBody; import org.miaixz.bus.http.metric.CookieJar; import org.miaixz.bus.http.metric.Interceptor; +import org.miaixz.bus.http.metric.NewChain; import java.io.IOException; import java.util.List; @@ -58,7 +59,7 @@ public BridgeInterceptor(CookieJar cookieJar) { } @Override - public Response intercept(Chain chain) throws IOException { + public Response intercept(NewChain chain) throws IOException { Request request = chain.request(); Request.Builder requestBuilder = request.newBuilder(); @@ -66,43 +67,43 @@ public Response intercept(Chain chain) throws IOException { if (null != body) { MediaType mediaType = body.mediaType(); if (null != mediaType) { - requestBuilder.header(Header.CONTENT_TYPE, mediaType.toString()); + requestBuilder.header(HTTP.CONTENT_TYPE, mediaType.toString()); } long length = body.length(); if (length != -1) { - requestBuilder.header(Header.CONTENT_LENGTH, Long.toString(length)); - requestBuilder.removeHeader(Header.TRANSFER_ENCODING); + requestBuilder.header(HTTP.CONTENT_LENGTH, Long.toString(length)); + requestBuilder.removeHeader(HTTP.TRANSFER_ENCODING); } else { - requestBuilder.header(Header.TRANSFER_ENCODING, "chunked"); - requestBuilder.removeHeader(Header.CONTENT_LENGTH); + requestBuilder.header(HTTP.TRANSFER_ENCODING, "chunked"); + requestBuilder.removeHeader(HTTP.CONTENT_LENGTH); } } - if (null == request.header(Header.HOST)) { - requestBuilder.header(Header.HOST, Builder.hostHeader(request.url(), false)); + if (null == request.header(HTTP.HOST)) { + requestBuilder.header(HTTP.HOST, Builder.hostHeader(request.url(), false)); } - if (null == request.header(Header.CONNECTION)) { - requestBuilder.header(Header.CONNECTION, Header.KEEP_ALIVE); + if (null == request.header(HTTP.CONNECTION)) { + requestBuilder.header(HTTP.CONNECTION, HTTP.KEEP_ALIVE); } // If we add an "Accept-Encoding: gzip" header field we're responsible for also decompressing // the transfer stream. boolean transparentGzip = false; - if (null == request.header(Header.ACCEPT_ENCODING) + if (null == request.header(HTTP.ACCEPT_ENCODING) && null == request.header("Range")) { transparentGzip = true; - requestBuilder.header(Header.ACCEPT_ENCODING, "gzip"); + requestBuilder.header(HTTP.ACCEPT_ENCODING, "gzip"); } List cookies = cookieJar.loadForRequest(request.url()); if (!cookies.isEmpty()) { - requestBuilder.header(Header.COOKIE, cookieHeader(cookies)); + requestBuilder.header(HTTP.COOKIE, cookieHeader(cookies)); } - if (null == request.header(Header.USER_AGENT)) { - requestBuilder.header(Header.USER_AGENT, "Httpd/" + Version.all()); + if (null == request.header(HTTP.USER_AGENT)) { + requestBuilder.header(HTTP.USER_AGENT, "Httpd/" + Version.all()); } Response networkResponse = chain.proceed(requestBuilder.build()); @@ -113,15 +114,15 @@ public Response intercept(Chain chain) throws IOException { .request(request); if (transparentGzip - && "gzip".equalsIgnoreCase(networkResponse.header(Header.CONTENT_ENCODING)) + && "gzip".equalsIgnoreCase(networkResponse.header(HTTP.CONTENT_ENCODING)) && Headers.hasBody(networkResponse)) { GzipSource responseBody = new GzipSource(networkResponse.body().source()); Headers strippedHeaders = networkResponse.headers().newBuilder() - .removeAll(Header.CONTENT_ENCODING) - .removeAll(Header.CONTENT_LENGTH) + .removeAll(HTTP.CONTENT_ENCODING) + .removeAll(HTTP.CONTENT_LENGTH) .build(); responseBuilder.headers(strippedHeaders); - String mediaType = networkResponse.header(Header.CONTENT_TYPE); + String mediaType = networkResponse.header(HTTP.CONTENT_TYPE); responseBuilder.body(new RealResponseBody(mediaType, -1L, IoKit.buffer(responseBody))); } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/CallServerInterceptor.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/CallServerInterceptor.java index 3b723a87a6..b8b7367192 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/CallServerInterceptor.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/CallServerInterceptor.java @@ -28,14 +28,14 @@ package org.miaixz.bus.http.metric.http; import org.miaixz.bus.core.io.sink.BufferSink; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.http.Builder; import org.miaixz.bus.http.Request; import org.miaixz.bus.http.Response; import org.miaixz.bus.http.accord.Exchange; import org.miaixz.bus.http.metric.Interceptor; +import org.miaixz.bus.http.metric.NewChain; import java.io.IOException; import java.net.ProtocolException; @@ -56,7 +56,7 @@ public CallServerInterceptor(boolean forWebSocket) { } @Override - public Response intercept(Chain chain) throws IOException { + public Response intercept(NewChain chain) throws IOException { RealInterceptorChain realChain = (RealInterceptorChain) chain; Exchange exchange = realChain.exchange(); Request request = realChain.request(); @@ -67,7 +67,7 @@ public Response intercept(Chain chain) throws IOException { boolean responseHeadersStarted = false; Response.Builder responseBuilder = null; - if (Http.permitsRequestBody(request.method()) && request.body() != null) { + if (HTTP.permitsRequestBody(request.method()) && request.body() != null) { // If there's a "Expect: 100-continue" header on the request, wait for a "HTTP/1.1 100 // Continue" response before transmitting the request body. If we don't get that, return // what we did get (such as a 4xx response) without ever transmitting the request body. @@ -148,8 +148,8 @@ public Response intercept(Chain chain) throws IOException { .build(); } - if ("close".equalsIgnoreCase(response.request().header(Header.CONNECTION)) - || "close".equalsIgnoreCase(response.header(Header.CONNECTION))) { + if ("close".equalsIgnoreCase(response.request().header(HTTP.CONNECTION)) + || "close".equalsIgnoreCase(response.header(HTTP.CONNECTION))) { exchange.noNewExchangesOnConnection(); } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Hpack.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Hpack.java index 2fe39d80fb..6b5a09e1f2 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Hpack.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Hpack.java @@ -31,20 +31,18 @@ import org.miaixz.bus.core.io.buffer.Buffer; import org.miaixz.bus.core.io.source.BufferSource; import org.miaixz.bus.core.io.source.Source; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.core.xyz.StringKit; -import org.miaixz.bus.http.Headers; import java.io.IOException; import java.util.*; /** * 读写HPACK v10. - *

                * 这个实现为动态表使用一个数组,为索引条目使用一个列表。 * 动态条目被添加到数组中,从最后一个位置开始向前移动。当数组填满时,它被加倍. * @@ -53,68 +51,68 @@ */ class Hpack { - static final Headers.Header[] STATIC_HEADER_TABLE = new Headers.Header[]{ - new Headers.Header(Headers.Header.TARGET_AUTHORITY, Normal.EMPTY), - new Headers.Header(Headers.Header.TARGET_METHOD, Http.GET), - new Headers.Header(Headers.Header.TARGET_METHOD, Http.POST), - new Headers.Header(Headers.Header.TARGET_PATH, Symbol.SLASH), - new Headers.Header(Headers.Header.TARGET_PATH, "/index.html"), - new Headers.Header(Headers.Header.TARGET_SCHEME, Http.HTTP), - new Headers.Header(Headers.Header.TARGET_SCHEME, Http.HTTPS), - new Headers.Header(Headers.Header.RESPONSE_STATUS, StringKit.toString(Http.HTTP_OK)), - new Headers.Header(Headers.Header.RESPONSE_STATUS, StringKit.toString(Http.HTTP_NO_CONTENT)), - new Headers.Header(Headers.Header.RESPONSE_STATUS, StringKit.toString(Http.HTTP_PARTIAL)), - new Headers.Header(Headers.Header.RESPONSE_STATUS, StringKit.toString(Http.HTTP_NOT_MODIFIED)), - new Headers.Header(Headers.Header.RESPONSE_STATUS, StringKit.toString(Http.HTTP_BAD_REQUEST)), - new Headers.Header(Headers.Header.RESPONSE_STATUS, StringKit.toString(Http.HTTP_NOT_FOUND)), - new Headers.Header(Headers.Header.RESPONSE_STATUS, StringKit.toString(Http.HTTP_INTERNAL_ERROR)), - new Headers.Header(Header.ACCEPT_CHARSET, Normal.EMPTY), - new Headers.Header(Header.ACCEPT_ENCODING, "gzip, deflate"), - new Headers.Header(Header.ACCEPT_LANGUAGE, Normal.EMPTY), - new Headers.Header(Header.ACCEPT_RANGES, Normal.EMPTY), - new Headers.Header(Header.ACCEPT, Normal.EMPTY), - new Headers.Header(Header.ACCESS_CONTROL_ALLOW_ORIGIN, Normal.EMPTY), - new Headers.Header(Header.AGE, Normal.EMPTY), - new Headers.Header(Header.ALLOW, Normal.EMPTY), - new Headers.Header(Header.AUTHORIZATION, Normal.EMPTY), - new Headers.Header(Header.CACHE_CONTROL, Normal.EMPTY), - new Headers.Header(Header.CONTENT_DISPOSITION, Normal.EMPTY), - new Headers.Header(Header.CONTENT_ENCODING, Normal.EMPTY), - new Headers.Header(Header.CONTENT_LANGUAGE, Normal.EMPTY), - new Headers.Header(Header.CONTENT_LENGTH, Normal.EMPTY), - new Headers.Header(Header.CONTENT_LOCATION, Normal.EMPTY), - new Headers.Header(Header.CONTENT_RANGE, Normal.EMPTY), - new Headers.Header(Header.CONTENT_TYPE, Normal.EMPTY), - new Headers.Header(Header.COOKIE, Normal.EMPTY), - new Headers.Header(Header.DATE, Normal.EMPTY), - new Headers.Header(Header.ETAG, Normal.EMPTY), - new Headers.Header(Header.EXPECT, Normal.EMPTY), - new Headers.Header(Header.EXPIRES, Normal.EMPTY), - new Headers.Header(Header.FROM, Normal.EMPTY), - new Headers.Header(Header.HOST, Normal.EMPTY), - new Headers.Header(Header.IF_MATCH, Normal.EMPTY), - new Headers.Header(Header.IF_MODIFIED_SINCE, Normal.EMPTY), - new Headers.Header(Header.IF_NONE_MATCH, Normal.EMPTY), - new Headers.Header(Header.IF_RANGE, Normal.EMPTY), - new Headers.Header(Header.IF_UNMODIFIED_SINCE, Normal.EMPTY), - new Headers.Header(Header.LAST_MODIFIED, Normal.EMPTY), - new Headers.Header(Header.LINK, Normal.EMPTY), - new Headers.Header(Header.LOCATION, Normal.EMPTY), - new Headers.Header(Header.MAX_FORWARDS, Normal.EMPTY), - new Headers.Header(Header.PROXY_AUTHENTICATE, Normal.EMPTY), - new Headers.Header(Header.PROXY_AUTHORIZATION, Normal.EMPTY), - new Headers.Header(Header.RANGE, Normal.EMPTY), - new Headers.Header(Header.REFERER, Normal.EMPTY), - new Headers.Header(Header.REFRESH, Normal.EMPTY), - new Headers.Header(Header.RETRY_AFTER, Normal.EMPTY), - new Headers.Header(Header.SERVER, Normal.EMPTY), - new Headers.Header(Header.SET_COOKIE, Normal.EMPTY), - new Headers.Header(Header.STRICT_TRANSPORT_SECURITY, Normal.EMPTY), - new Headers.Header(Header.TRANSFER_ENCODING, Normal.EMPTY), - new Headers.Header(Header.USER_AGENT, Normal.EMPTY), - new Headers.Header(Header.VARY, Normal.EMPTY), - new Headers.Header(Header.VIA, Normal.EMPTY), - new Headers.Header(Header.WWW_AUTHENTICATE, Normal.EMPTY) + static final Http2Header[] STATIC_HEADER_TABLE = new Http2Header[]{ + new Http2Header(Http2Header.TARGET_AUTHORITY, Normal.EMPTY), + new Http2Header(Http2Header.TARGET_METHOD, HTTP.GET), + new Http2Header(Http2Header.TARGET_METHOD, HTTP.POST), + new Http2Header(Http2Header.TARGET_PATH, Symbol.SLASH), + new Http2Header(Http2Header.TARGET_PATH, "/index.html"), + new Http2Header(Http2Header.TARGET_SCHEME, Protocol.HTTP.name), + new Http2Header(Http2Header.TARGET_SCHEME, Protocol.HTTPS.name), + new Http2Header(Http2Header.RESPONSE_STATUS, StringKit.toString(HTTP.HTTP_OK)), + new Http2Header(Http2Header.RESPONSE_STATUS, StringKit.toString(HTTP.HTTP_NO_CONTENT)), + new Http2Header(Http2Header.RESPONSE_STATUS, StringKit.toString(HTTP.HTTP_PARTIAL)), + new Http2Header(Http2Header.RESPONSE_STATUS, StringKit.toString(HTTP.HTTP_NOT_MODIFIED)), + new Http2Header(Http2Header.RESPONSE_STATUS, StringKit.toString(HTTP.HTTP_BAD_REQUEST)), + new Http2Header(Http2Header.RESPONSE_STATUS, StringKit.toString(HTTP.HTTP_NOT_FOUND)), + new Http2Header(Http2Header.RESPONSE_STATUS, StringKit.toString(HTTP.HTTP_INTERNAL_ERROR)), + new Http2Header(HTTP.ACCEPT_CHARSET, Normal.EMPTY), + new Http2Header(HTTP.ACCEPT_ENCODING, "gzip, deflate"), + new Http2Header(HTTP.ACCEPT_LANGUAGE, Normal.EMPTY), + new Http2Header(HTTP.ACCEPT_RANGES, Normal.EMPTY), + new Http2Header(HTTP.ACCEPT, Normal.EMPTY), + new Http2Header(HTTP.ACCESS_CONTROL_ALLOW_ORIGIN, Normal.EMPTY), + new Http2Header(HTTP.AGE, Normal.EMPTY), + new Http2Header(HTTP.ALLOW, Normal.EMPTY), + new Http2Header(HTTP.AUTHORIZATION, Normal.EMPTY), + new Http2Header(HTTP.CACHE_CONTROL, Normal.EMPTY), + new Http2Header(HTTP.CONTENT_DISPOSITION, Normal.EMPTY), + new Http2Header(HTTP.CONTENT_ENCODING, Normal.EMPTY), + new Http2Header(HTTP.CONTENT_LANGUAGE, Normal.EMPTY), + new Http2Header(HTTP.CONTENT_LENGTH, Normal.EMPTY), + new Http2Header(HTTP.CONTENT_LOCATION, Normal.EMPTY), + new Http2Header(HTTP.CONTENT_RANGE, Normal.EMPTY), + new Http2Header(HTTP.CONTENT_TYPE, Normal.EMPTY), + new Http2Header(HTTP.COOKIE, Normal.EMPTY), + new Http2Header(HTTP.DATE, Normal.EMPTY), + new Http2Header(HTTP.ETAG, Normal.EMPTY), + new Http2Header(HTTP.EXPECT, Normal.EMPTY), + new Http2Header(HTTP.EXPIRES, Normal.EMPTY), + new Http2Header(HTTP.FROM, Normal.EMPTY), + new Http2Header(HTTP.HOST, Normal.EMPTY), + new Http2Header(HTTP.IF_MATCH, Normal.EMPTY), + new Http2Header(HTTP.IF_MODIFIED_SINCE, Normal.EMPTY), + new Http2Header(HTTP.IF_NONE_MATCH, Normal.EMPTY), + new Http2Header(HTTP.IF_RANGE, Normal.EMPTY), + new Http2Header(HTTP.IF_UNMODIFIED_SINCE, Normal.EMPTY), + new Http2Header(HTTP.LAST_MODIFIED, Normal.EMPTY), + new Http2Header(HTTP.LINK, Normal.EMPTY), + new Http2Header(HTTP.LOCATION, Normal.EMPTY), + new Http2Header(HTTP.MAX_FORWARDS, Normal.EMPTY), + new Http2Header(HTTP.PROXY_AUTHENTICATE, Normal.EMPTY), + new Http2Header(HTTP.PROXY_AUTHORIZATION, Normal.EMPTY), + new Http2Header(HTTP.RANGE, Normal.EMPTY), + new Http2Header(HTTP.REFERER, Normal.EMPTY), + new Http2Header(HTTP.REFRESH, Normal.EMPTY), + new Http2Header(HTTP.RETRY_AFTER, Normal.EMPTY), + new Http2Header(HTTP.SERVER, Normal.EMPTY), + new Http2Header(HTTP.SET_COOKIE, Normal.EMPTY), + new Http2Header(HTTP.STRICT_TRANSPORT_SECURITY, Normal.EMPTY), + new Http2Header(HTTP.TRANSFER_ENCODING, Normal.EMPTY), + new Http2Header(HTTP.USER_AGENT, Normal.EMPTY), + new Http2Header(HTTP.VARY, Normal.EMPTY), + new Http2Header(HTTP.VIA, Normal.EMPTY), + new Http2Header(HTTP.WWW_AUTHENTICATE, Normal.EMPTY) }; static final Map NAME_TO_FIRST_INDEX = nameToFirstIndex(); private static final int PREFIX_4_BITS = 0x0f; @@ -151,11 +149,11 @@ static ByteString checkLowercase(ByteString name) throws IOException { static class Reader { - private final List headerList = new ArrayList<>(); + private final List headerList = new ArrayList<>(); private final BufferSource source; private final int headerTableSizeSetting; - Headers.Header[] dynamicTable = new Headers.Header[8]; + Http2Header[] dynamicTable = new Http2Header[8]; int nextHeaderIndex = dynamicTable.length - 1; int headerCount = 0; int dynamicTableByteCount = 0; @@ -241,15 +239,15 @@ void readHeaders() throws IOException { } } - public List getAndResetHeaderList() { - List result = new ArrayList<>(headerList); + public List getAndResetHeaderList() { + List result = new ArrayList<>(headerList); headerList.clear(); return result; } private void readIndexedHeader(int index) throws IOException { if (isStaticHeader(index)) { - Headers.Header staticEntry = STATIC_HEADER_TABLE[index]; + Http2Header staticEntry = STATIC_HEADER_TABLE[index]; headerList.add(staticEntry); } else { int dynamicTableIndex = dynamicTableIndex(index - STATIC_HEADER_TABLE.length); @@ -267,26 +265,26 @@ private int dynamicTableIndex(int index) { private void readLiteralHeaderWithoutIndexingIndexedName(int index) throws IOException { ByteString name = getName(index); ByteString value = readByteString(); - headerList.add(new Headers.Header(name, value)); + headerList.add(new Http2Header(name, value)); } private void readLiteralHeaderWithoutIndexingNewName() throws IOException { ByteString name = checkLowercase(readByteString()); ByteString value = readByteString(); - headerList.add(new Headers.Header(name, value)); + headerList.add(new Http2Header(name, value)); } private void readLiteralHeaderWithIncrementalIndexingIndexedName(int nameIndex) throws IOException { ByteString name = getName(nameIndex); ByteString value = readByteString(); - insertIntoDynamicTable(-1, new Headers.Header(name, value)); + insertIntoDynamicTable(-1, new Http2Header(name, value)); } private void readLiteralHeaderWithIncrementalIndexingNewName() throws IOException { ByteString name = checkLowercase(readByteString()); ByteString value = readByteString(); - insertIntoDynamicTable(-1, new Headers.Header(name, value)); + insertIntoDynamicTable(-1, new Http2Header(name, value)); } private ByteString getName(int index) throws IOException { @@ -309,7 +307,7 @@ private boolean isStaticHeader(int index) { /** * index == -1 when new. */ - private void insertIntoDynamicTable(int index, Headers.Header entry) { + private void insertIntoDynamicTable(int index, Http2Header entry) { headerList.add(entry); int delta = entry.hpackSize; @@ -329,7 +327,7 @@ private void insertIntoDynamicTable(int index, Headers.Header entry) { if (index == -1) { // Adding a value to the dynamic table. if (headerCount + 1 > dynamicTable.length) { // Need to grow the dynamic table. - Headers.Header[] doubled = new Headers.Header[dynamicTable.length * 2]; + Http2Header[] doubled = new Http2Header[dynamicTable.length * 2]; System.arraycopy(dynamicTable, 0, doubled, dynamicTable.length, dynamicTable.length); nextHeaderIndex = dynamicTable.length - 1; dynamicTable = doubled; @@ -401,7 +399,7 @@ static class Writer { int headerTableSizeSetting; int maxDynamicTableByteCount; // Visible for testing. - Headers.Header[] dynamicTable = new Headers.Header[8]; + Http2Header[] dynamicTable = new Http2Header[8]; // Array is populated back to front, so new entries always have lowest index. int nextHeaderIndex = dynamicTable.length - 1; int headerCount = 0; @@ -452,7 +450,7 @@ private int evictToRecoverBytes(int bytesToRecover) { return entriesToEvict; } - private void insertIntoDynamicTable(Headers.Header entry) { + private void insertIntoDynamicTable(Http2Header entry) { int delta = entry.hpackSize; // if the new or replacement header is too big, drop all entries. @@ -466,7 +464,7 @@ private void insertIntoDynamicTable(Headers.Header entry) { evictToRecoverBytes(bytesToRecover); if (headerCount + 1 > dynamicTable.length) { // Need to grow the dynamic table. - Headers.Header[] doubled = new Headers.Header[dynamicTable.length * 2]; + Http2Header[] doubled = new Http2Header[dynamicTable.length * 2]; System.arraycopy(dynamicTable, 0, doubled, dynamicTable.length, dynamicTable.length); nextHeaderIndex = dynamicTable.length - 1; dynamicTable = doubled; @@ -480,7 +478,7 @@ private void insertIntoDynamicTable(Headers.Header entry) { /** * This does not use "never indexed" semantics for sensitive headers. */ - void writeHeaders(List headerBlock) throws IOException { + void writeHeaders(List headerBlock) throws IOException { if (emitDynamicTableSizeUpdate) { if (smallestHeaderTableSizeSetting < maxDynamicTableByteCount) { // Multiple dynamic table size updates! @@ -492,7 +490,7 @@ void writeHeaders(List headerBlock) throws IOException { } for (int i = 0, size = headerBlock.size(); i < size; i++) { - Headers.Header header = headerBlock.get(i); + Http2Header header = headerBlock.get(i); ByteString name = header.name.toAsciiLowercase(); ByteString value = header.value; int headerIndex = -1; @@ -536,7 +534,7 @@ void writeHeaders(List headerBlock) throws IOException { writeByteString(name); writeByteString(value); insertIntoDynamicTable(header); - } else if (name.startsWith(Headers.Header.PSEUDO_PREFIX) && !Headers.Header.TARGET_AUTHORITY.equals(name)) { + } else if (name.startsWith(Http2Header.PSEUDO_PREFIX) && !Http2Header.TARGET_AUTHORITY.equals(name)) { // Follow Chromes lead - only include the :authority pseudo header, but exclude all other // pseudo headers. Literal Header Field without Indexing - Indexed Name. writeInt(headerNameIndex, PREFIX_4_BITS, 0); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http1Codec.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http1Codec.java index 604b0c2377..2a0778f4b6 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http1Codec.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http1Codec.java @@ -34,9 +34,9 @@ import org.miaixz.bus.core.io.source.Source; import org.miaixz.bus.core.io.timout.AssignTimeout; import org.miaixz.bus.core.io.timout.Timeout; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.*; import org.miaixz.bus.http.accord.RealConnection; import org.miaixz.bus.http.metric.Internal; @@ -227,9 +227,9 @@ public Response.Builder readResponseHeaders(boolean expectContinue) throws IOExc .message(statusLine.message) .headers(readHeaders()); - if (expectContinue && statusLine.code == Http.HTTP_CONTINUE) { + if (expectContinue && statusLine.code == HTTP.HTTP_CONTINUE) { return null; - } else if (statusLine.code == Http.HTTP_CONTINUE) { + } else if (statusLine.code == HTTP.HTTP_CONTINUE) { state = STATE_READ_RESPONSE_HEADERS; return responseBuilder; } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Codec.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Codec.java index 1dfb48c48b..b3a60ebe05 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Codec.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Codec.java @@ -29,13 +29,13 @@ import org.miaixz.bus.core.io.sink.Sink; import org.miaixz.bus.core.io.source.Source; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.http.*; import org.miaixz.bus.http.accord.RealConnection; -import org.miaixz.bus.http.metric.Interceptor; import org.miaixz.bus.http.metric.Internal; +import org.miaixz.bus.http.metric.NewChain; import java.io.IOException; import java.net.ProtocolException; @@ -55,29 +55,29 @@ public class Http2Codec implements HttpCodec { * See http://tools.ietf.org/html/draft-ietf-httpbis-http2-09#section-8.1.3. */ private static final List HTTP_2_SKIPPED_REQUEST_HEADERS = Builder.immutableList( - Header.CONNECTION, - Header.HOST, - Header.KEEP_ALIVE, - Header.PROXY_CONNECTION, - Header.TE, - Header.TRANSFER_ENCODING, - Header.ENCODING, - Header.UPGRADE, - Http.TARGET_METHOD_UTF8, - Http.TARGET_PATH_UTF8, - Http.TARGET_SCHEME_UTF8, - Http.TARGET_AUTHORITY_UTF8); + HTTP.CONNECTION, + HTTP.HOST, + HTTP.KEEP_ALIVE, + HTTP.PROXY_CONNECTION, + HTTP.TE, + HTTP.TRANSFER_ENCODING, + HTTP.ENCODING, + HTTP.UPGRADE, + HTTP.TARGET_METHOD_UTF8, + HTTP.TARGET_PATH_UTF8, + HTTP.TARGET_SCHEME_UTF8, + HTTP.TARGET_AUTHORITY_UTF8); private static final List HTTP_2_SKIPPED_RESPONSE_HEADERS = Builder.immutableList( - Header.CONNECTION, - Header.HOST, - Header.KEEP_ALIVE, - Header.PROXY_CONNECTION, - Header.TE, - Header.TRANSFER_ENCODING, - Header.ENCODING, - Header.UPGRADE); - - private final Interceptor.Chain chain; + HTTP.CONNECTION, + HTTP.HOST, + HTTP.KEEP_ALIVE, + HTTP.PROXY_CONNECTION, + HTTP.TE, + HTTP.TRANSFER_ENCODING, + HTTP.ENCODING, + HTTP.UPGRADE); + + private final NewChain chain; private final RealConnection realConnection; private final Http2Connection connection; private final Protocol protocol; @@ -85,7 +85,7 @@ public class Http2Codec implements HttpCodec { private volatile boolean canceled; public Http2Codec(Httpd client, RealConnection realConnection, - Interceptor.Chain chain, Http2Connection connection) { + NewChain chain, Http2Connection connection) { this.realConnection = realConnection; this.chain = chain; this.connection = connection; @@ -94,23 +94,23 @@ public Http2Codec(Httpd client, RealConnection realConnection, : Protocol.HTTP_2; } - public static List http2HeadersList(Request request) { + public static List http2HeadersList(Request request) { Headers headers = request.headers(); - List result = new ArrayList<>(headers.size() + 4); - result.add(new Headers.Header(Headers.Header.TARGET_METHOD, request.method())); - result.add(new Headers.Header(Headers.Header.TARGET_PATH, RequestLine.requestPath(request.url()))); + List result = new ArrayList<>(headers.size() + 4); + result.add(new Http2Header(Http2Header.TARGET_METHOD, request.method())); + result.add(new Http2Header(Http2Header.TARGET_PATH, RequestLine.requestPath(request.url()))); String host = request.header("Host"); if (host != null) { - result.add(new Headers.Header(Headers.Header.TARGET_AUTHORITY, host)); // Optional. + result.add(new Http2Header(Http2Header.TARGET_AUTHORITY, host)); // Optional. } - result.add(new Headers.Header(Headers.Header.TARGET_SCHEME, request.url().scheme())); + result.add(new Http2Header(Http2Header.TARGET_SCHEME, request.url().scheme())); for (int i = 0, size = headers.size(); i < size; i++) { // header names must be lowercase. String name = StringKit.upperFirst(headers.name(i)); - if (!HTTP_2_SKIPPED_REQUEST_HEADERS.contains(name) || name.equals(Header.TE) + if (!HTTP_2_SKIPPED_REQUEST_HEADERS.contains(name) || name.equals(HTTP.TE) && "trailers".equals(headers.value(i))) { - result.add(new Headers.Header(name, headers.value(i))); + result.add(new Http2Header(name, headers.value(i))); } } return result; @@ -126,7 +126,7 @@ public static Response.Builder readHttp2HeadersList(Headers headerBlock, for (int i = 0, size = headerBlock.size(); i < size; i++) { String name = headerBlock.name(i); String value = headerBlock.value(i); - if (name.equals(Http.RESPONSE_STATUS_UTF8)) { + if (name.equals(HTTP.RESPONSE_STATUS_UTF8)) { statusLine = StatusLine.parse("HTTP/1.1 " + value); } else if (!HTTP_2_SKIPPED_RESPONSE_HEADERS.contains(name)) { Internal.instance.addLenient(headersBuilder, name, value); @@ -156,12 +156,12 @@ public void writeRequestHeaders(Request request) throws IOException { if (stream != null) return; boolean hasRequestBody = request.body() != null; - List requestHeaders = http2HeadersList(request); + List requestHeaders = http2HeadersList(request); stream = connection.newStream(requestHeaders, hasRequestBody); // We may have been asked to cancel while creating the new stream and sending the request // headers, but there was still no stream to close. if (canceled) { - stream.closeLater(ErrorCode.CANCEL); + stream.closeLater(Http2ErrorCode.CANCEL); throw new IOException("Canceled"); } stream.readTimeout().timeout(chain.readTimeoutMillis(), TimeUnit.MILLISECONDS); @@ -182,7 +182,7 @@ public void finishRequest() throws IOException { public Response.Builder readResponseHeaders(boolean expectContinue) throws IOException { Headers headers = stream.takeHeaders(); Response.Builder responseBuilder = readHttp2HeadersList(headers, protocol); - if (expectContinue && Internal.instance.code(responseBuilder) == Http.HTTP_CONTINUE) { + if (expectContinue && Internal.instance.code(responseBuilder) == HTTP.HTTP_CONTINUE) { return null; } return responseBuilder; @@ -206,7 +206,7 @@ public Headers trailers() throws IOException { @Override public void cancel() { canceled = true; - if (stream != null) stream.closeLater(ErrorCode.CANCEL); + if (stream != null) stream.closeLater(Http2ErrorCode.CANCEL); } } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Connection.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Connection.java index 2a48bd9f7f..1bfd9c78c8 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Connection.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Connection.java @@ -31,11 +31,10 @@ import org.miaixz.bus.core.io.buffer.Buffer; import org.miaixz.bus.core.io.sink.BufferSink; import org.miaixz.bus.core.io.source.BufferSource; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.http.Headers; -import org.miaixz.bus.http.Settings; import org.miaixz.bus.http.metric.NamedRunnable; import org.miaixz.bus.logger.Logger; @@ -100,7 +99,7 @@ public class Http2Connection implements Closeable { /** * 我们从对等点接收设置. */ - final Settings peerSettings = new Settings(); + final Http2Settings peerSettings = new Http2Settings(); final Socket socket; final Http2Writer writer; final ReaderRunnable readerRunnable; @@ -127,7 +126,7 @@ public class Http2Connection implements Closeable { /** * 设置我们与对等点通信 */ - Settings settings = new Settings(); + Http2Settings settings = new Http2Settings(); private boolean shutdown; // Total number of pings send and received of the corresponding types. All guarded by this. private long intervalPingsSent = 0L; @@ -156,7 +155,7 @@ public class Http2Connection implements Closeable { // thrashing window updates every 64KiB, yet small enough to avoid blowing // up the heap. if (builder.client) { - settings.set(Http.INITIAL_WINDOW_SIZE, CLIENT_WINDOW_SIZE); + settings.set(HTTP.INITIAL_WINDOW_SIZE, CLIENT_WINDOW_SIZE); } connectionName = builder.connectionName; @@ -171,8 +170,8 @@ public class Http2Connection implements Closeable { // Like newSingleThreadExecutor, except lazy creates the thread. pushExecutor = new ThreadPoolExecutor(0, 1, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), org.miaixz.bus.http.Builder.threadFactory(String.format("Http %s Push Observer", connectionName), true)); - peerSettings.set(Http.INITIAL_WINDOW_SIZE, Http.DEFAULT_INITIAL_WINDOW_SIZE); - peerSettings.set(Http.MAX_FRAME_SIZE, Http2.INITIAL_MAX_FRAME_SIZE); + peerSettings.set(HTTP.INITIAL_WINDOW_SIZE, HTTP.DEFAULT_INITIAL_WINDOW_SIZE); + peerSettings.set(HTTP.MAX_FRAME_SIZE, Http2.INITIAL_MAX_FRAME_SIZE); bytesLeftInWriteWindow = peerSettings.getInitialWindowSize(); socket = builder.socket; writer = new Http2Writer(builder.sink, client); @@ -218,7 +217,7 @@ synchronized void updateConnectionFlowControl(long read) { * @return http请求流 * @throws IOException 异常 */ - public Http2Stream pushStream(int associatedStreamId, List requestHeaders, boolean out) + public Http2Stream pushStream(int associatedStreamId, List requestHeaders, boolean out) throws IOException { if (client) throw new IllegalStateException("Client cannot push requests."); return newStream(associatedStreamId, requestHeaders, out); @@ -230,12 +229,12 @@ public Http2Stream pushStream(int associatedStreamId, List reque * @param out true to create an output stream that we can use to send data to the remote peer. * Corresponds to {@code FLAG_FIN}. */ - public Http2Stream newStream(List requestHeaders, boolean out) throws IOException { + public Http2Stream newStream(List requestHeaders, boolean out) throws IOException { return newStream(0, requestHeaders, out); } private Http2Stream newStream( - int associatedStreamId, List requestHeaders, boolean out) throws IOException { + int associatedStreamId, List requestHeaders, boolean out) throws IOException { boolean outFinished = !out; boolean inFinished = false; boolean flushHeaders; @@ -245,7 +244,7 @@ private Http2Stream newStream( synchronized (writer) { synchronized (this) { if (nextStreamId > Integer.MAX_VALUE / 2) { - shutdown(ErrorCode.REFUSED_STREAM); + shutdown(Http2ErrorCode.REFUSED_STREAM); } if (shutdown) { throw new IOException(); @@ -274,7 +273,7 @@ private Http2Stream newStream( return stream; } - void writeHeaders(int streamId, boolean outFinished, List alternating) + void writeHeaders(int streamId, boolean outFinished, List alternating) throws IOException { writer.headers(outFinished, streamId, alternating); } @@ -324,7 +323,7 @@ public void writeData(int streamId, boolean outFinished, Buffer buffer, long byt } } - void writeSynResetLater(final int streamId, final ErrorCode errorCode) { + void writeSynResetLater(final int streamId, final Http2ErrorCode errorCode) { try { writerExecutor.execute(new NamedRunnable("Http %s stream %d", connectionName, streamId) { @Override @@ -341,7 +340,7 @@ public void execute() { } } - void writeSynReset(int streamId, ErrorCode statusCode) throws IOException { + void writeSynReset(int streamId, Http2ErrorCode statusCode) throws IOException { writer.rstStream(streamId, statusCode); } @@ -407,7 +406,7 @@ public void flush() throws IOException { * from the remote peer. Existing streams are not impacted. This is intended to permit an endpoint * to gracefully stop accepting new requests without harming previously established streams. */ - public void shutdown(ErrorCode statusCode) throws IOException { + public void shutdown(Http2ErrorCode statusCode) throws IOException { synchronized (writer) { int lastGoodStreamId; synchronized (this) { @@ -427,10 +426,10 @@ public void shutdown(ErrorCode statusCode) throws IOException { */ @Override public void close() { - close(ErrorCode.NO_ERROR, ErrorCode.CANCEL, null); + close(Http2ErrorCode.NO_ERROR, Http2ErrorCode.CANCEL, null); } - void close(ErrorCode connectionCode, ErrorCode streamCode, IOException cause) { + void close(Http2ErrorCode connectionCode, Http2ErrorCode streamCode, IOException cause) { assert (!Thread.holdsLock(this)); try { shutdown(connectionCode); @@ -472,7 +471,7 @@ void close(ErrorCode connectionCode, ErrorCode streamCode, IOException cause) { } private void failConnection(IOException e) { - close(ErrorCode.PROTOCOL_ERROR, ErrorCode.PROTOCOL_ERROR, e); + close(Http2ErrorCode.PROTOCOL_ERROR, Http2ErrorCode.PROTOCOL_ERROR, e); } /** @@ -492,8 +491,8 @@ void start(boolean sendConnectionPreface) throws IOException { writer.connectionPreface(); writer.settings(settings); int windowSize = settings.getInitialWindowSize(); - if (windowSize != Http.DEFAULT_INITIAL_WINDOW_SIZE) { - writer.windowUpdate(0, windowSize - Http.DEFAULT_INITIAL_WINDOW_SIZE); + if (windowSize != HTTP.DEFAULT_INITIAL_WINDOW_SIZE) { + writer.windowUpdate(0, windowSize - HTTP.DEFAULT_INITIAL_WINDOW_SIZE); } } new Thread(readerRunnable).start(); // Not a daemon thread. @@ -502,7 +501,7 @@ void start(boolean sendConnectionPreface) throws IOException { /** * Merges {@code settings} into this peer's settings and sends them to the remote peer. */ - public void setSettings(Settings settings) throws IOException { + public void setSettings(Http2Settings settings) throws IOException { synchronized (writer) { synchronized (this) { if (shutdown) { @@ -560,10 +559,10 @@ boolean pushedStream(int streamId) { return streamId != 0 && (streamId & 1) == 0; } - void pushRequestLater(final int streamId, final List requestHeaders) { + void pushRequestLater(final int streamId, final List requestHeaders) { synchronized (this) { if (currentPushRequests.contains(streamId)) { - writeSynResetLater(streamId, ErrorCode.PROTOCOL_ERROR); + writeSynResetLater(streamId, Http2ErrorCode.PROTOCOL_ERROR); return; } currentPushRequests.add(streamId); @@ -576,7 +575,7 @@ public void execute() { boolean cancel = pushObserver.onRequest(streamId, requestHeaders); try { if (cancel) { - writer.rstStream(streamId, ErrorCode.CANCEL); + writer.rstStream(streamId, Http2ErrorCode.CANCEL); synchronized (Http2Connection.this) { currentPushRequests.remove(streamId); } @@ -590,7 +589,7 @@ public void execute() { } } - void pushHeadersLater(final int streamId, final List requestHeaders, + void pushHeadersLater(final int streamId, final List requestHeaders, final boolean inFinished) { try { pushExecutorExecute(new NamedRunnable( @@ -599,7 +598,7 @@ void pushHeadersLater(final int streamId, final List requestHead public void execute() { boolean cancel = pushObserver.onHeaders(streamId, requestHeaders, inFinished); try { - if (cancel) writer.rstStream(streamId, ErrorCode.CANCEL); + if (cancel) writer.rstStream(streamId, Http2ErrorCode.CANCEL); if (cancel || inFinished) { synchronized (Http2Connection.this) { currentPushRequests.remove(streamId); @@ -629,7 +628,7 @@ void pushDataLater(final int streamId, final BufferSource source, final int byte public void execute() { try { boolean cancel = pushObserver.onData(streamId, buffer, byteCount, inFinished); - if (cancel) writer.rstStream(streamId, ErrorCode.CANCEL); + if (cancel) writer.rstStream(streamId, Http2ErrorCode.CANCEL); if (cancel || inFinished) { synchronized (Http2Connection.this) { currentPushRequests.remove(streamId); @@ -641,7 +640,7 @@ public void execute() { }); } - void pushResetLater(final int streamId, final ErrorCode errorCode) { + void pushResetLater(final int streamId, final Http2ErrorCode errorCode) { pushExecutorExecute(new NamedRunnable("Http %s Push Reset[%s]", connectionName, streamId) { @Override public void execute() { @@ -723,7 +722,7 @@ public abstract static class Listener { public static final Listener REFUSE_INCOMING_STREAMS = new Listener() { @Override public void onStream(Http2Stream stream) throws IOException { - stream.close(ErrorCode.REFUSED_STREAM, null); + stream.close(Http2ErrorCode.REFUSED_STREAM, null); } }; @@ -804,19 +803,19 @@ class ReaderRunnable extends NamedRunnable implements Http2Reader.Handler { @Override protected void execute() { - ErrorCode connectionErrorCode = ErrorCode.INTERNAL_ERROR; - ErrorCode streamErrorCode = ErrorCode.INTERNAL_ERROR; + Http2ErrorCode connectionErrorCode = Http2ErrorCode.INTERNAL_ERROR; + Http2ErrorCode streamErrorCode = Http2ErrorCode.INTERNAL_ERROR; IOException errorException = null; try { reader.readConnectionPreface(this); while (reader.nextFrame(false, this)) { } - connectionErrorCode = ErrorCode.NO_ERROR; - streamErrorCode = ErrorCode.CANCEL; + connectionErrorCode = Http2ErrorCode.NO_ERROR; + streamErrorCode = Http2ErrorCode.CANCEL; } catch (IOException e) { errorException = e; - connectionErrorCode = ErrorCode.PROTOCOL_ERROR; - streamErrorCode = ErrorCode.PROTOCOL_ERROR; + connectionErrorCode = Http2ErrorCode.PROTOCOL_ERROR; + streamErrorCode = Http2ErrorCode.PROTOCOL_ERROR; } finally { close(connectionErrorCode, streamErrorCode, errorException); IoKit.close(reader); @@ -832,7 +831,7 @@ public void data(boolean inFinished, int streamId, BufferSource source, int leng } Http2Stream dataStream = getStream(streamId); if (dataStream == null) { - writeSynResetLater(streamId, ErrorCode.PROTOCOL_ERROR); + writeSynResetLater(streamId, Http2ErrorCode.PROTOCOL_ERROR); updateConnectionFlowControl(length); source.skip(length); return; @@ -845,7 +844,7 @@ public void data(boolean inFinished, int streamId, BufferSource source, int leng @Override public void headers(boolean inFinished, int streamId, int associatedStreamId, - List headerBlock) { + List headerBlock) { if (pushedStream(streamId)) { pushHeadersLater(streamId, headerBlock, inFinished); return; @@ -879,7 +878,7 @@ public void execute() { } catch (IOException e) { Logger.info("Http2Connection.Listener failure for " + connectionName, e); try { - newStream.close(ErrorCode.PROTOCOL_ERROR, e); + newStream.close(Http2ErrorCode.PROTOCOL_ERROR, e); } catch (IOException ignored) { } } @@ -894,7 +893,7 @@ public void execute() { } @Override - public void rstStream(int streamId, ErrorCode errorCode) { + public void rstStream(int streamId, Http2ErrorCode errorCode) { if (pushedStream(streamId)) { pushResetLater(streamId, errorCode); return; @@ -906,7 +905,7 @@ public void rstStream(int streamId, ErrorCode errorCode) { } @Override - public void settings(boolean clearPrevious, Settings settings) { + public void settings(boolean clearPrevious, Http2Settings settings) { try { writerExecutor.execute(new NamedRunnable("Http %s ACK Settings", connectionName) { @Override @@ -919,7 +918,7 @@ public void execute() { } } - void applyAndAckSettings(boolean clearPrevious, Settings settings) { + void applyAndAckSettings(boolean clearPrevious, Http2Settings settings) { long delta = 0; Http2Stream[] streamsToNotify = null; synchronized (writer) { @@ -985,7 +984,7 @@ public void ping(boolean reply, int payload1, int payload2) { } @Override - public void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugData) { + public void goAway(int lastGoodStreamId, Http2ErrorCode errorCode, ByteString debugData) { if (debugData.size() > 0) { // TODO: log the debugData } @@ -998,7 +997,7 @@ public void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugDa for (Http2Stream http2Stream : streamsCopy) { if (http2Stream.getId() > lastGoodStreamId && http2Stream.isLocallyInitiated()) { - http2Stream.receiveRstStream(ErrorCode.REFUSED_STREAM); + http2Stream.receiveRstStream(Http2ErrorCode.REFUSED_STREAM); removeStream(http2Stream.getId()); } } @@ -1027,7 +1026,7 @@ public void priority(int streamId, int streamDependency, int weight, } @Override - public void pushPromise(int streamId, int promisedStreamId, List requestHeaders) { + public void pushPromise(int streamId, int promisedStreamId, List requestHeaders) { pushRequestLater(promisedStreamId, requestHeaders); } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/ErrorCode.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2ErrorCode.java similarity index 93% rename from bus-http/src/main/java/org/miaixz/bus/http/metric/http/ErrorCode.java rename to bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2ErrorCode.java index 9acb68b137..42e08d092e 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/ErrorCode.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2ErrorCode.java @@ -33,7 +33,7 @@ * @author Kimi Liu * @since Java 17+ */ -public enum ErrorCode { +public enum Http2ErrorCode { NO_ERROR(0), @@ -59,12 +59,12 @@ public enum ErrorCode { public final int httpCode; - ErrorCode(int httpCode) { + Http2ErrorCode(int httpCode) { this.httpCode = httpCode; } - public static ErrorCode fromHttp2(int code) { - for (ErrorCode errorCode : ErrorCode.values()) { + public static Http2ErrorCode fromHttp2(int code) { + for (Http2ErrorCode errorCode : Http2ErrorCode.values()) { if (errorCode.httpCode == code) return errorCode; } return null; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Header.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Header.java new file mode 100644 index 0000000000..268d79651a --- /dev/null +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Header.java @@ -0,0 +1,94 @@ +/* + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + ~ ~ + ~ The MIT License (MIT) ~ + ~ ~ + ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ + ~ ~ + ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ + ~ of this software and associated documentation files (the "Software"), to deal ~ + ~ in the Software without restriction, including without limitation the rights ~ + ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ + ~ copies of the Software, and to permit persons to whom the Software is ~ + ~ furnished to do so, subject to the following conditions: ~ + ~ ~ + ~ The above copyright notice and this permission notice shall be included in ~ + ~ all copies or substantial portions of the Software. ~ + ~ ~ + ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ + ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ + ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ + ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ + ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ + ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ + ~ THE SOFTWARE. ~ + ~ ~ + ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ + */ +package org.miaixz.bus.http.metric.http; + +import org.miaixz.bus.core.io.ByteString; +import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; + +/** + * HTTP header: the name is an ASCII string, but the value can be UTF-8. + */ +public class Http2Header { + + // Special header names defined in HTTP/2 spec. + public static final ByteString PSEUDO_PREFIX = ByteString.encodeUtf8(Symbol.COLON); + public static final ByteString RESPONSE_STATUS = ByteString.encodeUtf8(HTTP.RESPONSE_STATUS_UTF8); + public static final ByteString TARGET_METHOD = ByteString.encodeUtf8(HTTP.TARGET_METHOD_UTF8); + public static final ByteString TARGET_PATH = ByteString.encodeUtf8(HTTP.TARGET_PATH_UTF8); + public static final ByteString TARGET_SCHEME = ByteString.encodeUtf8(HTTP.TARGET_SCHEME_UTF8); + public static final ByteString TARGET_AUTHORITY = ByteString.encodeUtf8(HTTP.TARGET_AUTHORITY_UTF8); + + /** + * Name in case-insensitive ASCII encoding. + */ + public final ByteString name; + /** + * Value in UTF-8 encoding. + */ + public final ByteString value; + public final int hpackSize; + + // TODO: search for toLowerCase and consider moving logic here. + public Http2Header(String name, String value) { + this(ByteString.encodeUtf8(name), ByteString.encodeUtf8(value)); + } + + public Http2Header(ByteString name, String value) { + this(name, ByteString.encodeUtf8(value)); + } + + public Http2Header(ByteString name, ByteString value) { + this.name = name; + this.value = value; + this.hpackSize = 32 + name.size() + value.size(); + } + + @Override + public boolean equals(Object other) { + if (other instanceof Http2Header) { + Http2Header that = (Http2Header) other; + return this.name.equals(that.name) + && this.value.equals(that.value); + } + return false; + } + + @Override + public int hashCode() { + int result = 17; + result = 31 * result + name.hashCode(); + result = 31 * result + value.hashCode(); + return result; + } + + @Override + public String toString() { + return String.format("%s: %s", name.utf8(), value.utf8()); + } +} diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Reader.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Reader.java index fa17607b97..d50433e531 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Reader.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Reader.java @@ -32,8 +32,6 @@ import org.miaixz.bus.core.io.source.BufferSource; import org.miaixz.bus.core.io.source.Source; import org.miaixz.bus.core.io.timout.Timeout; -import org.miaixz.bus.http.Headers; -import org.miaixz.bus.http.Settings; import org.miaixz.bus.logger.Logger; import java.io.Closeable; @@ -42,7 +40,7 @@ /** * Reads HTTP/2运输框架 - * 此实现假设我们没有向对等端发送增加的{@link Settings#getMaxFrameSize frame size设置}。 + * 此实现假设我们没有向对等端发送增加的{@link Http2Settings#getMaxFrameSize frame size设置}。 * 因此,我们希望所有帧的最大长度为{@link Http2#INITIAL_MAX_FRAME_SIZE}。 * * @author Kimi Liu @@ -187,12 +185,12 @@ private void readHeaders(Handler handler, int length, byte flags, int streamId) length = lengthWithoutPadding(length, flags, padding); - List headerBlock = readHeaderBlock(length, padding, flags, streamId); + List headerBlock = readHeaderBlock(length, padding, flags, streamId); handler.headers(endStream, streamId, -1, headerBlock); } - private List readHeaderBlock(int length, short padding, byte flags, int streamId) + private List readHeaderBlock(int length, short padding, byte flags, int streamId) throws IOException { continuation.length = continuation.left = length; continuation.padding = padding; @@ -240,7 +238,7 @@ private void readRstStream(Handler handler, int length, byte flags, int streamId if (length != 4) throw Http2.ioException("TYPE_RST_STREAM length: %d != 4", length); if (streamId == 0) throw Http2.ioException("TYPE_RST_STREAM streamId == 0"); int errorCodeInt = source.readInt(); - ErrorCode errorCode = ErrorCode.fromHttp2(errorCodeInt); + Http2ErrorCode errorCode = Http2ErrorCode.fromHttp2(errorCodeInt); if (null == errorCode) { throw Http2.ioException("TYPE_RST_STREAM unexpected error code: %d", errorCodeInt); } @@ -257,7 +255,7 @@ private void readSettings(Handler handler, int length, byte flags, int streamId) } if (length % 6 != 0) throw Http2.ioException("TYPE_SETTINGS length %% 6 != 0: %s", length); - Settings settings = new Settings(); + Http2Settings settings = new Http2Settings(); for (int i = 0; i < length; i += 6) { int id = source.readShort() & 0xFFFF; int value = source.readInt(); @@ -303,7 +301,7 @@ private void readPushPromise(Handler handler, int length, byte flags, int stream int promisedStreamId = source.readInt() & 0x7fffffff; length -= 4; length = lengthWithoutPadding(length, flags, padding); - List headerBlock = readHeaderBlock(length, padding, flags, streamId); + List headerBlock = readHeaderBlock(length, padding, flags, streamId); handler.pushPromise(streamId, promisedStreamId, headerBlock); } @@ -324,7 +322,7 @@ private void readGoAway(Handler handler, int length, byte flags, int streamId) int lastStreamId = source.readInt(); int errorCodeInt = source.readInt(); int opaqueDataLength = length - 8; - ErrorCode errorCode = ErrorCode.fromHttp2(errorCodeInt); + Http2ErrorCode errorCode = Http2ErrorCode.fromHttp2(errorCodeInt); if (null == errorCode) { throw Http2.ioException("TYPE_GOAWAY unexpected error code: %d", errorCodeInt); } @@ -361,11 +359,11 @@ void data(boolean inFinished, int streamId, BufferSource source, int length) * @param headerBlock header信息 */ void headers(boolean inFinished, int streamId, int associatedStreamId, - List headerBlock); + List headerBlock); - void rstStream(int streamId, ErrorCode errorCode); + void rstStream(int streamId, Http2ErrorCode errorCode); - void settings(boolean clearPrevious, Settings settings); + void settings(boolean clearPrevious, Http2Settings settings); /** * HTTP/2 only. @@ -391,7 +389,7 @@ void headers(boolean inFinished, int streamId, int associatedStreamId, * @param errorCode 关闭连接的原因. * @param debugData 只适用于HTTP/2;要发送的不透明调试数据 */ - void goAway(int lastGoodStreamId, ErrorCode errorCode, ByteString debugData); + void goAway(int lastGoodStreamId, Http2ErrorCode errorCode, ByteString debugData); /** * 通知可以在{@code streamId}上发送额外的{@code windowSizeIncrement}字节 @@ -422,7 +420,7 @@ void headers(boolean inFinished, int streamId, int associatedStreamId, * @param requestHeaders 最低限度包括{@code:method}、{@code:scheme}、{@code:authority}和(@code:path}. * @throws IOException 异常信息 */ - void pushPromise(int streamId, int promisedStreamId, List requestHeaders) + void pushPromise(int streamId, int promisedStreamId, List requestHeaders) throws IOException; /** diff --git a/bus-http/src/main/java/org/miaixz/bus/http/Settings.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Settings.java similarity index 81% rename from bus-http/src/main/java/org/miaixz/bus/http/Settings.java rename to bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Settings.java index 090a814bbc..093eb33c2c 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/Settings.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Settings.java @@ -25,10 +25,9 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.http; +package org.miaixz.bus.http.metric.http; -import org.miaixz.bus.core.lang.Http; -import org.miaixz.bus.http.metric.http.Http2Connection; +import org.miaixz.bus.core.net.HTTP; import java.util.Arrays; @@ -39,7 +38,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class Settings { +public class Http2Settings { /** * 设置总数 @@ -59,7 +58,7 @@ public void clear() { Arrays.fill(values, 0); } - public Settings set(int id, int value) { + public Http2Settings set(int id, int value) { if (id < 0 || id >= values.length) { return this; } @@ -101,33 +100,33 @@ public int size() { } public int getHeaderTableSize() { - int bit = 1 << Http.HEADER_TABLE_SIZE; - return (bit & set) != 0 ? values[Http.HEADER_TABLE_SIZE] : -1; + int bit = 1 << HTTP.HEADER_TABLE_SIZE; + return (bit & set) != 0 ? values[HTTP.HEADER_TABLE_SIZE] : -1; } public boolean getEnablePush(boolean defaultValue) { - int bit = 1 << Http.ENABLE_PUSH; - return ((bit & set) != 0 ? values[Http.ENABLE_PUSH] : defaultValue ? 1 : 0) == 1; + int bit = 1 << HTTP.ENABLE_PUSH; + return ((bit & set) != 0 ? values[HTTP.ENABLE_PUSH] : defaultValue ? 1 : 0) == 1; } public int getMaxConcurrentStreams(int defaultValue) { - int bit = 1 << Http.MAX_CONCURRENT_STREAMS; - return (bit & set) != 0 ? values[Http.MAX_CONCURRENT_STREAMS] : defaultValue; + int bit = 1 << HTTP.MAX_CONCURRENT_STREAMS; + return (bit & set) != 0 ? values[HTTP.MAX_CONCURRENT_STREAMS] : defaultValue; } public int getMaxFrameSize(int defaultValue) { - int bit = 1 << Http.MAX_FRAME_SIZE; - return (bit & set) != 0 ? values[Http.MAX_FRAME_SIZE] : defaultValue; + int bit = 1 << HTTP.MAX_FRAME_SIZE; + return (bit & set) != 0 ? values[HTTP.MAX_FRAME_SIZE] : defaultValue; } public int getMaxHeaderListSize(int defaultValue) { - int bit = 1 << Http.MAX_HEADER_LIST_SIZE; - return (bit & set) != 0 ? values[Http.MAX_HEADER_LIST_SIZE] : defaultValue; + int bit = 1 << HTTP.MAX_HEADER_LIST_SIZE; + return (bit & set) != 0 ? values[HTTP.MAX_HEADER_LIST_SIZE] : defaultValue; } public int getInitialWindowSize() { - int bit = 1 << Http.INITIAL_WINDOW_SIZE; - return (bit & set) != 0 ? values[Http.INITIAL_WINDOW_SIZE] : Http.DEFAULT_INITIAL_WINDOW_SIZE; + int bit = 1 << HTTP.INITIAL_WINDOW_SIZE; + return (bit & set) != 0 ? values[HTTP.INITIAL_WINDOW_SIZE] : HTTP.DEFAULT_INITIAL_WINDOW_SIZE; } /** @@ -136,7 +135,7 @@ public int getInitialWindowSize() { * * @param other 设置信息 */ - public void merge(Settings other) { + public void merge(Http2Settings other) { for (int i = 0; i < COUNT; i++) { if (!other.isSet(i)) continue; set(i, other.get(i)); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Stream.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Stream.java index 87adb17f47..831a0d80f7 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Stream.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Stream.java @@ -84,7 +84,7 @@ public class Http2Stream { * 这条小溪非正常关闭的原因。如果有多个原因导致异常关闭这个流(例如两个对等点几乎同时关闭它), * 那么这就是这个对等点知道的第一个原因. */ - ErrorCode errorCode = null; + Http2ErrorCode errorCode = null; IOException errorException; /** * 如果已发送或接收响应头,则为 @@ -189,7 +189,7 @@ public synchronized Headers trailers() throws IOException { * Returns the reason why this stream was closed, or null if it closed normally or has not yet * been closed. */ - public synchronized ErrorCode getErrorCode() { + public synchronized Http2ErrorCode getErrorCode() { return errorCode; } @@ -201,7 +201,7 @@ public synchronized ErrorCode getErrorCode() { * @param flushHeaders true to force flush the response headers. This should be true unless the * response body exists and will be written immediately. */ - public void writeHeaders(List responseHeaders, boolean outFinished, boolean flushHeaders) + public void writeHeaders(List responseHeaders, boolean outFinished, boolean flushHeaders) throws IOException { assert (!Thread.holdsLock(Http2Stream.this)); if (responseHeaders == null) { @@ -271,7 +271,7 @@ public Sink getSink() { * Abnormally terminate this stream. This blocks until the {@code RST_STREAM} frame has been * transmitted. */ - public void close(ErrorCode rstStatusCode, IOException errorException) + public void close(Http2ErrorCode rstStatusCode, IOException errorException) throws IOException { if (!closeInternal(rstStatusCode, errorException)) { return; // Already closed. @@ -283,7 +283,7 @@ public void close(ErrorCode rstStatusCode, IOException errorException) * Abnormally terminate this stream. This enqueues a {@code RST_STREAM} frame and returns * immediately. */ - public void closeLater(ErrorCode errorCode) { + public void closeLater(Http2ErrorCode errorCode) { if (!closeInternal(errorCode, null)) { return; // Already closed. } @@ -293,7 +293,7 @@ public void closeLater(ErrorCode errorCode) { /** * Returns true if this stream was closed. */ - private boolean closeInternal(ErrorCode errorCode, IOException errorException) { + private boolean closeInternal(Http2ErrorCode errorCode, IOException errorException) { assert (!Thread.holdsLock(this)); synchronized (this) { if (this.errorCode != null) { @@ -340,7 +340,7 @@ void receiveHeaders(Headers headers, boolean inFinished) { } } - synchronized void receiveRstStream(ErrorCode errorCode) { + synchronized void receiveRstStream(Http2ErrorCode errorCode) { if (this.errorCode == null) { this.errorCode = errorCode; notifyAll(); @@ -360,7 +360,7 @@ void cancelStreamIfNecessary() throws IOException { // is safe because the input stream is closed (we won't use any // further bytes) and the output stream is either finished or closed // (so RSTing both streams doesn't cause harm). - Http2Stream.this.close(ErrorCode.CANCEL, null); + Http2Stream.this.close(Http2ErrorCode.CANCEL, null); } else if (!open) { connection.removeStream(id); } @@ -525,7 +525,7 @@ void receive(BufferSource in, long byteCount) throws IOException { // If the peer sends more data than we can handle, discard it and close the connection. if (flowControlError) { in.skip(byteCount); - closeLater(ErrorCode.FLOW_CONTROL_ERROR); + closeLater(Http2ErrorCode.FLOW_CONTROL_ERROR); return; } @@ -701,7 +701,7 @@ public void close() throws IOException { class StreamTimeout extends AsyncTimeout { @Override protected void timedOut() { - closeLater(ErrorCode.CANCEL); + closeLater(Http2ErrorCode.CANCEL); connection.sendDegradedPingLater(); } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Writer.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Writer.java index 24c3f782c5..9da32ac93f 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Writer.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/Http2Writer.java @@ -30,8 +30,6 @@ import org.miaixz.bus.core.io.buffer.Buffer; import org.miaixz.bus.core.io.sink.BufferSink; import org.miaixz.bus.core.lang.Normal; -import org.miaixz.bus.http.Headers; -import org.miaixz.bus.http.Settings; import org.miaixz.bus.logger.Logger; import java.io.Closeable; @@ -83,7 +81,7 @@ public synchronized void connectionPreface() throws IOException { /** * Applies {@code peerSettings} and then sends a settings ACK. */ - public synchronized void applyAndAckSettings(Settings peerSettings) throws IOException { + public synchronized void applyAndAckSettings(Http2Settings peerSettings) throws IOException { if (closed) throw new IOException("closed"); this.maxFrameSize = peerSettings.getMaxFrameSize(maxFrameSize); if (peerSettings.getHeaderTableSize() != -1) { @@ -110,7 +108,7 @@ public synchronized void applyAndAckSettings(Settings peerSettings) throws IOExc * @throws IOException 异常 */ public synchronized void pushPromise(int streamId, int promisedStreamId, - List requestHeaders) throws IOException { + List requestHeaders) throws IOException { if (closed) throw new IOException("closed"); hpackWriter.writeHeaders(requestHeaders); @@ -130,7 +128,7 @@ public synchronized void flush() throws IOException { sink.flush(); } - public synchronized void rstStream(int streamId, ErrorCode errorCode) + public synchronized void rstStream(int streamId, Http2ErrorCode errorCode) throws IOException { if (closed) throw new IOException("closed"); if (errorCode.httpCode == -1) throw new IllegalArgumentException(); @@ -177,14 +175,14 @@ void dataFrame(int streamId, byte flags, Buffer buffer, int byteCount) throws IO /** * Write httpd's settings to the peer. */ - public synchronized void settings(Settings settings) throws IOException { + public synchronized void settings(Http2Settings settings) throws IOException { if (closed) throw new IOException("closed"); int length = settings.size() * 6; byte type = Http2.TYPE_SETTINGS; byte flags = Http2.FLAG_NONE; int streamId = 0; frameHeader(streamId, length, type, flags); - for (int i = 0; i < Settings.COUNT; i++) { + for (int i = 0; i < Http2Settings.COUNT; i++) { if (!settings.isSet(i)) continue; int id = i; if (id == 4) { @@ -221,7 +219,7 @@ public synchronized void ping(boolean ack, int payload1, int payload2) throws IO * @param errorCode 关闭连接的原因. * @param debugData 只适用于HTTP/2;要发送的不透明调试数据. */ - public synchronized void goAway(int lastGoodStreamId, ErrorCode errorCode, byte[] debugData) + public synchronized void goAway(int lastGoodStreamId, Http2ErrorCode errorCode, byte[] debugData) throws IOException { if (closed) throw new IOException("closed"); if (errorCode.httpCode == -1) throw Http2.illegalArgument("errorCode.httpCode == -1"); @@ -286,7 +284,7 @@ private void writeContinuationFrames(int streamId, long byteCount) throws IOExce } public synchronized void headers( - boolean outFinished, int streamId, List headerBlock) throws IOException { + boolean outFinished, int streamId, List headerBlock) throws IOException { if (closed) throw new IOException("closed"); hpackWriter.writeHeaders(headerBlock); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/PushObserver.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/PushObserver.java index 589a6c4680..353b37d1da 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/PushObserver.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/PushObserver.java @@ -28,8 +28,7 @@ package org.miaixz.bus.http.metric.http; import org.miaixz.bus.core.io.source.BufferSource; -import org.miaixz.bus.http.Headers; -import org.miaixz.bus.http.Protocol; +import org.miaixz.bus.core.net.Protocol; import java.io.IOException; import java.util.List; @@ -48,12 +47,12 @@ public interface PushObserver { PushObserver CANCEL = new PushObserver() { @Override - public boolean onRequest(int streamId, List requestHeaders) { + public boolean onRequest(int streamId, List requestHeaders) { return true; } @Override - public boolean onHeaders(int streamId, List responseHeaders, boolean last) { + public boolean onHeaders(int streamId, List responseHeaders, boolean last) { return true; } @@ -65,7 +64,7 @@ public boolean onData(int streamId, BufferSource source, int byteCount, } @Override - public void onReset(int streamId, ErrorCode errorCode) { + public void onReset(int streamId, Http2ErrorCode errorCode) { } }; @@ -76,7 +75,7 @@ public void onReset(int streamId, ErrorCode errorCode) { * @param requestHeaders 最低限度包括 method、scheme、authority和path * @return the true/false */ - boolean onRequest(int streamId, List requestHeaders); + boolean onRequest(int streamId, List requestHeaders); /** * 推送请求对应的响应标头。当{@code last}为真时,则没有后续的数据帧 @@ -86,7 +85,7 @@ public void onReset(int streamId, ErrorCode errorCode) { * @param last 如果为真,则没有响应数据 * @return the true/false */ - boolean onHeaders(int streamId, List responseHeaders, boolean last); + boolean onHeaders(int streamId, List responseHeaders, boolean last); /** * 与推送请求对应的响应数据块。必须读取或跳过这些数据. @@ -107,6 +106,6 @@ boolean onData(int streamId, BufferSource source, int byteCount, boolean last) * @param streamId 服务器发起的流ID:偶数. * @param errorCode 错误码信息 */ - void onReset(int streamId, ErrorCode errorCode); + void onReset(int streamId, Http2ErrorCode errorCode); } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/RealInterceptorChain.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/RealInterceptorChain.java index f7fc07c782..d3f19f81c4 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/RealInterceptorChain.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/RealInterceptorChain.java @@ -35,6 +35,7 @@ import org.miaixz.bus.http.accord.Exchange; import org.miaixz.bus.http.accord.Transmitter; import org.miaixz.bus.http.metric.Interceptor; +import org.miaixz.bus.http.metric.NewChain; import java.io.IOException; import java.util.List; @@ -42,12 +43,12 @@ /** * 承载整个拦截器链的具体拦截器链: - * 所有应用程序拦截器、Httpd核心、所有网络拦截器,最后是网络调用者. + * 所有应用程序拦截器、Http核心、所有网络拦截器,最后是网络调用者. * * @author Kimi Liu * @since Java 17+ */ -public class RealInterceptorChain implements Interceptor.Chain { +public class RealInterceptorChain implements NewChain { private final List interceptors; private final Transmitter transmitter; @@ -85,7 +86,7 @@ public int connectTimeoutMillis() { } @Override - public Interceptor.Chain withConnectTimeout(int timeout, TimeUnit unit) { + public NewChain withConnectTimeout(int timeout, TimeUnit unit) { int millis = Builder.checkDuration("timeout", timeout, unit); return new RealInterceptorChain(interceptors, transmitter, exchange, index, request, call, millis, readTimeout, writeTimeout); @@ -97,7 +98,7 @@ public int readTimeoutMillis() { } @Override - public Interceptor.Chain withReadTimeout(int timeout, TimeUnit unit) { + public NewChain withReadTimeout(int timeout, TimeUnit unit) { int millis = Builder.checkDuration("timeout", timeout, unit); return new RealInterceptorChain(interceptors, transmitter, exchange, index, request, call, connectTimeout, millis, writeTimeout); @@ -109,7 +110,7 @@ public int writeTimeoutMillis() { } @Override - public Interceptor.Chain withWriteTimeout(int timeout, TimeUnit unit) { + public NewChain withWriteTimeout(int timeout, TimeUnit unit) { int millis = Builder.checkDuration("timeout", timeout, unit); return new RealInterceptorChain(interceptors, transmitter, exchange, index, request, call, connectTimeout, readTimeout, millis); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/RetryAndFollowUp.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/RetryAndFollowUp.java index 8b8e57fe3a..9ce8512d88 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/RetryAndFollowUp.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/RetryAndFollowUp.java @@ -27,8 +27,7 @@ */ package org.miaixz.bus.http.metric.http; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.http.*; import org.miaixz.bus.http.accord.Exchange; @@ -37,6 +36,7 @@ import org.miaixz.bus.http.bodys.RequestBody; import org.miaixz.bus.http.metric.Interceptor; import org.miaixz.bus.http.metric.Internal; +import org.miaixz.bus.http.metric.NewChain; import javax.net.ssl.SSLHandshakeException; import javax.net.ssl.SSLPeerUnverifiedException; @@ -70,7 +70,7 @@ public RetryAndFollowUp(Httpd httpd) { } @Override - public Response intercept(Chain chain) throws IOException { + public Response intercept(NewChain chain) throws IOException { Request request = chain.request(); RealInterceptorChain realChain = (RealInterceptorChain) chain; Transmitter transmitter = realChain.transmitter(); @@ -213,7 +213,7 @@ private Request followUpRequest(Response userResponse, Route route) throws IOExc final String method = userResponse.request().method(); switch (responseCode) { - case Http.HTTP_PROXY_AUTH: + case HTTP.HTTP_PROXY_AUTH: Proxy selectedProxy = route != null ? route.proxy() : httpd.proxy(); @@ -222,25 +222,25 @@ private Request followUpRequest(Response userResponse, Route route) throws IOExc } return httpd.proxyAuthenticator().authenticate(route, userResponse); - case Http.HTTP_UNAUTHORIZED: + case HTTP.HTTP_UNAUTHORIZED: return httpd.authenticator().authenticate(route, userResponse); - case Http.HTTP_PERM_REDIRECT: - case Http.HTTP_TEMP_REDIRECT: + case HTTP.HTTP_PERM_REDIRECT: + case HTTP.HTTP_TEMP_REDIRECT: // "If the 307 or 308 status code is received in response to a request other than GET // or HEAD, the user agent MUST NOT automatically redirect the request" if (!method.equals("GET") && !method.equals("HEAD")) { return null; } // fall-through - case Http.HTTP_MULT_CHOICE: - case Http.HTTP_MOVED_PERM: - case Http.HTTP_MOVED_TEMP: - case Http.HTTP_SEE_OTHER: + case HTTP.HTTP_MULT_CHOICE: + case HTTP.HTTP_MOVED_PERM: + case HTTP.HTTP_MOVED_TEMP: + case HTTP.HTTP_SEE_OTHER: // Does the client allow redirects? if (!httpd.followRedirects()) return null; - String location = userResponse.header(Header.LOCATION); + String location = userResponse.header(HTTP.LOCATION); if (null == location) return null; UnoUrl url = userResponse.request().url().resolve(location); @@ -253,18 +253,18 @@ private Request followUpRequest(Response userResponse, Route route) throws IOExc // Most redirects don't include a request body. Request.Builder requestBuilder = userResponse.request().newBuilder(); - if (Http.permitsRequestBody(method)) { - final boolean maintainBody = Http.redirectsWithBody(method); - if (Http.redirectsToGet(method)) { + if (HTTP.permitsRequestBody(method)) { + final boolean maintainBody = HTTP.redirectsWithBody(method); + if (HTTP.redirectsToGet(method)) { requestBuilder.method("GET", null); } else { RequestBody requestBody = maintainBody ? userResponse.request().body() : null; requestBuilder.method(method, requestBody); } if (!maintainBody) { - requestBuilder.removeHeader(Header.TRANSFER_ENCODING); - requestBuilder.removeHeader(Header.CONTENT_LENGTH); - requestBuilder.removeHeader(Header.CONTENT_TYPE); + requestBuilder.removeHeader(HTTP.TRANSFER_ENCODING); + requestBuilder.removeHeader(HTTP.CONTENT_LENGTH); + requestBuilder.removeHeader(HTTP.CONTENT_TYPE); } } @@ -277,7 +277,7 @@ private Request followUpRequest(Response userResponse, Route route) throws IOExc return requestBuilder.url(url).build(); - case Http.HTTP_CLIENT_TIMEOUT: + case HTTP.HTTP_CLIENT_TIMEOUT: // 408's are rare in practice, but some servers like HAProxy use this response code. The // spec says that we may repeat the request without modifications. Modern browsers also // repeat the request (even non-idempotent ones.) @@ -292,7 +292,7 @@ private Request followUpRequest(Response userResponse, Route route) throws IOExc } if (userResponse.priorResponse() != null - && userResponse.priorResponse().code() == Http.HTTP_CLIENT_TIMEOUT) { + && userResponse.priorResponse().code() == HTTP.HTTP_CLIENT_TIMEOUT) { // We attempted to retry and got another timeout. Give up. return null; } @@ -303,9 +303,9 @@ private Request followUpRequest(Response userResponse, Route route) throws IOExc return userResponse.request(); - case Http.HTTP_UNAVAILABLE: + case HTTP.HTTP_UNAVAILABLE: if (userResponse.priorResponse() != null - && userResponse.priorResponse().code() == Http.HTTP_UNAVAILABLE) { + && userResponse.priorResponse().code() == HTTP.HTTP_UNAVAILABLE) { // We attempted to retry and got another timeout. Give up. return null; } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/StatusLine.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/StatusLine.java index 16582b487f..88c899c37b 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/StatusLine.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/StatusLine.java @@ -29,7 +29,7 @@ import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; -import org.miaixz.bus.http.Protocol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.http.Response; import java.io.IOException; @@ -107,7 +107,7 @@ public static StatusLine parse(String statusLine) throws IOException { @Override public String toString() { StringBuilder result = new StringBuilder(); - result.append(protocol == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1"); + result.append(protocol == Protocol.HTTP_1_0 ? Protocol.HTTP_1_0.name : Protocol.HTTP_1_1.name); result.append(Symbol.C_SPACE).append(code); if (null != message) { result.append(Symbol.C_SPACE).append(message); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/StreamException.java b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/StreamException.java index 6ed60bbe32..15f72e1e35 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/metric/http/StreamException.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/metric/http/StreamException.java @@ -37,9 +37,9 @@ */ public class StreamException extends RevisedException { - public final ErrorCode errorCode; + public final Http2ErrorCode errorCode; - public StreamException(ErrorCode errorCode) { + public StreamException(Http2ErrorCode errorCode) { super("stream was reset: " + errorCode); this.errorCode = errorCode; } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverCall.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverCall.java index 687fb77bd3..03f986c625 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverCall.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverCall.java @@ -28,8 +28,8 @@ package org.miaixz.bus.http.plugin.httpv; import org.miaixz.bus.core.io.ByteString; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Httpv; import org.miaixz.bus.http.Request; import org.miaixz.bus.http.Response; @@ -79,7 +79,7 @@ public synchronized boolean close(int code, String reason) { } public void msgType(String type) { - if (null == type || type.equalsIgnoreCase(Http.FORM)) { + if (null == type || type.equalsIgnoreCase(HTTP.FORM)) { throw new IllegalArgumentException("msgType 不可为空 或 form"); } this.msgType = type; @@ -355,7 +355,7 @@ public Client heatbeat(int pingSeconds, int pongSeconds) { */ public CoverCall listen() { String bodyType = getBodyType(); - String msgType = Http.FORM.equalsIgnoreCase(bodyType) ? Http.JSON : bodyType; + String msgType = HTTP.FORM.equalsIgnoreCase(bodyType) ? HTTP.JSON : bodyType; CoverCall socket = new CoverCall(httpv.executor(), msgType); registeTagTask(socket); httpv.preprocess(this, () -> { diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverHttp.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverHttp.java index 6a3584fde0..e4b5872722 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverHttp.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverHttp.java @@ -27,10 +27,10 @@ */ package org.miaixz.bus.http.plugin.httpv; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.MapKit; import org.miaixz.bus.core.xyz.ObjectKit; import org.miaixz.bus.http.*; @@ -541,7 +541,7 @@ protected NewCall prepareCall(String method) { } protected Request prepareRequest(String method) { - boolean bodyCanUsed = Http.permitsRequestBody(method); + boolean bodyCanUsed = HTTP.permitsRequestBody(method); assertNotConflict(!bodyCanUsed); Request.Builder builder = new Request.Builder() .url(buildUrlPath()); @@ -632,7 +632,7 @@ private RequestBody buildRequestBody() { if (null == bodyParams) { return new FormBody.Builder(charset).build(); } - if (Http.FORM.equalsIgnoreCase(bodyType)) { + if (HTTP.FORM.equalsIgnoreCase(bodyType)) { FormBody.Builder builder = new FormBody.Builder(charset); for (String name : bodyParams.keySet()) { String value = bodyParams.get(name); @@ -786,7 +786,7 @@ public Sync(Httpv client, String url) { * @return 请求结果 */ public CoverResult get() { - return request(Http.GET); + return request(HTTP.GET); } /** @@ -795,7 +795,7 @@ public CoverResult get() { * @return 请求结果 */ public CoverResult head() { - return request(Http.HEAD); + return request(HTTP.HEAD); } /** @@ -804,7 +804,7 @@ public CoverResult head() { * @return 请求结果 */ public CoverResult post() { - return request(Http.POST); + return request(HTTP.POST); } /** @@ -813,7 +813,7 @@ public CoverResult post() { * @return 请求结果 */ public CoverResult put() { - return request(Http.PUT); + return request(HTTP.PUT); } /** @@ -822,7 +822,7 @@ public CoverResult put() { * @return HttpCall */ public CoverResult patch() { - return request(Http.PATCH); + return request(HTTP.PATCH); } /** @@ -831,7 +831,7 @@ public CoverResult patch() { * @return 请求结果 */ public CoverResult delete() { - return request(Http.DELETE); + return request(HTTP.DELETE); } /** @@ -973,7 +973,7 @@ public Async setOnResponse(Callback onResponse) { * @return GiveCall */ public GiveCall get() { - return request(Http.GET); + return request(HTTP.GET); } /** @@ -982,7 +982,7 @@ public GiveCall get() { * @return GiveCall */ public GiveCall head() { - return request(Http.HEAD); + return request(HTTP.HEAD); } /** @@ -991,7 +991,7 @@ public GiveCall head() { * @return GiveCall */ public GiveCall post() { - return request(Http.POST); + return request(HTTP.POST); } /** @@ -1000,7 +1000,7 @@ public GiveCall post() { * @return GiveCall */ public GiveCall put() { - return request(Http.PUT); + return request(HTTP.PUT); } /** @@ -1009,7 +1009,7 @@ public GiveCall put() { * @return GiveCall */ public GiveCall patch() { - return request(Http.PATCH); + return request(HTTP.PATCH); } /** @@ -1018,7 +1018,7 @@ public GiveCall patch() { * @return GiveCall */ public GiveCall delete() { - return request(Http.DELETE); + return request(HTTP.DELETE); } /** diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverTasks.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverTasks.java index 05f0a09798..79588a40ef 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverTasks.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/CoverTasks.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.http.plugin.httpv; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Callback; import java.io.File; @@ -177,13 +177,13 @@ public Data doMsgConvert(String type, ConvertFunc callable) { private String toMediaType(String type) { if (type != null) { String lower = type.toLowerCase(); - if (lower.contains(Http.JSON)) { + if (lower.contains(HTTP.JSON)) { return MediaType.APPLICATION_JSON; } - if (lower.contains(Http.XML)) { + if (lower.contains(HTTP.XML)) { return MediaType.APPLICATION_XML; } - if (lower.contains(Http.PROTOBUF)) { + if (lower.contains(HTTP.PROTOBUF)) { return MediaType.APPLICATION_PROTOBUF; } } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/ResultBody.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/ResultBody.java index 8238147823..72554cacc4 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/ResultBody.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpv/ResultBody.java @@ -29,8 +29,12 @@ import org.miaixz.bus.core.io.ByteString; import org.miaixz.bus.core.io.buffer.Buffer; -import org.miaixz.bus.core.lang.*; +import org.miaixz.bus.core.lang.Charset; +import org.miaixz.bus.core.lang.MediaType; +import org.miaixz.bus.core.lang.Normal; +import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Callback; import org.miaixz.bus.http.Response; import org.miaixz.bus.http.bodys.ResponseBody; @@ -326,7 +330,7 @@ private long getRangeStart() { if (response.code() != HttpURLConnection.HTTP_PARTIAL) { return rangeStart; } - String range = response.header(Header.CONTENT_RANGE); + String range = response.header(HTTP.CONTENT_RANGE); if (null != range && range.startsWith("bytes")) { int index = range.indexOf(Symbol.C_MINUS); if (index > 5) { diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpx/HttpProxy.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpx/HttpProxy.java index 2234ed7fb0..5b385a42e9 100755 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpx/HttpProxy.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpx/HttpProxy.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.http.plugin.httpx; -import org.miaixz.bus.core.lang.Header; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.secure.Authenticator; import org.miaixz.bus.http.secure.Credentials; @@ -75,8 +75,8 @@ public Authenticator authenticator() { return (route, response) -> { String credential = Credentials.basic(user, password); return response.request().newBuilder(). - header(Header.PROXY_AUTHORIZATION, credential). - header(Header.PROXY_CONNECTION, Header.KEEP_ALIVE).build(); + header(HTTP.PROXY_AUTHORIZATION, credential). + header(HTTP.PROXY_CONNECTION, HTTP.KEEP_ALIVE).build(); }; } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/FileInterceptor.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/FileInterceptor.java index d619c5419f..1cee6f4ba1 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/FileInterceptor.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/FileInterceptor.java @@ -36,6 +36,7 @@ import org.miaixz.bus.http.Response; import org.miaixz.bus.http.bodys.ResponseBody; import org.miaixz.bus.http.metric.Interceptor; +import org.miaixz.bus.http.metric.NewChain; import java.io.IOException; @@ -48,7 +49,7 @@ public abstract class FileInterceptor implements Interceptor, ProgressListener { @Override - public Response intercept(Chain chain) throws IOException { + public Response intercept(NewChain chain) throws IOException { Response rsp = chain.proceed(chain.request()); return rsp.newBuilder() .body(new DownloadFileProgressResponseBody(rsp.body(), this)) diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/HttpBuilder.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/HttpBuilder.java index f022d78873..527b3ce567 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/HttpBuilder.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/HttpBuilder.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.http.plugin.httpz; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.net.tls.SSLContextBuilder; import org.miaixz.bus.http.DnsX; import org.miaixz.bus.http.Httpd; import org.miaixz.bus.http.Httpz; -import org.miaixz.bus.http.Protocol; import org.miaixz.bus.http.accord.ConnectionPool; import org.miaixz.bus.http.accord.ConnectionSuite; import org.miaixz.bus.http.cache.Cache; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/PostRequest.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/PostRequest.java index 0655f3cd96..5fedb4463e 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/PostRequest.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/PostRequest.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.http.plugin.httpz; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.FileKit; import org.miaixz.bus.core.xyz.ObjectKit; import org.miaixz.bus.http.Headers; @@ -85,8 +85,8 @@ protected RequestBody buildRequestBody() { return builder.build(); } else if (null != body && body.length() > 0) { MediaType mediaType; - if (headers.containsKey(Header.CONTENT_TYPE)) { - mediaType = MediaType.valueOf(headers.get(Header.CONTENT_TYPE)); + if (headers.containsKey(HTTP.CONTENT_TYPE)) { + mediaType = MediaType.valueOf(headers.get(HTTP.CONTENT_TYPE)); } else { mediaType = MediaType.TEXT_PLAIN_TYPE; } @@ -114,7 +114,7 @@ private void addParam(FormBody.Builder builder) { private void addParam(MultipartBody.Builder builder) { if (null != params && !params.isEmpty()) { - params.forEach((k, v) -> builder.addPart(Headers.of(Header.CONTENT_DISPOSITION, "form-data; name=\"" + k + Symbol.DOUBLE_QUOTES), + params.forEach((k, v) -> builder.addPart(Headers.of(HTTP.CONTENT_DISPOSITION, "form-data; name=\"" + k + Symbol.DOUBLE_QUOTES), RequestBody.create(null, v))); } } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/PutRequest.java b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/PutRequest.java index a9d8b76fac..67b3694031 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/PutRequest.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/plugin/httpz/PutRequest.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.http.plugin.httpz; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.FileKit; import org.miaixz.bus.http.Headers; import org.miaixz.bus.http.Request; @@ -84,8 +84,8 @@ protected RequestBody buildRequestBody() { return builder.build(); } else if (null != body && body.length() > 0) { MediaType mediaType; - if (headers.containsKey(Header.CONTENT_TYPE)) { - mediaType = MediaType.valueOf(headers.get(Header.CONTENT_TYPE)); + if (headers.containsKey(HTTP.CONTENT_TYPE)) { + mediaType = MediaType.valueOf(headers.get(HTTP.CONTENT_TYPE)); } else { mediaType = MediaType.TEXT_PLAIN_TYPE; } @@ -115,7 +115,7 @@ private void addParam(MultipartBody.Builder builder) { if (null != params && !params.isEmpty()) { params.forEach((k, v) -> builder.addPart(Headers.of( - Header.CONTENT_DISPOSITION, + HTTP.CONTENT_DISPOSITION, "form-data; name=" + k + Symbol.DOUBLE_QUOTES), RequestBody.create(null, v) ) diff --git a/bus-http/src/main/java/org/miaixz/bus/http/secure/CertificatePinner.java b/bus-http/src/main/java/org/miaixz/bus/http/secure/CertificatePinner.java index 2a77cae169..a8e2a4fcdf 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/secure/CertificatePinner.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/secure/CertificatePinner.java @@ -28,8 +28,8 @@ package org.miaixz.bus.http.secure; import org.miaixz.bus.core.io.ByteString; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.http.UnoUrl; import javax.net.ssl.SSLPeerUnverifiedException; @@ -208,8 +208,8 @@ static class Pin { Pin(String pattern, String pin) { this.pattern = pattern; this.canonicalHostname = pattern.startsWith(WILDCARD) - ? UnoUrl.get(Http.HTTP_PREFIX + pattern.substring(WILDCARD.length())).host() - : UnoUrl.get(Http.HTTP_PREFIX + pattern).host(); + ? UnoUrl.get(Protocol.HTTP_PREFIX + pattern.substring(WILDCARD.length())).host() + : UnoUrl.get(Protocol.HTTP_PREFIX + pattern).host(); if (pin.startsWith("sha1/")) { this.hashAlgorithm = "sha1/"; this.hash = ByteString.decodeBase64(pin.substring("sha1/".length())); diff --git a/bus-http/src/main/java/org/miaixz/bus/http/secure/NetAuthenticator.java b/bus-http/src/main/java/org/miaixz/bus/http/secure/NetAuthenticator.java index e771e852de..4049cd6338 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/secure/NetAuthenticator.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/secure/NetAuthenticator.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.http.secure; -import org.miaixz.bus.core.lang.Header; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Request; import org.miaixz.bus.http.Response; import org.miaixz.bus.http.Route; @@ -75,7 +75,7 @@ public Request authenticate(Route route, Response response) throws IOException { String credential = Credentials.basic( auth.getUserName(), new String(auth.getPassword()), challenge.charset()); return request.newBuilder() - .header(proxyAuthorization ? Header.PROXY_AUTHENTICATE : Header.AUTHORIZATION, credential) + .header(proxyAuthorization ? HTTP.PROXY_AUTHENTICATE : HTTP.AUTHORIZATION, credential) .build(); } } diff --git a/bus-http/src/main/java/org/miaixz/bus/http/socket/Handshake.java b/bus-http/src/main/java/org/miaixz/bus/http/socket/Handshake.java index 4d00d712c1..a99f91efee 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/socket/Handshake.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/socket/Handshake.java @@ -53,7 +53,7 @@ public class Handshake { /** * 用于此连接的TLS版本。在Httpd 3.0之前没有跟踪这个值。 - * 对于之前版本缓存的响应,它返回{@link TlsVersion#SSL_3_0} + * 对于之前版本缓存的响应,它返回{@link TlsVersion#SSLv3} */ private final TlsVersion tlsVersion; /** @@ -122,7 +122,7 @@ public static Handshake get(TlsVersion tlsVersion, CipherSuite cipherSuite, /** * Returns the TLS version used for this connection. This value wasn't tracked prior to Http - * 3.0. For responses cached by preceding versions this returns {@link TlsVersion#SSL_3_0}. + * 3.0. For responses cached by preceding versions this returns {@link TlsVersion#SSLv3}. */ public TlsVersion tlsVersion() { return tlsVersion; diff --git a/bus-http/src/main/java/org/miaixz/bus/http/socket/RealWebSocket.java b/bus-http/src/main/java/org/miaixz/bus/http/socket/RealWebSocket.java index de33316dd7..171ac24db1 100644 --- a/bus-http/src/main/java/org/miaixz/bus/http/socket/RealWebSocket.java +++ b/bus-http/src/main/java/org/miaixz/bus/http/socket/RealWebSocket.java @@ -30,10 +30,10 @@ import org.miaixz.bus.core.io.ByteString; import org.miaixz.bus.core.io.sink.BufferSink; import org.miaixz.bus.core.io.source.BufferSource; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.http.*; import org.miaixz.bus.http.accord.Exchange; @@ -164,7 +164,7 @@ public class RealWebSocket implements WebSocket, WebSocketReader.FrameCallback { public RealWebSocket(Request request, WebSocketListener listener, Random random, long pingIntervalMillis) { - if (!Http.GET.equals(request.method())) { + if (!HTTP.GET.equals(request.method())) { throw new IllegalArgumentException("Request must be GET: " + request.method()); } this.originalRequest = request; @@ -207,10 +207,10 @@ public void connect(Httpd client) { .protocols(ONLY_HTTP1) .build(); final Request request = originalRequest.newBuilder() - .header(Header.UPGRADE, "websocket") - .header(Header.CONNECTION, Header.UPGRADE) - .header(Header.SEC_WEBSOCKET_KEY, key) - .header(Header.SEC_WEBSOCKET_VERSION, "13") + .header(HTTP.UPGRADE, "websocket") + .header(HTTP.CONNECTION, HTTP.UPGRADE) + .header(HTTP.SEC_WEBSOCKET_KEY, key) + .header(HTTP.SEC_WEBSOCKET_VERSION, "13") .build(); call = Internal.instance.newWebSocketCall(client, request); call.enqueue(new Callback() { @@ -252,19 +252,19 @@ void checkUpgradeSuccess(Response response, Exchange exchange) throws IOExceptio + response.code() + Symbol.SPACE + response.message() + Symbol.SINGLE_QUOTE); } - String headerConnection = response.header(Header.CONNECTION); - if (!Header.UPGRADE.equalsIgnoreCase(headerConnection)) { + String headerConnection = response.header(HTTP.CONNECTION); + if (!HTTP.UPGRADE.equalsIgnoreCase(headerConnection)) { throw new ProtocolException("Expected 'Connection' header value 'Upgrade' but was '" + headerConnection + Symbol.SINGLE_QUOTE); } - String headerUpgrade = response.header(Header.UPGRADE); + String headerUpgrade = response.header(HTTP.UPGRADE); if (!"websocket".equalsIgnoreCase(headerUpgrade)) { throw new ProtocolException( "Expected 'Upgrade' header value 'websocket' but was '" + headerUpgrade + Symbol.SINGLE_QUOTE); } - String headerAccept = response.header(Header.SEC_WEBSOCKET_ACCEPT); + String headerAccept = response.header(HTTP.SEC_WEBSOCKET_ACCEPT); String acceptExpected = ByteString.encodeUtf8(key + WebSocketProtocol.ACCEPT_MAGIC) .sha1().base64(); if (!acceptExpected.equals(headerAccept)) { diff --git a/bus-image/pom.xml b/bus-image/pom.xml index bb4f5e3477..159efb39ba 100755 --- a/bus-image/pom.xml +++ b/bus-image/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-image - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -119,63 +119,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - maven-surefire-plugin - - @{argLine} -XX:+IgnoreUnrecognizedVMOptions - --add-opens=java.desktop/javax.imageio.stream=ALL-UNNAMED - --add-opens=java.base/java.io=ALL-UNNAMED - - - - - - - - diff --git a/bus-image/src/main/java/org/miaixz/bus/image/Centre.java b/bus-image/src/main/java/org/miaixz/bus/image/Centre.java index a53022b36c..240d762564 100644 --- a/bus-image/src/main/java/org/miaixz/bus/image/Centre.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/Centre.java @@ -28,7 +28,10 @@ package org.miaixz.bus.image; import lombok.AllArgsConstructor; +import lombok.Getter; import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; import org.miaixz.bus.core.xyz.BooleanKit; @@ -54,7 +57,9 @@ * @author Kimi Liu * @since Java 17+ */ -@lombok.Builder +@Getter +@Setter +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Centre { diff --git a/bus-image/src/main/java/org/miaixz/bus/image/Device.java b/bus-image/src/main/java/org/miaixz/bus/image/Device.java index 72674e98ec..05db3b144e 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/Device.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/Device.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.image; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.image.galaxy.Material; import org.miaixz.bus.image.galaxy.data.Code; import org.miaixz.bus.image.galaxy.data.Issuer; @@ -1203,7 +1203,7 @@ public SSLContext sslContext() throws GeneralSecurityException, IOException { if (null != ctx) return ctx; - ctx = SSLContext.getInstance(Http.TLS); + ctx = SSLContext.getInstance(Protocol.TLS.name); ctx.init(keyManagers(), trustManagers(), null); sslContext = ctx; return ctx; diff --git a/bus-image/src/main/java/org/miaixz/bus/image/Node.java b/bus-image/src/main/java/org/miaixz/bus/image/Node.java index 0db60bd3c0..0ff6f202f4 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/Node.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/Node.java @@ -29,8 +29,8 @@ import lombok.Getter; import lombok.Setter; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.image.metric.Association; import org.miaixz.bus.logger.Logger; @@ -88,7 +88,7 @@ public static String convertToIP(String hostname) { } catch (UnknownHostException e) { Logger.error("Cannot resolve hostname", e); } - return StringKit.hasText(hostname) ? hostname : Http.HOST_IPV4; + return StringKit.hasText(hostname) ? hostname : Protocol.HOST_IPV4; } public static Node buildLocalDicomNode(Association as) { diff --git a/bus-image/src/main/java/org/miaixz/bus/image/Option.java b/bus-image/src/main/java/org/miaixz/bus/image/Option.java index ed561b6562..199bd1ce47 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/Option.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/Option.java @@ -29,7 +29,7 @@ import lombok.Getter; import lombok.Setter; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.image.metric.Connection; import org.miaixz.bus.image.metric.internal.pdu.ExtendedNegotiate; @@ -90,8 +90,8 @@ public Option(boolean tlsNeedClientAuth, String keystoreURL, String keystoreType "SSL_RSA_WITH_3DES_EDE_CBC_SHA" }, new String[]{ - Http.TLS_V_10, - Http.SSL_V_30 + Protocol.TLSv1.name, + Protocol.SSLv3.name }, tlsNeedClientAuth, keystoreURL, diff --git a/bus-image/src/main/java/org/miaixz/bus/image/galaxy/media/AbstractStowrs.java b/bus-image/src/main/java/org/miaixz/bus/image/galaxy/media/AbstractStowrs.java index b8be51ad33..75d26c087b 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/galaxy/media/AbstractStowrs.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/galaxy/media/AbstractStowrs.java @@ -27,10 +27,10 @@ */ package org.miaixz.bus.image.galaxy.media; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.image.Tag; import org.miaixz.bus.image.UID; import org.miaixz.bus.image.galaxy.data.Attributes; @@ -186,10 +186,10 @@ protected HttpURLConnection buildConnection() throws IOException { httpPost.setRequestMethod("POST"); httpPost.setConnectTimeout(10000); httpPost.setReadTimeout(60000); - httpPost.setRequestProperty(Header.CONTENT_TYPE, + httpPost.setRequestProperty(HTTP.CONTENT_TYPE, MediaType.MULTIPART_RELATED + "; type=\"" + contentType + "\"; boundary=" + MULTIPART_BOUNDARY); - httpPost.setRequestProperty(Header.USER_AGENT, null == agentName ? "STOWRS" : agentName); - httpPost.setRequestProperty(Header.ACCEPT, + httpPost.setRequestProperty(HTTP.USER_AGENT, null == agentName ? "STOWRS" : agentName); + httpPost.setRequestProperty(HTTP.ACCEPT, contentType == MediaType.APPLICATION_DICOM_JSON ? MediaType.APPLICATION_DICOM_JSON : MediaType.APPLICATION_DICOM_XML); if (null != headers && !headers.isEmpty()) { @@ -222,7 +222,7 @@ protected void writeContentMarkers(DataOutputStream out) throws IOException { out.write(MultipartParser.Separator.BOUNDARY.getType()); out.writeBytes(MULTIPART_BOUNDARY); out.write(MultipartParser.Separator.FIELD.getType()); - out.writeBytes(Header.CONTENT_TYPE + ": "); + out.writeBytes(HTTP.CONTENT_TYPE + ": "); out.writeBytes(contentType); out.write(MultipartParser.Separator.HEADER.getType()); } diff --git a/bus-image/src/main/java/org/miaixz/bus/image/galaxy/media/StowrsSingleFile.java b/bus-image/src/main/java/org/miaixz/bus/image/galaxy/media/StowrsSingleFile.java index 66832ea2a0..3e2e094653 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/galaxy/media/StowrsSingleFile.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/galaxy/media/StowrsSingleFile.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.image.galaxy.media; -import org.miaixz.bus.core.lang.Header; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.image.Tag; import org.miaixz.bus.image.galaxy.data.Attributes; import org.miaixz.bus.image.galaxy.data.BulkData; @@ -115,10 +115,10 @@ public void uploadEncapsulatedDocument(Attributes metadata, File bulkDataFile, S out.writeBytes(MULTIPART_BOUNDARY); byte[] fsep = MultipartParser.Separator.FIELD.getType(); out.write(fsep); - out.writeBytes(Header.CONTENT_TYPE + ": "); + out.writeBytes(HTTP.CONTENT_TYPE + ": "); out.writeBytes(mdiaType); out.write(fsep); - out.writeBytes(Header.CONTENT_LOCATION + ": "); + out.writeBytes(HTTP.CONTENT_LOCATION + ": "); out.writeBytes(getContentLocation(metadata)); out.write(MultipartParser.Separator.HEADER.getType()); diff --git a/bus-image/src/main/java/org/miaixz/bus/image/metric/ApplicationEntity.java b/bus-image/src/main/java/org/miaixz/bus/image/metric/ApplicationEntity.java index 3120bdc81c..b87e445f82 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/metric/ApplicationEntity.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/metric/ApplicationEntity.java @@ -30,6 +30,7 @@ import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.image.Device; import org.miaixz.bus.image.Dimse; @@ -463,7 +464,7 @@ void onDimseRQ(Association as, Presentation pc, Dimse cmd, } public void addConnection(Connection conn) { - if (conn.getProtocol() != Connection.Protocol.DICOM) + if (conn.getProtocol() != Protocol.DICOM) throw new IllegalArgumentException( "protocol != DICOM - " + conn.getProtocol()); diff --git a/bus-image/src/main/java/org/miaixz/bus/image/metric/Connection.java b/bus-image/src/main/java/org/miaixz/bus/image/metric/Connection.java index fefd5aa00f..d194024714 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/metric/Connection.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/metric/Connection.java @@ -32,6 +32,7 @@ import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.image.Device; import org.miaixz.bus.image.galaxy.Material; @@ -70,10 +71,8 @@ public class Connection implements Serializable { // 适应SunJSSE TLS应用程序数据长度16408 public static final String TLS_RSA_WITH_AES_128_CBC_SHA = "TLS_RSA_WITH_AES_128_CBC_SHA"; public static final String[] DEFAULT_TLS_PROTOCOLS = {"TLSv1.2", "TLSv1.1", "TLSv1"}; - private static final EnumMap tcpHandlers = - new EnumMap(Protocol.class); - private static final EnumMap udpHandlers = - new EnumMap(Protocol.class); + private static final EnumMap tcpHandlers = new EnumMap<>(Protocol.class); + private static final EnumMap udpHandlers = new EnumMap<>(Protocol.class); static { registerTCPProtocolHandler(Protocol.DICOM, AdvancedHandler.INSTANCE); @@ -937,7 +936,7 @@ public synchronized boolean bind() throws IOException, GeneralSecurityException throw new IllegalStateException("Not attached to Device"); if (isListening()) throw new IllegalStateException("Already listening - " + listener); - if (protocol.isTCP()) { + if (protocol.isTcp()) { TCPHandler handler = tcpHandlers.get(protocol); if (null == handler) { Logger.info("No TCP Protocol Handler for protocol {}", protocol); @@ -980,7 +979,7 @@ public synchronized void unbind() { public Socket connect(Connection remoteConn) throws IOException, InternalException, GeneralSecurityException { checkInstalled(); - if (!protocol.isTCP()) + if (!protocol.isTcp()) throw new IllegalStateException("Not a TCP Connection"); checkCompatible(remoteConn); SocketAddress bindPoint = getClientBindPoint(); @@ -1038,7 +1037,7 @@ public Socket connect(Connection remoteConn) public DatagramSocket createDatagramSocket() throws IOException { checkInstalled(); - if (protocol.isTCP()) + if (protocol.isTcp()) throw new IllegalStateException("Not a UDP Connection"); DatagramSocket ds = new DatagramSocket(getClientBindPoint()); @@ -1106,7 +1105,7 @@ public boolean isCompatible(Connection remoteConn) { if (remoteConn.protocol != protocol) return false; - if (!protocol.isTCP()) + if (!protocol.isTcp()) return true; if (!isTls()) @@ -1165,18 +1164,6 @@ public void reconfigure(Connection from) { setInstalled(from.installed); } - public enum Protocol { - DICOM, HL7, SYSLOG_TLS, SYSLOG_UDP, HTTP; - - public boolean isTCP() { - return this != SYSLOG_UDP; - } - - public boolean isSyslog() { - return this == SYSLOG_TLS || this == SYSLOG_UDP; - } - } - private static class HTTPResponse extends ByteArrayOutputStream { private final String rsp; diff --git a/bus-image/src/main/java/org/miaixz/bus/image/metric/WebApplication.java b/bus-image/src/main/java/org/miaixz/bus/image/metric/WebApplication.java index e3858e4c89..3556d77e13 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/metric/WebApplication.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/metric/WebApplication.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.image.metric; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.image.Device; import java.util.ArrayList; @@ -155,7 +155,7 @@ public KeycloakClient getKeycloakClient() { } public void addConnection(Connection conn) { - if (conn.getProtocol() != Connection.Protocol.HTTP) + if (conn.getProtocol() != Protocol.HTTP) throw new IllegalArgumentException( "Web Application does not support protocol " + conn.getProtocol()); if (null != device && device != conn.getDevice()) @@ -178,7 +178,7 @@ private Connection firstInstalledConnection() { public StringBuilder getServiceURL(Connection conn) { return new StringBuilder(Normal._64) - .append(conn.isTls() ? Http.HTTPS_PREFIX : Http.HTTP_PREFIX) + .append(conn.isTls() ? Protocol.HTTPS_PREFIX : Protocol.HTTP_PREFIX) .append(conn.getHostname()) .append(Symbol.C_COLON) .append(conn.getPort()) diff --git a/bus-image/src/main/java/org/miaixz/bus/image/metric/acquire/HL7ApplicationExtension.java b/bus-image/src/main/java/org/miaixz/bus/image/metric/acquire/HL7ApplicationExtension.java index 749ca6d810..adf5cde47c 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/metric/acquire/HL7ApplicationExtension.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/metric/acquire/HL7ApplicationExtension.java @@ -45,9 +45,7 @@ public final HL7Application getHL7Application() { public void setHL7Application(HL7Application hl7App) { if (null != hl7App && null != this.hl7App) - throw new IllegalStateException( - "already owned by HL7 Application: " - + hl7App.getApplicationName()); + throw new IllegalStateException("already owned by HL7 Application: " + hl7App.getApplicationName()); this.hl7App = hl7App; } diff --git a/bus-image/src/main/java/org/miaixz/bus/image/metric/acquire/HL7DeviceExtension.java b/bus-image/src/main/java/org/miaixz/bus/image/metric/acquire/HL7DeviceExtension.java index 2000c06b0b..675e24d808 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/metric/acquire/HL7DeviceExtension.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/metric/acquire/HL7DeviceExtension.java @@ -28,6 +28,7 @@ package org.miaixz.bus.image.metric.acquire; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.image.Builder; import org.miaixz.bus.image.metric.Connection; import org.miaixz.bus.image.metric.internal.hl7.*; @@ -43,7 +44,7 @@ public class HL7DeviceExtension extends DeviceExtension { static { - Connection.registerTCPProtocolHandler(Connection.Protocol.HL7, HL7Handler.INSTANCE); + Connection.registerTCPProtocolHandler(Protocol.HL7, HL7Handler.INSTANCE); } private final LinkedHashMap hl7apps = new LinkedHashMap<>(); diff --git a/bus-image/src/main/java/org/miaixz/bus/image/metric/internal/hl7/HL7Application.java b/bus-image/src/main/java/org/miaixz/bus/image/metric/internal/hl7/HL7Application.java index 0b906dec46..1cd2d74390 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/metric/internal/hl7/HL7Application.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/metric/internal/hl7/HL7Application.java @@ -29,6 +29,7 @@ import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.image.Builder; import org.miaixz.bus.image.Device; import org.miaixz.bus.image.metric.Compatible; @@ -202,7 +203,7 @@ public final void setHL7MessageListener(HL7MessageListener listener) { } public void addConnection(Connection conn) { - if (conn.getProtocol() != Connection.Protocol.HL7) + if (conn.getProtocol() != Protocol.HL7) throw new IllegalArgumentException( "protocol != HL7 - " + conn.getProtocol()); diff --git a/bus-image/src/main/java/org/miaixz/bus/image/plugin/HL7Rcv.java b/bus-image/src/main/java/org/miaixz/bus/image/plugin/HL7Rcv.java index 9d49696074..9c2f039b9b 100755 --- a/bus-image/src/main/java/org/miaixz/bus/image/plugin/HL7Rcv.java +++ b/bus-image/src/main/java/org/miaixz/bus/image/plugin/HL7Rcv.java @@ -28,6 +28,7 @@ package org.miaixz.bus.image.plugin; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.image.Device; import org.miaixz.bus.image.galaxy.io.SAXTransformer; import org.miaixz.bus.image.metric.Connection; @@ -74,7 +75,7 @@ public class HL7Rcv { }; public HL7Rcv() { - conn.setProtocol(Connection.Protocol.HL7); + conn.setProtocol(Protocol.HL7); device.addDeviceExtension(hl7Ext); device.addConnection(conn); hl7Ext.addHL7Application(hl7App); diff --git a/bus-limiter/pom.xml b/bus-limiter/pom.xml index 4b962ffcce..741e7272b5 100755 --- a/bus-limiter/pom.xml +++ b/bus-limiter/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-limiter - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -131,54 +131,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-limiter/src/main/java/org/miaixz/bus/limiter/Context.java b/bus-limiter/src/main/java/org/miaixz/bus/limiter/Context.java index a05d223e10..eec67f77ea 100644 --- a/bus-limiter/src/main/java/org/miaixz/bus/limiter/Context.java +++ b/bus-limiter/src/main/java/org/miaixz/bus/limiter/Context.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.limiter; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; +import lombok.Builder; +import lombok.*; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.core.lang.Normal; /** @@ -40,22 +40,27 @@ */ @Getter @Setter +@SuperBuilder @NoArgsConstructor +@AllArgsConstructor public class Context { /** * 热点缓存默认时长 */ + @Builder.Default private int seconds = 60; /** * 是否启动日志 */ + @Builder.Default private boolean logger = true; /** * 用户标识提供者全限定类名 */ + @Builder.Default private String supplier = Normal.EMPTY; } diff --git a/bus-limiter/src/main/java/org/miaixz/bus/limiter/magic/FlowGrade.java b/bus-limiter/src/main/java/org/miaixz/bus/limiter/magic/FlowGrade.java index f76e50a625..f9a930bc4a 100644 --- a/bus-limiter/src/main/java/org/miaixz/bus/limiter/magic/FlowGrade.java +++ b/bus-limiter/src/main/java/org/miaixz/bus/limiter/magic/FlowGrade.java @@ -27,12 +27,17 @@ */ package org.miaixz.bus.limiter.magic; +import lombok.AllArgsConstructor; +import lombok.Getter; + /** * 流量等级 * * @author Kimi Liu * @since Java 17+ */ +@Getter +@AllArgsConstructor public enum FlowGrade { /** @@ -46,16 +51,4 @@ public enum FlowGrade { private int grade; - FlowGrade(int grade) { - this.grade = grade; - } - - public int getGrade() { - return grade; - } - - public void setGrade(int grade) { - this.grade = grade; - } - } diff --git a/bus-limiter/src/main/java/org/miaixz/bus/limiter/metric/RequestProvider.java b/bus-limiter/src/main/java/org/miaixz/bus/limiter/metric/RequestProvider.java index 7e50b3028d..8ebb4bc1de 100644 --- a/bus-limiter/src/main/java/org/miaixz/bus/limiter/metric/RequestProvider.java +++ b/bus-limiter/src/main/java/org/miaixz/bus/limiter/metric/RequestProvider.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.limiter.metric; -import org.miaixz.bus.core.data.UUID; +import org.miaixz.bus.core.data.id.ID; import org.miaixz.bus.core.xyz.MethodKit; import org.miaixz.bus.core.xyz.ThreadKit; import org.miaixz.bus.limiter.Builder; @@ -62,7 +62,7 @@ public class RequestProvider implements Provider { @Override public Serializable get() { - return UUID.fastUUID(); + return ID.objectId(); } }; diff --git a/bus-logger/pom.xml b/bus-logger/pom.xml index 4c372440e5..f21dc97140 100644 --- a/bus-logger/pom.xml +++ b/bus-logger/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-logger - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -152,54 +152,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-logger/src/main/java/org/miaixz/bus/logger/Holder.java b/bus-logger/src/main/java/org/miaixz/bus/logger/Holder.java index 48b6453852..418840f215 100755 --- a/bus-logger/src/main/java/org/miaixz/bus/logger/Holder.java +++ b/bus-logger/src/main/java/org/miaixz/bus/logger/Holder.java @@ -34,8 +34,8 @@ import org.miaixz.bus.logger.metric.commons.CommonsFactory; import org.miaixz.bus.logger.metric.console.ConsoleFactory; import org.miaixz.bus.logger.metric.jdk.JdkFactory; -import org.miaixz.bus.logger.metric.log4j.Log4JFactory; -import org.miaixz.bus.logger.metric.slf4j.Slf4JFactory; +import org.miaixz.bus.logger.metric.log4j.Log4jFactory; +import org.miaixz.bus.logger.metric.slf4j.Slf4jFactory; import java.net.URL; @@ -59,7 +59,7 @@ public Holder() { * * @return the factory */ - public static Factory get() { + public static Factory getFactory() { return InstanceHolder.INSTANCE; } @@ -67,15 +67,15 @@ public static Factory get() { * 自定义默认日志实现 * * @param clazz 日志工厂类 - * @see Slf4JFactory - * @see Log4JFactory + * @see Slf4jFactory + * @see Log4jFactory * @see CommonsFactory * @see JdkFactory * @see ConsoleFactory */ - public static void set(final Class clazz) { + public static void setFactory(final Class clazz) { try { - set(ReflectKit.newInstance(clazz)); + setFactory(ReflectKit.newInstance(clazz)); } catch (final Exception e) { throw new IllegalArgumentException("Can not instance LogFactory class!", e); } @@ -85,13 +85,13 @@ public static void set(final Class clazz) { * 自定义日志实现 * * @param factory 日志工厂对象 - * @see Slf4JFactory - * @see Log4JFactory + * @see Slf4jFactory + * @see Log4jFactory * @see CommonsFactory * @see JdkFactory * @see ConsoleFactory */ - public static void set(final Factory factory) { + public static void setFactory(final Factory factory) { Instances.put(Holder.class.getName(), factory); factory.create(Holder.class).debug("Custom Use [{}] Logger.", factory.getName()); } diff --git a/bus-logger/src/main/java/org/miaixz/bus/logger/Registry.java b/bus-logger/src/main/java/org/miaixz/bus/logger/Registry.java index 6c84d44534..798aa0d047 100644 --- a/bus-logger/src/main/java/org/miaixz/bus/logger/Registry.java +++ b/bus-logger/src/main/java/org/miaixz/bus/logger/Registry.java @@ -49,7 +49,7 @@ public Registry() { * @return 日志对象 */ public static Supplier get(final String name) { - return Holder.get().get(name); + return Holder.getFactory().get(name); } /** @@ -59,7 +59,7 @@ public static Supplier get(final String name) { * @return 日志对象 */ public static Supplier get(final Class clazz) { - return Holder.get().get(clazz); + return Holder.getFactory().get(clazz); } } diff --git a/bus-logger/src/main/java/org/miaixz/bus/logger/metric/log4j/Log4JFactory.java b/bus-logger/src/main/java/org/miaixz/bus/logger/metric/log4j/Log4jFactory.java similarity index 97% rename from bus-logger/src/main/java/org/miaixz/bus/logger/metric/log4j/Log4JFactory.java rename to bus-logger/src/main/java/org/miaixz/bus/logger/metric/log4j/Log4jFactory.java index a01f1b096b..e64b879633 100644 --- a/bus-logger/src/main/java/org/miaixz/bus/logger/metric/log4j/Log4JFactory.java +++ b/bus-logger/src/main/java/org/miaixz/bus/logger/metric/log4j/Log4jFactory.java @@ -36,12 +36,12 @@ * @author Kimi Liu * @since Java 17+ */ -public class Log4JFactory extends AbstractFactory { +public class Log4jFactory extends AbstractFactory { /** * 构造 */ - public Log4JFactory() { + public Log4jFactory() { super("Log4j"); check(org.apache.logging.log4j.LogManager.class); } diff --git a/bus-logger/src/main/java/org/miaixz/bus/logger/metric/slf4j/Slf4JFactory.java b/bus-logger/src/main/java/org/miaixz/bus/logger/metric/slf4j/Slf4jFactory.java similarity index 96% rename from bus-logger/src/main/java/org/miaixz/bus/logger/metric/slf4j/Slf4JFactory.java rename to bus-logger/src/main/java/org/miaixz/bus/logger/metric/slf4j/Slf4jFactory.java index f9dbfec049..cfc8b6c527 100644 --- a/bus-logger/src/main/java/org/miaixz/bus/logger/metric/slf4j/Slf4JFactory.java +++ b/bus-logger/src/main/java/org/miaixz/bus/logger/metric/slf4j/Slf4jFactory.java @@ -42,12 +42,12 @@ * @author Kimi Liu * @since Java 17+ */ -public class Slf4JFactory extends AbstractFactory { +public class Slf4jFactory extends AbstractFactory { /** * 构造 */ - public Slf4JFactory() { + public Slf4jFactory() { this(true); } @@ -56,7 +56,7 @@ public Slf4JFactory() { * * @param fail 如果未找到桥接包是否报错 */ - public Slf4JFactory(final boolean fail) { + public Slf4jFactory(final boolean fail) { super("Slf4j"); check(LoggerFactory.class); if (!fail) { diff --git a/bus-logger/src/main/resources/META-INF/services/org.miaixz.bus.logger.Factory b/bus-logger/src/main/resources/META-INF/services/org.miaixz.bus.logger.Factory index 7a14c83968..8e1e373030 100644 --- a/bus-logger/src/main/resources/META-INF/services/org.miaixz.bus.logger.Factory +++ b/bus-logger/src/main/resources/META-INF/services/org.miaixz.bus.logger.Factory @@ -26,6 +26,6 @@ org.miaixz.bus.logger.metric.commons.CommonsFactory org.miaixz.bus.logger.metric.jboss.JbossFactory -org.miaixz.bus.logger.metric.log4j.Log4JFactory -org.miaixz.bus.logger.metric.slf4j.Slf4JFactory +org.miaixz.bus.logger.metric.log4j.Log4jFactory +org.miaixz.bus.logger.metric.slf4j.Slf4jFactory org.miaixz.bus.logger.metric.tinylog.TinyLogFactory diff --git a/bus-mapper/pom.xml b/bus-mapper/pom.xml index 61ab865865..dfc20d2759 100755 --- a/bus-mapper/pom.xml +++ b/bus-mapper/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-mapper - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -73,7 +73,7 @@ 1.18.32 3.5.16 3.0.3 - 3.2.0-M2 + 3.2.0 @@ -133,54 +133,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/SaveMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/SaveMapper.java index 0661d4d2a8..efda9f023d 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/SaveMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/SaveMapper.java @@ -44,7 +44,7 @@ public interface SaveMapper { * 保存一个实体,如果实体的主键不为null则更新记录, 主键不存在或主键为null, 则插入记录 * * @param record 不能为空 - * @return + * @return the int 操作结果 */ @InsertProvider(type = SaveProvider.class, method = "dynamicSQL") int save(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/delete/DeleteByPrimaryKeyMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/delete/DeleteByPrimaryKeyMapper.java index d2ac709a9f..d2c0b747b8 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/delete/DeleteByPrimaryKeyMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/delete/DeleteByPrimaryKeyMapper.java @@ -44,8 +44,8 @@ public interface DeleteByPrimaryKeyMapper { /** * 根据主键字段进行删除,方法参数必须包含完整的主键属性 * - * @param key - * @return + * @param key 主键 + * @return the int 操作结果 */ @DeleteProvider(type = BasicDeleteProvider.class, method = "dynamicSQL") int deleteByPrimaryKey(Object key); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/delete/DeleteMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/delete/DeleteMapper.java index aff7a76e91..99f42e3efc 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/delete/DeleteMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/delete/DeleteMapper.java @@ -44,8 +44,8 @@ public interface DeleteMapper { /** * 根据实体属性作为条件进行删除,查询条件使用等号 * - * @param record - * @return + * @param record 泛型对象 + * @return the int 操作结果 */ @DeleteProvider(type = BasicDeleteProvider.class, method = "dynamicSQL") int delete(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/insert/InsertMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/insert/InsertMapper.java index cf6954ced1..692297bac0 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/insert/InsertMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/insert/InsertMapper.java @@ -44,8 +44,8 @@ public interface InsertMapper { /** * 保存一个实体,null的属性也会保存,不会使用数据库默认值 * - * @param record - * @return + * @param record 泛型对象 + * @return the int 操作结果 */ @InsertProvider(type = BasicInsertProvider.class, method = "dynamicSQL") int insert(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/insert/InsertSelectiveMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/insert/InsertSelectiveMapper.java index fc86118008..eed7df0fa2 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/insert/InsertSelectiveMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/insert/InsertSelectiveMapper.java @@ -44,8 +44,8 @@ public interface InsertSelectiveMapper { /** * 保存一个实体,null的属性不会保存,会使用数据库默认值 * - * @param record - * @return + * @param record 泛型对象 + * @return the int 操作结果 */ @InsertProvider(type = BasicInsertProvider.class, method = "dynamicSQL") int insertSelective(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/ExistsWithPrimaryKeyMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/ExistsWithPrimaryKeyMapper.java index 87e4114f9b..c4dd0982e6 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/ExistsWithPrimaryKeyMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/ExistsWithPrimaryKeyMapper.java @@ -44,8 +44,8 @@ public interface ExistsWithPrimaryKeyMapper { /** * 根据主键字段查询总数,方法参数必须包含完整的主键属性,查询条件使用等号 * - * @param key - * @return + * @param key 泛型对象 + * @return the boolean 操作结果 */ @SelectProvider(type = BasicSelectProvider.class, method = "dynamicSQL") boolean existsWithPrimaryKey(Object key); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectAllMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectAllMapper.java index e6a2611976..1395963ebe 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectAllMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectAllMapper.java @@ -46,7 +46,7 @@ public interface SelectAllMapper { /** * 查询全部结果 * - * @return + * @return the list 操作结果 */ @SelectProvider(type = BasicSelectProvider.class, method = "dynamicSQL") List selectAll(); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectByPrimaryKeyMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectByPrimaryKeyMapper.java index 26479c3fa0..c6ee1a9762 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectByPrimaryKeyMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectByPrimaryKeyMapper.java @@ -46,8 +46,8 @@ public interface SelectByPrimaryKeyMapper { /** * 根据主键字段进行查询,方法参数必须包含完整的主键属性,查询条件使用等号 * - * @param key - * @return + * @param key 主键 + * @return the object 操作结果 */ @SelectProvider(type = BasicSelectProvider.class, method = "dynamicSQL") T selectByPrimaryKey(Object key); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectCountMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectCountMapper.java index 0c841b6e0e..157b8a108c 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectCountMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectCountMapper.java @@ -44,8 +44,8 @@ public interface SelectCountMapper { /** * 根据实体中的属性查询总数,查询条件使用等号 * - * @param record - * @return + * @param record 泛型对象 + * @return the int 操作结果 */ @SelectProvider(type = BasicSelectProvider.class, method = "dynamicSQL") int selectCount(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectMapper.java index fad9eb89b0..def251b81a 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectMapper.java @@ -46,8 +46,8 @@ public interface SelectMapper { /** * 根据实体中的属性值进行查询,查询条件使用等号 * - * @param record - * @return + * @param record 泛型对象 + * @return the list 操作结果 */ @SelectProvider(type = BasicSelectProvider.class, method = "dynamicSQL") List select(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectOneMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectOneMapper.java index 0bf0ec73d7..cf7a01f333 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectOneMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/select/SelectOneMapper.java @@ -44,8 +44,8 @@ public interface SelectOneMapper { /** * 根据实体中的属性进行查询,只能有一个返回值,有多个结果是抛出异常,查询条件使用等号 * - * @param record - * @return + * @param record 泛型对象 + * @return the object 操作结果 */ @SelectProvider(type = BasicSelectProvider.class, method = "dynamicSQL") T selectOne(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/update/UpdateByPrimaryKeyMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/update/UpdateByPrimaryKeyMapper.java index 2e42a42758..ff00838897 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/update/UpdateByPrimaryKeyMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/update/UpdateByPrimaryKeyMapper.java @@ -44,8 +44,8 @@ public interface UpdateByPrimaryKeyMapper { /** * 根据主键更新实体全部字段,null值会被更新 * - * @param record - * @return + * @param record 泛型对象 + * @return the int 操作结果 */ @UpdateProvider(type = BasicUpdateProvider.class, method = "dynamicSQL") int updateByPrimaryKey(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/update/UpdateByPrimaryKeySelectiveMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/update/UpdateByPrimaryKeySelectiveMapper.java index ffa35764bc..3aba48c7ea 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/update/UpdateByPrimaryKeySelectiveMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/basic/update/UpdateByPrimaryKeySelectiveMapper.java @@ -44,8 +44,8 @@ public interface UpdateByPrimaryKeySelectiveMapper { /** * 根据主键更新属性不为null的值 * - * @param record - * @return + * @param record 泛型对象 + * @return the int 操作结果 */ @UpdateProvider(type = BasicUpdateProvider.class, method = "dynamicSQL") int updateByPrimaryKeySelective(T record); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/DeleteByConditionMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/DeleteByConditionMapper.java index 5e2f2a6133..51d33931ec 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/DeleteByConditionMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/DeleteByConditionMapper.java @@ -45,7 +45,7 @@ public interface DeleteByConditionMapper { * 根据Condition条件删除数据 * * @param condition 条件 - * @return the int + * @return the int 操作结果 */ @DeleteProvider(type = ConditionProvider.class, method = "dynamicSQL") int deleteByCondition(Object condition); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectByConditionMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectByConditionMapper.java index ffee87094f..feab1da5f6 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectByConditionMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectByConditionMapper.java @@ -47,7 +47,7 @@ public interface SelectByConditionMapper { * 根据Condition条件进行查询 * * @param condition 条件 - * @return the list + * @return the list 操作结果 */ @SelectProvider(type = ConditionProvider.class, method = "dynamicSQL") List selectByCondition(Object condition); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectCountByConditionMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectCountByConditionMapper.java index 353f5984a0..c491a26a60 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectCountByConditionMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectCountByConditionMapper.java @@ -45,7 +45,7 @@ public interface SelectCountByConditionMapper { * 根据Condition条件进行查询总数 * * @param condition 条件 - * @return the int + * @return the int 操作结果 */ @SelectProvider(type = ConditionProvider.class, method = "dynamicSQL") int selectCountByCondition(Object condition); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectOneByConditionMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectOneByConditionMapper.java index 7b7e8bc8ab..8f72567ab6 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectOneByConditionMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/SelectOneByConditionMapper.java @@ -45,7 +45,7 @@ public interface SelectOneByConditionMapper { * 根据Condition条件进行查询 * * @param condition 条件 - * @return the object + * @return the object 操作结果 */ @SelectProvider(type = ConditionProvider.class, method = "dynamicSQL") T selectOneByCondition(Object condition); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/UpdateByConditionMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/UpdateByConditionMapper.java index 6ddced05ea..382bec9dc1 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/UpdateByConditionMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/UpdateByConditionMapper.java @@ -47,7 +47,7 @@ public interface UpdateByConditionMapper { * * @param record 记录值 * @param condition 条件 - * @return the int + * @return the int 操作结果 */ @UpdateProvider(type = ConditionProvider.class, method = "dynamicSQL") int updateByCondition(@Param("record") T record, @Param("condition") Object condition); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/UpdateByConditionSelectiveMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/UpdateByConditionSelectiveMapper.java index 41a79df540..3bbb1fea1d 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/UpdateByConditionSelectiveMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/condition/UpdateByConditionSelectiveMapper.java @@ -45,9 +45,9 @@ public interface UpdateByConditionSelectiveMapper { /** * 根据Condition条件更新实体`record`包含的不是null的属性值 * - * @param record 记录值 + * @param record 泛型对象 * @param condition 条件 - * @return the int + * @return the int 操作结果 */ @UpdateProvider(type = ConditionProvider.class, method = "dynamicSQL") int updateByConditionSelective(@Param("record") T record, @Param("condition") Object condition); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/ids/DeleteByIdsMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/ids/DeleteByIdsMapper.java index 51323eb96f..58867b7e42 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/ids/DeleteByIdsMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/ids/DeleteByIdsMapper.java @@ -45,7 +45,7 @@ public interface DeleteByIdsMapper { * 根据主键字符串进行删除,类中只有存在一个带有@Id注解的字段 * * @param ids 如 "1,2,3,4" - * @return the int + * @return the int 操作结果 */ @DeleteProvider(type = IdsProvider.class, method = "dynamicSQL") int deleteByIds(String ids); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/ids/SelectByIdsMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/ids/SelectByIdsMapper.java index 6da3932cf9..83090cd302 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/ids/SelectByIdsMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/ids/SelectByIdsMapper.java @@ -47,7 +47,7 @@ public interface SelectByIdsMapper { * 根据主键字符串进行查询,类中只有存在一个带有@Id注解的字段 * * @param ids 如 "1,2,3,4" - * @return the int + * @return the int 操作结果 */ @SelectProvider(type = IdsProvider.class, method = "dynamicSQL") List selectByIds(String ids); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/rowbounds/SelectByConditionRowBoundsMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/rowbounds/SelectByConditionRowBoundsMapper.java index 1033ef0377..b02e735a54 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/rowbounds/SelectByConditionRowBoundsMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/rowbounds/SelectByConditionRowBoundsMapper.java @@ -49,7 +49,7 @@ public interface SelectByConditionRowBoundsMapper { * * @param condition 条件 * @param rowBounds RowBounds - * @return the list + * @return the list 操作结果 */ @SelectProvider(type = ConditionProvider.class, method = "dynamicSQL") List selectByConditionAndRowBounds(Object condition, RowBounds rowBounds); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/rowbounds/SelectRowBoundsMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/rowbounds/SelectRowBoundsMapper.java index 6c53233a0d..38dd907d62 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/rowbounds/SelectRowBoundsMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/rowbounds/SelectRowBoundsMapper.java @@ -49,7 +49,7 @@ public interface SelectRowBoundsMapper { * * @param record 记录值 * @param rowBounds RowBounds - * @return the list + * @return the list 操作结果 */ @SelectProvider(type = BasicSelectProvider.class, method = "dynamicSQL") List selectByRowBounds(T record, RowBounds rowBounds); diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/special/InsertListMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/special/InsertListMapper.java index 0c98cf7397..168f6bfb9a 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/special/InsertListMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/special/InsertListMapper.java @@ -47,11 +47,11 @@ public interface InsertListMapper { /** * 批量插入,支持批量插入的数据库可以使用,例如MySQL,H2等,另外该接口限制实体包含`id`属性并且必须为自增列 * - * @param recordList 记录值 - * @return the int + * @param list 记录值 + * @return the int 操作结果 */ @Options(useGeneratedKeys = true) @InsertProvider(type = SpecialProvider.class, method = "dynamicSQL") - int insertList(List recordList); + int insertList(List list); } \ No newline at end of file diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/special/InsertUseGeneratedKeysMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/special/InsertUseGeneratedKeysMapper.java index 5438ffde48..9f4e389cd7 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/special/InsertUseGeneratedKeysMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/special/InsertUseGeneratedKeysMapper.java @@ -46,7 +46,7 @@ public interface InsertUseGeneratedKeysMapper { * 插入数据,限制为实体包含`id`属性并且必须为自增列,实体配置的主键策略无效 * * @param record 记录值 - * @return the int + * @return the int 操作结果 */ @Options(useGeneratedKeys = true) @InsertProvider(type = SpecialProvider.class, method = "dynamicSQL") diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/sqlserver/InsertMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/sqlserver/InsertMapper.java index c6ab314d40..5ad42c30d6 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/sqlserver/InsertMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/sqlserver/InsertMapper.java @@ -46,7 +46,7 @@ public interface InsertMapper { * 插入数据库,`null`值也会插入,不会使用列的默认值 * * @param record 记录值 - * @return the int + * @return the int 操作结果 */ @Options(useGeneratedKeys = true) @InsertProvider(type = SqlServerProvider.class, method = "dynamicSQL") diff --git a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/sqlserver/InsertSelectiveMapper.java b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/sqlserver/InsertSelectiveMapper.java index 4eb631588f..6ab465d91a 100644 --- a/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/sqlserver/InsertSelectiveMapper.java +++ b/bus-mapper/src/main/java/org/miaixz/bus/mapper/common/sqlserver/InsertSelectiveMapper.java @@ -42,6 +42,12 @@ @RegisterMapper public interface InsertSelectiveMapper { + /** + * 插入数据库,`null`值不会插入 + * + * @param record 泛型对象 + * @return the int 操作结果 + */ @Options(useGeneratedKeys = true) @InsertProvider(type = SqlServerProvider.class, method = "dynamicSQL") int insertSelective(T record); diff --git a/bus-notify/pom.xml b/bus-notify/pom.xml index 0c3edb8a98..b54ae625d8 100755 --- a/bus-notify/pom.xml +++ b/bus-notify/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-notify - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -134,55 +134,45 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/Context.java b/bus-notify/src/main/java/org/miaixz/bus/notify/Context.java index 4f56a1da3d..e81365e360 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/Context.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/Context.java @@ -27,9 +27,11 @@ */ package org.miaixz.bus.notify; -import lombok.Builder; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * 配置信息 @@ -39,7 +41,9 @@ */ @Getter @Setter -@Builder +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class Context { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/Provider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/Provider.java index 3bce388128..6197fed4c9 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/Provider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/Provider.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.notify; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.xyz.ListKit; import org.miaixz.bus.notify.magic.Material; -import org.miaixz.bus.notify.magic.Message; import java.util.Collections; import java.util.List; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/magic/Material.java b/bus-notify/src/main/java/org/miaixz/bus/notify/magic/Material.java index 831fac262d..b6790bd6ff 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/magic/Material.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/magic/Material.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.notify.magic; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.util.Map; @@ -40,6 +43,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/magic/Message.java b/bus-notify/src/main/java/org/miaixz/bus/notify/magic/Message.java deleted file mode 100644 index fc16880b28..0000000000 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/magic/Message.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - ~ ~ - ~ The MIT License (MIT) ~ - ~ ~ - ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ - ~ ~ - ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ - ~ of this software and associated documentation files (the "Software"), to deal ~ - ~ in the Software without restriction, including without limitation the rights ~ - ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ - ~ copies of the Software, and to permit persons to whom the Software is ~ - ~ furnished to do so, subject to the following conditions: ~ - ~ ~ - ~ The above copyright notice and this permission notice shall be included in ~ - ~ all copies or substantial portions of the Software. ~ - ~ ~ - ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ - ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ - ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ - ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ - ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ - ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ - ~ THE SOFTWARE. ~ - ~ ~ - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - */ -package org.miaixz.bus.notify.magic; - -import lombok.Builder; -import lombok.Getter; -import lombok.Setter; - -/** - * 返回消息 - * - * @author Justubborn - * @since Java 17+ - */ -@Getter -@Setter -@Builder -public class Message { - - /** - * 请求返回码,错误为具体返回码,正确为 0 - */ - public String errcode; - - /** - * 请求返回消息 - */ - public String errmsg; - - /** - * 请求返回数据 JSON - */ - public Object data; - -} diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/AbstractProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/AbstractProvider.java index 8f82ed3691..b9619bbe86 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/AbstractProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/AbstractProvider.java @@ -28,11 +28,11 @@ package org.miaixz.bus.notify.metric; import lombok.AllArgsConstructor; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.xyz.ObjectKit; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.Provider; import org.miaixz.bus.notify.magic.Material; -import org.miaixz.bus.notify.magic.Message; import java.util.List; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunEmailProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunEmailProvider.java index 2430bf6bfb..1644cc54ad 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunEmailProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunEmailProvider.java @@ -27,13 +27,13 @@ */ package org.miaixz.bus.notify.metric.aliyun; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Fields; import org.miaixz.bus.core.lang.exception.InternalException; import org.miaixz.bus.core.xyz.DateKit; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.generic.GenericMaterial; import java.util.Date; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunMaterial.java index bf7df6f7ff..e33d1a2538 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunMaterial.java @@ -27,13 +27,19 @@ */ package org.miaixz.bus.notify.metric.aliyun; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class AliyunMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunProvider.java index 3117608261..f6b0f83ed6 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunProvider.java @@ -27,16 +27,16 @@ */ package org.miaixz.bus.notify.metric.aliyun; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Algorithm; import org.miaixz.bus.core.lang.Charset; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; import org.miaixz.bus.notify.magic.Material; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import javax.crypto.Mac; @@ -101,7 +101,7 @@ protected String getSign(Map params) { } // 去除第一个多余的&符号 String sortedQueryString = sortQueryStringTmp.substring(1); - String stringToSign = Http.GET + Symbol.AND + + String stringToSign = HTTP.GET + Symbol.AND + specialUrlEncode(Symbol.SLASH) + Symbol.AND + specialUrlEncode(sortedQueryString); return sign(stringToSign); diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunSmsProvider.java index 941ea06cc3..0fd5153c93 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunSmsProvider.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.notify.metric.aliyun; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Fields; import org.miaixz.bus.core.xyz.DateKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; -import org.miaixz.bus.notify.magic.Message; import java.util.Date; import java.util.HashMap; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunVmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunVmsProvider.java index 32cb2c4183..4e801d0423 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunVmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/aliyun/AliyunVmsProvider.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.notify.metric.aliyun; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Fields; import org.miaixz.bus.core.xyz.DateKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; -import org.miaixz.bus.notify.magic.Message; import java.util.Date; import java.util.HashMap; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/baidu/BaiduMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/baidu/BaiduMaterial.java index c037f5c0c9..f33778ff14 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/baidu/BaiduMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/baidu/BaiduMaterial.java @@ -27,8 +27,10 @@ */ package org.miaixz.bus.notify.metric.baidu; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +42,8 @@ */ @Getter @Setter +@SuperBuilder +@AllArgsConstructor public class BaiduMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/baidu/BaiduSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/baidu/BaiduSmsProvider.java index 9bfe55867f..58ebb59122 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/baidu/BaiduSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/baidu/BaiduSmsProvider.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.notify.metric.baidu; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/cloopen/CloopenMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/cloopen/CloopenMaterial.java index 13c10db6a0..134dc99b9e 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/cloopen/CloopenMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/cloopen/CloopenMaterial.java @@ -27,8 +27,10 @@ */ package org.miaixz.bus.notify.metric.cloopen; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +42,8 @@ */ @Getter @Setter +@SuperBuilder +@AllArgsConstructor public class CloopenMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/cloopen/CloopenSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/cloopen/CloopenSmsProvider.java index cba3efe313..da858df8e6 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/cloopen/CloopenSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/cloopen/CloopenSmsProvider.java @@ -27,12 +27,12 @@ */ package org.miaixz.bus.notify.metric.cloopen; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.xyz.MapKit; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.Map; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/ctyun/CtyunMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/ctyun/CtyunMaterial.java index ba3a135f1f..e838f69796 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/ctyun/CtyunMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/ctyun/CtyunMaterial.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.notify.metric.ctyun; -import lombok.Getter; -import lombok.Setter; +import lombok.*; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +40,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class CtyunMaterial extends Material { /** @@ -50,6 +53,7 @@ public class CtyunMaterial extends Material { /** * 接口名称 */ + @Builder.Default private String action = "SendSms"; /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/ctyun/CtyunSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/ctyun/CtyunSmsProvider.java index ec1f89e426..cb38d31a1a 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/ctyun/CtyunSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/ctyun/CtyunSmsProvider.java @@ -27,6 +27,7 @@ */ package org.miaixz.bus.notify.metric.ctyun; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.center.date.Formatter; import org.miaixz.bus.core.codec.binary.Base64; import org.miaixz.bus.core.lang.MediaType; @@ -35,7 +36,6 @@ import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.nio.charset.StandardCharsets; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/dingtalk/DingTalkMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/dingtalk/DingTalkMaterial.java index c67e52db90..5df6649235 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/dingtalk/DingTalkMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/dingtalk/DingTalkMaterial.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.notify.metric.dingtalk; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.magic.Material; /** @@ -39,6 +42,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class DingTalkMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/dingtalk/DingTalkProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/dingtalk/DingTalkProvider.java index cae3a24a45..682216a877 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/dingtalk/DingTalkProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/dingtalk/DingTalkProvider.java @@ -28,14 +28,14 @@ package org.miaixz.bus.notify.metric.dingtalk; import lombok.Setter; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.basics.entity.Message; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.logger.Logger; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.time.Duration; @@ -76,7 +76,7 @@ public Message send(DingTalkMaterial entity) { String response = Httpx.post(this.getUrl(entity), bodys); String errcode = JsonKit.getValue(response, "errcode"); return Message.builder() - .errcode(String.valueOf(Http.HTTP_OK).equals(errcode) ? ErrorCode.SUCCESS.getCode() : errcode) + .errcode(String.valueOf(HTTP.HTTP_OK).equals(errcode) ? ErrorCode.SUCCESS.getCode() : errcode) .errmsg(JsonKit.getValue(response, "errmsg")) .build(); } @@ -99,7 +99,7 @@ private String requestToken(String url) { paramMap.put("corpsecret", context.getAppSecret()); String response = Httpx.get(url, paramMap); String errcode = JsonKit.getValue(response, "errcode"); - if (String.valueOf(Http.HTTP_OK).equals(errcode)) { + if (String.valueOf(HTTP.HTTP_OK).equals(errcode)) { String access_token = JsonKit.getValue(response, "access_token"); refreshTokenTime = System.currentTimeMillis(); accessToken.set(access_token); diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/emay/EmayMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/emay/EmayMaterial.java index 96460f6e77..bd38176876 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/emay/EmayMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/emay/EmayMaterial.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.notify.metric.emay; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.magic.Material; /** @@ -39,6 +42,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class EmayMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/emay/EmaySmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/emay/EmaySmsProvider.java index 2a8dc2d8bb..f703a81f02 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/emay/EmaySmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/emay/EmaySmsProvider.java @@ -27,9 +27,10 @@ */ package org.miaixz.bus.notify.metric.emay; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Charset; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.MediaType; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.net.url.UrlEncoder; import org.miaixz.bus.core.xyz.DateKit; import org.miaixz.bus.core.xyz.MapKit; @@ -38,7 +39,6 @@ import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.time.format.DateTimeFormatter; @@ -67,7 +67,7 @@ public Message send(EmayMaterial entity) { String response = Httpx.post(this.getUrl(entity), bodys, headers); String errcode = JsonKit.getValue(response, "errcode"); return Message.builder() - .errcode(String.valueOf(Http.HTTP_OK).equals(errcode) ? ErrorCode.SUCCESS.getCode() : errcode) + .errcode(String.valueOf(HTTP.HTTP_OK).equals(errcode) ? ErrorCode.SUCCESS.getCode() : errcode) .errmsg(JsonKit.getValue(response, "errmsg")) .build(); } diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/generic/GenericEmailProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/generic/GenericEmailProvider.java index dbe3a9f06e..9b53b10bef 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/generic/GenericEmailProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/generic/GenericEmailProvider.java @@ -32,6 +32,7 @@ import jakarta.activation.FileDataSource; import jakarta.mail.*; import jakarta.mail.internet.*; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; import org.miaixz.bus.core.xyz.ArrayKit; @@ -40,7 +41,6 @@ import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; import org.miaixz.bus.notify.magic.Material; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.io.File; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/generic/GenericMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/generic/GenericMaterial.java index d55b1e8ffc..07e4688d85 100755 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/generic/GenericMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/generic/GenericMaterial.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.notify.metric.generic; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.xyz.StringKit; @@ -44,6 +47,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class GenericMaterial extends Material { private static final String SMTP_HOST = "mail.smtp.host"; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/huawei/HuaweiMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/huawei/HuaweiMaterial.java index 33188c46c5..b6c82b652e 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/huawei/HuaweiMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/huawei/HuaweiMaterial.java @@ -27,8 +27,10 @@ */ package org.miaixz.bus.notify.metric.huawei; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +42,8 @@ */ @Getter @Setter +@SuperBuilder +@AllArgsConstructor public class HuaweiMaterial extends Material { /** @@ -51,6 +55,4 @@ public String getUrl() { return this.url = "https://smsapi.cn-north-4.myhuaweicloud.com/sms/batchSendSms/v1/"; } - - } diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/huawei/HuaweiSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/huawei/HuaweiSmsProvider.java index 59059c9927..a8b48a7465 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/huawei/HuaweiSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/huawei/HuaweiSmsProvider.java @@ -27,14 +27,18 @@ */ package org.miaixz.bus.notify.metric.huawei; -import org.miaixz.bus.core.lang.*; +import org.miaixz.bus.core.basics.entity.Message; +import org.miaixz.bus.core.lang.Charset; +import org.miaixz.bus.core.lang.Fields; +import org.miaixz.bus.core.lang.MediaType; +import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.DateKit; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.security.MessageDigest; @@ -89,8 +93,8 @@ public Message send(HuaweiMaterial entity) { bodys.put("signature", entity.getSignature()); Map headers = new HashMap<>(); - headers.put(Header.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); - headers.put(Header.AUTHORIZATION, AUTH_HEADER_VALUE); + headers.put(HTTP.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); + headers.put(HTTP.AUTHORIZATION, AUTH_HEADER_VALUE); headers.put("X-WSSE", buildWsseHeader()); String response = Httpx.post(this.getUrl(entity), bodys, headers); diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jdcloud/JdcloudMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jdcloud/JdcloudMaterial.java index e87e644136..5cd21ab75a 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jdcloud/JdcloudMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jdcloud/JdcloudMaterial.java @@ -27,8 +27,10 @@ */ package org.miaixz.bus.notify.metric.jdcloud; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +42,8 @@ */ @Getter @Setter +@SuperBuilder +@AllArgsConstructor public class JdcloudMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jdcloud/JdcloudSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jdcloud/JdcloudSmsProvider.java index 4649f22053..7899a64d3d 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jdcloud/JdcloudSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jdcloud/JdcloudSmsProvider.java @@ -27,14 +27,13 @@ */ package org.miaixz.bus.notify.metric.jdcloud; -import org.miaixz.bus.core.lang.Header; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.MediaType; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.HashMap; @@ -62,13 +61,13 @@ public Message send(JdcloudMaterial entity) { bodys.put("signId", entity.getSignature()); Map headers = new HashMap<>(); - headers.put(Header.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.put(HTTP.CONTENT_TYPE, MediaType.APPLICATION_JSON); String response = Httpx.post(this.getUrl(entity), bodys, headers); int status = JsonKit.getValue(response, "statusCode"); - String errcode = status == Http.HTTP_OK ? ErrorCode.SUCCESS.getCode() : ErrorCode.FAILURE.getCode(); - String errmsg = status == Http.HTTP_OK ? ErrorCode.SUCCESS.getDesc() : ErrorCode.FAILURE.getDesc(); + String errcode = status == HTTP.HTTP_OK ? ErrorCode.SUCCESS.getCode() : ErrorCode.FAILURE.getCode(); + String errmsg = status == HTTP.HTTP_OK ? ErrorCode.SUCCESS.getDesc() : ErrorCode.FAILURE.getDesc(); return Message.builder() .errcode(errcode) diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jpush/JpushMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jpush/JpushMaterial.java index c1e824b491..0b1470e5f6 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jpush/JpushMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jpush/JpushMaterial.java @@ -27,8 +27,10 @@ */ package org.miaixz.bus.notify.metric.jpush; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +42,8 @@ */ @Getter @Setter +@SuperBuilder +@AllArgsConstructor public class JpushMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jpush/JpushSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jpush/JpushSmsProvider.java index 8ecc451084..cf58514fb1 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jpush/JpushSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/jpush/JpushSmsProvider.java @@ -27,15 +27,15 @@ */ package org.miaixz.bus.notify.metric.jpush; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Charset; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.Base64; @@ -64,8 +64,8 @@ public Message send(JpushMaterial entity) { bodys.put("temp_para", entity.getParams()); Map headers = new HashMap<>(); - headers.put(Header.CONTENT_TYPE, MediaType.APPLICATION_JSON); - headers.put(Header.AUTHORIZATION, "Basic " + getSign()); + headers.put(HTTP.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.put(HTTP.AUTHORIZATION, "Basic " + getSign()); String response = Httpx.post(this.getUrl(entity), bodys, headers); boolean succeed = Objects.equals(JsonKit.getValue(response, "success_count"), 0); diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseMaterial.java index 710cd4433c..07051ec0b0 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseMaterial.java @@ -27,8 +27,10 @@ */ package org.miaixz.bus.notify.metric.netease; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +42,8 @@ */ @Getter @Setter +@SuperBuilder +@AllArgsConstructor public class NeteaseMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseProvider.java index 18dc92f5d8..a7db6f63c1 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseProvider.java @@ -27,14 +27,14 @@ */ package org.miaixz.bus.notify.metric.netease; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.basics.entity.Message; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.logger.Logger; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; import org.miaixz.bus.notify.magic.Material; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.security.MessageDigest; @@ -98,7 +98,7 @@ public Message post(String routerUrl, Map map) { Logger.debug("netease result:{}", response); String code = JsonKit.getValue(response, "Code"); return Message.builder() - .errcode(String.valueOf(Http.HTTP_OK).equals(code) ? ErrorCode.SUCCESS.getCode() : code) + .errcode(String.valueOf(HTTP.HTTP_OK).equals(code) ? ErrorCode.SUCCESS.getCode() : code) .errmsg(JsonKit.getValue(response, "desc")).build(); } diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseSmsProvider.java index b19a4ed980..8cec7b179a 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/netease/NeteaseSmsProvider.java @@ -27,9 +27,9 @@ */ package org.miaixz.bus.notify.metric.netease; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.notify.Context; -import org.miaixz.bus.notify.magic.Message; import java.util.HashMap; import java.util.Map; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/qiniu/QiniuMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/qiniu/QiniuMaterial.java index 5c2d62ad4e..d634205092 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/qiniu/QiniuMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/qiniu/QiniuMaterial.java @@ -27,8 +27,10 @@ */ package org.miaixz.bus.notify.metric.qiniu; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +42,8 @@ */ @Getter @Setter +@SuperBuilder +@AllArgsConstructor public class QiniuMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/qiniu/QiniuSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/qiniu/QiniuSmsProvider.java index aff8df98fd..3011450e65 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/qiniu/QiniuSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/qiniu/QiniuSmsProvider.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.notify.metric.qiniu; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/tencent/TencentMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/tencent/TencentMaterial.java index 96ecf23a65..11aa95dc01 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/tencent/TencentMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/tencent/TencentMaterial.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.notify.metric.tencent; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +43,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class TencentMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/tencent/TencentSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/tencent/TencentSmsProvider.java index 7efc0d1974..f718a29e10 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/tencent/TencentSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/tencent/TencentSmsProvider.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.notify.metric.tencent; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/unisms/UniMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/unisms/UniMaterial.java index 69ff3e06e0..1916e2c34c 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/unisms/UniMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/unisms/UniMaterial.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.notify.metric.unisms; -import lombok.Getter; -import lombok.Setter; +import lombok.*; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,11 +40,15 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class UniMaterial extends Material { /** * 是否为简易模式 */ + @Builder.Default private boolean simple = true; /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/unisms/UniSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/unisms/UniSmsProvider.java index 8d6989bcd4..e92c00c1e9 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/unisms/UniSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/unisms/UniSmsProvider.java @@ -27,6 +27,7 @@ */ package org.miaixz.bus.notify.metric.unisms; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Algorithm; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.exception.ValidateException; @@ -36,7 +37,6 @@ import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.*; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/upyun/UpyunMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/upyun/UpyunMaterial.java index aae52f2088..be15c87d41 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/upyun/UpyunMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/upyun/UpyunMaterial.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.notify.metric.upyun; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -41,6 +44,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class UpyunMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/upyun/UpyunSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/upyun/UpyunSmsProvider.java index 883a013876..6e4f0df193 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/upyun/UpyunSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/upyun/UpyunSmsProvider.java @@ -27,15 +27,15 @@ */ package org.miaixz.bus.notify.metric.upyun; -import org.miaixz.bus.core.lang.Header; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.MediaType; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.CollKit; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.Collection; @@ -63,8 +63,8 @@ public Message send(UpyunMaterial entity) { bodys.put("vars", StringKit.split(entity.getParams(), "|").toString()); Map headers = new HashMap<>(); - headers.put(Header.CONTENT_TYPE, MediaType.APPLICATION_JSON); - headers.put(Header.AUTHORIZATION, entity.getToken()); + headers.put(HTTP.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.put(HTTP.AUTHORIZATION, entity.getToken()); String response = Httpx.post(this.getUrl(entity), bodys, headers); Collection list = JsonKit.toList(response, UpyunMaterial.MessageId.class); diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatCpProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatCpProvider.java index 64962228e7..43951f4e8b 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatCpProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatCpProvider.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.notify.metric.wechat; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.notify.Context; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatKfProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatKfProvider.java index 2887506954..496855c74e 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatKfProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatKfProvider.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.notify.metric.wechat; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.notify.Context; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMaterial.java index 111b528870..021e799618 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMaterial.java @@ -27,8 +27,10 @@ */ package org.miaixz.bus.notify.metric.wechat; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.magic.Material; /** @@ -39,6 +41,8 @@ */ @Getter @Setter +@SuperBuilder +@AllArgsConstructor public class WechatMaterial extends Material { } diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMiniProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMiniProvider.java index 948feac2c2..f01d8f6952 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMiniProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMiniProvider.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.notify.metric.wechat; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.notify.Context; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMpProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMpProvider.java index 9c42cfa97e..f342488d9f 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMpProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/wechat/WechatMpProvider.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.notify.metric.wechat; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.notify.Context; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/yunpian/YunpianMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/yunpian/YunpianMaterial.java index 155d0fd96b..331bdd7b5f 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/yunpian/YunpianMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/yunpian/YunpianMaterial.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.notify.metric.yunpian; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +43,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class YunpianMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/yunpian/YunpianSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/yunpian/YunpianSmsProvider.java index 8a45afece6..268ea7d90b 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/yunpian/YunpianSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/yunpian/YunpianSmsProvider.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.notify.metric.yunpian; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/zhutong/ZhutongMaterial.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/zhutong/ZhutongMaterial.java index 83f70480d7..6187e1662d 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/zhutong/ZhutongMaterial.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/zhutong/ZhutongMaterial.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.notify.metric.zhutong; +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.Material; @@ -40,6 +43,9 @@ */ @Getter @Setter +@SuperBuilder +@NoArgsConstructor +@AllArgsConstructor public class ZhutongMaterial extends Material { /** diff --git a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/zhutong/ZhutongSmsProvider.java b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/zhutong/ZhutongSmsProvider.java index 9062278573..9ecceb9dd2 100644 --- a/bus-notify/src/main/java/org/miaixz/bus/notify/metric/zhutong/ZhutongSmsProvider.java +++ b/bus-notify/src/main/java/org/miaixz/bus/notify/metric/zhutong/ZhutongSmsProvider.java @@ -27,6 +27,7 @@ */ package org.miaixz.bus.notify.metric.zhutong; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; @@ -39,7 +40,6 @@ import org.miaixz.bus.http.Httpx; import org.miaixz.bus.notify.Context; import org.miaixz.bus.notify.magic.ErrorCode; -import org.miaixz.bus.notify.magic.Message; import org.miaixz.bus.notify.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/pom.xml b/bus-oauth/pom.xml index 72b9d7272f..896b626de6 100755 --- a/bus-oauth/pom.xml +++ b/bus-oauth/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-oauth - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -70,10 +70,10 @@ UTF-8 21 21 - 4.39.42.ALL 1.18.32 1.78.1 2.0.49 + 4.39.42.ALL @@ -169,54 +169,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/Checker.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/Checker.java index 32749c0660..7aa5399a96 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/Checker.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/Checker.java @@ -28,8 +28,8 @@ package org.miaixz.bus.oauth; import org.miaixz.bus.cache.metric.ExtendCache; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.exception.AuthorizedException; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.oauth.magic.Callback; import org.miaixz.bus.oauth.magic.ErrorCode; @@ -84,21 +84,21 @@ public static void checkConfig(Context context, Complex complex) { if (StringKit.isEmpty(redirectUri)) { throw new AuthorizedException(ErrorCode.ILLEGAL_REDIRECT_URI.getCode(), complex); } - if (!Http.isHttp(redirectUri) && !Http.isHttps(redirectUri)) { + if (!Protocol.isHttp(redirectUri) && !Protocol.isHttps(redirectUri)) { throw new AuthorizedException(ErrorCode.ILLEGAL_REDIRECT_URI.getCode(), complex); } // facebook的回调地址必须为https的链接 - if (Registry.FACEBOOK == complex && !Http.isHttps(redirectUri)) { + if (Registry.FACEBOOK == complex && !Protocol.isHttps(redirectUri)) { // FacebookScope's redirect uri must use the HTTPS protocol throw new AuthorizedException(ErrorCode.ILLEGAL_REDIRECT_URI.getCode(), complex); } // 微软的回调地址必须为https的链接或者localhost,不允许使用http - if (Registry.MICROSOFT == complex && !Http.isHttpsOrLocalHost(redirectUri)) { + if (Registry.MICROSOFT == complex && !Protocol.isHttpsOrLocalHost(redirectUri)) { // MicrosoftScope's redirect uri must use the HTTPS or localhost throw new AuthorizedException(ErrorCode.ILLEGAL_REDIRECT_URI.getCode(), complex); } // 微软中国的回调地址必须为https的链接或者localhost,不允许使用http - if (Registry.MICROSOFT_CN == complex && !Http.isHttpsOrLocalHost(redirectUri)) { + if (Registry.MICROSOFT_CN == complex && !Protocol.isHttpsOrLocalHost(redirectUri)) { // MicrosoftScope's redirect uri must use the HTTPS or localhost throw new AuthorizedException(ErrorCode.ILLEGAL_REDIRECT_URI.getCode(), complex); } diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/Context.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/Context.java index a34a776c45..598077d226 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/Context.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/Context.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.oauth; -import lombok.Builder; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.oauth.magic.Callback; import org.miaixz.bus.oauth.metric.AbstractProvider; @@ -42,7 +45,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Context { diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/Provider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/Provider.java index 310f0adcaf..2b3ef091d6 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/Provider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/Provider.java @@ -27,11 +27,11 @@ */ package org.miaixz.bus.oauth; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.exception.AuthorizedException; import org.miaixz.bus.oauth.magic.AccToken; import org.miaixz.bus.oauth.magic.Callback; import org.miaixz.bus.oauth.magic.ErrorCode; -import org.miaixz.bus.oauth.magic.Message; /** * {@code Provider}公共接口,所有平台的{@code Provider}都需要实现该接口 diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/AccToken.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/AccToken.java index fe324bc106..8563d0b35d 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/AccToken.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/AccToken.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.oauth.magic; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.io.Serializable; @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class AccToken implements Serializable { diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Callback.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Callback.java index f3a2167839..d3ee9455a6 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Callback.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Callback.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.oauth.magic; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.io.Serializable; @@ -39,9 +43,9 @@ */ @Getter @Setter -@Builder -@AllArgsConstructor +@SuperBuilder @NoArgsConstructor +@AllArgsConstructor public class Callback implements Serializable { /** diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Material.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Material.java index ff0f7a4a52..0675488e20 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Material.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Material.java @@ -28,7 +28,11 @@ package org.miaixz.bus.oauth.magic; import com.alibaba.fastjson.JSONObject; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.core.lang.Gender; import java.io.Serializable; @@ -41,7 +45,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Material implements Serializable { diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Message.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Message.java deleted file mode 100644 index 29975b912b..0000000000 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/magic/Message.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - ~ ~ - ~ The MIT License (MIT) ~ - ~ ~ - ~ Copyright (c) 2015-2024 miaixz.org and other contributors. ~ - ~ ~ - ~ Permission is hereby granted, free of charge, to any person obtaining a copy ~ - ~ of this software and associated documentation files (the "Software"), to deal ~ - ~ in the Software without restriction, including without limitation the rights ~ - ~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ~ - ~ copies of the Software, and to permit persons to whom the Software is ~ - ~ furnished to do so, subject to the following conditions: ~ - ~ ~ - ~ The above copyright notice and this permission notice shall be included in ~ - ~ all copies or substantial portions of the Software. ~ - ~ ~ - ~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ~ - ~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, ~ - ~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE ~ - ~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER ~ - ~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, ~ - ~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ~ - ~ THE SOFTWARE. ~ - ~ ~ - ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ - */ -package org.miaixz.bus.oauth.magic; - -import lombok.*; - -/** - * 统一授权响应类 - * - * @author Kimi Liu - * @since Java 17+ - */ -@Getter -@Setter -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class Message { - - /** - * 请求返回码,错误为具体返回码,正确为 0 - */ - public String errcode; - - /** - * 请求返回消息 - */ - public String errmsg; - - /** - * 请求返回数据 JSON - */ - public Object data; - -} diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/AbstractProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/AbstractProvider.java index b433cbdfec..70b241187c 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/AbstractProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/AbstractProvider.java @@ -28,7 +28,8 @@ package org.miaixz.bus.oauth.metric; import org.miaixz.bus.cache.metric.ExtendCache; -import org.miaixz.bus.core.data.ID; +import org.miaixz.bus.core.basics.entity.Message; +import org.miaixz.bus.core.data.id.ID; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -38,7 +39,10 @@ import org.miaixz.bus.logger.Logger; import org.miaixz.bus.oauth.*; import org.miaixz.bus.oauth.cache.OauthCache; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import java.util.Arrays; import java.util.List; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/alipay/AlipayProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/alipay/AlipayProvider.java index 24955dbdc3..62c3045ef0 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/alipay/AlipayProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/alipay/AlipayProvider.java @@ -36,16 +36,20 @@ import com.alipay.api.response.AlipaySystemOauthTokenResponse; import com.alipay.api.response.AlipayUserInfoShareResponse; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.lang.Gender; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.exception.AuthorizedException; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Checker; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; /** @@ -109,7 +113,7 @@ protected void check(Context context) { } // 支付宝在创建回调地址时,不允许使用localhost或者127.0.0.1 - if (Http.isLocalHost(context.getRedirectUri())) { + if (Protocol.isLocalHost(context.getRedirectUri())) { // The redirect uri of alipay is forbidden to use localhost or 127.0.0.1 throw new AuthorizedException(ErrorCode.ILLEGAL_REDIRECT_URI.getCode(), Registry.ALIPAY); } diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/amazon/AmazonProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/amazon/AmazonProvider.java index 9637bc891f..ac2568085f 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/amazon/AmazonProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/amazon/AmazonProvider.java @@ -29,19 +29,23 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.codec.binary.Base64; import org.miaixz.bus.core.lang.Gender; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.net.url.UrlEncoder; import org.miaixz.bus.core.xyz.RandomKit; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.nio.charset.StandardCharsets; @@ -165,8 +169,8 @@ public Message refresh(AccToken accToken) { private AccToken getToken(Map param, String url) { Map header = new HashMap<>(); - header.put(Header.HOST, "api.amazon.com"); - header.put(Header.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED + ";charset=UTF-8"); + header.put(HTTP.HOST, "api.amazon.com"); + header.put(HTTP.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED + ";charset=UTF-8"); String response = Httpx.post(url, param, header); JSONObject jsonObject = JSONObject.parseObject(response); @@ -201,8 +205,8 @@ protected Material getUserInfo(AccToken accToken) { String accessToken = accToken.getAccessToken(); this.checkToken(accessToken); Map header = new HashMap<>(); - header.put(Header.HOST, "api.amazon.com"); - header.put(Header.AUTHORIZATION, "bearer " + accessToken); + header.put(HTTP.HOST, "api.amazon.com"); + header.put(HTTP.AUTHORIZATION, "bearer " + accessToken); String userInfo = Httpx.get(this.complex.userInfo(), new HashMap<>(0), header); JSONObject jsonObject = JSONObject.parseObject(userInfo); diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/baidu/BaiduProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/baidu/BaiduProvider.java index 7eeca86153..965848c686 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/baidu/BaiduProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/baidu/BaiduProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -37,7 +38,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; /** diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/douyin/DouyinProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/douyin/DouyinProvider.java index e6dae32ff7..eb35926a20 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/douyin/DouyinProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/douyin/DouyinProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -36,7 +37,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; /** diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/eleme/ElemeProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/eleme/ElemeProvider.java index e624974ad5..8822c7a2b7 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/eleme/ElemeProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/eleme/ElemeProvider.java @@ -30,18 +30,22 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.codec.binary.Base64; -import org.miaixz.bus.core.data.ID; +import org.miaixz.bus.core.data.id.ID; import org.miaixz.bus.core.lang.Gender; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; @@ -198,10 +202,10 @@ private String getBasic(String appKey, String appSecret) { private Map buildHeader(String contentType, String requestId, boolean auth) { Map header = new HashMap<>(); - header.put(Header.ACCEPT, "text/xml,text/javascript,text/html"); - header.put(Header.CONTENT_TYPE, contentType); - header.put(Header.ACCEPT_ENCODING, "gzip"); - header.put(Header.USER_AGENT, "eleme-openapi-java-sdk"); + header.put(HTTP.ACCEPT, "text/xml,text/javascript,text/html"); + header.put(HTTP.CONTENT_TYPE, contentType); + header.put(HTTP.ACCEPT_ENCODING, "gzip"); + header.put(HTTP.USER_AGENT, "eleme-openapi-java-sdk"); header.put("x-eleme-requestid", requestId); if (auth) { diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/feishu/FeishuProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/feishu/FeishuProvider.java index ff50bdd6c5..8302081078 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/feishu/FeishuProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/feishu/FeishuProvider.java @@ -30,6 +30,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -39,7 +40,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/huawei/HuaweiProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/huawei/HuaweiProvider.java index 9a00fa588e..84f2384da0 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/huawei/HuaweiProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/huawei/HuaweiProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -36,7 +37,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/jd/JdProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/jd/JdProvider.java index 71e21b0733..908b134310 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/jd/JdProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/jd/JdProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -37,7 +38,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.time.LocalDateTime; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/kujiale/KujialeProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/kujiale/KujialeProvider.java index f4753369b4..8aa718349f 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/kujiale/KujialeProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/kujiale/KujialeProvider.java @@ -29,13 +29,17 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; /** diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/line/LineProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/line/LineProvider.java index f29ef60811..3462fb0342 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/line/LineProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/line/LineProvider.java @@ -29,13 +29,17 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/linkedin/LinkedinProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/linkedin/LinkedinProvider.java index f5bbd9265a..ad475597ff 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/linkedin/LinkedinProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/linkedin/LinkedinProvider.java @@ -32,9 +32,9 @@ import com.alibaba.fastjson.JSONPath; import org.miaixz.bus.cache.metric.ExtendCache; import org.miaixz.bus.core.lang.Gender; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; @@ -205,7 +205,7 @@ private void checkResponse(JSONObject object) { private AccToken getToken(String accessTokenUrl) { Map header = new HashMap(); header.put("Host", "www.linkedin.com"); - header.put(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); + header.put(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"); String response = Httpx.post(accessTokenUrl, null, header); JSONObject accessTokenObject = JSONObject.parseObject(response); diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/meituan/MeituanProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/meituan/MeituanProvider.java index ff8cb2880f..dbe305e934 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/meituan/MeituanProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/meituan/MeituanProvider.java @@ -29,13 +29,17 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.exception.AuthorizedException; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/mi/MiProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/mi/MiProvider.java index 15a6681eeb..bb54462e02 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/mi/MiProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/mi/MiProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; @@ -38,7 +39,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.text.MessageFormat; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/microsoft/AbstractMicrosoftProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/microsoft/AbstractMicrosoftProvider.java index 1ff2f3287a..484f383193 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/microsoft/AbstractMicrosoftProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/microsoft/AbstractMicrosoftProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; @@ -39,7 +40,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Complex; import org.miaixz.bus.oauth.Context; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/okta/OktaProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/okta/OktaProvider.java index df57f5ea86..aa50d0ef6d 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/okta/OktaProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/okta/OktaProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.codec.binary.Base64; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; @@ -38,7 +39,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/qq/QqProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/qq/QqProvider.java index 1b55b6cb89..cb1cf6717d 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/qq/QqProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/qq/QqProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -37,7 +38,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.Map; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/renren/RenrenProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/renren/RenrenProvider.java index ac94387596..7de8348f51 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/renren/RenrenProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/renren/RenrenProvider.java @@ -30,6 +30,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -38,7 +39,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.Objects; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/slack/SlackProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/slack/SlackProvider.java index d7207066ff..e06c0b1ae9 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/slack/SlackProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/slack/SlackProvider.java @@ -30,6 +30,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -38,7 +39,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/stackoverflow/StackOverflowProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/stackoverflow/StackOverflowProvider.java index cf619d383e..e3f4e09e01 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/stackoverflow/StackOverflowProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/stackoverflow/StackOverflowProvider.java @@ -31,9 +31,9 @@ import org.miaixz.bus.cache.metric.ExtendCache; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.lang.Gender; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.net.url.UrlDecoder; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Builder; @@ -70,7 +70,7 @@ protected AccToken getAccessToken(Callback callback) { UrlDecoder.decodeMap(accessTokenUrl, Charset.DEFAULT_UTF_8).forEach(form::put); Map header = new HashMap<>(); - header.put(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); + header.put(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"); String response = Httpx.post(accessTokenUrl, form, header); JSONObject accessTokenObject = JSONObject.parseObject(response); diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/taobao/TaobaoProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/taobao/TaobaoProvider.java index ccecd8e411..b807978220 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/taobao/TaobaoProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/taobao/TaobaoProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.exception.AuthorizedException; import org.miaixz.bus.core.net.url.UrlDecoder; @@ -37,7 +38,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; /** diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/teambition/TeambitionProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/teambition/TeambitionProvider.java index 2db691b957..32e76f15a1 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/teambition/TeambitionProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/teambition/TeambitionProvider.java @@ -29,12 +29,16 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.exception.AuthorizedException; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/twitter/TwitterProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/twitter/TwitterProvider.java index db029546b5..f077ee17ca 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/twitter/TwitterProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/twitter/TwitterProvider.java @@ -32,8 +32,8 @@ import org.miaixz.bus.core.codec.binary.Base64; import org.miaixz.bus.core.lang.Algorithm; import org.miaixz.bus.core.lang.Charset; -import org.miaixz.bus.core.lang.Header; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.net.url.UrlEncoder; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.http.Httpx; @@ -163,7 +163,7 @@ protected AccToken getAccessToken(Callback callback) { Map header = new HashMap<>(); header.put("Authorization", buildHeader(headerMap)); - header.put(Header.CONTENT_TYPE, "application/x-www-form-urlencoded"); + header.put(HTTP.CONTENT_TYPE, "application/x-www-form-urlencoded"); Map form = new HashMap<>(3); form.put("oauth_verifier", callback.getOauth_verifier()); diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/AbstractWeChatProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/AbstractWeChatProvider.java index b35e725b55..89a9bec2ac 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/AbstractWeChatProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/AbstractWeChatProvider.java @@ -46,12 +46,10 @@ public AbstractWeChatProvider(Context context, Complex complex) { super(context, complex); } - public AbstractWeChatProvider(Context context, Complex complex, ExtendCache cache) { super(context, complex, cache); } - /** * 获取微信平台用户的实际性别,0表示未定义,1表示男性,2表示女性 * diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/ee/WeChatEeThirdQrcodeProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/ee/WeChatEeThirdQrcodeProvider.java index c36fdb379d..438eb1fd50 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/ee/WeChatEeThirdQrcodeProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/ee/WeChatEeThirdQrcodeProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.lang.exception.AuthorizedException; import org.miaixz.bus.http.Httpx; @@ -37,7 +38,10 @@ import org.miaixz.bus.oauth.Checker; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; /** * 企业微信 第三方二维码登录 diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/mp/WeChatMpProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/mp/WeChatMpProvider.java index 01148ae723..ce526f85ad 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/mp/WeChatMpProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/mp/WeChatMpProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; import org.miaixz.bus.core.net.url.UrlEncoder; @@ -37,7 +38,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.wechat.AbstractWeChatProvider; /** diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/open/WeChatOpenProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/open/WeChatOpenProvider.java index 58da58062e..defa9e499a 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/open/WeChatOpenProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/wechat/open/WeChatOpenProvider.java @@ -29,12 +29,16 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.exception.AuthorizedException; import org.miaixz.bus.http.Httpx; import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.wechat.AbstractWeChatProvider; /** diff --git a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/weibo/WeiboProvider.java b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/weibo/WeiboProvider.java index 4b7dd094b0..93d3828184 100644 --- a/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/weibo/WeiboProvider.java +++ b/bus-oauth/src/main/java/org/miaixz/bus/oauth/metric/weibo/WeiboProvider.java @@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSONObject; import org.miaixz.bus.cache.metric.ExtendCache; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Gender; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.AuthorizedException; @@ -38,7 +39,10 @@ import org.miaixz.bus.oauth.Builder; import org.miaixz.bus.oauth.Context; import org.miaixz.bus.oauth.Registry; -import org.miaixz.bus.oauth.magic.*; +import org.miaixz.bus.oauth.magic.AccToken; +import org.miaixz.bus.oauth.magic.Callback; +import org.miaixz.bus.oauth.magic.ErrorCode; +import org.miaixz.bus.oauth.magic.Material; import org.miaixz.bus.oauth.metric.AbstractProvider; import java.util.HashMap; diff --git a/bus-office/pom.xml b/bus-office/pom.xml index 6248c52598..773a3fe493 100755 --- a/bus-office/pom.xml +++ b/bus-office/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-office - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -163,54 +163,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvParser.java b/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvParser.java index a42616253b..bcd4f9f53a 100644 --- a/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvParser.java +++ b/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvParser.java @@ -131,7 +131,7 @@ public List getHeader() { if (lineNo < config.beginLineNo) { throw new IllegalStateException("No header available - call nextRow() first"); } - return header.fields; + return header.getRaw(); } @Override diff --git a/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvRow.java b/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvRow.java index d620d49d23..feb90e6ff5 100644 --- a/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvRow.java +++ b/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvRow.java @@ -28,8 +28,8 @@ package org.miaixz.bus.office.csv; import org.miaixz.bus.core.beans.copier.CopyOptions; +import org.miaixz.bus.core.center.list.ListWrapper; import org.miaixz.bus.core.lang.Assert; -import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.xyz.BeanKit; import java.util.*; @@ -40,27 +40,26 @@ * @author Kimi Liu * @since Java 17+ */ -public final class CsvRow implements List { +public final class CsvRow extends ListWrapper { - final Map headerMap; - final List fields; /** * 原始行号 */ private final long originalLineNumber; + final Map headerMap; + /** * 构造 * * @param originalLineNumber 对应文件中的第几行 - * @param headerMap 标题Map - * @param fields 数据列表 + * @param headerMap 标题Map + * @param fields 数据列表 */ public CsvRow(final long originalLineNumber, final Map headerMap, final List fields) { - Assert.notNull(fields, "fields must be not null!"); + super(Assert.notNull(fields, "fields must be not null!")); this.originalLineNumber = originalLineNumber; this.headerMap = headerMap; - this.fields = fields; } /** @@ -89,15 +88,6 @@ public String getByName(final String name) { return null; } - /** - * 获取本行所有字段值列表 - * - * @return 字段值列表 - */ - public List getRawList() { - return fields; - } - /** * 获取标题与字段值对应的Map * @@ -126,136 +116,22 @@ public Map getFieldMap() { /** * 一行数据转换为Bean对象,忽略转换错误 * - * @param Bean类型 + * @param Bean类型 * @param clazz bean类 - * @return Bean + * @return the object */ public T toBean(final Class clazz) { return BeanKit.toBean(getFieldMap(), clazz, CopyOptions.of().setIgnoreError(true)); } - /** - * 获取字段格式 - * - * @return 字段格式 - */ - public int getFieldCount() { - return fields.size(); - } - - @Override - public int size() { - return this.fields.size(); - } - - @Override - public boolean isEmpty() { - return this.fields.isEmpty(); - } - - @Override - public boolean contains(final Object o) { - return this.fields.contains(o); - } - - @Override - public Iterator iterator() { - return this.fields.iterator(); - } - - @Override - public Object[] toArray() { - return this.fields.toArray(); - } - - @Override - public T[] toArray(final T[] a) { - return this.fields.toArray(a); - } - - @Override - public boolean add(final String e) { - return this.fields.add(e); - } - - @Override - public boolean remove(final Object o) { - return this.fields.remove(o); - } - @Override public boolean containsAll(final Collection c) { - return new HashSet<>(this.fields).containsAll(c); - } - - @Override - public boolean addAll(final Collection c) { - return this.fields.addAll(c); - } - - @Override - public boolean addAll(final int index, final Collection c) { - return this.fields.addAll(index, c); - } - - @Override - public boolean removeAll(final Collection c) { - return this.fields.removeAll(c); - } - - @Override - public boolean retainAll(final Collection c) { - return this.fields.retainAll(c); - } - - @Override - public void clear() { - this.fields.clear(); + return new HashSet<>(this.raw).containsAll(c); } @Override public String get(final int index) { - return index >= fields.size() ? null : fields.get(index); - } - - @Override - public String set(final int index, final String element) { - return this.fields.set(index, element); - } - - @Override - public void add(final int index, final String element) { - this.fields.add(index, element); - } - - @Override - public String remove(final int index) { - return this.fields.remove(index); - } - - @Override - public int indexOf(final Object o) { - return this.fields.indexOf(o); - } - - @Override - public int lastIndexOf(final Object o) { - return this.fields.lastIndexOf(o); - } - - @Override - public ListIterator listIterator() { - return this.fields.listIterator(); - } - - @Override - public ListIterator listIterator(final int index) { - return this.fields.listIterator(index); - } - - @Override - public List subList(final int fromIndex, final int toIndex) { - return this.fields.subList(fromIndex, toIndex); + return index >= size() ? null : super.get(index); } @Override @@ -272,7 +148,7 @@ public String toString() { final Map.Entry entry = it.next(); sb.append(entry.getKey()); - sb.append(Symbol.C_EQUAL); + sb.append('='); if (entry.getValue() != null) { sb.append(entry.getValue()); } @@ -282,7 +158,7 @@ public String toString() { } sb.append('}'); } else { - sb.append(fields.toString()); + sb.append(this.raw.toString()); } sb.append('}'); diff --git a/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvWriter.java b/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvWriter.java index def10e764a..29143de0c5 100644 --- a/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvWriter.java +++ b/bus-office/src/main/java/org/miaixz/bus/office/csv/CsvWriter.java @@ -248,7 +248,7 @@ public CsvWriter write(final String[]... lines) throws InternalException { public CsvWriter write(final Iterable lines) throws InternalException { if (CollKit.isNotEmpty(lines)) { for (final Object values : lines) { - appendLine(Convert.toStrArray(values)); + appendLine(Convert.toStringArray(values)); } flush(); } @@ -304,7 +304,7 @@ public CsvWriter writeBeans(final Iterable beans, final boolean writeHeaderLi writeHeaderLine(map.keySet().toArray(new String[0])); isFirst = false; } - writeLine(Convert.toStrArray(map.values())); + writeLine(Convert.toStringArray(map.values())); } flush(); } diff --git a/bus-office/src/main/java/org/miaixz/bus/office/excel/ExcelBase.java b/bus-office/src/main/java/org/miaixz/bus/office/excel/ExcelBase.java index 6ef8d1707d..753a0eda83 100644 --- a/bus-office/src/main/java/org/miaixz/bus/office/excel/ExcelBase.java +++ b/bus-office/src/main/java/org/miaixz/bus/office/excel/ExcelBase.java @@ -33,7 +33,7 @@ import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.miaixz.bus.core.data.ID; +import org.miaixz.bus.core.data.id.ID; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.net.url.UrlEncoder; @@ -535,7 +535,7 @@ public String getDisposition(String fileName, java.nio.charset.Charset charset) if (StringKit.isBlank(fileName)) { // 未提供文件名使用随机UUID作为文件名 - fileName = ID.fastSimpleUUID(); + fileName = ID.objectId(); } fileName = StringKit.addSuffixIfNot(UrlEncoder.encodeAll(fileName, charset), isXlsx() ? ".xlsx" : ".xls"); diff --git a/bus-office/src/main/java/org/miaixz/bus/office/excel/style/DefaultStyleSet.java b/bus-office/src/main/java/org/miaixz/bus/office/excel/style/DefaultStyleSet.java index 5f78bea0ee..c26b2817bb 100644 --- a/bus-office/src/main/java/org/miaixz/bus/office/excel/style/DefaultStyleSet.java +++ b/bus-office/src/main/java/org/miaixz/bus/office/excel/style/DefaultStyleSet.java @@ -175,7 +175,6 @@ public CellStyle getCellStyleForDate() { * 获取链接单元格样式,获取后可以定义整体链接样式 * * @return 链接单元格样式 - * @since 5.7.13 */ public CellStyle getCellStyleForHyperlink() { return this.cellStyleForHyperlink; @@ -187,7 +186,6 @@ public CellStyle getCellStyleForHyperlink() { * @param borderSize 边框粗细{@link BorderStyle}枚举 * @param colorIndex 颜色的short值 * @return this - * @since 4.0.0 */ public DefaultStyleSet setBorder(final BorderStyle borderSize, final IndexedColors colorIndex) { Styles.setBorder(this.headCellStyle, borderSize, colorIndex); @@ -204,7 +202,6 @@ public DefaultStyleSet setBorder(final BorderStyle borderSize, final IndexedColo * @param halign 横向位置 * @param valign 纵向位置 * @return this - * @since 4.0.0 */ public DefaultStyleSet setAlign(final HorizontalAlignment halign, final VerticalAlignment valign) { Styles.setAlign(this.headCellStyle, halign, valign); @@ -221,7 +218,6 @@ public DefaultStyleSet setAlign(final HorizontalAlignment halign, final Vertical * @param backgroundColor 背景色 * @param withHeadCell 是否也定义头部样式 * @return this - * @since 4.0.0 */ public DefaultStyleSet setBackgroundColor(final IndexedColors backgroundColor, final boolean withHeadCell) { if (withHeadCell) { @@ -254,7 +250,6 @@ public DefaultStyleSet setFont(final short color, final short fontSize, final St * @param font 字体,可以通过{@link Styles#createFont(Workbook, short, short, String)}创建 * @param ignoreHead 是否跳过头部样式 * @return this - * @since 4.1.0 */ public DefaultStyleSet setFont(final Font font, final boolean ignoreHead) { if (!ignoreHead) { @@ -271,7 +266,6 @@ public DefaultStyleSet setFont(final Font font, final boolean ignoreHead) { * 设置单元格文本自动换行 * * @return this - * @since 4.5.16 */ public DefaultStyleSet setWrapText() { this.cellStyle.setWrapText(true); diff --git a/bus-opencv/pom.xml b/bus-opencv/pom.xml index c771b5ad5e..20d6439a0f 100755 --- a/bus-opencv/pom.xml +++ b/bus-opencv/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-opencv - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -87,10 +87,6 @@ org.apache.maven.plugins maven-javadoc-plugin 3.6.3 - - -Xdoclint:none - -Xdoclint:none - attach-javadocs @@ -101,54 +97,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-pager/pom.xml b/bus-pager/pom.xml index 8e2ac01b94..e2eb7750ff 100755 --- a/bus-pager/pom.xml +++ b/bus-pager/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-pager - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -151,54 +151,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-pager/src/main/java/org/miaixz/bus/pager/plugin/NatureSqlHandler.java b/bus-pager/src/main/java/org/miaixz/bus/pager/plugin/NatureSqlHandler.java index 6949636fd5..d824caa0f9 100755 --- a/bus-pager/src/main/java/org/miaixz/bus/pager/plugin/NatureSqlHandler.java +++ b/bus-pager/src/main/java/org/miaixz/bus/pager/plugin/NatureSqlHandler.java @@ -38,7 +38,7 @@ import org.apache.ibatis.session.ResultHandler; import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.type.TypeHandlerRegistry; -import org.miaixz.bus.core.data.ID; +import org.miaixz.bus.core.data.id.ID; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; diff --git a/bus-parent/README.md b/bus-parent/README.md new file mode 100755 index 0000000000..fa4c223f92 --- /dev/null +++ b/bus-parent/README.md @@ -0,0 +1,42 @@ +

                + +

                +

                + 👉 https://www.miaixz.org 👈 +

                + +## 📚bus-parent 模块介绍 + +`bus-parent`模块只由一个`pom.xml`组成,同时提供了`dependencyManagement`声明。 + +------------------------------------------------------------------------------- + +## 🍒使用 + +如果同 Spring Boot 方式引入 bus ,再由子模块决定用到哪些bus模块,你可以在父模块中加入: + +```xml + + org.miaixz + bus-parent + xx.xx.xx + +``` + +在子模块中就可以引入自己需要的模块了: + +```xml + + org.miaixz + bus-all + +``` + +或者,单独引入某个模块 + +```xml + + org.miaixz + bus-core + +``` \ No newline at end of file diff --git a/bus-parent/pom.xml b/bus-parent/pom.xml new file mode 100755 index 0000000000..2779328b30 --- /dev/null +++ b/bus-parent/pom.xml @@ -0,0 +1,1380 @@ + + + + 4.0.0 + + org.miaixz + bus-parent + 8.0.5 + pom + + ${project.artifactId} + Bus parent + https://github.com/839128/bus + + + org.springframework.boot + spring-boot-dependencies + 3.3.1 + + + + + The MIT License (MIT) + https://opensource.org/licenses/MIT + + + + + scm:git@github.com:839128/bus.git + scm:git@github.com:839128/bus.git + git@github.com:839128/bus.git + + + + + Kimi Liu + https://github.com/839128/bus.git + + + + + Github Issue + https://github.com/839128/bus/issues + + + + UTF-8 + UTF-8 + 21 + 21 + 1.18.32 + 3.2.0 + 2.1.3 + 6.1.0-M2 + 1.3.2 + 3.6.0.Final + 1.5.6 + 2.23.1 + 2.0.13 + 2.7.0 + 2.2 + 1.9.22 + 1.78.1 + 2.0.49 + 2.11.0 + 2.17.1 + 1.1.8 + 2.5.1 + 2.0.3.RELEASE + 1.0.1 + 0.4.0 + 0.2.17 + 0.38.0 + 3.5.3 + 3.10.0 + 5.1.1 + 1.26.2 + 3.15.14.RELEASE + 2.3.32 + 3.1.2.RELEASE + 7.0.0 + 5.1.3 + 2.4.8 + 5.6.0 + 33.2.1-jre + 4.0.66 + 8.4.0 + 3.1.1 + 2.17.1 + 5.14.0 + 1.8.7 + 1.12.23 + 3.5.16 + 3.0.3 + 5.2.5 + 2.2.13 + 4.9 + 5.1.0 + 1.2.23 + 4.12.0 + 4.5.8 + 3.2.11 + 7.17.21 + 4.39.42.ALL + 3.17.4 + 0.10.314 + 3.24.3 + 1.12.734 + 8.5.10 + 7.15.1 + 5.6.213 + 4.2.3 + 8.0.5 + 3.3.1 + + + + + + org.miaixz + bus-all + ${bus.version} + + + org.miaixz + bus-base + ${bus.version} + + + org.miaixz + bus-cache + ${bus.version} + + + org.miaixz + bus-core + ${bus.version} + + + org.miaixz + bus-cron + ${bus.version} + + + org.miaixz + bus-crypto + ${bus.version} + + + org.miaixz + bus-extra + ${bus.version} + + + org.miaixz + bus-gitlab + ${bus.version} + + + org.miaixz + bus-goalie + ${bus.version} + + + org.miaixz + bus-health + ${bus.version} + + + org.miaixz + bus-http + ${bus.version} + + + org.miaixz + bus-image + ${bus.version} + + + org.miaixz + bus-limiter + ${bus.version} + + + org.miaixz + bus-logger + ${bus.version} + + + org.miaixz + bus-mapper + ${bus.version} + + + org.miaixz + bus-oauth + ${bus.version} + + + org.miaixz + bus-office + ${bus.version} + + + org.miaixz + bus-opencv + ${bus.version} + + + org.miaixz + bus-pager + ${bus.version} + + + org.miaixz + bus-proxy + ${bus.version} + + + org.miaixz + bus-sensitive + ${bus.version} + + + org.miaixz + bus-setting + ${bus.version} + + + org.miaixz + bus-socket + ${bus.version} + + + org.miaixz + bus-starter + ${bus.version} + + + org.miaixz + bus-storage + ${bus.version} + + + org.miaixz + bus-tracer + ${bus.version} + + + org.miaixz + bus-validate + ${bus.version} + + + org.miaixz + lancia + ${bus.version} + + + org.projectlombok + lombok + ${lombok.version} + + + jakarta.persistence + jakarta.persistence-api + ${persistence.version} + + + jakarta.mail + jakarta.mail-api + ${mail.version} + + + jakarta.servlet + jakarta.servlet-api + ${servlet.version} + + + commons-logging + commons-logging + ${commons.logging.version} + + + org.jboss.logging + jboss-logging + ${jboss.version} + + + org.apache.logging.log4j + log4j-core + ${log4j.version} + + + ch.qos.logback + logback-classic + ${logback.version} + + + slf4j-api + org.slf4j + + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.tinylog + tinylog-api + ${tinylog.version} + + + org.yaml + snakeyaml + ${yaml.version} + + + org.aspectj + aspectjweaver + ${aspectj.version} + + + org.bouncycastle + bcpkix-jdk18on + ${bouncycastle.version} + + + com.alibaba + fastjson + ${fastjson.version} + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.google.code.gson + gson + ${gson.version} + + + com.github.stuxuhai + jpinyin + ${jpinyin.version} + + + com.belerweb + pinyin4j + ${pinyin4j.version} + + + io.github.biezhi + TinyPinyin + ${tiny.version} + + + com.rnkrsoft.bopomofo4j + bopomofo4j + ${bopomofo4j.version} + + + com.github.houbb + pinyin + ${houbb.version} + + + com.github.mwiede + jsch + ${jsch.version} + + + com.hierynomus + sshj + ${sshj.version} + + + org.slf4j + slf4j-api + + + org.bouncycastle + bcpkix-jdk18on + + + org.bouncycastle + bcprov-jdk18on + + + + + com.google.zxing + core + ${zxing.version} + + + commons-net + commons-net + ${net.version} + + + org.apache.ftpserver + ftpserver-core + 1.2.0 + + + slf4j-api + org.slf4j + + + + + com.vdurmont + emoji-java + ${emoji.java.version} + + + org.apache.commons + commons-compress + ${compress.version} + + + org.apache.sshd + sshd-core + 2.12.0 + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + + + + + com.ibeetl + beetl + ${beetl.version} + + + org.freemarker + freemarker + ${freemarker.version} + + + org.thymeleaf + thymeleaf + ${thymeleaf.version} + + + slf4j-api + org.slf4j + + + org.javassist + javassist + + + + + org.ansj + ansj_seg + 5.1.6 + + + com.huaban + jieba-analysis + 1.0.2 + + + commons-lang3 + org.apache.commons + + + + + org.lionsoul + jcseg-core + 2.6.3 + + + com.chenlb.mmseg4j + mmseg4j-core + 1.10.0 + + + com.janeluo + ikanalyzer + 2012_u6 + + + org.apache.lucene + lucene-analyzers-common + + + org.apache.lucene + lucene-core + + + org.apache.lucene + lucene-queryparser + + + + + com.hankcs + hanlp + portable-1.8.4 + + + org.apache.lucene + lucene-analyzers-smartcn + 8.11.3 + + + org.apdplat + word + 1.3.1 + + + logback-classic + ch.qos.logback + + + slf4j-api + org.slf4j + + + pinyin4j + com.belerweb + + + lucene-core + org.apache.lucene + + + lucene-analyzers-common + org.apache.lucene + + + jedis + redis.clients + + + org.apache.lucene + lucene-suggest + + + org.apache.lucene + lucene-queryparser + + + + + com.mayabot.mynlp + mynlp-all + 4.0.0 + + + org.jetbrains + annotations + + + + + com.google.guava + guava + ${guava.version} + + + com.caucho + hessian + ${hessian.version} + + + com.mysql + mysql-connector-j + ${mysql.version} + + + redis.clients + jedis + ${jedis.version} + + + org.slf4j + slf4j-api + + + org.json + json + + + com.google.code.gson + gson + + + + + com.google.inject + guice + ${guice.version} + + + aopalliance + aopalliance + + + org.slf4j + slf4j-api + + + + + com.googlecode.xmemcached + xmemcached + ${xmemcached.version} + + + org.slf4j + slf4j-api + + + + + org.apache.curator + curator-recipes + ${curator.version} + + + log4j + log4j + + + com.google.guava + guava + + + org.slf4j + slf4j-api + + + io.netty + netty-handler + + + io.netty + netty-transport-native-epoll + + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + org.glassfish.jersey.core + jersey-client + ${jersey.version} + + + org.glassfish.jersey.inject + jersey-hk2 + ${jersey.version} + + + org.glassfish.jersey.media + jersey-media-multipart + ${jersey.version} + + + net.java.dev.jna + jna-platform + ${jna.version} + + + net.bytebuddy + byte-buddy + ${bytebuddy.version} + + + com.alibaba.csp + sentinel-parameter-flow-control + ${sentinel.version} + + + org.mybatis + mybatis + ${mybatis.version} + + + org.mybatis + mybatis-spring + ${mybatis.spring.version} + + + com.alipay.sdk + alipay-sdk-java + ${alipay.version} + + + com.alibaba + fastjson + + + org.bouncycastle + bcprov-jdk15on + + + xml-apis + xml-apis + + + commons-logging + commons-logging + + + com.squareup.okhttp3 + okhttp + + + dom4j + dom4j + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + commons-io + commons-io + + + commons-codec + commons-codec + + + org.apache.commons + commons-compress + + + org.apache.logging.log4j + log4j-api + + + + + org.ofdrw + ofdrw-full + ${ofdrw.version} + + + org.bouncycastle + bcpkix-jdk15on + + + org.bouncycastle + bcprov-jdk15on + + + commons-io + commons-io + + + commons-logging + commons-logging + + + org.slf4j + slf4j-api + + + org.json + json + + + + + com.github.jsqlparser + jsqlparser + ${jsqlparser.version} + + + com.alibaba + druid + ${druid.version} + + + com.zaxxer + HikariCP + ${hikaricp.version} + + + org.slf4j + slf4j-api + + + + + io.vertx + vertx-web + ${vertx.version} + + + com.fasterxml.jackson.core + jackson-core + + + + + org.apache.dubbo + dubbo + ${dubbo.version} + + + org.springframework + spring-context + + + io.netty + netty-all + + + + + org.elasticsearch + elasticsearch + ${elasticsearch.version} + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-core + + + org.apache.httpcomponents + httpasyncclient + + + org.apache.httpcomponents + httpcore + + + com.fasterxml.jackson.core + jackson-core + + + net.java.dev.jna + jna + + + joda-time + joda-time + + + + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + + + com.aliyun.oss + aliyun-sdk-oss + ${aliyun.oss.version} + + + com.google.code.gson + gson + + + commons-codec + commons-codec + + + org.slf4j + slf4j-api + + + org.apache.httpcomponents + httpcore + + + org.apache.httpcomponents + httpclient + + + commons-logging + commons-logging + + + + + com.baidubce + bce-java-sdk + ${baidu.bos.version} + + + org.apache.commons + commons-lang3 + + + ch.qos.logback + logback-core + + + ch.qos.logback + logback-classic + + + org.springframework + spring-core + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + com.github.stephenc.findbugs + findbugs-annotations + + + com.google.code.findbugs + jsr305 + + + com.google.guava + guava + + + com.google.protobuf + protobuf-java + + + commons-codec + commons-codec + + + commons-io + commons-io + + + org.apache.commons + commons-compress + + + org.bouncycastle + bcprov-jdk15on + + + org.slf4j + slf4j-api + + + org.slf4j + jcl-over-slf4j + + + org.apache.hbase + hbase-client + + + org.apache.httpcomponents + httpcore + + + org.apache.httpcomponents + httpasyncclient + + + javax.validation + validation-api + + + joda-time + joda-time + + + + + com.huaweicloud + esdk-obs-java + ${huawei.oss.version} + + + org.apache.logging.log4j + log4j-core + + + org.apache.logging.log4j + log4j-api + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + org.jetbrains.kotlin + kotlin-stdlib-jdk7 + + + org.slf4j + slf4j-api + + + com.squareup.okhttp3 + okhttp + + + com.squareup.okio + okio + + + + + com.amazonaws + aws-java-sdk-s3 + ${aws.oss.version} + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + commons-codec + commons-codec + + + commons-logging + commons-logging + + + org.slf4j + slf4j-api + + + org.apache.hbase + hbase-client + + + org.apache.httpcomponents + httpclient + + + + + io.minio + minio + ${minio.oss.version} + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + com.google.guava + guava + + + org.bouncycastle + bcprov-jdk18on + + + commons-codec + commons-codec + + + commons-io + commons-io + + + org.apache.commons + commons-compress + + + com.squareup.okhttp3 + okhttp + + + org.slf4j + slf4j-api + + + + + com.qiniu + qiniu-java-sdk + ${qiniu.oss.version} + + + com.google.code.gson + gson + + + com.squareup.okhttp3 + okhttp + + + + + com.qcloud + cos_api + ${qcloud.oss.version} + + + org.slf4j + slf4j-log4j12 + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-core + + + com.google.code.gson + gson + + + commons-codec + commons-codec + + + org.bouncycastle + bcprov-jdk15on + + + org.slf4j + slf4j-api + + + org.apache.httpcomponents + httpclient + + + commons-logging + commons-logging + + + com.squareup.okio + okio + + + com.squareup.okhttp + logging-interceptor + + + joda-time + joda-time + + + + + com.upyun + java-sdk + ${upyun.oss.version} + + + org.json + json + + + com.squareup.okhttp3 + okhttp + + + + + org.springframework.boot + spring-boot-starter-jdbc + ${spring.boot.version} + + + org.slf4j + slf4j-api + + + + + org.springframework.boot + spring-boot-starter-webflux + ${spring.boot.version} + + + org.springframework.boot + spring-boot-starter-websocket + ${spring.boot.version} + + + org.springframework.boot + spring-boot-starter-web-services + ${spring.boot.version} + + + org.springframework.boot + spring-boot-starter-aop + ${spring.boot.version} + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + + + org.springframework.boot + spring-boot-starter-json + + + org.springframework.boot + spring-boot-starter-tomcat + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.datatype + jackson-datatype-jdk8 + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + ${maven.compiler.source} + ${maven.compiler.target} + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.6.3 + + + attach-javadocs + package + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + + + + + diff --git a/bus-pay/pom.xml b/bus-pay/pom.xml index 7f16ba7f5c..a786ed0803 100644 --- a/bus-pay/pom.xml +++ b/bus-pay/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-pay - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -169,54 +169,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/Builder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/Builder.java index 64002c92f0..0cf3883c9d 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/Builder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/Builder.java @@ -31,11 +31,10 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.miaixz.bus.core.center.date.DateTime; import org.miaixz.bus.core.codec.binary.Base64; -import org.miaixz.bus.core.data.ID; -import org.miaixz.bus.core.data.Snowflake; import org.miaixz.bus.core.io.resource.ClassPathResource; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.lang.Normal; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.CompareKit; import org.miaixz.bus.core.xyz.DateKit; import org.miaixz.bus.core.xyz.IoKit; @@ -233,17 +232,6 @@ public static String encryptData(String data, String key) { return org.miaixz.bus.crypto.Builder.aes(org.miaixz.bus.crypto.Builder.md5(key).toLowerCase().getBytes()).encryptBase64(data.getBytes()); } - /** - * 雪花算法 - * - * @param workerId 终端ID - * @param dataCenterId 数据中心ID - * @return {@link Snowflake} - */ - public static Snowflake getSnowflake(long workerId, long dataCenterId) { - return ID.getSnowflake(workerId, dataCenterId); - } - /** * 把所有元素排序 * @@ -347,7 +335,7 @@ public static StringBuffer forEachMap(Map params, String prefix, /** * 构造签名串 * - * @param method {@link org.miaixz.bus.core.lang.Http} GET,POST,PUT等 + * @param method {@link HTTP} GET,POST,PUT等 * @param url 请求接口 /v3/certificates * @param timestamp 获取发起请求时的系统当前时间戳 * @param nonceStr 随机字符串 diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/Complex.java b/bus-pay/src/main/java/org/miaixz/bus/pay/Complex.java index b6e679c0b6..cfa06e63a7 100755 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/Complex.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/Complex.java @@ -27,7 +27,8 @@ */ package org.miaixz.bus.pay; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.pay.metric.AbstractProvider; import java.util.Arrays; @@ -74,7 +75,7 @@ default boolean isSandbox() { * @return the string */ default String sandbox() { - return Http.HOST_IPV4; + return Protocol.HOST_IPV4; } /** @@ -83,7 +84,7 @@ default String sandbox() { * @return the string */ default String service() { - return Http.HOST_IPV4; + return Protocol.HOST_IPV4; } /** @@ -92,7 +93,7 @@ default String service() { * @return the string */ default String method() { - return Http.NONE; + return HTTP.NONE; } /** diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/magic/Material.java b/bus-pay/src/main/java/org/miaixz/bus/pay/magic/Material.java index 8362c8f4e6..a2c55b71c6 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/magic/Material.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/magic/Material.java @@ -31,6 +31,7 @@ import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.core.xyz.StringKit; import java.lang.reflect.Field; @@ -46,6 +47,7 @@ */ @Getter @Setter +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/magic/Message.java b/bus-pay/src/main/java/org/miaixz/bus/pay/magic/Message.java index 0b717faf75..0410fa22d0 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/magic/Message.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/magic/Message.java @@ -27,12 +27,15 @@ */ package org.miaixz.bus.pay.magic; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.core.center.map.CaseInsensitiveMap; import org.miaixz.bus.core.xyz.CollKit; import org.miaixz.bus.core.xyz.StringKit; -import java.io.Serializable; import java.util.List; import java.util.Map; @@ -44,29 +47,13 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor -public class Message implements Serializable { +public class Message extends org.miaixz.bus.core.basics.entity.Message { private static final long serialVersionUID = -1L; - - /** - * 请求返回码,错误为具体返回码,正确为 0 - */ - public String errcode; - - /** - * 请求返回消息 - */ - public String errmsg; - - /** - * 请求返回数据 JSON - */ - public Object data; - - + private String body; private byte[] bodyByte; private int status; diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/AbstractProvider.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/AbstractProvider.java index ad6cdcb5ee..136a6b0e66 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/AbstractProvider.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/AbstractProvider.java @@ -30,8 +30,12 @@ import jakarta.servlet.http.HttpServletRequest; import lombok.SneakyThrows; import org.miaixz.bus.cache.metric.ExtendCache; -import org.miaixz.bus.core.lang.*; +import org.miaixz.bus.core.lang.Assert; +import org.miaixz.bus.core.lang.MediaType; +import org.miaixz.bus.core.lang.Normal; +import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.PaymentException; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.core.net.tls.SSLContextBuilder; import org.miaixz.bus.core.net.url.UrlEncoder; import org.miaixz.bus.core.xyz.FileKit; @@ -198,11 +202,11 @@ public static String post(String url, String data) { public static Message post(String url, String data, Map headerMap) { try { Response response = postTo(url, headerMap, data); - Message message = new Message(); - message.setBody(response.body().string()); - message.setStatus(response.code()); - message.setHeaders(response.headers().toMultimap()); - return message; + return Message.builder() + .body(response.body().string()) + .status(response.code()) + .headers(response.headers().toMultimap()) + .build(); } catch (IOException e) { throw new RuntimeException(e); } @@ -219,11 +223,11 @@ public static Message post(String url, String data, Map headerMa public static Message get(String url, Map formMap, Map headerMap) { try { Response response = getTo(url, formMap, headerMap); - Message message = new Message(); - message.setBody(response.body().string()); - message.setStatus(response.code()); - message.setHeaders(response.headers().toMultimap()); - return message; + return Message.builder() + .body(response.body().string()) + .status(response.code()) + .headers(response.headers().toMultimap()) + .build(); } catch (IOException e) { throw new RuntimeException(e); } @@ -240,11 +244,11 @@ public static Message get(String url, Map formMap, Map formMap, Map headerMap) { try { Response response = postTo(url, headerMap, formMap); - Message message = new Message(); - message.setBody(response.body().string()); - message.setStatus(response.code()); - message.setHeaders(response.headers().toMultimap()); - return message; + return Message.builder() + .body(response.body().string()) + .status(response.code()) + .headers(response.headers().toMultimap()) + .build(); } catch (IOException e) { throw new RuntimeException(e); } @@ -262,11 +266,11 @@ public static Message post(String url, Map formMap, Map formMap, Map headerMap, File file) { try { Response response = postTo(url, headerMap, formMap); - Message message = new Message(); - message.setBody(response.body().string()); - message.setStatus(response.code()); - message.setHeaders(response.headers().toMultimap()); - return message; + return Message.builder() + .body(response.body().string()) + .status(response.code()) + .headers(response.headers().toMultimap()) + .build(); } catch (IOException e) { throw new RuntimeException(e); } @@ -285,7 +289,7 @@ public static Message post(String url, Map formMap, Map headerMap) { try { Response response = putTo(url, headerMap, data); - Message message = new Message(); - message.setBody(response.body().string()); - message.setStatus(response.code()); - message.setHeaders(response.headers().toMultimap()); - return message; + return Message.builder() + .body(response.body().string()) + .status(response.code()) + .headers(response.headers().toMultimap()) + .build(); } catch (IOException e) { throw new RuntimeException(e); } @@ -384,7 +388,7 @@ public static String upload(String url, String data, String certPath, String cer * @return {@link String} 请求返回的结果 */ public static String upload(String url, String data, String certPath, String certPass, String filePath) { - return upload(url, data, certPath, certPass, filePath, Http.TLS_V_10); + return upload(url, data, certPath, certPass, filePath, Protocol.TLSv1.name); } /** @@ -609,11 +613,11 @@ public String post(String url, Map formMap) { public Message put(String url, Map formMap, Map headerMap) { try { Response response = putTo(url, headerMap, formMap); - Message message = new Message(); - message.setBody(response.body().string()); - message.setStatus(response.code()); - message.setHeaders(response.headers().toMultimap()); - return message; + return Message.builder() + .body(response.body().string()) + .status(response.code()) + .headers(response.headers().toMultimap()) + .build(); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/alipay/AliPayProvider.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/alipay/AliPayProvider.java index 054e4ef3c0..df0e73fcde 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/alipay/AliPayProvider.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/alipay/AliPayProvider.java @@ -36,7 +36,7 @@ import org.miaixz.bus.core.lang.Algorithm; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.Charset; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.DateKit; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.pay.Complex; @@ -81,7 +81,7 @@ public AliPayProvider(Context context, Complex complex, ExtendCache cache) { Assert.notBlank(this.context.getPrivateKey(), "[privateKey] not defined"); Assert.notBlank(this.context.getPublicKey(), "[publicKey] not defined"); - this.client = new DefaultAlipayClient(getUrl(), this.context.getAppId(), this.context.getPrivateKey(), Http.JSON, + this.client = new DefaultAlipayClient(getUrl(), this.context.getAppId(), this.context.getPrivateKey(), HTTP.JSON, Charset.DEFAULT_UTF_8, this.context.getPublicKey(), Algorithm.RSA2.getValue()); } diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/CustomerPay.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/CustomerPay.java index 0b9a78d39a..d8f0eb0b1b 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/CustomerPay.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/CustomerPay.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class CustomerPay extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/FkmModel.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/FkmModel.java index 92ee1da644..f1469de9c6 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/FkmModel.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/FkmModel.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class FkmModel extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/JdPayRequest.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/JdPayRequest.java index 105b450e4d..c03e576eb4 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/JdPayRequest.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/JdPayRequest.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class JdPayRequest extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/QueryBaiTiao.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/QueryBaiTiao.java index e621661100..5df3f19e3f 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/QueryBaiTiao.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/QueryBaiTiao.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class QueryBaiTiao extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/QueryOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/QueryOrder.java index 5dc967882d..28a338cb5a 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/QueryOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/QueryOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class QueryOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/Refund.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/Refund.java index 4c9a75f8b5..78ec1cbead 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/Refund.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/Refund.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Refund extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/Revoke.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/Revoke.java index 0e1c48cbd6..680e47a578 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/Revoke.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/Revoke.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Revoke extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/SaveOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/SaveOrder.java index 35a0a5c0c1..c410bae83d 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/SaveOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/SaveOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class SaveOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/UniOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/UniOrder.java index a61e53c198..b5094bb0f4 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/UniOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/UniOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class UniOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/UserRelation.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/UserRelation.java index 7788abfa4f..17f377dfb8 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/UserRelation.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/jdpay/entity/UserRelation.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.jdpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class UserRelation extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/CloseOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/CloseOrder.java index 5c942ea08f..842818758c 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/CloseOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/CloseOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class CloseOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/CreateHb.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/CreateHb.java index 819381e400..fd5dc953a3 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/CreateHb.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/CreateHb.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class CreateHb extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadBill.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadBill.java index a2849f68a8..d72c6df9ab 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadBill.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadBill.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class DownloadBill extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadHbBill.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadHbBill.java index 6e9cead355..6c8666bebf 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadHbBill.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadHbBill.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class DownloadHbBill extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadTransferBill.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadTransferBill.java index dc01f36af1..43725e3329 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadTransferBill.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/DownloadTransferBill.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class DownloadTransferBill extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/GetHbInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/GetHbInfo.java index 461b26a656..2773706bb5 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/GetHbInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/GetHbInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class GetHbInfo extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/GetTransferInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/GetTransferInfo.java index 7f3e69356b..aac8785cd2 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/GetTransferInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/GetTransferInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class GetTransferInfo extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/MicroPay.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/MicroPay.java index f147254b9d..51adbc2df5 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/MicroPay.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/MicroPay.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class MicroPay extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderQuery.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderQuery.java index 34bb875440..69ed34f285 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderQuery.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderQuery.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class OrderQuery extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderRefund.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderRefund.java index 26a6631563..8bede3a4a6 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderRefund.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderRefund.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class OrderRefund extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderReverse.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderReverse.java index 22bdf9cdb1..e523539472 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderReverse.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/OrderReverse.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class OrderReverse extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/RefundQuery.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/RefundQuery.java index 992e0e2cc8..27e1ac83d5 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/RefundQuery.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/RefundQuery.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class RefundQuery extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/Transfer.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/Transfer.java index 44373f9444..bce181f2a5 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/Transfer.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/Transfer.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Transfer extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/UnifiedOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/UnifiedOrder.java index 184e8231b8..35403e2814 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/UnifiedOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/tenpay/entity/UnifiedOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.tenpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class UnifiedOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Apply.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Apply.java index 4a5dad75e7..62fbf2bca8 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Apply.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Apply.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Apply extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/AuthCodeToOpenId.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/AuthCodeToOpenId.java index 94ec90edf3..b518aad738 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/AuthCodeToOpenId.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/AuthCodeToOpenId.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class AuthCodeToOpenId extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/BillDownload.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/BillDownload.java index 653c713f21..4f4ad744d5 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/BillDownload.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/BillDownload.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class BillDownload extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/CloseOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/CloseOrder.java index 276d23993e..4fb84be1af 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/CloseOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/CloseOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class CloseOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/MicroPay.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/MicroPay.java index 7d657afac6..db59f8bfad 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/MicroPay.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/MicroPay.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class MicroPay extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/OrderQuery.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/OrderQuery.java index 4dec43b131..cf564cdac1 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/OrderQuery.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/OrderQuery.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class OrderQuery extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Refund.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Refund.java index ac28a63723..eb41ffaf8b 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Refund.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Refund.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Refund extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/RefundQuery.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/RefundQuery.java index 8dd7133834..420ce9b607 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/RefundQuery.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/RefundQuery.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class RefundQuery extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Reverse.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Reverse.java index 84efad8a42..9ee696357b 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Reverse.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/Reverse.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Reverse extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/UnifiedOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/UnifiedOrder.java index 736cd5c383..5e2bd08df3 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/UnifiedOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/UnifiedOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class UnifiedOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/UnionPayUserId.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/UnionPayUserId.java index 1644f965e1..76246f33bf 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/UnionPayUserId.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/unionpay/entity/UnionPayUserId.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.unionpay.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class UnionPayUserId extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/WechatPayProvider.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/WechatPayProvider.java index 308d297996..1222b8b46f 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/WechatPayProvider.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/WechatPayProvider.java @@ -29,7 +29,7 @@ import org.miaixz.bus.cache.metric.ExtendCache; import org.miaixz.bus.core.lang.Algorithm; -import org.miaixz.bus.core.lang.Http; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.DateKit; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.core.xyz.XmlKit; @@ -261,15 +261,15 @@ public Message v3(String method, platSerialNo = serialNo; } - if (Http.GET.equals(method)) { + if (HTTP.GET.equals(method)) { return get(prefix.concat(suffix), authorization, platSerialNo, null); - } else if (Http.POST.equals(method)) { + } else if (HTTP.POST.equals(method)) { return post(prefix.concat(suffix), authorization, platSerialNo, body); - } else if (Http.DELETE.equals(method)) { + } else if (HTTP.DELETE.equals(method)) { return delete(prefix.concat(suffix), authorization, platSerialNo, body); - } else if (Http.PATCH.equals(method)) { + } else if (HTTP.PATCH.equals(method)) { return patch(prefix.concat(suffix), authorization, platSerialNo, body); - } else if (Http.PUT.equals(method)) { + } else if (HTTP.PUT.equals(method)) { return put(prefix.concat(suffix), authorization, platSerialNo, body); } return upload(prefix.concat(suffix), authorization, platSerialNo, body, file); @@ -312,15 +312,15 @@ public Message v3(String method, platSerialNo = serialNo; } - if (Http.GET.equals(method)) { + if (HTTP.GET.equals(method)) { return get(prefix.concat(suffix), authorization, platSerialNo, null); - } else if (Http.POST.equals(method)) { + } else if (HTTP.POST.equals(method)) { return post(prefix.concat(suffix), authorization, platSerialNo, body); - } else if (Http.DELETE.equals(method)) { + } else if (HTTP.DELETE.equals(method)) { return delete(prefix.concat(suffix), authorization, platSerialNo, body); - } else if (Http.PATCH.equals(method)) { + } else if (HTTP.PATCH.equals(method)) { return patch(prefix.concat(suffix), authorization, platSerialNo, body); - } else if (Http.PUT.equals(method)) { + } else if (HTTP.PUT.equals(method)) { return put(prefix.concat(suffix), authorization, platSerialNo, body); } return upload(prefix.concat(suffix), authorization, platSerialNo, body, file); diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/Receiver.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/Receiver.java index 8bfed405b0..9e11560769 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/Receiver.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/Receiver.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Receiver extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/AuthCodeToOpenId.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/AuthCodeToOpenId.java index 267e2b0bb1..328b083b5a 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/AuthCodeToOpenId.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/AuthCodeToOpenId.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class AuthCodeToOpenId extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/AuthInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/AuthInfo.java index 16f0fc0012..20ff8e1b67 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/AuthInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/AuthInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class AuthInfo extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/BatchQueryComment.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/BatchQueryComment.java index 75e09fcc30..4c594c6e58 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/BatchQueryComment.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/BatchQueryComment.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class BatchQueryComment extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/CloseOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/CloseOrder.java index 0a1250bc2d..5a1382f029 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/CloseOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/CloseOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class CloseOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/CustomDeclare.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/CustomDeclare.java index e4dad21b57..660cf5b8e6 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/CustomDeclare.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/CustomDeclare.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class CustomDeclare extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DepositConsume.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DepositConsume.java index c1cc8dc841..87d5394b65 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DepositConsume.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DepositConsume.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class DepositConsume extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DownloadBill.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DownloadBill.java index ba4a426ba1..6d65fdb0f3 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DownloadBill.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DownloadBill.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class DownloadBill extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DownloadFundFlow.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DownloadFundFlow.java index cae712f25c..a03c99b4e7 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DownloadFundFlow.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/DownloadFundFlow.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class DownloadFundFlow extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetHbInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetHbInfo.java index d74987e21d..4aa02214f2 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetHbInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetHbInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class GetHbInfo extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetPublicKey.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetPublicKey.java index 1c2b289454..d726dd189e 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetPublicKey.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetPublicKey.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class GetPublicKey extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetTransferInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetTransferInfo.java index cf4e746176..428275fa02 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetTransferInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/GetTransferInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class GetTransferInfo extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/MicroPay.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/MicroPay.java index 7c31901d70..c864fe4c27 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/MicroPay.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/MicroPay.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class MicroPay extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/OrderQuery.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/OrderQuery.java index b8816339f7..fc7b741d28 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/OrderQuery.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/OrderQuery.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class OrderQuery extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/PayBank.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/PayBank.java index 37c5f6aa89..f7e12a97b3 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/PayBank.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/PayBank.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class PayBank extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ProfitSharing.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ProfitSharing.java index 3cf2116281..b63eee0bf4 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ProfitSharing.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ProfitSharing.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class ProfitSharing extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ProfitSharingReturn.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ProfitSharingReturn.java index 1ce9ebd325..ac553ca78e 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ProfitSharingReturn.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ProfitSharingReturn.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class ProfitSharingReturn extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/QueryTrans2Pocket.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/QueryTrans2Pocket.java index 36577806ba..1846288ae4 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/QueryTrans2Pocket.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/QueryTrans2Pocket.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class QueryTrans2Pocket extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/QueryWorkWxRedPack.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/QueryWorkWxRedPack.java index 5f8b9cb671..484281a19f 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/QueryWorkWxRedPack.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/QueryWorkWxRedPack.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class QueryWorkWxRedPack extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Refund.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Refund.java index 95922856f4..03eee93dc1 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Refund.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Refund.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Refund extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/RefundQuery.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/RefundQuery.java index d0c9750342..6a7240883d 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/RefundQuery.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/RefundQuery.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class RefundQuery extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Report.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Report.java index 763600da9d..761b7fc671 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Report.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Report.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Report extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Reverse.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Reverse.java index ee731843c1..9126ba9827 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Reverse.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Reverse.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Reverse extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/SendRedPack.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/SendRedPack.java index f24343ad1a..55ef68e018 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/SendRedPack.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/SendRedPack.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class SendRedPack extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/SendWorkWxRedPack.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/SendWorkWxRedPack.java index ff112fc405..23b587b290 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/SendWorkWxRedPack.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/SendWorkWxRedPack.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class SendWorkWxRedPack extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ShortUrl.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ShortUrl.java index cc1354776a..c588e24f6c 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ShortUrl.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/ShortUrl.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class ShortUrl extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Trans2Pocket.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Trans2Pocket.java index 75cee5dd18..6f0b063de4 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Trans2Pocket.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Trans2Pocket.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Trans2Pocket extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Transfer.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Transfer.java index 08dc9b9043..c3d39c3582 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Transfer.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/Transfer.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Transfer extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/UnifiedOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/UnifiedOrder.java index 2fd0945a49..b2c4998110 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/UnifiedOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v2/UnifiedOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v2; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class UnifiedOrder extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/AddReceivers.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/AddReceivers.java index de7dfb443e..87b78671a5 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/AddReceivers.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/AddReceivers.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; /** @@ -38,7 +42,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class AddReceivers extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Amount.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Amount.java index 3835f65faa..b2bc1a92fd 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Amount.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Amount.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 统一下单-订单金额 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Amount { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/BatchTransferModel.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/BatchTransferModel.java index cea2a14028..d286a60f7b 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/BatchTransferModel.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/BatchTransferModel.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.util.List; @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class BatchTransferModel { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Certificate.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Certificate.java index 0f933d003e..36eb03d53b 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Certificate.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Certificate.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.io.Serializable; import java.util.List; @@ -40,7 +44,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Certificate implements Serializable { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/CertificateInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/CertificateInfo.java index 36e61e4ce5..2f26c9f604 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/CertificateInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/CertificateInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.io.Serializable; @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class CertificateInfo implements Serializable { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Detail.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Detail.java index c4a47c5674..ba0463fe53 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Detail.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Detail.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.util.List; @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Detail { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/EncryptCertificate.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/EncryptCertificate.java index 934c6b05ab..629faf30c5 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/EncryptCertificate.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/EncryptCertificate.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.io.Serializable; @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class EncryptCertificate implements Serializable { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/GoodsDetail.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/GoodsDetail.java index f9d5ae37b0..10bdc45a39 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/GoodsDetail.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/GoodsDetail.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 统一下单-单品列表 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class GoodsDetail { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/H5Info.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/H5Info.java index 195dd7596e..54dfdfbe12 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/H5Info.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/H5Info.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 统一下单-H5 场景信息 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class H5Info { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Payer.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Payer.java index 8785d1f404..71eccac4cd 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Payer.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Payer.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 统一下单-支付者 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Payer { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/ProfitSharing.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/ProfitSharing.java index fa281daf05..9e5387dd94 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/ProfitSharing.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/ProfitSharing.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import org.miaixz.bus.pay.magic.Material; import org.miaixz.bus.pay.metric.wechat.entity.Receiver; @@ -42,7 +46,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class ProfitSharing extends Material { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Refund.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Refund.java index 9d37747a3b..d587e74406 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Refund.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/Refund.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.util.List; @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Refund { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/RefundAmount.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/RefundAmount.java index b5e14d8249..763822d5df 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/RefundAmount.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/RefundAmount.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 微信申请退款-金额信息 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class RefundAmount { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/RefundGoodsDetail.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/RefundGoodsDetail.java index ed468c8ba0..1954b5228e 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/RefundGoodsDetail.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/RefundGoodsDetail.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 微信申请退款-退款商品 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class RefundGoodsDetail { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/SceneInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/SceneInfo.java index 92110fdc96..86765ad490 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/SceneInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/SceneInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 统一下单-场景信息 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class SceneInfo { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/SettleInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/SettleInfo.java index 715ecd93ef..13a118a7b3 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/SettleInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/SettleInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 统一下单-结算信息 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class SettleInfo { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/StoreInfo.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/StoreInfo.java index ff4f575945..fce42ebaee 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/StoreInfo.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/StoreInfo.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 统一下单-商户门店信息 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class StoreInfo { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/TransferDetailInput.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/TransferDetailInput.java index 77553694b5..3e4bb08d3f 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/TransferDetailInput.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/TransferDetailInput.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * 发起批量转账的明细列表 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class TransferDetailInput { diff --git a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/UnifiedOrder.java b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/UnifiedOrder.java index 5faa33cb4d..7886c996a6 100644 --- a/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/UnifiedOrder.java +++ b/bus-pay/src/main/java/org/miaixz/bus/pay/metric/wechat/entity/v3/UnifiedOrder.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.pay.metric.wechat.entity.v3; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * V3 统一下单 @@ -37,7 +41,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class UnifiedOrder { diff --git a/bus-proxy/pom.xml b/bus-proxy/pom.xml index 36d5da2e32..574768ff2a 100755 --- a/bus-proxy/pom.xml +++ b/bus-proxy/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-proxy - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -70,8 +70,8 @@ UTF-8 21 21 - 3.3.0 1.9.22 + 3.3.1 @@ -88,7 +88,7 @@
                org.springframework.boot - spring-boot-starter + spring-boot-starter-web ${spring.boot.version} true @@ -119,54 +119,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-sensitive/pom.xml b/bus-sensitive/pom.xml index 08b018b719..97ce71954a 100755 --- a/bus-sensitive/pom.xml +++ b/bus-sensitive/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-sensitive - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -124,54 +124,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-setting/pom.xml b/bus-setting/pom.xml index 33ddc84492..f5b751e4b0 100755 --- a/bus-setting/pom.xml +++ b/bus-setting/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-setting - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -112,54 +112,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-shade/pom.xml b/bus-shade/pom.xml index ee6b5d8bff..96326baa49 100755 --- a/bus-shade/pom.xml +++ b/bus-shade/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-shade - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -70,12 +70,12 @@ UTF-8 21 21 - 3.3.0 + 3.3.1 1.26.2 2.3.32 1.18.32 5.1.0 - 8.3.0 + 8.4.0 @@ -165,54 +165,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-shade/src/main/resources/META-INF/template/Entity.ftl b/bus-shade/src/main/resources/META-INF/template/Entity.ftl index f8ca27529b..29ed4831e2 100755 --- a/bus-shade/src/main/resources/META-INF/template/Entity.ftl +++ b/bus-shade/src/main/resources/META-INF/template/Entity.ftl @@ -27,7 +27,7 @@ */ package ${entityUrl}; -import lombok.Getter; +import lombok.*; import lombok.Setter; import entity.base.org.miaixz.bus.BaseEntity; import javax.persistence.Table; diff --git a/bus-socket/pom.xml b/bus-socket/pom.xml index c77328434b..36f81100fd 100755 --- a/bus-socket/pom.xml +++ b/bus-socket/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-socket - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -105,54 +105,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/Context.java b/bus-socket/src/main/java/org/miaixz/bus/socket/Context.java index 2fc8605f68..52dff8dd1c 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/Context.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/Context.java @@ -77,9 +77,9 @@ public final class Context { */ private Handler processor; /** - * 协议编解码 + * 消息编解码 */ - private Protocol protocol; + private Message message; /** * Socket 配置 @@ -144,12 +144,12 @@ public Monitor getMonitor() { return monitor; } - public Protocol getProtocol() { - return protocol; + public Message getProtocol() { + return message; } - public void setProtocol(Protocol protocol) { - this.protocol = protocol; + public void setProtocol(Message message) { + this.message = message; } public Handler getProcessor() { @@ -233,7 +233,7 @@ public String toString() { ", port=" + port + ", backlog=" + backlog + ", processor=" + processor + - ", protocol=" + protocol + + ", protocol=" + message + ", socketOptions=" + socketOptions + ", threadNum=" + threadNum + ", bufferFactory=" + bufferFactory + diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/Protocol.java b/bus-socket/src/main/java/org/miaixz/bus/socket/Message.java similarity index 88% rename from bus-socket/src/main/java/org/miaixz/bus/socket/Protocol.java rename to bus-socket/src/main/java/org/miaixz/bus/socket/Message.java index 451b331a85..b3c8e33054 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/Protocol.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/Message.java @@ -33,17 +33,17 @@ import java.nio.ByteBuffer; /** - * 消息传输采用的协议 + * 消息传输采用的模式 *

                - * 根据通信双方约定的协议规范实现{@code Protocol}接口,使用时将该实现类注册至服务启动类{@link AioClient}、{@link AioServer} + * 根据通信双方约定的模式规范实现{@code Message}接口,使用时将该实现类注册至服务启动类{@link AioClient}、{@link AioServer} *

                - * 注意:框架本身的所有Socket链路复用同一个Protocol,请勿在其实现类的成员变量中存储特定链路的数据。 + * 注意:框架本身的所有Socket链路复用同一个Message,请勿在其实现类的成员变量中存储特定链路的数据。 * * @param 消息对象实体类型 * @author Kimi Liu * @since Java 17+ */ -public interface Protocol { +public interface Message { /** * 对于从Socket流中获取到的数据采用当前Protocol的实现类协议进行解析。 diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/Session.java b/bus-socket/src/main/java/org/miaixz/bus/socket/Session.java index 1ff4d6bf87..c7b27f67d5 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/Session.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/Session.java @@ -88,7 +88,7 @@ public abstract class Session { /** * 强制关闭当前Session - *

                若此时还存留待输出的数据,则会导致该部分数据丢失

                + * 若此时还存留待输出的数据,则会导致该部分数据丢失 */ public final void close() { close(true); @@ -166,13 +166,9 @@ public final void setAttachment(A attachment) { public abstract InetSocketAddress getRemoteAddress() throws IOException; /** - * 获得数据输入流对象。 - *

                + * 获得数据输入流对象 * faster模式下调用该方法会触发UnsupportedOperationException异常。 - *

                - *

                * Handler采用异步处理消息的方式时,调用该方法可能会出现异常。 - *

                * * @return 输入流 * @throws IOException IO异常 diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/Status.java b/bus-socket/src/main/java/org/miaixz/bus/socket/Status.java index 822b1791d7..f72179e9b7 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/Status.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/Status.java @@ -62,7 +62,7 @@ public enum Status { PROCESS_EXCEPTION, /** * 协议解码异常 - * 执行{@link Protocol#decode(ByteBuffer, Session)}期间发生未捕获的异常 + * 执行{@link Message#decode(ByteBuffer, Session)}期间发生未捕获的异常 */ DECODE_EXCEPTION, /** diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/AioClient.java b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/AioClient.java index c2823869f3..088eb4a610 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/AioClient.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/AioClient.java @@ -30,7 +30,7 @@ import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.socket.Context; import org.miaixz.bus.socket.Handler; -import org.miaixz.bus.socket.Protocol; +import org.miaixz.bus.socket.Message; import org.miaixz.bus.socket.Session; import org.miaixz.bus.socket.buffer.BufferFactory; import org.miaixz.bus.socket.buffer.BufferPagePool; @@ -57,6 +57,9 @@ */ public final class AioClient { + /** + * 健康检查 + */ private static final ScheduledExecutorService CONNECT_TIMEOUT_EXECUTOR = Executors.newSingleThreadScheduledExecutor(r -> { Thread thread = new Thread(r, "connection-timeout-monitor"); thread.setDaemon(true); @@ -73,6 +76,9 @@ public final class AioClient { * @see TcpSession */ private TcpSession session; + /** + * ByteBuffer内存池 + */ private BufferPagePool innerBufferPool = null; /** * IO事件处理线程组 @@ -99,13 +105,13 @@ public final class AioClient { * * @param host 远程服务器地址 * @param port 远程服务器端口号 - * @param protocol 协议编解码 + * @param message 协议编解码 * @param handler 消息处理器 */ - public AioClient(String host, int port, Protocol protocol, Handler handler) { + public AioClient(String host, int port, Message message, Handler handler) { context.setHost(host); context.setPort(port); - context.setProtocol(protocol); + context.setProtocol(message); context.setProcessor(handler); } diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/AioServer.java b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/AioServer.java index 8666993566..0869170027 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/AioServer.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/AioServer.java @@ -30,7 +30,7 @@ import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.socket.Context; import org.miaixz.bus.socket.Handler; -import org.miaixz.bus.socket.Protocol; +import org.miaixz.bus.socket.Message; import org.miaixz.bus.socket.Status; import org.miaixz.bus.socket.buffer.*; import org.miaixz.bus.socket.metric.channels.AsynchronousChannelProvider; @@ -55,6 +55,9 @@ */ public final class AioServer { + /** + * 线程序号 + */ private static long threadSeqNumber; /** * 客户端服务配置 @@ -66,11 +69,11 @@ public final class AioServer { */ private BufferPagePool innerBufferPool = null; /** - * asynchronousServerSocketChannel + * 异步服务器套接字通道 */ private AsynchronousServerSocketChannel serverSocketChannel = null; /** - * asynchronousChannelGroup + * 异步通道组 */ private AsynchronousChannelGroup asynchronousChannelGroup; /** @@ -81,31 +84,33 @@ public final class AioServer { * 内存池 */ private BufferPagePool bufferPool = null; - + /** + * 虚拟缓冲区工厂 + */ private VirtualBufferFactory readBufferFactory = bufferPage -> bufferPage.allocate(context.getReadBufferSize()); /** * 设置服务端启动必要参数配置 * - * @param port 绑定服务端口号 - * @param protocol 协议编解码 - * @param handler 消息处理器 + * @param port 绑定服务端口号 + * @param message 协议编解码 + * @param handler 消息处理器 */ - public AioServer(int port, Protocol protocol, Handler handler) { + public AioServer(int port, Message message, Handler handler) { context.setPort(port); - context.setProtocol(protocol); + context.setProtocol(message); context.setProcessor(handler); context.setThreadNum(Runtime.getRuntime().availableProcessors()); } /** - * @param host 绑定服务端Host地址 - * @param port 绑定服务端口号 - * @param protocol 协议编解码 - * @param handler 消息处理器 + * @param host 绑定服务端Host地址 + * @param port 绑定服务端口号 + * @param message 协议编解码 + * @param handler 消息处理器 */ - public AioServer(String host, int port, Protocol protocol, Handler handler) { - this(port, protocol, handler); + public AioServer(String host, int port, Message message, Handler handler) { + this(port, message, handler); context.setHost(host); } @@ -136,13 +141,13 @@ public void start(AsynchronousChannelGroup asynchronousChannelGroup) throws IOEx } this.serverSocketChannel = AsynchronousServerSocketChannel.open(asynchronousChannelGroup); - // set socket options + // 设置套接字选项 if (context.getSocketOptions() != null) { for (Map.Entry, Object> entry : context.getSocketOptions().entrySet()) { this.serverSocketChannel.setOption(entry.getKey(), entry.getValue()); } } - // bind host + // 绑定主机 if (context.getHost() != null) { serverSocketChannel.bind(new InetSocketAddress(context.getHost(), context.getPort()), context.getBacklog()); } else { @@ -183,6 +188,7 @@ public void failed(Throwable exc, Void attachment) { * 为每个新建立的连接创建Session对象 * * @param channel 当前已建立连接通道 + * @param function */ private void createSession(AsynchronousSocketChannel channel, Function function) { // 连接成功则构造Session对象 @@ -298,7 +304,7 @@ public AioServer setBacklog(int backlog) { } /** - * 设置内存池。 + * 设置内存池 * 通过该方法设置的内存池,在AioServer执行shutdown时不会触发内存池的释放。 * 该方法适用于多个AioServer、AioClient共享内存池的场景。 * 在启用内存池的情况下会有更好的性能表现 @@ -313,7 +319,7 @@ public AioServer setBufferPagePool(BufferPagePool bufferPool) { } /** - * 设置内存池的构造工厂。 + * 设置内存池的构造工厂 * 通过工厂形式生成的内存池会强绑定到当前AioServer对象, * 在AioServer执行shutdown时会释放内存池。 * 在启用内存池的情况下会有更好的性能表现 diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/TcpSession.java b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/TcpSession.java index dc11d9c51b..5c8ff7a61e 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/TcpSession.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/TcpSession.java @@ -68,6 +68,7 @@ * @since Java 17+ */ public final class TcpSession extends Session { + /** * 底层通信channel对象 */ @@ -76,15 +77,21 @@ public final class TcpSession extends Session { * 输出流 */ private final WriteBuffer byteBuf; + /** + * 缓冲页 + */ private final BufferPage bufferPage; /** * 服务上下文 */ private final Context context; + /** + * 缓冲函数 + */ private final Function function; /** - * 读缓冲。 - *

                大小取决于AioClient/AioServer设置的setReadBufferSize

                + * 读缓冲 + * 大小取决于AioClient/AioServer设置的setReadBufferSize */ private VirtualBuffer readBuffer; /** @@ -118,7 +125,7 @@ void doRead() { /** * 触发AIO的写操作, - *

                需要调用控制同步

                + * 需要调用控制同步 */ void writeCompleted(int result) { Monitor monitor = context.getMonitor(); @@ -139,11 +146,11 @@ void writeCompleted(int result) { return; } byteBuf.finishWrite(); - //此时可能是Closing或Closed状态 + // 此时可能是Closing或Closed状态 if (status != SESSION_STATUS_ENABLED) { close(); } else { - //也许此时有新的消息通过write方法添加到writeCacheQueue中 + // 也许此时有新的消息通过write方法添加到writeCacheQueue中 byteBuf.flush(); } } @@ -270,7 +277,7 @@ public void signalRead() { break; } - //处理消息 + // 处理消息 try { handler.process(this, dataEntry); if (modCount != this.modCount) { @@ -293,14 +300,14 @@ public void signalRead() { byteBuf.flush(); readBuffer.compact(); - //读缓冲区已满 + // 读缓冲区已满 if (!readBuffer.hasRemaining()) { InternalException exception = new InternalException("readBuffer overflow. The current TCP connection will be closed. Please fix your " + context.getProtocol().getClass().getSimpleName() + "#decode bug."); handler.stateEvent(this, Status.DECODE_EXCEPTION, exception); throw exception; } - //read from channel + // 从通道读取 Monitor monitor = context.getMonitor(); if (monitor != null) { monitor.beforeRead(this); @@ -485,8 +492,6 @@ public void close() { } } - - /** * 写事件回调处理 */ @@ -515,5 +520,4 @@ public void failed(Throwable exc, TcpSession session) { } }; - } diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/UdpBootstrap.java b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/UdpBootstrap.java index 72423ad029..93be01d2de 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/UdpBootstrap.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/UdpBootstrap.java @@ -29,7 +29,7 @@ import org.miaixz.bus.socket.Context; import org.miaixz.bus.socket.Handler; -import org.miaixz.bus.socket.Protocol; +import org.miaixz.bus.socket.Message; import org.miaixz.bus.socket.Worker; import org.miaixz.bus.socket.buffer.BufferFactory; import org.miaixz.bus.socket.buffer.BufferPagePool; @@ -54,18 +54,41 @@ public class UdpBootstrap { * 内存池 */ private BufferPagePool bufferPool; + /** + * 缓冲页池 + */ private BufferPagePool innerBufferPool = null; + /** + * 工作者 + */ private Worker worker; + /** + * 内部工作者 + */ private boolean innerWorker = false; - - public UdpBootstrap(Protocol protocol, Handler handler, Worker worker) { - this(protocol, handler); + /** + * 构造 + * + * @param message 消息处理 + * @param handler 拦截器 + * @param worker 工作者 + * @param 当前请求 + */ + public UdpBootstrap(Message message, Handler handler, Worker worker) { + this(message, handler); this.worker = worker; } - public UdpBootstrap(Protocol protocol, Handler handler) { - context.setProtocol(protocol); + /** + * 构造 + * + * @param message 消息处理 + * @param handler 拦截器 + * @param 当前请求 + */ + public UdpBootstrap(Message message, Handler handler) { + context.setProtocol(message); context.setProcessor(handler); } @@ -166,7 +189,7 @@ public final UdpBootstrap setBufferPagePool(BufferPagePool bufferPool) { } /** - * 设置内存池的构造工厂。 + * 设置内存池的构造工厂 * 通过工厂形式生成的内存池会强绑定到当前UdpBootstrap对象, * 在UdpBootstrap执行shutdown时会释放内存池。 * 在启用内存池的情况下会有更好的性能表现 diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/UdpChannel.java b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/UdpChannel.java index a96cbc0616..bc5eba5f63 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/UdpChannel.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/UdpChannel.java @@ -56,6 +56,9 @@ public final class UdpChannel { * 服务上下文 */ public final Context context; + /** + * 缓冲页 + */ private final BufferPage bufferPage; /** * 真实的UDP通道 @@ -65,7 +68,13 @@ public final class UdpChannel { * 待输出消息 */ private ConcurrentLinkedQueue responseTasks; + /** + * 工作者 + */ private Worker worker; + /** + * 注册者key + */ private SelectionKey selectionKey; /** * 发送失败的 diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/kcp/KcpProtocol.java b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/kcp/KcpMessage.java similarity index 96% rename from bus-socket/src/main/java/org/miaixz/bus/socket/accord/kcp/KcpProtocol.java rename to bus-socket/src/main/java/org/miaixz/bus/socket/accord/kcp/KcpMessage.java index c09bcfbdaf..5ebbe6bbd5 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/accord/kcp/KcpProtocol.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/accord/kcp/KcpMessage.java @@ -27,7 +27,7 @@ */ package org.miaixz.bus.socket.accord.kcp; -import org.miaixz.bus.socket.Protocol; +import org.miaixz.bus.socket.Message; import org.miaixz.bus.socket.Session; import java.nio.ByteBuffer; @@ -36,7 +36,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class KcpProtocol implements Protocol { +public class KcpMessage implements Message { @Override public KcpPacket decode(ByteBuffer readBuffer, Session session) { diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/ByteArrayProtocol.java b/bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/ByteArrayMessage.java similarity index 95% rename from bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/ByteArrayProtocol.java rename to bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/ByteArrayMessage.java index 9a1624edeb..24625e9b73 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/ByteArrayProtocol.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/ByteArrayMessage.java @@ -25,7 +25,7 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.socket.metric.protocol; +package org.miaixz.bus.socket.metric.message; import org.miaixz.bus.socket.Session; @@ -35,7 +35,7 @@ * @author Kimi Liu * @since Java 17+ */ -public class ByteArrayProtocol extends FixedLengthBytesProtocol { +public class ByteArrayMessage extends FixedLengthBytesMessage { @Override protected byte[] decode(byte[] bytes, Session session) { diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/FixedLengthBytesProtocol.java b/bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/FixedLengthBytesMessage.java similarity index 94% rename from bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/FixedLengthBytesProtocol.java rename to bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/FixedLengthBytesMessage.java index 9c82f2594c..5893db4d17 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/FixedLengthBytesProtocol.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/FixedLengthBytesMessage.java @@ -25,9 +25,9 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.socket.metric.protocol; +package org.miaixz.bus.socket.metric.message; -import org.miaixz.bus.socket.Protocol; +import org.miaixz.bus.socket.Message; import org.miaixz.bus.socket.Session; import java.nio.ByteBuffer; @@ -38,7 +38,7 @@ * @author Kimi Liu * @since Java 17+ */ -public abstract class FixedLengthBytesProtocol implements Protocol { +public abstract class FixedLengthBytesMessage implements Message { @Override public final T decode(ByteBuffer readBuffer, Session session) { diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/StringProtocol.java b/bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/StringMessage.java similarity index 95% rename from bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/StringProtocol.java rename to bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/StringMessage.java index fb0d8067e0..f7ba37d415 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/StringProtocol.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/StringMessage.java @@ -25,9 +25,9 @@ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ */ -package org.miaixz.bus.socket.metric.protocol; +package org.miaixz.bus.socket.metric.message; -import org.miaixz.bus.socket.Protocol; +import org.miaixz.bus.socket.Message; import org.miaixz.bus.socket.Session; import org.miaixz.bus.socket.metric.decoder.FixedLengthFrameDecoder; @@ -42,18 +42,18 @@ * @author Kimi Liu * @since Java 17+ */ -public class StringProtocol implements Protocol { +public class StringMessage implements Message { private final Charset charset; private final Map decoderMap = new ConcurrentHashMap<>(); private long lastClearTime = System.currentTimeMillis(); - public StringProtocol(Charset charset) { + public StringMessage(Charset charset) { this.charset = charset; } - public StringProtocol() { + public StringMessage() { this(org.miaixz.bus.core.lang.Charset.UTF_8); } diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/package-info.java b/bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/package-info.java similarity index 97% rename from bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/package-info.java rename to bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/package-info.java index 599bef8ca4..0cd894d635 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/metric/protocol/package-info.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/metric/message/package-info.java @@ -31,4 +31,4 @@ * @author Kimi Liu * @since Java 17+ */ -package org.miaixz.bus.socket.metric.protocol; \ No newline at end of file +package org.miaixz.bus.socket.metric.message; \ No newline at end of file diff --git a/bus-socket/src/main/java/org/miaixz/bus/socket/package-info.java b/bus-socket/src/main/java/org/miaixz/bus/socket/package-info.java index df8942e239..26aab11291 100644 --- a/bus-socket/src/main/java/org/miaixz/bus/socket/package-info.java +++ b/bus-socket/src/main/java/org/miaixz/bus/socket/package-info.java @@ -28,7 +28,7 @@ /** * 定义用户进行通信开发所需实现的接口 *

                - * 用户进行通信开发时需要实现该package中的接口,通常情况下仅需实现{@link org.miaixz.bus.socket.Protocol}/{@link org.miaixz.bus.socket.Handler}即可。 + * 用户进行通信开发时需要实现该package中的接口,通常情况下仅需实现{@link org.miaixz.bus.socket.Message}/{@link org.miaixz.bus.socket.Handler}即可。 * 如需仅需通讯层面的监控,本项目提供了接口{@link org.miaixz.bus.socket.Monitor}以供使用。 *

                *

                diff --git a/bus-spring/pom.xml b/bus-spring/pom.xml index b46cd1bb85..dea8c33a12 100755 --- a/bus-spring/pom.xml +++ b/bus-spring/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-spring - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -70,8 +70,8 @@ UTF-8 21 21 - 3.3.0 1.18.32 + 3.3.1 @@ -120,54 +120,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-starter/pom.xml b/bus-starter/pom.xml index 7c22cefbb9..95ed7e6bd4 100755 --- a/bus-starter/pom.xml +++ b/bus-starter/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-starter - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -70,9 +70,9 @@ UTF-8 21 21 - 3.3.0 + 3.3.1 1.18.32 - 3.2.0-M2 + 3.2.0 6.1.0-M2 1.9.22 4.5.8 @@ -294,24 +294,6 @@ - - org.springframework.boot - spring-boot-starter-jdbc - ${spring.boot.version} - true - - - org.springframework.boot - spring-boot-starter-web - ${spring.boot.version} - true - - - org.springframework.boot - spring-boot-starter-webflux - ${spring.boot.version} - true - org.elasticsearch elasticsearch @@ -364,6 +346,24 @@ + + org.springframework.boot + spring-boot-starter-jdbc + ${spring.boot.version} + true + + + org.springframework.boot + spring-boot-starter-web + ${spring.boot.version} + true + + + org.springframework.boot + spring-boot-starter-webflux + ${spring.boot.version} + true + @@ -391,54 +391,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-starter/src/main/java/org/miaixz/bus/starter/bridge/BridgeVerticleService.java b/bus-starter/src/main/java/org/miaixz/bus/starter/bridge/BridgeVerticleService.java index 014f507326..4834fc6988 100644 --- a/bus-starter/src/main/java/org/miaixz/bus/starter/bridge/BridgeVerticleService.java +++ b/bus-starter/src/main/java/org/miaixz/bus/starter/bridge/BridgeVerticleService.java @@ -31,9 +31,9 @@ import io.vertx.core.Vertx; import io.vertx.ext.web.Router; import jakarta.annotation.Resource; -import org.miaixz.bus.base.entity.Message; -import org.miaixz.bus.core.lang.Header; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.MediaType; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.ObjectKit; import org.miaixz.bus.extra.json.JsonKit; import org.miaixz.bus.logger.Logger; @@ -74,7 +74,7 @@ public void start() { Logger.error("get error", e); result = JsonKit.toJsonString(Message.builder().errcode("-1").build()); } - context.response().putHeader(Header.CONTENT_TYPE, MediaType.APPLICATION_JSON).end(result); + context.response().putHeader(HTTP.CONTENT_TYPE, MediaType.APPLICATION_JSON).end(result); }); vertx.createHttpServer().requestHandler(router).listen(this.properties.getPort()); diff --git a/bus-starter/src/main/java/org/miaixz/bus/starter/cors/CorsProperties.java b/bus-starter/src/main/java/org/miaixz/bus/starter/cors/CorsProperties.java index ac2ebf5e38..226bafedbc 100755 --- a/bus-starter/src/main/java/org/miaixz/bus/starter/cors/CorsProperties.java +++ b/bus-starter/src/main/java/org/miaixz/bus/starter/cors/CorsProperties.java @@ -29,8 +29,8 @@ import lombok.Getter; import lombok.Setter; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.spring.BusXConfig; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -60,7 +60,7 @@ public class CorsProperties { /** * 允许的方法 */ - private String[] allowedMethods = new String[]{Http.GET, Http.POST, Http.PUT, Http.OPTIONS, Http.DELETE}; + private String[] allowedMethods = new String[]{HTTP.GET, HTTP.POST, HTTP.PUT, HTTP.OPTIONS, HTTP.DELETE}; /** * 响应头信息公开 */ diff --git a/bus-starter/src/main/java/org/miaixz/bus/starter/elastic/ElasticConfiguration.java b/bus-starter/src/main/java/org/miaixz/bus/starter/elastic/ElasticConfiguration.java index 41fad985b6..f595ea6186 100644 --- a/bus-starter/src/main/java/org/miaixz/bus/starter/elastic/ElasticConfiguration.java +++ b/bus-starter/src/main/java/org/miaixz/bus/starter/elastic/ElasticConfiguration.java @@ -32,7 +32,7 @@ import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestHighLevelClient; -import org.miaixz.bus.base.normal.Consts; +import org.miaixz.bus.core.basics.normal.Consts; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; import org.miaixz.bus.core.xyz.CollKit; diff --git a/bus-starter/src/main/java/org/miaixz/bus/starter/goalie/GoalieConfiguration.java b/bus-starter/src/main/java/org/miaixz/bus/starter/goalie/GoalieConfiguration.java index 8f3510bf8f..f40dbe1b8a 100644 --- a/bus-starter/src/main/java/org/miaixz/bus/starter/goalie/GoalieConfiguration.java +++ b/bus-starter/src/main/java/org/miaixz/bus/starter/goalie/GoalieConfiguration.java @@ -64,7 +64,7 @@ * 路由自动配置 * * @author Kimi Liu - * @since Java 17++ + * @since Java 17+ */ @ConditionalOnWebApplication @EnableConfigurationProperties(value = {GoalieProperties.class}) diff --git a/bus-starter/src/main/java/org/miaixz/bus/starter/sensitive/ResponseBodyAdvice.java b/bus-starter/src/main/java/org/miaixz/bus/starter/sensitive/ResponseBodyAdvice.java index 3d87135866..44fb208b93 100755 --- a/bus-starter/src/main/java/org/miaixz/bus/starter/sensitive/ResponseBodyAdvice.java +++ b/bus-starter/src/main/java/org/miaixz/bus/starter/sensitive/ResponseBodyAdvice.java @@ -29,8 +29,8 @@ import jakarta.annotation.Resource; import org.miaixz.bus.base.advice.BaseAdvice; -import org.miaixz.bus.base.entity.Message; -import org.miaixz.bus.base.entity.Result; +import org.miaixz.bus.core.basics.entity.Message; +import org.miaixz.bus.core.basics.entity.Result; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.lang.exception.InternalException; import org.miaixz.bus.core.xyz.*; diff --git a/bus-starter/src/main/java/org/miaixz/bus/starter/socket/SocketQuickService.java b/bus-starter/src/main/java/org/miaixz/bus/starter/socket/SocketQuickService.java index bfce4649bd..2ce12e1bda 100644 --- a/bus-starter/src/main/java/org/miaixz/bus/starter/socket/SocketQuickService.java +++ b/bus-starter/src/main/java/org/miaixz/bus/starter/socket/SocketQuickService.java @@ -29,7 +29,7 @@ import jakarta.annotation.Resource; import org.miaixz.bus.socket.Handler; -import org.miaixz.bus.socket.Protocol; +import org.miaixz.bus.socket.Message; import org.miaixz.bus.socket.accord.AioServer; import java.io.IOException; @@ -44,7 +44,7 @@ public class SocketQuickService { @Resource private Handler handler; @Resource - private Protocol protocol; + private Message message; private AioServer aioQuickServer; public SocketQuickService(SocketProperties properties) { @@ -52,7 +52,7 @@ public SocketQuickService(SocketProperties properties) { } public void start() { - this.aioQuickServer = new AioServer(this.properties.getPort(), protocol, handler); + this.aioQuickServer = new AioServer(this.properties.getPort(), message, handler); try { aioQuickServer.start(); } catch (IOException e) { diff --git a/bus-starter/src/main/java/org/miaixz/bus/starter/wrapper/GenieWrapperHandler.java b/bus-starter/src/main/java/org/miaixz/bus/starter/wrapper/GenieWrapperHandler.java index 925b581b24..efa8a01f1b 100755 --- a/bus-starter/src/main/java/org/miaixz/bus/starter/wrapper/GenieWrapperHandler.java +++ b/bus-starter/src/main/java/org/miaixz/bus/starter/wrapper/GenieWrapperHandler.java @@ -29,9 +29,9 @@ import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.ansi.Ansi4BitColor; import org.miaixz.bus.core.lang.ansi.AnsiEncoder; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.ArrayKit; import org.miaixz.bus.core.xyz.NetKit; import org.miaixz.bus.logger.Logger; @@ -116,10 +116,10 @@ public static String getClientIPByHeader(final HttpServletRequest request, final public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { final String method = request.getMethod().toUpperCase(); this.requestInfo(request, method); - if (Http.GET.equals(method) - || Http.POST.equals(method) - || Http.PATCH.equals(method) - || Http.PUT.equals(method)) { + if (HTTP.GET.equals(method) + || HTTP.POST.equals(method) + || HTTP.PATCH.equals(method) + || HTTP.PUT.equals(method)) { if (request instanceof CacheRequestWrapper) { CacheRequestWrapper cacheRequestWrapper = ((CacheRequestWrapper) request); Logger.info("==> {}", new String(cacheRequestWrapper.getBody())); @@ -143,9 +143,9 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons @Override public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) { final String method = request.getMethod(); - if (Http.POST.equals(method) - || Http.PATCH.equals(method) - || Http.PUT.equals(method)) { + if (HTTP.POST.equals(method) + || HTTP.PATCH.equals(method) + || HTTP.PUT.equals(method)) { if (response instanceof CacheResponseWrapper) { CacheResponseWrapper cacheResponseWrapper = ((CacheResponseWrapper) response); Logger.info("<== {}", new String(cacheResponseWrapper.getBody()).length()); @@ -181,25 +181,25 @@ public void postHandle(HttpServletRequest request, HttpServletResponse response, private void requestInfo(HttpServletRequest request, String method) { String requestMethod = AnsiEncoder.encode(Ansi4BitColor.GREEN, " %s ", method); switch (method) { - case Http.ALL: + case HTTP.ALL: requestMethod = AnsiEncoder.encode(Ansi4BitColor.WHITE, " %s ", method); break; - case Http.POST: + case HTTP.POST: requestMethod = AnsiEncoder.encode(Ansi4BitColor.MAGENTA, " %s ", method); break; - case Http.DELETE: + case HTTP.DELETE: requestMethod = AnsiEncoder.encode(Ansi4BitColor.BLUE, " %s ", method); break; - case Http.PUT: + case HTTP.PUT: requestMethod = AnsiEncoder.encode(Ansi4BitColor.RED, " %s ", method); break; - case Http.OPTIONS: + case HTTP.OPTIONS: requestMethod = AnsiEncoder.encode(Ansi4BitColor.YELLOW, " %s ", method); break; - case Http.BEFORE: + case HTTP.BEFORE: requestMethod = AnsiEncoder.encode(Ansi4BitColor.BLACK, " %s ", method); break; - case Http.AFTER: + case HTTP.AFTER: requestMethod = AnsiEncoder.encode(Ansi4BitColor.CYAN, " %s ", method); break; } diff --git a/bus-starter/src/main/java/org/miaixz/bus/starter/wrapper/WrapperConfiguration.java b/bus-starter/src/main/java/org/miaixz/bus/starter/wrapper/WrapperConfiguration.java index 0975a31393..700a7c0075 100755 --- a/bus-starter/src/main/java/org/miaixz/bus/starter/wrapper/WrapperConfiguration.java +++ b/bus-starter/src/main/java/org/miaixz/bus/starter/wrapper/WrapperConfiguration.java @@ -32,8 +32,8 @@ import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Symbol; +import org.miaixz.bus.core.net.HTTP; import org.miaixz.bus.core.xyz.CollKit; import org.miaixz.bus.core.xyz.MapKit; import org.miaixz.bus.core.xyz.ObjectKit; @@ -138,7 +138,7 @@ class BodyCacheFilter extends OncePerRequestFilter { protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException { final String method = request.getMethod(); // 如果不是 POST PATCH PUT 等有流的接口则无需进行类型转换,提高性能 - if (Http.POST.equals(method) || Http.PATCH.equals(method) || Http.PUT.equals(method)) { + if (HTTP.POST.equals(method) || HTTP.PATCH.equals(method) || HTTP.PUT.equals(method)) { if (!(request instanceof CacheRequestWrapper)) { request = new CacheRequestWrapper(request); } diff --git a/bus-starter/src/main/resources/META-INF/services/org.miaixz.bus.core.basics.service.ErrorService b/bus-starter/src/main/resources/META-INF/services/org.miaixz.bus.core.basics.service.ErrorService new file mode 100644 index 0000000000..f0bbbbe44e --- /dev/null +++ b/bus-starter/src/main/resources/META-INF/services/org.miaixz.bus.core.basics.service.ErrorService @@ -0,0 +1 @@ +org.miaixz.bus.core.basics.service.ErrorService \ No newline at end of file diff --git a/bus-starter/src/main/resources/config/application.yml b/bus-starter/src/main/resources/config/application.yml new file mode 100755 index 0000000000..4d361af92a --- /dev/null +++ b/bus-starter/src/main/resources/config/application.yml @@ -0,0 +1,17 @@ +version: "@project.version@" + +logging: + pattern: + console: "%green(%d{yyyy-MM-dd HH:mm:ss}) %yellow([%p]) [%t] - %highlight(%logger{40}:%L) : - %magenta(%m%n)" + file: "%green(%d{yyyy-MM-dd HH:mm:ss}) %yellow([%p]) - %highlight(%C:%L) : - %magenta(%m%n)" + logback: + rollingpolicy: + max-file-size: 10MB + max-history: 90 + +spring: + main: + allow-circular-references: true + output: + ansi: + enabled: always \ No newline at end of file diff --git a/bus-storage/pom.xml b/bus-storage/pom.xml index f204cf068d..963241d749 100755 --- a/bus-storage/pom.xml +++ b/bus-storage/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-storage - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -486,54 +486,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/Context.java b/bus-storage/src/main/java/org/miaixz/bus/storage/Context.java index 9010e1e167..d1d5d757e3 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/Context.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/Context.java @@ -27,8 +27,11 @@ */ package org.miaixz.bus.storage; -import lombok.Builder; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; /** * @author Kimi Liu @@ -36,7 +39,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Context { diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/Provider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/Provider.java index 4fbc6f5f5d..60aca8a617 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/Provider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/Provider.java @@ -27,8 +27,8 @@ */ package org.miaixz.bus.storage; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.storage.magic.ErrorCode; -import org.miaixz.bus.storage.magic.Message; import java.io.File; import java.io.InputStream; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/magic/Material.java b/bus-storage/src/main/java/org/miaixz/bus/storage/magic/Material.java index baafac9eba..41e295b15f 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/magic/Material.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/magic/Material.java @@ -27,7 +27,11 @@ */ package org.miaixz.bus.storage.magic; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.experimental.SuperBuilder; import java.util.Map; @@ -39,7 +43,7 @@ */ @Getter @Setter -@Builder +@SuperBuilder @NoArgsConstructor @AllArgsConstructor public class Material { diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/AbstractProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/AbstractProvider.java index 1e54767882..4f787a4af7 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/AbstractProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/AbstractProvider.java @@ -27,10 +27,11 @@ */ package org.miaixz.bus.storage.metric; -import org.miaixz.bus.core.lang.Http; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.lang.exception.InternalException; +import org.miaixz.bus.core.net.HTTP; +import org.miaixz.bus.core.net.Protocol; import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.Provider; @@ -59,7 +60,7 @@ protected static String downloadFile(String fileURL, String saveDir) { httpConn = (HttpURLConnection) url.openConnection(); int responseCode = httpConn.getResponseCode(); - if (responseCode == Http.HTTP_OK) { + if (responseCode == HTTP.HTTP_OK) { String fileName = Normal.EMPTY; String disposition = httpConn.getHeaderField("Content-Disposition"); @@ -105,7 +106,7 @@ protected static String downloadFile(String fileURL, String saveDir) { } protected String getFullPath(String file) { - if (file.startsWith(Http.HTTP_PREFIX) || file.startsWith(Http.HTTPS_PREFIX)) { + if (file.startsWith(Protocol.HTTP_PREFIX) || file.startsWith(Protocol.HTTPS_PREFIX)) { return file; } return this.context.getPrefix() + file; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/AliYunOssProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/AliYunOssProvider.java index 9ccbf39a3c..46681b8ad3 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/AliYunOssProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/AliYunOssProvider.java @@ -31,6 +31,7 @@ import com.aliyun.oss.common.auth.DefaultCredentialProvider; import com.aliyun.oss.common.comm.ResponseMessage; import com.aliyun.oss.model.*; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.Normal; import org.miaixz.bus.core.xyz.StringKit; @@ -38,7 +39,6 @@ import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; import org.miaixz.bus.storage.magic.Material; -import org.miaixz.bus.storage.magic.Message; import java.io.*; import java.nio.file.Path; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/BaiduYunBosProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/BaiduYunBosProvider.java index c8f3bf362e..ae883ad238 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/BaiduYunBosProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/BaiduYunBosProvider.java @@ -33,12 +33,12 @@ import com.baidubce.services.bos.model.GetObjectRequest; import com.baidubce.services.bos.model.ListObjectsRequest; import com.baidubce.services.bos.model.ListObjectsResponse; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; import org.miaixz.bus.storage.magic.Material; -import org.miaixz.bus.storage.magic.Message; import java.io.File; import java.io.InputStream; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/HuaweiObsProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/HuaweiObsProvider.java index 0b42a66cbf..f5401efddb 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/HuaweiObsProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/HuaweiObsProvider.java @@ -31,12 +31,12 @@ import com.obs.services.model.DownloadFileRequest; import com.obs.services.model.ListObjectsRequest; import com.obs.services.model.ObjectListing; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; import org.miaixz.bus.storage.magic.Material; -import org.miaixz.bus.storage.magic.Message; import java.io.File; import java.io.InputStream; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/JdYunOssProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/JdYunOssProvider.java index c3887d102e..c38468b244 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/JdYunOssProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/JdYunOssProvider.java @@ -38,12 +38,12 @@ import com.amazonaws.services.s3.model.GetObjectRequest; import com.amazonaws.services.s3.model.ListObjectsRequest; import com.amazonaws.services.s3.model.ObjectListing; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; import org.miaixz.bus.storage.magic.Material; -import org.miaixz.bus.storage.magic.Message; import java.io.File; import java.io.InputStream; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/LocalFileProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/LocalFileProvider.java index 0efd69a78e..7eb2336b0f 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/LocalFileProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/LocalFileProvider.java @@ -27,13 +27,13 @@ */ package org.miaixz.bus.storage.metric; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.core.xyz.IoKit; import org.miaixz.bus.logger.Logger; import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; -import org.miaixz.bus.storage.magic.Message; import java.io.File; import java.io.IOException; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/MinioOssProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/MinioOssProvider.java index 9bdcd8e131..3299abd299 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/MinioOssProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/MinioOssProvider.java @@ -30,6 +30,7 @@ import io.minio.*; import io.minio.errors.*; import io.minio.messages.Item; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.MediaType; import org.miaixz.bus.core.xyz.IoKit; @@ -38,7 +39,6 @@ import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; import org.miaixz.bus.storage.magic.Material; -import org.miaixz.bus.storage.magic.Message; import java.io.*; import java.nio.file.Path; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/QiniuYunOssProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/QiniuYunOssProvider.java index 0732b1f4c6..7c6b9cb5f9 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/QiniuYunOssProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/QiniuYunOssProvider.java @@ -34,6 +34,7 @@ import com.qiniu.storage.Region; import com.qiniu.storage.UploadManager; import com.qiniu.util.Auth; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.Charset; import org.miaixz.bus.core.lang.Normal; @@ -43,7 +44,6 @@ import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; import org.miaixz.bus.storage.magic.Material; -import org.miaixz.bus.storage.magic.Message; import java.io.File; import java.io.InputStream; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/TencentCosProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/TencentCosProvider.java index f4be6ebdcc..13d7dd7b7d 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/TencentCosProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/TencentCosProvider.java @@ -35,13 +35,13 @@ import com.qcloud.cos.model.PutObjectRequest; import com.qcloud.cos.model.PutObjectResult; import com.qcloud.cos.region.Region; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.xyz.StringKit; import org.miaixz.bus.logger.Logger; import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; import org.miaixz.bus.storage.magic.Material; -import org.miaixz.bus.storage.magic.Message; import java.io.ByteArrayInputStream; import java.io.File; diff --git a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/UpyunOssProvider.java b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/UpyunOssProvider.java index 372bf60185..a87f2c70c7 100755 --- a/bus-storage/src/main/java/org/miaixz/bus/storage/metric/UpyunOssProvider.java +++ b/bus-storage/src/main/java/org/miaixz/bus/storage/metric/UpyunOssProvider.java @@ -29,12 +29,12 @@ import com.UpYun; import com.upyun.UpException; +import org.miaixz.bus.core.basics.entity.Message; import org.miaixz.bus.core.lang.Assert; import org.miaixz.bus.core.lang.Symbol; import org.miaixz.bus.logger.Logger; import org.miaixz.bus.storage.Context; import org.miaixz.bus.storage.magic.ErrorCode; -import org.miaixz.bus.storage.magic.Message; import java.io.File; import java.io.IOException; diff --git a/bus-tracer/pom.xml b/bus-tracer/pom.xml index bdb023f363..89d8989f03 100755 --- a/bus-tracer/pom.xml +++ b/bus-tracer/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-tracer - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -112,54 +112,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - - diff --git a/bus-validate/pom.xml b/bus-validate/pom.xml index 45d0a27247..634c22f82b 100755 --- a/bus-validate/pom.xml +++ b/bus-validate/pom.xml @@ -33,7 +33,7 @@ org.miaixz bus-validate - 8.0.2 + 8.0.5 jar ${project.artifactId} @@ -112,54 +112,44 @@ + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.3 + + + sonatype-nexus-staging + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.5.0 + true + + central + true + + - - - release - - - - org.apache.maven.plugins - maven-source-plugin - 3.3.1 - - - attach-sources - - jar-no-fork - - - - - - org.apache.maven.plugins - maven-gpg-plugin - 3.2.3 - - - sonatype-nexus-staging - verify - - sign - - - - - - org.sonatype.central - central-publishing-maven-plugin - 0.4.0 - true - - central - true - - - - - - -