Merge remote-tracking branch 'origin/develop' into wh/expression_utils
# Conflicts: # pom.xml # spring-boot-nebula-dependencies/pom.xml # spring-boot-nebula-web-common/src/main/java/com/nebula/web/common/utils/ExpressionUtil.java
This commit is contained in:
commit
3349fa1a44
|
@ -4,9 +4,11 @@ on:
|
|||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
junit:
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!--
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
-->
|
||||
<profiles version="13">
|
||||
<profile kind="CodeFormatterProfile" name="'ShardingSphere Apache Current'" version="13">
|
||||
<setting id="org.eclipse.jdt.core.compiler.source" value="1.8" />
|
||||
<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.8" />
|
||||
<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.8" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="true" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="200" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="200" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="1" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="160" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="10" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="106" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="106" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="106" />
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call.count_dependent" value="16|5|80" />
|
||||
</profile>
|
||||
</profiles>
|
139
pom.xml
139
pom.xml
|
@ -1,13 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>${revision}</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>spring-boot-nebula</name>
|
||||
<description>spring-boot-common</description>
|
||||
|
||||
<modules>
|
||||
<module>spring-boot-nebula-web</module>
|
||||
|
@ -22,29 +24,15 @@
|
|||
<module>spring-boot-nebula-all</module>
|
||||
</modules>
|
||||
|
||||
<name>spring-boot-nebula</name>
|
||||
<description>spring-boot-common</description>
|
||||
<url>https://github.com/weihubeats/spring-boot-common</url>
|
||||
|
||||
|
||||
<properties>
|
||||
<revision>0.0.01</revision>
|
||||
<flatten-maven-plugin.version>1.2.7</flatten-maven-plugin.version>
|
||||
<maven-gpg-plugin.version>3.0.1</maven-gpg-plugin.version>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -57,35 +45,6 @@
|
|||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>weihubeats</name>
|
||||
<email>weihu@apche.org</email>
|
||||
<organization>https://weihubeats.blog.csdn.net/</organization>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git@github.com:weihubeats/spring-boot-common.git</connection>
|
||||
<developerConnection>scm:git@github.com:weihubeats/spring-boot-common.git</developerConnection>
|
||||
<url>git@github.com:weihubeats/spring-boot-common.git</url>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>Github Issue</system>
|
||||
<url>https://github.com/weihubeats/spring-boot-common/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -118,10 +77,10 @@
|
|||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -143,10 +102,10 @@
|
|||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -158,10 +117,10 @@
|
|||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<phase>verify</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -177,32 +136,100 @@
|
|||
<executions>
|
||||
<execution>
|
||||
<id>flatten</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>flatten</goal>
|
||||
</goals>
|
||||
<phase>process-resources</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>flatten.clean</id>
|
||||
<phase>clean</phase>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
<phase>clean</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>${spotless-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<java>
|
||||
<eclipse>
|
||||
<file>${maven.multiModuleProjectDirectory}/dev-support/spotless_nebula_formatter.xml</file>
|
||||
</eclipse>
|
||||
<licenseHeader>
|
||||
<file>${maven.multiModuleProjectDirectory}/dev-support/license-header</file>
|
||||
</licenseHeader>
|
||||
</java>
|
||||
<pom>
|
||||
<sortPom>
|
||||
<encoding>UTF-8</encoding>
|
||||
<nrOfIndentSpace>4</nrOfIndentSpace>
|
||||
<keepBlankLines>true</keepBlankLines>
|
||||
<indentBlankLines>false</indentBlankLines>
|
||||
<indentSchemaLocation>true</indentSchemaLocation>
|
||||
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
|
||||
<sortModules>false</sortModules>
|
||||
<sortExecutions>false</sortExecutions>
|
||||
<predefinedSortOrder>custom_1</predefinedSortOrder>
|
||||
<expandEmptyElements>false</expandEmptyElements>
|
||||
<sortProperties>false</sortProperties>
|
||||
</sortPom>
|
||||
</pom>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>apply</goal>
|
||||
</goals>
|
||||
<phase>compile</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<url>https://github.com/weihubeats/spring-boot-common</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>weihubeats</name>
|
||||
<email>weihu@apche.org</email>
|
||||
<organization>https://weihubeats.blog.csdn.net/</organization>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git@github.com:weihubeats/spring-boot-common.git</connection>
|
||||
<developerConnection>scm:git@github.com:weihubeats/spring-boot-common.git</developerConnection>
|
||||
<url>git@github.com:weihubeats/spring-boot-common.git</url>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>Github Issue</system>
|
||||
<url>https://github.com/weihubeats/spring-boot-common/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>sonatype</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>sonatype</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
@ -11,7 +10,6 @@
|
|||
|
||||
<artifactId>spring-boot-nebula-aggregate</artifactId>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.aggregate.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.aggregate.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.aggregate.annotation;
|
||||
|
||||
import com.nebula.aggregate.core.AbstractOldObj;
|
||||
|
@ -19,7 +36,7 @@ import org.springframework.stereotype.Component;
|
|||
public class CreateOldObjAspect {
|
||||
|
||||
@AfterReturning(pointcut = "@annotation(com.nebula.aggregate.annotation.AggregateCreate) || " +
|
||||
"@annotation(com.nebula.aggregate.annotation.CreateOldObj)", returning = "returnVal")
|
||||
"@annotation(com.nebula.aggregate.annotation.CreateOldObj)", returning = "returnVal")
|
||||
public void handleRequestMethod(JoinPoint pjp, Object returnVal) {
|
||||
if (returnVal instanceof AbstractOldObj) {
|
||||
((AbstractOldObj) returnVal).setOldObject(copy(returnVal));
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.aggregate.core;
|
||||
|
||||
/**
|
||||
|
@ -7,4 +24,3 @@ package com.nebula.aggregate.core;
|
|||
*/
|
||||
public abstract class AbstractAggregate<T> extends AbstractOldObj<T> {
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.aggregate.core;
|
||||
|
||||
import org.javers.core.metamodel.annotation.DiffIgnore;
|
||||
|
@ -12,7 +29,6 @@ public abstract class AbstractOldObj<T> {
|
|||
@DiffIgnore
|
||||
private T oldObject;
|
||||
|
||||
|
||||
public void setOldObject(T oldObject) {
|
||||
this.oldObject = oldObject;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.aggregate.core;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
@ -112,9 +129,9 @@ public class AggregateDiff {
|
|||
* @param <T>
|
||||
*/
|
||||
public <T> void objectChangeFunction(Consumer<T> addConsume,
|
||||
Consumer<T> updateConsume,
|
||||
Consumer<T> deleteConsume,
|
||||
Class<T> clazz) {
|
||||
Consumer<T> updateConsume,
|
||||
Consumer<T> deleteConsume,
|
||||
Class<T> clazz) {
|
||||
Changes changes = this.diff.getChanges();
|
||||
for (Change change : changes) {
|
||||
if ((change instanceof NewObject && Objects.nonNull(addConsume))) {
|
||||
|
@ -143,11 +160,11 @@ public class AggregateDiff {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> void listChangeFunction(List<T> oldList,
|
||||
List<T> newList,
|
||||
Class<T> clazz,
|
||||
Consumer<List<T>> addConsume,
|
||||
Consumer<List<T>> updateConsume,
|
||||
Consumer<List<T>> removeConsume) {
|
||||
List<T> newList,
|
||||
Class<T> clazz,
|
||||
Consumer<List<T>> addConsume,
|
||||
Consumer<List<T>> updateConsume,
|
||||
Consumer<List<T>> removeConsume) {
|
||||
|
||||
initNegativeId(clazz, newList);
|
||||
Diff listDiff = javers.compareCollections(oldList, newList, clazz);
|
||||
|
@ -217,11 +234,11 @@ public class AggregateDiff {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> void collectionChangeFunction(Collection<T> oldList,
|
||||
Collection<T> newList,
|
||||
Class<T> clazz,
|
||||
Consumer<Map<String, T>> addConsume,
|
||||
Consumer<Map<String, T>> updateConsume,
|
||||
Consumer<Map<String, T>> removeConsume) {
|
||||
Collection<T> newList,
|
||||
Class<T> clazz,
|
||||
Consumer<Map<String, T>> addConsume,
|
||||
Consumer<Map<String, T>> updateConsume,
|
||||
Consumer<Map<String, T>> removeConsume) {
|
||||
|
||||
Diff listDiff = javers.compareCollections(oldList, newList, clazz);
|
||||
|
||||
|
@ -291,10 +308,10 @@ public class AggregateDiff {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> void simpleListChangeFunction(Collection<T> oldList,
|
||||
Collection<T> newList,
|
||||
Class<T> clazz,
|
||||
Consumer<List<T>> addConsume,
|
||||
Consumer<List<T>> removeConsume) {
|
||||
Collection<T> newList,
|
||||
Class<T> clazz,
|
||||
Consumer<List<T>> addConsume,
|
||||
Consumer<List<T>> removeConsume) {
|
||||
|
||||
Diff listDiff = javers.compareCollections(oldList, newList, clazz);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
@ -19,10 +18,10 @@
|
|||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
|
@ -34,8 +33,6 @@
|
|||
<artifactId>spring-boot-nebula-distribute-lock</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.aop.base;
|
||||
|
||||
import lombok.NonNull;
|
||||
|
@ -35,7 +52,7 @@ public class NebulaBaseAnnotationAdvisor extends AbstractPointcutAdvisor impleme
|
|||
private final Class<? extends Annotation> annotation;
|
||||
|
||||
public NebulaBaseAnnotationAdvisor(@NonNull MethodInterceptor advice,
|
||||
@NonNull Class<? extends Annotation> annotation) {
|
||||
@NonNull Class<? extends Annotation> annotation) {
|
||||
this.advice = advice;
|
||||
this.annotation = annotation;
|
||||
this.pointcut = buildPointcut();
|
||||
|
@ -87,6 +104,7 @@ public class NebulaBaseAnnotationAdvisor extends AbstractPointcutAdvisor impleme
|
|||
}
|
||||
|
||||
private static class AnnotationMethodMatcher extends StaticMethodMatcher {
|
||||
|
||||
private final Class<? extends Annotation> annotationType;
|
||||
|
||||
public AnnotationMethodMatcher(Class<? extends Annotation> annotationType) {
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>spring-boot-nebula</artifactId>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-boot-nebula-common</artifactId>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
@ -66,8 +64,6 @@
|
|||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.exception;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
@ -28,7 +45,7 @@ public class ExceptionUtil {
|
|||
*/
|
||||
public static RuntimeException unchecked(Throwable e) {
|
||||
if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
|
||||
|| e instanceof NoSuchMethodException) {
|
||||
|| e instanceof NoSuchMethodException) {
|
||||
return new IllegalArgumentException(e);
|
||||
} else if (e instanceof InvocationTargetException) {
|
||||
return new RuntimeException(((InvocationTargetException) e).getTargetException());
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
@ -9,7 +26,6 @@ import java.lang.reflect.Array;
|
|||
*/
|
||||
public class ArraysUtil {
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- wrap
|
||||
|
||||
/**
|
||||
|
@ -76,7 +92,6 @@ public class ArraysUtil {
|
|||
return elements;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- join
|
||||
|
||||
/**
|
||||
|
@ -110,7 +125,6 @@ public class ArraysUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Join <code>String</code> arrays.
|
||||
*/
|
||||
|
@ -318,7 +332,6 @@ public class ArraysUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- resize
|
||||
|
||||
/**
|
||||
|
@ -331,7 +344,6 @@ public class ArraysUtil {
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Resizes a <code>String</code> array.
|
||||
*/
|
||||
|
@ -413,7 +425,6 @@ public class ArraysUtil {
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- append
|
||||
|
||||
/**
|
||||
|
@ -506,7 +517,6 @@ public class ArraysUtil {
|
|||
return t;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- remove
|
||||
|
||||
/**
|
||||
|
@ -628,7 +638,6 @@ public class ArraysUtil {
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- subarray
|
||||
|
||||
/**
|
||||
|
@ -730,7 +739,6 @@ public class ArraysUtil {
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- insert
|
||||
|
||||
/**
|
||||
|
@ -969,7 +977,6 @@ public class ArraysUtil {
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- insertAt
|
||||
|
||||
/**
|
||||
|
@ -1091,10 +1098,8 @@ public class ArraysUtil {
|
|||
return temp;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- convert
|
||||
|
||||
|
||||
/**
|
||||
* Converts to primitive array.
|
||||
*/
|
||||
|
@ -1119,7 +1124,6 @@ public class ArraysUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts to primitive array.
|
||||
*/
|
||||
|
@ -1144,7 +1148,6 @@ public class ArraysUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts to primitive array.
|
||||
*/
|
||||
|
@ -1169,7 +1172,6 @@ public class ArraysUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts to primitive array.
|
||||
*/
|
||||
|
@ -1194,7 +1196,6 @@ public class ArraysUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts to primitive array.
|
||||
*/
|
||||
|
@ -1219,7 +1220,6 @@ public class ArraysUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts to primitive array.
|
||||
*/
|
||||
|
@ -1244,7 +1244,6 @@ public class ArraysUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts to primitive array.
|
||||
*/
|
||||
|
@ -1269,7 +1268,6 @@ public class ArraysUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts to primitive array.
|
||||
*/
|
||||
|
@ -1294,11 +1292,8 @@ public class ArraysUtil {
|
|||
return dest;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- indexof
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence of an element in an array.
|
||||
*/
|
||||
|
@ -1651,12 +1646,8 @@ public class ArraysUtil {
|
|||
return indexOf(array, value, startIndex) != -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- indexof 2
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array.
|
||||
*/
|
||||
|
@ -1667,7 +1658,6 @@ public class ArraysUtil {
|
|||
return indexOf(array, sub) != -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array from specified given position.
|
||||
*/
|
||||
|
@ -1685,8 +1675,7 @@ public class ArraysUtil {
|
|||
}
|
||||
final int total = endIndex - sublen + 1;
|
||||
final byte c = sub[0];
|
||||
mainloop:
|
||||
for (int i = startIndex; i < total; i++) {
|
||||
mainloop: for (int i = startIndex; i < total; i++) {
|
||||
if (array[i] != c) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1696,7 +1685,8 @@ public class ArraysUtil {
|
|||
if (sub[j] != array[k]) {
|
||||
continue mainloop;
|
||||
}
|
||||
j++; k++;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -1713,7 +1703,6 @@ public class ArraysUtil {
|
|||
return indexOf(array, sub) != -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array from specified given position.
|
||||
*/
|
||||
|
@ -1731,8 +1720,7 @@ public class ArraysUtil {
|
|||
}
|
||||
final int total = endIndex - sublen + 1;
|
||||
final char c = sub[0];
|
||||
mainloop:
|
||||
for (int i = startIndex; i < total; i++) {
|
||||
mainloop: for (int i = startIndex; i < total; i++) {
|
||||
if (array[i] != c) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1742,7 +1730,8 @@ public class ArraysUtil {
|
|||
if (sub[j] != array[k]) {
|
||||
continue mainloop;
|
||||
}
|
||||
j++; k++;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -1759,7 +1748,6 @@ public class ArraysUtil {
|
|||
return indexOf(array, sub) != -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array from specified given position.
|
||||
*/
|
||||
|
@ -1777,8 +1765,7 @@ public class ArraysUtil {
|
|||
}
|
||||
final int total = endIndex - sublen + 1;
|
||||
final short c = sub[0];
|
||||
mainloop:
|
||||
for (int i = startIndex; i < total; i++) {
|
||||
mainloop: for (int i = startIndex; i < total; i++) {
|
||||
if (array[i] != c) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1788,7 +1775,8 @@ public class ArraysUtil {
|
|||
if (sub[j] != array[k]) {
|
||||
continue mainloop;
|
||||
}
|
||||
j++; k++;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -1805,7 +1793,6 @@ public class ArraysUtil {
|
|||
return indexOf(array, sub) != -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array from specified given position.
|
||||
*/
|
||||
|
@ -1823,8 +1810,7 @@ public class ArraysUtil {
|
|||
}
|
||||
final int total = endIndex - sublen + 1;
|
||||
final int c = sub[0];
|
||||
mainloop:
|
||||
for (int i = startIndex; i < total; i++) {
|
||||
mainloop: for (int i = startIndex; i < total; i++) {
|
||||
if (array[i] != c) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1834,7 +1820,8 @@ public class ArraysUtil {
|
|||
if (sub[j] != array[k]) {
|
||||
continue mainloop;
|
||||
}
|
||||
j++; k++;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -1851,7 +1838,6 @@ public class ArraysUtil {
|
|||
return indexOf(array, sub) != -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array from specified given position.
|
||||
*/
|
||||
|
@ -1869,8 +1855,7 @@ public class ArraysUtil {
|
|||
}
|
||||
final int total = endIndex - sublen + 1;
|
||||
final long c = sub[0];
|
||||
mainloop:
|
||||
for (int i = startIndex; i < total; i++) {
|
||||
mainloop: for (int i = startIndex; i < total; i++) {
|
||||
if (array[i] != c) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1880,7 +1865,8 @@ public class ArraysUtil {
|
|||
if (sub[j] != array[k]) {
|
||||
continue mainloop;
|
||||
}
|
||||
j++; k++;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -1897,7 +1883,6 @@ public class ArraysUtil {
|
|||
return indexOf(array, sub) != -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array from specified given position.
|
||||
*/
|
||||
|
@ -1915,8 +1900,7 @@ public class ArraysUtil {
|
|||
}
|
||||
final int total = endIndex - sublen + 1;
|
||||
final boolean c = sub[0];
|
||||
mainloop:
|
||||
for (int i = startIndex; i < total; i++) {
|
||||
mainloop: for (int i = startIndex; i < total; i++) {
|
||||
if (array[i] != c) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1926,7 +1910,8 @@ public class ArraysUtil {
|
|||
if (sub[j] != array[k]) {
|
||||
continue mainloop;
|
||||
}
|
||||
j++; k++;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -1943,7 +1928,6 @@ public class ArraysUtil {
|
|||
return indexOf(array, sub) != -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array from specified given position.
|
||||
*/
|
||||
|
@ -1961,8 +1945,7 @@ public class ArraysUtil {
|
|||
}
|
||||
final int total = endIndex - sublen + 1;
|
||||
final float c = sub[0];
|
||||
mainloop:
|
||||
for (int i = startIndex; i < total; i++) {
|
||||
mainloop: for (int i = startIndex; i < total; i++) {
|
||||
if (Float.compare(array[i], c) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1972,7 +1955,8 @@ public class ArraysUtil {
|
|||
if (Float.compare(sub[j], array[k]) != 0) {
|
||||
continue mainloop;
|
||||
}
|
||||
j++; k++;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
@ -1989,7 +1973,6 @@ public class ArraysUtil {
|
|||
return indexOf(array, sub) != -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first occurrence in an array from specified given position.
|
||||
*/
|
||||
|
@ -2007,8 +1990,7 @@ public class ArraysUtil {
|
|||
}
|
||||
final int total = endIndex - sublen + 1;
|
||||
final double c = sub[0];
|
||||
mainloop:
|
||||
for (int i = startIndex; i < total; i++) {
|
||||
mainloop: for (int i = startIndex; i < total; i++) {
|
||||
if (Double.compare(array[i], c) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2018,14 +2000,14 @@ public class ArraysUtil {
|
|||
if (Double.compare(sub[j], array[k]) != 0) {
|
||||
continue mainloop;
|
||||
}
|
||||
j++; k++;
|
||||
j++;
|
||||
k++;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- toString
|
||||
|
||||
/**
|
||||
|
@ -2238,7 +2220,6 @@ public class ArraysUtil {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts an array to string array.
|
||||
*/
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
@ -433,6 +450,6 @@ public class CharUtil {
|
|||
return HEX_CHARS[i];
|
||||
}
|
||||
|
||||
public static final char[] HEX_CHARS = new char[] {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
public static final char[] HEX_CHARS = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
|
@ -32,20 +49,20 @@ public interface ClassLoaderStrategy {
|
|||
/**
|
||||
* List of primitive type names.
|
||||
*/
|
||||
public static final String[] PRIMITIVE_TYPE_NAMES = new String[] {
|
||||
"boolean", "byte", "char", "double", "float", "int", "long", "short",
|
||||
public static final String[] PRIMITIVE_TYPE_NAMES = new String[]{
|
||||
"boolean", "byte", "char", "double", "float", "int", "long", "short",
|
||||
};
|
||||
/**
|
||||
* List of primitive types that matches names list.
|
||||
*/
|
||||
public static final Class[] PRIMITIVE_TYPES = new Class[] {
|
||||
boolean.class, byte.class, char.class, double.class, float.class, int.class, long.class, short.class,
|
||||
public static final Class[] PRIMITIVE_TYPES = new Class[]{
|
||||
boolean.class, byte.class, char.class, double.class, float.class, int.class, long.class, short.class,
|
||||
};
|
||||
/**
|
||||
* List of primitive bytecode characters that matches names list.
|
||||
*/
|
||||
public static final char[] PRIMITIVE_BYTECODE_NAME = new char[] {
|
||||
'Z', 'B', 'C', 'D', 'F', 'I', 'J', 'S'
|
||||
public static final char[] PRIMITIVE_BYTECODE_NAME = new char[]{
|
||||
'Z', 'B', 'C', 'D', 'F', 'I', 'J', 'S'
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------- flags
|
||||
|
@ -147,7 +164,7 @@ public interface ClassLoaderStrategy {
|
|||
}
|
||||
|
||||
// try #3 - using caller classloader, similar as Class.forName()
|
||||
//Class callerClass = ReflectUtil.getCallerClass(2);
|
||||
// Class callerClass = ReflectUtil.getCallerClass(2);
|
||||
final Class callerClass = ClassUtil.getCallerClass();
|
||||
final ClassLoader callerClassLoader = callerClass.getClassLoader();
|
||||
|
||||
|
@ -201,7 +218,7 @@ public interface ClassLoaderStrategy {
|
|||
* Loads array class using component type.
|
||||
*/
|
||||
protected Class loadArrayClassByComponentType(final String className,
|
||||
final ClassLoader classLoader) throws ClassNotFoundException {
|
||||
final ClassLoader classLoader) throws ClassNotFoundException {
|
||||
final int ndx = className.indexOf('[');
|
||||
final int multi = StringUtils.count(className, '[');
|
||||
|
||||
|
@ -216,9 +233,9 @@ public interface ClassLoaderStrategy {
|
|||
final int[] multiSizes;
|
||||
|
||||
if (multi == 2) {
|
||||
multiSizes = new int[] {0, 0};
|
||||
multiSizes = new int[]{0, 0};
|
||||
} else if (multi == 3) {
|
||||
multiSizes = new int[] {0, 0, 0};
|
||||
multiSizes = new int[]{0, 0, 0};
|
||||
} else {
|
||||
multiSizes = (int[]) Array.newInstance(int.class, multi);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import com.nebula.base.utils.io.IOUtil;
|
||||
|
@ -42,7 +59,7 @@ public class ClassLoaderUtil {
|
|||
return Thread.currentThread().getContextClassLoader();
|
||||
} else {
|
||||
return AccessController.doPrivileged(
|
||||
(PrivilegedAction<ClassLoader>) () -> Thread.currentThread().getContextClassLoader());
|
||||
(PrivilegedAction<ClassLoader>) () -> Thread.currentThread().getContextClassLoader());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +71,7 @@ public class ClassLoaderUtil {
|
|||
return ClassLoader.getSystemClassLoader();
|
||||
} else {
|
||||
return AccessController.doPrivileged(
|
||||
(PrivilegedAction<ClassLoader>) ClassLoader::getSystemClassLoader);
|
||||
(PrivilegedAction<ClassLoader>) ClassLoader::getSystemClassLoader);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -140,7 +157,7 @@ public class ClassLoaderUtil {
|
|||
* Opens a class of the specified name for reading using provided class loader.
|
||||
*/
|
||||
public static InputStream getClassAsStream(final String className,
|
||||
final ClassLoader classLoader) throws IOException {
|
||||
final ClassLoader classLoader) throws IOException {
|
||||
return ResourcesUtil.getResourceAsStream(ClassUtil.convertClassNameToFileName(className), classLoader);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -251,26 +268,26 @@ public class ClassUtil {
|
|||
if (Modifier.isVolatile(method.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
// if (Modifier.isAbstract(method.getModifiers())) {
|
||||
// continue;
|
||||
// }
|
||||
if (top) { // add all top declared methods
|
||||
// if (Modifier.isAbstract(method.getModifiers())) {
|
||||
// continue;
|
||||
// }
|
||||
if (top) { // add all top declared methods
|
||||
methodList.add(method);
|
||||
continue;
|
||||
}
|
||||
final int modifier = method.getModifiers();
|
||||
if (Modifier.isPrivate(modifier)) {
|
||||
continue; // ignore super private methods
|
||||
continue; // ignore super private methods
|
||||
}
|
||||
if (Modifier.isAbstract(modifier)) { // ignore super abstract methods
|
||||
if (Modifier.isAbstract(modifier)) { // ignore super abstract methods
|
||||
continue;
|
||||
}
|
||||
if (Modifier.isPublic(modifier)) {
|
||||
addMethodIfNotExist(methodList, method); // add super public methods
|
||||
addMethodIfNotExist(methodList, method); // add super public methods
|
||||
continue;
|
||||
}
|
||||
if (Modifier.isProtected(modifier)) {
|
||||
addMethodIfNotExist(methodList, method); // add super protected methods
|
||||
addMethodIfNotExist(methodList, method); // add super protected methods
|
||||
continue;
|
||||
}
|
||||
// add super default methods from the same package
|
||||
|
@ -281,8 +298,7 @@ public class ClassUtil {
|
|||
}
|
||||
}
|
||||
top = false;
|
||||
}
|
||||
while ((clazz = clazz.getSuperclass()) != limit);
|
||||
} while ((clazz = clazz.getSuperclass()) != limit);
|
||||
|
||||
final Method[] methods = new Method[methodList.size()];
|
||||
for (int i = 0; i < methods.length; i++) {
|
||||
|
@ -317,20 +333,20 @@ public class ClassUtil {
|
|||
}
|
||||
final Field[] declaredFields = clazz.getDeclaredFields();
|
||||
for (final Field field : declaredFields) {
|
||||
if (top) { // add all top declared fields
|
||||
if (top) { // add all top declared fields
|
||||
fieldList.add(field);
|
||||
continue;
|
||||
}
|
||||
final int modifier = field.getModifiers();
|
||||
if (Modifier.isPrivate(modifier)) {
|
||||
continue; // ignore super private fields
|
||||
continue; // ignore super private fields
|
||||
}
|
||||
if (Modifier.isPublic(modifier)) {
|
||||
addFieldIfNotExist(fieldList, field); // add super public methods
|
||||
addFieldIfNotExist(fieldList, field); // add super public methods
|
||||
continue;
|
||||
}
|
||||
if (Modifier.isProtected(modifier)) {
|
||||
addFieldIfNotExist(fieldList, field); // add super protected methods
|
||||
addFieldIfNotExist(fieldList, field); // add super protected methods
|
||||
continue;
|
||||
}
|
||||
// add super default methods from the same package
|
||||
|
@ -341,8 +357,7 @@ public class ClassUtil {
|
|||
}
|
||||
}
|
||||
top = false;
|
||||
}
|
||||
while ((clazz = clazz.getSuperclass()) != limit);
|
||||
} while ((clazz = clazz.getSuperclass()) != limit);
|
||||
|
||||
final Field[] fields = new Field[fieldList.size()];
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
|
@ -524,7 +539,7 @@ public class ClassUtil {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T newInstance(final Class<T> clazz,
|
||||
final Object... params) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
|
||||
final Object... params) throws InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException {
|
||||
if (params.length == 0) {
|
||||
return newInstance(clazz);
|
||||
}
|
||||
|
@ -549,7 +564,7 @@ public class ClassUtil {
|
|||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T newInstance(
|
||||
final Class<T> type) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
|
||||
final Class<T> type) throws IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
|
||||
if (type.isPrimitive()) {
|
||||
if (type == int.class) {
|
||||
return (T) Integer.valueOf(0);
|
||||
|
@ -688,16 +703,16 @@ public class ClassUtil {
|
|||
final String methodName = method.getName();
|
||||
final Class returnType = method.getReturnType();
|
||||
final Class[] paramTypes = method.getParameterTypes();
|
||||
if (methodName.startsWith(METHOD_GET_PREFIX)) { // getter method must starts with 'get' and it is not getClass()
|
||||
if ((returnType != null) && (paramTypes.length == 0)) { // getter must have a return type and no arguments
|
||||
if (methodName.startsWith(METHOD_GET_PREFIX)) { // getter method must starts with 'get' and it is not getClass()
|
||||
if ((returnType != null) && (paramTypes.length == 0)) { // getter must have a return type and no arguments
|
||||
return true;
|
||||
}
|
||||
} else if (methodName.startsWith(METHOD_IS_PREFIX)) { // ister must starts with 'is'
|
||||
if ((returnType != null) && (paramTypes.length == 0)) { // ister must have return type and no arguments
|
||||
} else if (methodName.startsWith(METHOD_IS_PREFIX)) { // ister must starts with 'is'
|
||||
if ((returnType != null) && (paramTypes.length == 0)) { // ister must have return type and no arguments
|
||||
return true;
|
||||
}
|
||||
} else if (methodName.startsWith(METHOD_SET_PREFIX)) { // setter must start with a 'set'
|
||||
if (paramTypes.length == 1) { // setter must have just one argument
|
||||
} else if (methodName.startsWith(METHOD_SET_PREFIX)) { // setter must start with a 'set'
|
||||
if (paramTypes.length == 1) { // setter must have just one argument
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -718,12 +733,12 @@ public class ClassUtil {
|
|||
final String methodName = method.getName();
|
||||
final Class returnType = method.getReturnType();
|
||||
final Class[] paramTypes = method.getParameterTypes();
|
||||
if (methodName.startsWith(METHOD_GET_PREFIX)) { // getter method must starts with 'get' and it is not getClass()
|
||||
if ((returnType != null) && (paramTypes.length == 0)) { // getter must have a return type and no arguments
|
||||
if (methodName.startsWith(METHOD_GET_PREFIX)) { // getter method must starts with 'get' and it is not getClass()
|
||||
if ((returnType != null) && (paramTypes.length == 0)) { // getter must have a return type and no arguments
|
||||
return 3;
|
||||
}
|
||||
} else if (methodName.startsWith(METHOD_IS_PREFIX)) { // ister must starts with 'is'
|
||||
if ((returnType != null) && (paramTypes.length == 0)) { // ister must have return type and no arguments
|
||||
} else if (methodName.startsWith(METHOD_IS_PREFIX)) { // ister must starts with 'is'
|
||||
if ((returnType != null) && (paramTypes.length == 0)) { // ister must have return type and no arguments
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
@ -756,8 +771,8 @@ public class ClassUtil {
|
|||
}
|
||||
final String methodName = method.getName();
|
||||
final Class[] paramTypes = method.getParameterTypes();
|
||||
if (methodName.startsWith(METHOD_SET_PREFIX)) { // setter must start with a 'set'
|
||||
if (paramTypes.length == 1) { // setter must have just one argument
|
||||
if (methodName.startsWith(METHOD_SET_PREFIX)) { // setter must start with a 'set'
|
||||
if (paramTypes.length == 1) { // setter must have just one argument
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
@ -840,7 +855,7 @@ public class ClassUtil {
|
|||
if (type instanceof Class) {
|
||||
final Class clazz = (Class) type;
|
||||
if (clazz.isArray()) {
|
||||
return new Class[] {clazz.getComponentType()};
|
||||
return new Class[]{clazz.getComponentType()};
|
||||
}
|
||||
} else if (type instanceof ParameterizedType) {
|
||||
final ParameterizedType pt = (ParameterizedType) type;
|
||||
|
@ -865,7 +880,7 @@ public class ClassUtil {
|
|||
return null;
|
||||
}
|
||||
|
||||
return new Class[] {rawType};
|
||||
return new Class[]{rawType};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1107,6 +1122,7 @@ public class ClassUtil {
|
|||
// ---------------------------------------------------------------- caller
|
||||
|
||||
private static class ReflectUtilSecurityManager extends SecurityManager {
|
||||
|
||||
public Class getCallerClass(final int callStackDepth) {
|
||||
return getClassContext()[callStackDepth + 1];
|
||||
}
|
||||
|
@ -1247,7 +1263,7 @@ public class ClassUtil {
|
|||
*/
|
||||
public static JarFile jarFileOf(final Class<?> klass) {
|
||||
final URL url = klass.getResource(
|
||||
"/" + klass.getName().replace('.', '/') + ".class");
|
||||
"/" + klass.getName().replace('.', '/') + ".class");
|
||||
|
||||
if (url == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -129,8 +146,8 @@ public class DataUtils {
|
|||
*/
|
||||
public static <T, S> T getDefaultValue(S value, T defaultValue, Function<S, T> function) {
|
||||
return isNotEmpty(value)
|
||||
? function.apply(value)
|
||||
: defaultValue;
|
||||
? function.apply(value)
|
||||
: defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,8 +162,8 @@ public class DataUtils {
|
|||
public static <T, S> T getDefaultValueSafety(S value, T defaultValue, Function<S, T> function) {
|
||||
try {
|
||||
return isNotEmpty(value)
|
||||
? function.apply(value)
|
||||
: defaultValue;
|
||||
? function.apply(value)
|
||||
: defaultValue;
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import com.nebula.base.utils.io.IOUtil;
|
||||
|
@ -47,8 +64,7 @@ public interface DigestEngine {
|
|||
|
||||
while (dis.read() != -1) {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
IOUtil.close(dis);
|
||||
IOUtil.close(bis);
|
||||
IOUtil.close(fis);
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
|
@ -17,7 +34,6 @@ import java.time.LocalTime;
|
|||
*/
|
||||
public class JacksonTimeModule extends SimpleModule {
|
||||
|
||||
|
||||
public JacksonTimeModule() {
|
||||
super(PackageVersion.VERSION);
|
||||
this.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(TimeUtil.DATETIME_FORMAT));
|
||||
|
@ -28,5 +44,4 @@ public class JacksonTimeModule extends SimpleModule {
|
|||
this.addSerializer(LocalTime.class, new LocalTimeSerializer(TimeUtil.TIME_FORMAT));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
@ -33,8 +50,7 @@ public class JsonUtil {
|
|||
public static <T> String toJSONString(T value) {
|
||||
try {
|
||||
return getInstance().writeValueAsString(value);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
|
@ -43,8 +59,7 @@ public class JsonUtil {
|
|||
public static <T> String toJSONString(ObjectMapper objectMapper, T value) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(value);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
|
@ -70,8 +85,7 @@ public class JsonUtil {
|
|||
public static byte[] toJsonAsBytes(Object object) {
|
||||
try {
|
||||
return getInstance().writeValueAsBytes(object);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
} catch (JsonProcessingException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -87,8 +101,7 @@ public class JsonUtil {
|
|||
public static <T> T json2JavaBean(String content, Class<T> valueType) {
|
||||
try {
|
||||
return getInstance().readValue(content, valueType);
|
||||
}
|
||||
catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
|
@ -105,8 +118,7 @@ public class JsonUtil {
|
|||
public static <T> T json2JavaBean(String content, TypeReference<T> typeReference) {
|
||||
try {
|
||||
return getInstance().readValue(content, typeReference);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -122,13 +134,11 @@ public class JsonUtil {
|
|||
public static <T> T json2JavaBean(byte[] bytes, Class<T> valueType) {
|
||||
try {
|
||||
return getInstance().readValue(bytes, valueType);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将json反序列化成对象
|
||||
*
|
||||
|
@ -140,8 +150,7 @@ public class JsonUtil {
|
|||
public static <T> T json2JavaBean(byte[] bytes, TypeReference<T> typeReference) {
|
||||
try {
|
||||
return getInstance().readValue(bytes, typeReference);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -157,8 +166,7 @@ public class JsonUtil {
|
|||
public static <T> T json2JavaBean(InputStream in, Class<T> valueType) {
|
||||
try {
|
||||
return getInstance().readValue(in, valueType);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -174,8 +182,7 @@ public class JsonUtil {
|
|||
public static <T> T json2JavaBean(InputStream in, TypeReference<T> typeReference) {
|
||||
try {
|
||||
return getInstance().readValue(in, typeReference);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -188,8 +195,7 @@ public class JsonUtil {
|
|||
JavaType javaType = getInstance().getTypeFactory().constructParametricType(List.class, valueTypeRef);
|
||||
try {
|
||||
return getInstance().readValue(json, javaType);
|
||||
}
|
||||
catch (JsonProcessingException e) {
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return objectList;
|
||||
|
@ -200,14 +206,12 @@ public class JsonUtil {
|
|||
List<T> objectList = Collections.emptyList();
|
||||
try {
|
||||
return reader.readValue(jsonNode);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return objectList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* json to Map
|
||||
* @param content
|
||||
|
@ -216,8 +220,7 @@ public class JsonUtil {
|
|||
public static Map<String, Object> json2Map(String content) {
|
||||
try {
|
||||
return getInstance().readValue(content, Map.class);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
|
@ -232,8 +235,7 @@ public class JsonUtil {
|
|||
result.put(entry.getKey(), toPojo(entry.getValue(), valueTypeRef));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return null;
|
||||
|
@ -252,8 +254,7 @@ public class JsonUtil {
|
|||
public static JsonNode json2JsonNode(String jsonString) {
|
||||
try {
|
||||
return getInstance().readTree(jsonString);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -266,8 +267,7 @@ public class JsonUtil {
|
|||
public static String jsonNodeToString(JsonNode jsonNode) {
|
||||
try {
|
||||
return getInstance().writeValueAsString(jsonNode);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -281,8 +281,7 @@ public class JsonUtil {
|
|||
public static JsonNode byte2JsonNode(byte[] content) {
|
||||
try {
|
||||
return getInstance().readTree(content);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -296,8 +295,7 @@ public class JsonUtil {
|
|||
public static JsonNode json2JsonNode(InputStream in) {
|
||||
try {
|
||||
return getInstance().readTree(in);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -311,8 +309,7 @@ public class JsonUtil {
|
|||
public static JsonNode json2JsonNode(byte[] content) {
|
||||
try {
|
||||
return getInstance().readTree(content);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -326,8 +323,7 @@ public class JsonUtil {
|
|||
public static JsonNode json2JsonNode(JsonParser jsonParser) {
|
||||
try {
|
||||
return getInstance().readTree(jsonParser);
|
||||
}
|
||||
catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
throw ExceptionUtil.unchecked(e);
|
||||
}
|
||||
}
|
||||
|
@ -336,7 +332,6 @@ public class JsonUtil {
|
|||
return JacksonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
private static class JacksonHolder {
|
||||
|
||||
private static final ObjectMapper INSTANCE = new JacksonObjectMapper();
|
||||
|
@ -350,27 +345,27 @@ public class JsonUtil {
|
|||
|
||||
public JacksonObjectMapper() {
|
||||
super();
|
||||
//设置地点为中国
|
||||
// 设置地点为中国
|
||||
super.setLocale(CHINA);
|
||||
super.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
//去掉默认的时间戳格式
|
||||
// 去掉默认的时间戳格式
|
||||
super.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
|
||||
//设置为中国上海时区
|
||||
// 设置为中国上海时区
|
||||
super.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()));
|
||||
//序列化时,日期的统一格式
|
||||
// 序列化时,日期的统一格式
|
||||
super.setDateFormat(new SimpleDateFormat(TimeUtil.YYYYMMddHHmmss, Locale.CHINA));
|
||||
//序列化处理
|
||||
// 序列化处理
|
||||
super.configure(JsonReadFeature.ALLOW_UNESCAPED_CONTROL_CHARS.mappedFeature(), true);
|
||||
super.configure(JsonReadFeature.ALLOW_BACKSLASH_ESCAPING_ANY_CHARACTER.mappedFeature(), true);
|
||||
super.findAndRegisterModules();
|
||||
//失败处理
|
||||
// 失败处理
|
||||
super.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
||||
super.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
//单引号处理
|
||||
// 单引号处理
|
||||
super.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
|
||||
//反序列化时,属性不存在的兼容处理
|
||||
// 反序列化时,属性不存在的兼容处理
|
||||
super.getDeserializationConfig().withoutFeatures(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
//日期格式化
|
||||
// 日期格式化
|
||||
super.registerModule(new JacksonTimeModule());
|
||||
super.findAndRegisterModules();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
@ -94,5 +111,4 @@ public enum PatternEnum {
|
|||
return pattern.matcher(input).matches();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
|
@ -25,7 +42,6 @@ public class ReflectionUtils {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ReflectionUtils.class);
|
||||
|
||||
|
||||
/**
|
||||
* 获取 Function 名
|
||||
* @param func
|
||||
|
@ -72,9 +88,9 @@ public class ReflectionUtils {
|
|||
*/
|
||||
public static <T> boolean isExistFieldName(String fieldName, Class<T> clazz) {
|
||||
boolean flag = false;
|
||||
//获取这个类的所有属性
|
||||
// 获取这个类的所有属性
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
//循环遍历所有的fields
|
||||
// 循环遍历所有的fields
|
||||
for (Field field : fields) {
|
||||
if (field.getName().equals(fieldName)) {
|
||||
flag = true;
|
||||
|
@ -86,9 +102,9 @@ public class ReflectionUtils {
|
|||
|
||||
public static <T, V extends Annotation> boolean isExistFieldName(String fieldName, Class<T> clazz, Class<V> annotationClass) {
|
||||
boolean flag = false;
|
||||
//获取这个类的所有属性
|
||||
// 获取这个类的所有属性
|
||||
Field[] fields = clazz.getDeclaredFields();
|
||||
//循环遍历所有的fields
|
||||
// 循环遍历所有的fields
|
||||
for (Field field : fields) {
|
||||
if (field.getName().equals(fieldName) && Objects.nonNull(field.getAnnotation(annotationClass))) {
|
||||
flag = true;
|
||||
|
@ -98,7 +114,6 @@ public class ReflectionUtils {
|
|||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取指定属性
|
||||
*
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -270,7 +287,7 @@ public class RegexUtils {
|
|||
var length = str.length() - 1;
|
||||
|
||||
int fuzzyLength = lastIndexOf - firstIndex + 1;
|
||||
//todo 后续再重构兼容星不连续类型字段
|
||||
// todo 后续再重构兼容星不连续类型字段
|
||||
if (fuzzyLength == length + 1) {
|
||||
throw new RuntimeException("暂时不兼容该类型字段");
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import com.nebula.base.utils.io.IOUtil;
|
||||
|
@ -80,8 +97,7 @@ public class ResourcesUtil {
|
|||
try {
|
||||
final char[] data = IOUtil.readChars(inputStream);
|
||||
return new String(data);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
IOUtil.close(inputStream);
|
||||
}
|
||||
}
|
||||
|
@ -122,5 +138,4 @@ public class ResourcesUtil {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -124,7 +141,7 @@ public class StringUtils {
|
|||
|
||||
public static String[] splitc(final String src, final char[] delimiters) {
|
||||
if ((delimiters.length == 0) || (src.isEmpty())) {
|
||||
return new String[] {src};
|
||||
return new String[]{src};
|
||||
}
|
||||
final char[] srcc = src.toCharArray();
|
||||
|
||||
|
@ -136,14 +153,14 @@ public class StringUtils {
|
|||
|
||||
start[0] = 0;
|
||||
int s = 0, e;
|
||||
if (CharUtil.equalsOne(srcc[0], delimiters)) { // string starts with delimiter
|
||||
if (CharUtil.equalsOne(srcc[0], delimiters)) { // string starts with delimiter
|
||||
end[0] = 0;
|
||||
count++;
|
||||
s = CharUtil.findFirstDiff(srcc, 1, delimiters);
|
||||
if (s == -1) { // nothing after delimiters
|
||||
return new String[] {EMPTY, EMPTY};
|
||||
if (s == -1) { // nothing after delimiters
|
||||
return new String[]{EMPTY, EMPTY};
|
||||
}
|
||||
start[1] = s; // new start
|
||||
start[1] = s; // new start
|
||||
}
|
||||
while (true) {
|
||||
// find new end
|
||||
|
@ -173,7 +190,7 @@ public class StringUtils {
|
|||
|
||||
public static String[] splitc(final String src, final char delimiter) {
|
||||
if (src.isEmpty()) {
|
||||
return new String[] {EMPTY};
|
||||
return new String[]{EMPTY};
|
||||
}
|
||||
final char[] srcc = src.toCharArray();
|
||||
|
||||
|
@ -185,14 +202,14 @@ public class StringUtils {
|
|||
|
||||
start[0] = 0;
|
||||
int s = 0, e;
|
||||
if (srcc[0] == delimiter) { // string starts with delimiter
|
||||
if (srcc[0] == delimiter) { // string starts with delimiter
|
||||
end[0] = 0;
|
||||
count++;
|
||||
s = CharUtil.findFirstDiff(srcc, 1, delimiter);
|
||||
if (s == -1) { // nothing after delimiters
|
||||
return new String[] {EMPTY, EMPTY};
|
||||
if (s == -1) { // nothing after delimiters
|
||||
return new String[]{EMPTY, EMPTY};
|
||||
}
|
||||
start[1] = s; // new start
|
||||
start[1] = s; // new start
|
||||
}
|
||||
while (true) {
|
||||
// find new end
|
||||
|
@ -222,12 +239,13 @@ public class StringUtils {
|
|||
|
||||
public static String[] splitc(final String src, final String d) {
|
||||
if ((d.isEmpty()) || (src.isEmpty())) {
|
||||
return new String[] {src};
|
||||
return new String[]{src};
|
||||
}
|
||||
return splitc(src, d.toCharArray());
|
||||
}
|
||||
|
||||
public static class MessageFormatter {
|
||||
|
||||
static final char DELIM_START = '{';
|
||||
static final char DELIM_STOP = '}';
|
||||
static final String DELIM_STR = "{}";
|
||||
|
@ -265,7 +283,7 @@ public class StringUtils {
|
|||
}
|
||||
|
||||
final public static FormattingTuple arrayFormat(final String messagePattern, final Object[] argArray,
|
||||
Throwable throwable) {
|
||||
Throwable throwable) {
|
||||
|
||||
if (messagePattern == null) {
|
||||
return new FormattingTuple(null, argArray, throwable);
|
||||
|
@ -559,10 +577,10 @@ public class StringUtils {
|
|||
return Lists.newArrayList();
|
||||
}
|
||||
return Splitter.on(",").omitEmptyStrings()
|
||||
.trimResults().splitToList(str.trim())
|
||||
.stream()
|
||||
.filter(NumberUtils::isDigits)
|
||||
.map(Long::parseLong).collect(Collectors.toList());
|
||||
.trimResults().splitToList(str.trim())
|
||||
.stream()
|
||||
.filter(NumberUtils::isDigits)
|
||||
.map(Long::parseLong).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -573,10 +591,10 @@ public class StringUtils {
|
|||
return Lists.newArrayList();
|
||||
}
|
||||
return Splitter.on(",").omitEmptyStrings()
|
||||
.trimResults().splitToList(str.trim())
|
||||
.stream()
|
||||
.filter(NumberUtils::isDigits)
|
||||
.map(Integer::parseInt).collect(Collectors.toList());
|
||||
.trimResults().splitToList(str.trim())
|
||||
.stream()
|
||||
.filter(NumberUtils::isDigits)
|
||||
.map(Integer::parseInt).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -646,7 +664,7 @@ public class StringUtils {
|
|||
}
|
||||
char c = s.charAt(0);
|
||||
return (c > 0x3130 && c < 0x318F)
|
||||
|| (c >= 0xAC00 && c <= 0xD7A3);
|
||||
|| (c >= 0xAC00 && c <= 0xD7A3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -764,8 +782,7 @@ public class StringUtils {
|
|||
sb.append(s, c, i);
|
||||
sb.append(with);
|
||||
c = i + sub.length();
|
||||
}
|
||||
while ((i = s.indexOf(sub, c)) != -1);
|
||||
} while ((i = s.indexOf(sub, c)) != -1);
|
||||
if (c < length) {
|
||||
sb.append(s, c, length);
|
||||
}
|
||||
|
@ -818,8 +835,8 @@ public class StringUtils {
|
|||
return name;
|
||||
}
|
||||
if (name.length() > 1 &&
|
||||
Character.isUpperCase(name.charAt(1)) &&
|
||||
Character.isUpperCase(name.charAt(0))) {
|
||||
Character.isUpperCase(name.charAt(1)) &&
|
||||
Character.isUpperCase(name.charAt(0))) {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -21,6 +38,7 @@ public class SystemInfo {
|
|||
* is forbidden in Android, we will get an exception.
|
||||
*/
|
||||
private static class HostInfoLazy {
|
||||
|
||||
private final String HOST_NAME;
|
||||
private final String HOST_ADDRESS;
|
||||
|
||||
|
@ -232,7 +250,6 @@ public class SystemInfo {
|
|||
return packages.toArray(new String[0]);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- java checks
|
||||
|
||||
private int detectJavaVersionNumber() {
|
||||
|
@ -268,7 +285,6 @@ public class SystemInfo {
|
|||
return JAVA_VERSION_NUMBER == version;
|
||||
}
|
||||
|
||||
|
||||
private final String OS_VERSION = SystemUtil.get("os.version");
|
||||
private final String OS_ARCH = SystemUtil.get("os.arch");
|
||||
private final String OS_NAME = SystemUtil.get("os.name");
|
||||
|
@ -324,7 +340,6 @@ public class SystemInfo {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public final boolean isAix() {
|
||||
return IS_OS_AIX;
|
||||
}
|
||||
|
@ -433,35 +448,35 @@ public class SystemInfo {
|
|||
/**
|
||||
* Returns MAX memory.
|
||||
*/
|
||||
public final long getMaxMemory(){
|
||||
public final long getMaxMemory() {
|
||||
return runtime.maxMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns TOTAL memory.
|
||||
*/
|
||||
public final long getTotalMemory(){
|
||||
public final long getTotalMemory() {
|
||||
return runtime.totalMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns FREE memory.
|
||||
*/
|
||||
public final long getFreeMemory(){
|
||||
public final long getFreeMemory() {
|
||||
return runtime.freeMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns usable memory.
|
||||
*/
|
||||
public final long getAvailableMemory(){
|
||||
public final long getAvailableMemory() {
|
||||
return runtime.maxMemory() - runtime.totalMemory() + runtime.freeMemory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns used memory.
|
||||
*/
|
||||
public final long getUsedMemory(){
|
||||
public final long getUsedMemory() {
|
||||
return runtime.totalMemory() - runtime.freeMemory();
|
||||
}
|
||||
|
||||
|
@ -481,7 +496,6 @@ public class SystemInfo {
|
|||
|
||||
// ---------------------------------------------------------------- user
|
||||
|
||||
|
||||
private final String USER_NAME = SystemUtil.get("user.name");
|
||||
private final String USER_HOME = nosep(SystemUtil.get("user.home"));
|
||||
private final String USER_DIR = nosep(SystemUtil.get("user.dir"));
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.security.AccessController;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
@ -30,8 +47,7 @@ public class ThreadFactoryImpl implements ThreadFactory {
|
|||
Thread thread = new Thread(r, threadNamePrefix + this.threadIndex.incrementAndGet());
|
||||
thread.setDaemon(daemon);
|
||||
|
||||
thread.setUncaughtExceptionHandler((t, e) ->
|
||||
log.error("Thread has an uncaught exception, threadId={}, threadName={}",
|
||||
thread.setUncaughtExceptionHandler((t, e) -> log.error("Thread has an uncaught exception, threadId={}, threadName={}",
|
||||
t.getId(), t.getName(), e));
|
||||
|
||||
return thread;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils;
|
||||
|
||||
import java.time.Instant;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils.io;
|
||||
|
||||
import com.nebula.base.utils.DigestEngine;
|
||||
|
@ -824,7 +841,6 @@ public class FileUtil {
|
|||
|
||||
// ---------------------------------------------------------------- stream
|
||||
|
||||
|
||||
/**
|
||||
* @see #writeStream(File, InputStream)
|
||||
*/
|
||||
|
@ -1224,7 +1240,6 @@ public class FileUtil {
|
|||
moveFile(src, dest);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------- smart delete
|
||||
|
||||
/**
|
||||
|
@ -1398,7 +1413,7 @@ public class FileUtil {
|
|||
while (true) {
|
||||
try {
|
||||
return File.createTempFile(prefix, suffix, tempDir).getCanonicalFile();
|
||||
} catch (final IOException ioex) { // fixes java.io.WinNTFileSystem.createFileExclusively access denied
|
||||
} catch (final IOException ioex) { // fixes java.io.WinNTFileSystem.createFileExclusively access denied
|
||||
if (++exceptionsCount >= 50) {
|
||||
throw ioex;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils.io;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.base.utils.io;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -11,7 +28,7 @@ import java.nio.charset.StandardCharsets;
|
|||
* @date : 2022/1/14 13:55
|
||||
* @description:
|
||||
*/
|
||||
public class UnicodeInputStream extends InputStream{
|
||||
public class UnicodeInputStream extends InputStream {
|
||||
|
||||
public static final int MAX_BOM_SIZE = 4;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
@ -11,8 +10,6 @@
|
|||
|
||||
<name>spring-boot-nebula-dependencies</name>
|
||||
<description>spring boot 基础组件,快速构建spring boot项目</description>
|
||||
<url>https://github.com/weihubeats/spring-boot-common</url>
|
||||
|
||||
|
||||
<properties>
|
||||
<revision>0.0.01</revision>
|
||||
|
@ -29,6 +26,8 @@
|
|||
<javers-core.version>6.6.5</javers-core.version>
|
||||
<mybatis-plus-boot-starter.version>3.5.5</mybatis-plus-boot-starter.version>
|
||||
<redission.version>3.17.3</redission.version>
|
||||
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
||||
|
@ -116,38 +115,10 @@
|
|||
<version>${redission.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</dependencyManagement>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>weihubeats</name>
|
||||
<email>weihu@apche.org</email>
|
||||
<organization>https://weihubeats.blog.csdn.net/</organization>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git@github.com:weihubeats/spring-boot-common.git</connection>
|
||||
<developerConnection>scm:git@github.com:weihubeats/spring-boot-common.git</developerConnection>
|
||||
<url>git@github.com:weihubeats/spring-boot-common.git</url>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>Github Issue</system>
|
||||
<url>https://github.com/weihubeats/spring-boot-common/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
@ -180,10 +151,10 @@
|
|||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar-no-fork</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -205,10 +176,10 @@
|
|||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>package</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -220,10 +191,10 @@
|
|||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
<phase>verify</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
@ -239,33 +210,100 @@
|
|||
<executions>
|
||||
<execution>
|
||||
<id>flatten</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>flatten</goal>
|
||||
</goals>
|
||||
<phase>process-resources</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>flatten.clean</id>
|
||||
<phase>clean</phase>
|
||||
<goals>
|
||||
<goal>clean</goal>
|
||||
</goals>
|
||||
<phase>clean</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.diffplug.spotless</groupId>
|
||||
<artifactId>spotless-maven-plugin</artifactId>
|
||||
<version>${spotless-maven-plugin.version}</version>
|
||||
<configuration>
|
||||
<java>
|
||||
<eclipse>
|
||||
<file>${maven.multiModuleProjectDirectory}/dev-support/spotless_nebula_formatter.xml</file>
|
||||
</eclipse>
|
||||
<licenseHeader>
|
||||
<file>${maven.multiModuleProjectDirectory}/dev-support/license-header</file>
|
||||
</licenseHeader>
|
||||
</java>
|
||||
<pom>
|
||||
<sortPom>
|
||||
<encoding>UTF-8</encoding>
|
||||
<nrOfIndentSpace>4</nrOfIndentSpace>
|
||||
<keepBlankLines>true</keepBlankLines>
|
||||
<indentBlankLines>false</indentBlankLines>
|
||||
<indentSchemaLocation>true</indentSchemaLocation>
|
||||
<spaceBeforeCloseEmptyElement>true</spaceBeforeCloseEmptyElement>
|
||||
<sortModules>false</sortModules>
|
||||
<sortExecutions>false</sortExecutions>
|
||||
<predefinedSortOrder>custom_1</predefinedSortOrder>
|
||||
<expandEmptyElements>false</expandEmptyElements>
|
||||
<sortProperties>false</sortProperties>
|
||||
</sortPom>
|
||||
</pom>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>apply</goal>
|
||||
</goals>
|
||||
<phase>compile</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<url>https://github.com/weihubeats/spring-boot-common</url>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>weihubeats</name>
|
||||
<email>weihu@apche.org</email>
|
||||
<organization>https://weihubeats.blog.csdn.net/</organization>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git@github.com:weihubeats/spring-boot-common.git</connection>
|
||||
<developerConnection>scm:git@github.com:weihubeats/spring-boot-common.git</developerConnection>
|
||||
<url>git@github.com:weihubeats/spring-boot-common.git</url>
|
||||
</scm>
|
||||
|
||||
<issueManagement>
|
||||
<system>Github Issue</system>
|
||||
<url>https://github.com/weihubeats/spring-boot-common/issues</url>
|
||||
</issueManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>sonatype</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>sonatype</id>
|
||||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
</project>
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.aop;
|
||||
|
||||
import com.nebula.base.utils.DataUtils;
|
||||
|
@ -43,6 +60,7 @@ public class NebulaDistributedLockAnnotationInterceptor implements MethodInterce
|
|||
boolean fairLock = annotation.fairLock();
|
||||
if (annotation.tryLock()) {
|
||||
return lock.tryLock(new DistributedLock<>() {
|
||||
|
||||
@Override
|
||||
public Object process() {
|
||||
return proceed(methodInvocation);
|
||||
|
@ -55,6 +73,7 @@ public class NebulaDistributedLockAnnotationInterceptor implements MethodInterce
|
|||
}, annotation.tryWaitTime(), annotation.outTime(), annotation.timeUnit(), fairLock);
|
||||
} else {
|
||||
return lock.lock(new DistributedLock<>() {
|
||||
|
||||
@Override
|
||||
public Object process() {
|
||||
return proceed(methodInvocation);
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.autoconfigure;
|
||||
|
||||
import com.nebula.aop.base.NebulaBaseAnnotationAdvisor;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.core;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.core;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -16,7 +33,7 @@ public interface NebulaDistributedLockTemplate {
|
|||
/**
|
||||
* 默认尝试加锁时间
|
||||
*/
|
||||
long DEFAULT_TRY_OUT_TIME = 30;
|
||||
long DEFAULT_TRY_OUT_TIME = 30;
|
||||
/**
|
||||
* 默认时间单位
|
||||
*/
|
||||
|
@ -63,5 +80,4 @@ public interface NebulaDistributedLockTemplate {
|
|||
*/
|
||||
<T> T tryLock(DistributedLock<T> distributedLock, long tryOutTime, long outTime, TimeUnit timeUnit, boolean fairLock);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.core;
|
||||
|
||||
import com.nebula.distribute.lock.exception.DistributedLockException;
|
||||
|
@ -43,7 +60,7 @@ public class RedissonDistributedLockTemplate implements NebulaDistributedLockTem
|
|||
|
||||
@Override
|
||||
public <T> T tryLock(DistributedLock<T> distributedLock, long tryOutTime, long outTime, TimeUnit timeUnit,
|
||||
boolean fairLock) {
|
||||
boolean fairLock) {
|
||||
String lockName = distributedLock.lockName();
|
||||
RLock lock = getLock(lockName, fairLock);
|
||||
try {
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.exception;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.mybatis.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.mybatis.handler;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
@ -21,6 +38,7 @@ import org.apache.ibatis.type.TypeException;
|
|||
@MappedJdbcTypes(JdbcType.ARRAY)
|
||||
@MappedTypes({Integer[].class, String[].class, Boolean[].class, Double[].class, Long[].class, BigDecimal[].class})
|
||||
public class ArrayTypeHandler extends BaseTypeHandler<Object[]> {
|
||||
|
||||
private static final String TYPE_NAME_VARCHAR = "varchar";
|
||||
private static final String TYPE_NAME_INTEGER = "integer";
|
||||
private static final String TYPE_NAME_BOOLEAN = "boolean";
|
||||
|
@ -29,7 +47,7 @@ public class ArrayTypeHandler extends BaseTypeHandler<Object[]> {
|
|||
|
||||
@Override
|
||||
public void setNonNullParameter(
|
||||
PreparedStatement ps, int i, Object[] parameter, JdbcType jdbcType) throws SQLException {
|
||||
PreparedStatement ps, int i, Object[] parameter, JdbcType jdbcType) throws SQLException {
|
||||
String typeName = null;
|
||||
if (parameter instanceof Integer[]) {
|
||||
typeName = TYPE_NAME_INTEGER;
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>spring-boot-nebula</artifactId>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>spring-boot-nebula-samples</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>spring-boot-nebula-web-sample</module>
|
||||
<module>spring-boot-nebula-distribute-lock-sample</module>
|
||||
</modules>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<artifactId>spring-boot-nebula-samples</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.sample;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.sample.config;
|
||||
|
||||
import com.nebula.base.utils.DataUtils;
|
||||
|
@ -25,7 +42,6 @@ public class RedissonConfig {
|
|||
@Value("${redis.password}")
|
||||
private String redisLoginPassword;
|
||||
|
||||
|
||||
@Bean
|
||||
public RedissonClient redissonClient() {
|
||||
return createRedis(redisLoginHost, redisLoginPort, redisLoginPassword);
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.sample.controller;
|
||||
|
||||
import com.nebula.distribute.lock.sample.service.TestService;
|
||||
|
@ -19,10 +36,9 @@ public class TestController {
|
|||
|
||||
private final TestService testServcie;
|
||||
|
||||
|
||||
@GetMapping("/test")
|
||||
@NebulaResponseBody
|
||||
public String test() throws Exception{
|
||||
public String test() throws Exception {
|
||||
testServcie.test();
|
||||
return "小奏";
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.distribute.lock.sample.service;
|
||||
|
||||
import com.nebula.distribute.lock.annotation.NebulaDistributedLock;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.sample;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.sample.controller;
|
||||
|
||||
import com.nebula.web.boot.annotation.NebulaResponseBody;
|
||||
|
@ -14,7 +31,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RequestMapping()
|
||||
public class TestController {
|
||||
|
||||
|
||||
@GetMapping("/test")
|
||||
@NebulaResponseBody
|
||||
public String test() {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
|
@ -29,6 +28,19 @@
|
|||
<artifactId>spring-boot-nebula-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.assertj</groupId>
|
||||
<artifactId>assertj-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.common.autoconfigure;
|
||||
|
||||
import com.nebula.web.common.utils.NebulaSysWebUtils;
|
||||
|
@ -19,9 +36,8 @@ public class NebulaWebCommonAutoConfiguration {
|
|||
}
|
||||
|
||||
@Bean
|
||||
public NebulaSysWebUtils nebulaSysWebUtils() {
|
||||
public NebulaSysWebUtils nebulaSysWebUtils() {
|
||||
return new NebulaSysWebUtils();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,25 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.common.utils;
|
||||
|
||||
import com.nebula.base.utils.DataUtils;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
|
@ -28,8 +44,9 @@ public class ExpressionUtil {
|
|||
if (DataUtils.isEmpty(expressionString)) {
|
||||
return null;
|
||||
}
|
||||
//获取被拦截方法参数名列表
|
||||
// 获取被拦截方法参数名列表
|
||||
LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
|
||||
// SPEL解析
|
||||
String[] paramNames = discoverer.getParameterNames(method);
|
||||
if (paramNames == null || args == null || paramNames.length != args.length) {
|
||||
throw new IllegalArgumentException("Method parameter names and argument values do not match.");
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.common.utils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.common.utils;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
package com.nebula.web.common.utils;
|
||||
|
||||
import com.nebula.web.common.autoconfigure.NebulaWebCommonAutoConfiguration;
|
||||
import java.util.Objects;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* @author : wh
|
||||
* @date : 2024/3/28 09:45
|
||||
* @description:
|
||||
*/
|
||||
@SpringBootTest(classes = SpringBeanUtilsTest.TestConfig.class)
|
||||
public class SpringBeanUtilsTest {
|
||||
|
||||
@Test
|
||||
public void getBean() {
|
||||
Object bean = SpringBeanUtils.getBean("testBean");
|
||||
assertTrue(bean instanceof TestBean);
|
||||
TestBean bean1 = SpringBeanUtils.getBean(TestBean.class);
|
||||
assertTrue(Objects.nonNull(bean1));
|
||||
assertThrowsExactly(NoSuchBeanDefinitionException.class, () -> SpringBeanUtils.getBean(NoTestBean.class));
|
||||
|
||||
}
|
||||
|
||||
static final class TestBean {
|
||||
}
|
||||
|
||||
static final class NoTestBean {
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ImportAutoConfiguration({NebulaWebCommonAutoConfiguration.class})
|
||||
public static class TestConfig {
|
||||
|
||||
@Bean
|
||||
public TestBean testBean() {
|
||||
return new TestBean();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>io.github.weihubeats</groupId>
|
||||
<artifactId>spring-boot-nebula</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>spring-boot-nebula-web</artifactId>
|
||||
|
||||
|
@ -37,5 +36,4 @@
|
|||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.annotation;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.annotation;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.api;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.api;
|
||||
|
||||
import java.util.Collection;
|
||||
|
@ -76,7 +93,7 @@ public class NebulaPage<T> {
|
|||
*/
|
||||
public static <T> NebulaPage<T> ofMemory(Collection<T> list, NebulaPageQuery pageQuery) {
|
||||
List<T> pageList = list.stream().skip((long) (pageQuery.getPageIndex() - 1) * pageQuery.getPageSize())
|
||||
.limit(pageQuery.getPageSize()).collect(Collectors.toList());
|
||||
.limit(pageQuery.getPageSize()).collect(Collectors.toList());
|
||||
NebulaPage<T> page = new NebulaPage<>();
|
||||
page.setList(pageList);
|
||||
page.setTotalCount(list.size());
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.api;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.api;
|
||||
|
||||
import com.nebula.web.boot.enums.ResultCode;
|
||||
|
@ -37,7 +54,6 @@ public class NebulaResponse<T> implements Serializable {
|
|||
*/
|
||||
private String msg;
|
||||
|
||||
|
||||
private NebulaResponse(IResultCode resultCode) {
|
||||
this(resultCode, null, resultCode.getMessage());
|
||||
}
|
||||
|
@ -145,7 +161,4 @@ public class NebulaResponse<T> implements Serializable {
|
|||
return new NebulaResponse<>(ResultCode.FAILURE, msg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -28,16 +45,13 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|||
@AllArgsConstructor
|
||||
public class BaseWebMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
|
||||
returnValueHandlers.add(new NebulaResponseBodyHandleReturnValue());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 使用 JACKSON 作为JSON MessageConverter
|
||||
* @param converters
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.enums;
|
||||
|
||||
import com.nebula.web.boot.api.IResultCode;
|
||||
|
@ -35,7 +52,6 @@ public enum ResultCode implements IResultCode {
|
|||
|
||||
BIZ_EXCEPTION(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "业务异常");
|
||||
|
||||
|
||||
/**
|
||||
* code编码
|
||||
*/
|
||||
|
@ -45,10 +61,4 @@ public enum ResultCode implements IResultCode {
|
|||
*/
|
||||
final String message;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.error;
|
||||
|
||||
import com.nebula.web.boot.api.NebulaResponse;
|
||||
|
@ -98,7 +115,7 @@ public class NebulaRestExceptionHandler {
|
|||
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public NebulaResponse<?> methodArgumentTypeMismatchException(HttpServletRequest request,
|
||||
MethodArgumentTypeMismatchException e) {
|
||||
MethodArgumentTypeMismatchException e) {
|
||||
log.error("参数类型异常 ", e);
|
||||
return NebulaResponse.fail(ResultCode.PARAM_BIND_ERROR);
|
||||
}
|
||||
|
@ -106,7 +123,7 @@ public class NebulaRestExceptionHandler {
|
|||
@ExceptionHandler(HttpMessageNotReadableException.class)
|
||||
@ResponseStatus(HttpStatus.BAD_REQUEST)
|
||||
public NebulaResponse<?> httpMessageNotReadableExceptionHandle(HttpServletRequest request,
|
||||
HttpMessageNotReadableException e) {
|
||||
HttpMessageNotReadableException e) {
|
||||
log.error("数据格式错误 ", e);
|
||||
return NebulaResponse.fail(ResultCode.PARAM_BIND_ERROR, "数据格式错误");
|
||||
}
|
||||
|
@ -114,7 +131,7 @@ public class NebulaRestExceptionHandler {
|
|||
@ExceptionHandler(Exception.class)
|
||||
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
public NebulaResponse<?> defaultErrorHandle(HttpServletRequest request, HttpServletResponse response,
|
||||
Object handler, Exception ex) {
|
||||
Object handler, Exception ex) {
|
||||
NebulaResponse<?> baseResponse = new NebulaResponse<>();
|
||||
baseResponse.setCode(ResultCode.INTERNAL_SERVER_ERROR.getCode());
|
||||
baseResponse.setMsg("Server busy");
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.exception;
|
||||
|
||||
import com.nebula.web.boot.api.IResultCode;
|
||||
|
@ -9,7 +26,8 @@ import lombok.Getter;
|
|||
* @date : 2023/4/13 10:11
|
||||
* @description:
|
||||
*/
|
||||
@Getter public abstract class BaseException extends RuntimeException {
|
||||
@Getter
|
||||
public abstract class BaseException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.exception;
|
||||
|
||||
import com.nebula.web.boot.api.IResultCode;
|
||||
|
@ -12,7 +29,6 @@ public class BizException extends BaseException {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
public BizException(String errMessage) {
|
||||
super(ResultCode.FAILURE, errMessage);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.exception;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.exception;
|
||||
|
||||
import com.nebula.web.boot.enums.ResultCode;
|
||||
|
@ -8,6 +25,7 @@ import com.nebula.web.boot.enums.ResultCode;
|
|||
* @description:
|
||||
*/
|
||||
public class UnauthorizedException extends BaseException {
|
||||
|
||||
public UnauthorizedException(String errMessage) {
|
||||
super(ResultCode.UNAUTHORIZED, errMessage);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.interceptor;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
@ -28,7 +45,7 @@ public class NebulaResponseBodyHandleReturnValue implements HandlerMethodReturnV
|
|||
*/
|
||||
@Override
|
||||
public boolean supportsReturnType(MethodParameter returnType) {
|
||||
//如果已经是基础的返回值
|
||||
// 如果已经是基础的返回值
|
||||
return returnType.getParameterType() != NebulaResponseBody.class
|
||||
&& DataUtils.isNotEmpty(returnType.getAnnotatedElement().getAnnotation(NebulaResponseBody.class));
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.jackson;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonEncoding;
|
||||
|
@ -32,6 +49,7 @@ import org.springframework.util.TypeUtils;
|
|||
* AbstractReadWriteJackson2HttpMessageConverter
|
||||
*/
|
||||
public abstract class AbstractReadWriteJackson2HttpMessageConverter extends AbstractJackson2HttpMessageConverter {
|
||||
|
||||
private static final java.nio.charset.Charset DEFAULT_CHARSET = Charsets.UTF_8;
|
||||
|
||||
private final ObjectMapper writeObjectMapper;
|
||||
|
@ -76,8 +94,7 @@ public abstract class AbstractReadWriteJackson2HttpMessageConverter extends Abst
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage)
|
||||
throws IOException, HttpMessageNotWritableException {
|
||||
protected void writeInternal(Object object, @Nullable Type type, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException {
|
||||
|
||||
MediaType contentType = outputMessage.getHeaders().getContentType();
|
||||
JsonEncoding encoding = getJsonEncoding(contentType);
|
||||
|
@ -100,8 +117,7 @@ public abstract class AbstractReadWriteJackson2HttpMessageConverter extends Abst
|
|||
javaType = getJavaType(type, null);
|
||||
}
|
||||
|
||||
ObjectWriter objectWriter = (serializationView != null ?
|
||||
this.writeObjectMapper.writerWithView(serializationView) : this.writeObjectMapper.writer());
|
||||
ObjectWriter objectWriter = (serializationView != null ? this.writeObjectMapper.writerWithView(serializationView) : this.writeObjectMapper.writer());
|
||||
if (filters != null) {
|
||||
objectWriter = objectWriter.with(filters);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.jackson;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
|
@ -18,9 +35,10 @@ import java.time.LocalDateTime;
|
|||
* </>
|
||||
*/
|
||||
public class LocalDateTimeJacksonDeserializer extends JsonDeserializer<LocalDateTime> {
|
||||
|
||||
@Override
|
||||
public LocalDateTime deserialize(
|
||||
JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||
JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
|
||||
long longValue = jsonParser.getLongValue();
|
||||
return TimeUtil.toLocalDateTime(longValue);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.jackson;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.jackson;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerator;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.resolver;
|
||||
|
||||
import com.nebula.base.utils.DataUtils;
|
||||
|
@ -22,62 +39,62 @@ import org.springframework.web.method.support.ModelAndViewContainer;
|
|||
*/
|
||||
public class TimestampArgumentResolver implements HandlerMethodArgumentResolver {
|
||||
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter methodParameter) {
|
||||
return methodParameter.hasParameterAnnotation(GetTimestamp.class);
|
||||
}
|
||||
@Override
|
||||
public boolean supportsParameter(MethodParameter methodParameter) {
|
||||
return methodParameter.hasParameterAnnotation(GetTimestamp.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception {
|
||||
GetTimestamp getTimestamp = methodParameter.getParameterAnnotation(GetTimestamp.class);
|
||||
Object instance = methodParameter.getParameterType().getDeclaredConstructor().newInstance();
|
||||
String name = getTimestamp.name();
|
||||
if (DataUtils.isEmpty(name)) {
|
||||
name = methodParameter.getParameterName();
|
||||
}
|
||||
if (instance instanceof LocalDateTime) {
|
||||
assert name != null;
|
||||
String parameter = nativeWebRequest.getParameter(name);
|
||||
return parse(parameter);
|
||||
}
|
||||
@Override
|
||||
public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest,
|
||||
WebDataBinderFactory webDataBinderFactory) throws Exception {
|
||||
GetTimestamp getTimestamp = methodParameter.getParameterAnnotation(GetTimestamp.class);
|
||||
Object instance = methodParameter.getParameterType().getDeclaredConstructor().newInstance();
|
||||
String name = getTimestamp.name();
|
||||
if (DataUtils.isEmpty(name)) {
|
||||
name = methodParameter.getParameterName();
|
||||
}
|
||||
if (instance instanceof LocalDateTime) {
|
||||
assert name != null;
|
||||
String parameter = nativeWebRequest.getParameter(name);
|
||||
return parse(parameter);
|
||||
}
|
||||
|
||||
WebDataBinder binder = webDataBinderFactory.createBinder(nativeWebRequest, instance, name);
|
||||
binder.registerCustomEditor(LocalDateTime.class, new LocalDateTimeEditor());
|
||||
WebDataBinder binder = webDataBinderFactory.createBinder(nativeWebRequest, instance, name);
|
||||
binder.registerCustomEditor(LocalDateTime.class, new LocalDateTimeEditor());
|
||||
|
||||
ServletRequestParameterPropertyValues propertyValues = new ServletRequestParameterPropertyValues(Objects.requireNonNull(nativeWebRequest.getNativeRequest(ServletRequest.class)));
|
||||
ServletRequestParameterPropertyValues propertyValues = new ServletRequestParameterPropertyValues(Objects.requireNonNull(nativeWebRequest.getNativeRequest(ServletRequest.class)));
|
||||
|
||||
binder.bind(propertyValues);
|
||||
return instance;
|
||||
}
|
||||
binder.bind(propertyValues);
|
||||
return instance;
|
||||
}
|
||||
|
||||
class LocalDateTimeEditor extends PropertyEditorSupport {
|
||||
@Override
|
||||
public String getAsText() {
|
||||
final LocalDateTime localDateTime = (LocalDateTime) getValue();
|
||||
if (localDateTime == null) {
|
||||
return "";
|
||||
}
|
||||
return localDateTime.toString();
|
||||
}
|
||||
class LocalDateTimeEditor extends PropertyEditorSupport {
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(parse(text));
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDateTime parse(String timestampStr) {
|
||||
if (DataUtils.isEmpty(timestampStr)) {
|
||||
return null;
|
||||
}
|
||||
timestampStr = timestampStr.replaceAll("\"", "");
|
||||
long timestamp = Long.parseLong(timestampStr);
|
||||
if (timestamp == 0) {
|
||||
return null;
|
||||
}
|
||||
return TimeUtil.toLocalDateTime(timestamp);
|
||||
}
|
||||
@Override
|
||||
public String getAsText() {
|
||||
final LocalDateTime localDateTime = (LocalDateTime) getValue();
|
||||
if (localDateTime == null) {
|
||||
return "";
|
||||
}
|
||||
return localDateTime.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAsText(String text) throws IllegalArgumentException {
|
||||
setValue(parse(text));
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDateTime parse(String timestampStr) {
|
||||
if (DataUtils.isEmpty(timestampStr)) {
|
||||
return null;
|
||||
}
|
||||
timestampStr = timestampStr.replaceAll("\"", "");
|
||||
long timestamp = Long.parseLong(timestampStr);
|
||||
if (timestamp == 0) {
|
||||
return null;
|
||||
}
|
||||
return TimeUtil.toLocalDateTime(timestamp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.nebula.web.boot.api;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
Loading…
Reference in New Issue