Skip to content

Commit

Permalink
refactor: 移动Springs的package,加入meta信息
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarlosdasilva committed Aug 8, 2024
1 parent 5040cb0 commit 274d37e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ ij_editorconfig_align_group_field_declarations = true

[*.java]
ij_java_annotation_parameter_wrap = on_every_item
ij_java_array_initializer_wrap = split_into_lines
ij_java_array_initializer_wrap = on_every_item
ij_java_binary_operation_wrap = on_every_item
ij_java_call_parameters_wrap = on_every_item
ij_java_enum_constants_wrap = split_into_lines
ij_java_enum_constants_wrap = on_every_item
ij_java_extends_list_wrap = on_every_item
ij_java_method_call_chain_wrap = on_every_item
ij_java_method_parameters_wrap = on_every_item
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.labzen.spring.helper;
package cn.labzen.spring;

import cn.labzen.meta.spring.SpringApplicationContextInitializerOrder;
import org.springframework.context.ApplicationContextInitializer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package cn.labzen.spring.helper;
package cn.labzen.spring;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ListableBeanFactory;
Expand All @@ -13,12 +13,14 @@
import org.springframework.lang.NonNull;
import org.springframework.util.ClassUtils;

import javax.annotation.Nullable;
import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class Springs {

private static ConfigurableApplicationContext applicationContext;
Expand Down Expand Up @@ -212,7 +214,10 @@ public static boolean isProfileActivated(String name) {
/**
* 获取 Spring 环境属性
*/
public static String environmentProperty(String name, String defaultValue) {
public static String environmentProperty(String name, @Nullable String defaultValue) {
if (defaultValue == null) {
return environment.getProperty(name);
}
return environment.getProperty(name, defaultValue);
}

Expand All @@ -226,6 +231,7 @@ public static String environmentProperty(String name) {
/**
* 根据注解扫描符合条件的类
*/
@SafeVarargs
public static Set<Class<?>> scanClassesByAnnotation(String pkg,
Class<?> type,
Class<Annotation>... annotationClasses) {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/cn/labzen/spring/meta/SpringConfiguration.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cn.labzen.spring.meta;

import cn.labzen.meta.configuration.annotation.Configured;

@Configured(namespace = "spring")
public interface SpringConfiguration {

// todo 暂无配置项
}
26 changes: 26 additions & 0 deletions src/main/java/cn/labzen/spring/meta/SpringMeta.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package cn.labzen.spring.meta;

import cn.labzen.meta.component.LabzenComponent;

import javax.annotation.Nonnull;

public class SpringMeta implements LabzenComponent {

@Nonnull
@Override
public String description() {
return "对基于Spring的企业项目做增强";
}

@Nonnull
@Override
public String mark() {
return "Labzen-Spring";
}

@Nonnull
@Override
public String packageBased() {
return "cn.labzen.spring";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cn.labzen.spring.meta.SpringMeta
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/spring.factories
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
org.springframework.context.ApplicationContextInitializer=cn.labzen.spring.helper.LabzenSpringHelperInitializer
org.springframework.context.ApplicationContextInitializer=cn.labzen.spring.LabzenSpringHelperInitializer
org.springframework.context.ApplicationListener=cn.labzen.spring.env.ExternalPropertySourcesInfoPrinter
org.springframework.boot.env.EnvironmentPostProcessor=cn.labzen.spring.env.ExternalPropertySourcesLoader

0 comments on commit 274d37e

Please sign in to comment.