Merge branch 'develop' into add-spring-boot-nebula-all

# Conflicts:
#	spring-boot-nebula-web-common/pom.xml
This commit is contained in:
weihu 2024-03-28 10:21:20 +08:00
commit d61f85d4ca
87 changed files with 3269 additions and 2010 deletions

View File

@ -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.
*/

View File

@ -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>

280
pom.xml
View File

@ -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,21 +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>
<dependencyManagement>
<dependencies>
<dependency>
@ -49,7 +45,154 @@
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<inherited>true</inherited>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<inherited>true</inherited>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<!-- <skipTests>false</skipTests>-->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<goals>
<goal>jar-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
<additionalJOptions>
<additionalJOption>-Xdoclint:none</additionalJOption>
</additionalJOptions>
</configuration>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
<!-- Gpg Signature -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<goals>
<goal>sign</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<goals>
<goal>flatten</goal>
</goals>
<phase>process-resources</phase>
</execution>
<execution>
<id>flatten.clean</id>
<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>
@ -78,124 +221,15 @@
<url>https://github.com/weihubeats/spring-boot-common/issues</url>
</issueManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<inherited>true</inherited>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<inherited>true</inherited>
<configuration>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
<!-- <skipTests>false</skipTests>-->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<!-- Javadoc -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
<additionalJOptions>
<additionalJOption>-Xdoclint:none</additionalJOption>
</additionalJOptions>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Gpg Signature -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>${maven-gpg-plugin.version}</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>flatten-maven-plugin</artifactId>
<version>${flatten-maven-plugin.version}</version>
<configuration>
<updatePomFile>true</updatePomFile>
<flattenMode>resolveCiFriendliesOnly</flattenMode>
</configuration>
<executions>
<execution>
<id>flatten</id>
<phase>process-resources</phase>
<goals>
<goal>flatten</goal>
</goals>
</execution>
<execution>
<id>flatten.clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<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>

View File

@ -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>

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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> {
}

View File

@ -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;
}

View File

@ -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;

View File

@ -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>
@ -34,8 +33,6 @@
<artifactId>spring-boot-nebula-distribute-lock</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -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>

View File

@ -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;
@ -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) {

View File

@ -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>

View File

@ -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;

View File

@ -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.
*/

View File

@ -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'};
}

View File

@ -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,19 +49,19 @@ public interface ClassLoaderStrategy {
/**
* List of primitive type names.
*/
public static final String[] PRIMITIVE_TYPE_NAMES = new String[] {
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[] {
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[] {
public static final char[] PRIMITIVE_BYTECODE_NAME = new char[]{
'Z', 'B', 'C', 'D', 'F', 'I', 'J', 'S'
};
@ -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();
@ -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);
}

View File

@ -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;

View File

@ -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,9 +268,9 @@ public class ClassUtil {
if (Modifier.isVolatile(method.getModifiers())) {
continue;
}
// if (Modifier.isAbstract(method.getModifiers())) {
// continue;
// }
// if (Modifier.isAbstract(method.getModifiers())) {
// continue;
// }
if (top) { // add all top declared methods
methodList.add(method);
continue;
@ -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++) {
@ -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++) {
@ -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];
}

View File

@ -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;

View File

@ -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);

View File

@ -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));
}
}

View File

@ -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();
}

View File

@ -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();
}
}

View File

@ -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;

View File

@ -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;
}
/**
* 获取指定属性
*

View File

@ -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("暂时不兼容该类型字段");
}

View File

@ -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;
}
}

View File

@ -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;
/**

View File

@ -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();
@ -141,7 +158,7 @@ public class StringUtils {
count++;
s = CharUtil.findFirstDiff(srcc, 1, delimiters);
if (s == -1) { // nothing after delimiters
return new String[] {EMPTY, EMPTY};
return new String[]{EMPTY, EMPTY};
}
start[1] = s; // new start
}
@ -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();
@ -190,7 +207,7 @@ public class StringUtils {
count++;
s = CharUtil.findFirstDiff(srcc, 1, delimiter);
if (s == -1) { // nothing after delimiters
return new String[] {EMPTY, EMPTY};
return new String[]{EMPTY, EMPTY};
}
start[1] = s; // new start
}
@ -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 = "{}";
@ -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);
}

View File

@ -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"));

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
/**

View File

@ -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;

View File

@ -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;

View File

@ -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,8 +26,9 @@
<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>
</properties>
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
</properties>
<dependencyManagement>
@ -114,38 +112,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>
@ -178,10 +148,10 @@
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
@ -203,10 +173,10 @@
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
@ -218,10 +188,10 @@
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<phase>verify</phase>
</execution>
</executions>
</plugin>
@ -237,33 +207,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>

View File

@ -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>

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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;
/**

View File

@ -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;
@ -63,5 +80,4 @@ public interface NebulaDistributedLockTemplate {
*/
<T> T tryLock(DistributedLock<T> distributedLock, long tryOutTime, long outTime, TimeUnit timeUnit, boolean fairLock);
}

View File

@ -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;

View File

@ -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;
/**

View File

@ -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>

View File

@ -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;

View File

@ -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";

View File

@ -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>

View File

@ -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>

View File

@ -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;

View File

@ -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);

View File

@ -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 "小奏";
}

View File

@ -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;

View File

@ -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>

View File

@ -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;

View File

@ -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() {

View File

@ -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,7 @@
<artifactId>spring-boot-nebula-common</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@ -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;
@ -23,5 +40,4 @@ public class NebulaWebCommonAutoConfiguration {
return new NebulaSysWebUtils();
}
}

View File

@ -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 com.nebula.base.utils.DataUtils;
@ -27,10 +44,10 @@ public class ExpressionUtil {
if (DataUtils.isEmpty(expressionString)) {
return null;
}
//获取被拦截方法参数名列表
// 获取被拦截方法参数名列表
LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
String[] paramNameArr = discoverer.getParameterNames(method);
//SPEL解析
// SPEL解析
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
for (int i = 0; i < Objects.requireNonNull(paramNameArr).length; i++) {

View File

@ -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;

View File

@ -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;

View File

@ -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>
@ -42,5 +41,4 @@
</dependencies>
</project>

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;
/**

View File

@ -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);
}
}

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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;
/**

View File

@ -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);
}

View File

@ -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));
}

View File

@ -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);
}

View File

@ -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,6 +35,7 @@ import java.time.LocalDateTime;
* </>
*/
public class LocalDateTimeJacksonDeserializer extends JsonDeserializer<LocalDateTime> {
@Override
public LocalDateTime deserialize(
JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {

View File

@ -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;

View File

@ -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;

View File

@ -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;
@ -28,7 +45,8 @@ public class TimestampArgumentResolver implements HandlerMethodArgumentResolver
}
@Override
public Object resolveArgument(MethodParameter methodParameter, ModelAndViewContainer modelAndViewContainer, NativeWebRequest nativeWebRequest, WebDataBinderFactory webDataBinderFactory) throws Exception {
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();
@ -51,6 +69,7 @@ public class TimestampArgumentResolver implements HandlerMethodArgumentResolver
}
class LocalDateTimeEditor extends PropertyEditorSupport {
@Override
public String getAsText() {
final LocalDateTime localDateTime = (LocalDateTime) getValue();
@ -78,6 +97,4 @@ public class TimestampArgumentResolver implements HandlerMethodArgumentResolver
return TimeUtil.toLocalDateTime(timestamp);
}
}

View File

@ -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;

View File

@ -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;