Skip to content

Commit

Permalink
Merge pull request #27 from microsphere-projects/dev-1.x
Browse files Browse the repository at this point in the history
Release 0.1.0
  • Loading branch information
mercyblitz authored Jan 9, 2025
2 parents 26be0da + c5ba691 commit ba4edef
Show file tree
Hide file tree
Showing 50 changed files with 2,332 additions and 107 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/maven-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ jobs:
strategy:
matrix:
java: [ '8', '11' , '17' , '21' ]
maven-profile-spring-boot: [ 'spring-boot-2.4' , 'spring-boot-2.5' , 'spring-boot-2.6' , 'spring-boot-2.7' ]
maven-profile-spring-boot: [ 'spring-boot-2.1' , 'spring-boot-2.2' , 'spring-boot-2.3',
'spring-boot-2.4' ,'spring-boot-2.5' , 'spring-boot-2.6' ,
'spring-boot-2.7' ]
steps:
- name: Checkout Source
uses: actions/checkout@v4
Expand All @@ -38,6 +40,11 @@ jobs:
--update-snapshots
--file pom.xml
-Drevision=0.0.1-SNAPSHOT
-DargLine="${{ matrix.java >= 16 && '--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.lang.invoke=ALL-UNNAMED' || '' }}"
-P${{ matrix.maven-profile-spring-boot }}
test
test
--activate-profiles test,coverage,${{ matrix.maven-profile-spring-boot }}

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: microsphere-projects/microsphere-spring-boot
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,8 @@ compiler/.gradle/*
.extract
.java-version

# vscode
.vscode/

# others
build.txt
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# microsphere-spring-boot
Microsphere Projects for Spring Boot
> Microsphere Projects for Spring Boot
[![Maven Build](https://github.com/microsphere-projects/microsphere-spring-boot/actions/workflows/maven-build.yml/badge.svg)](https://github.com/microsphere-projects/microsphere-spring-boot/actions/workflows/maven-build.yml)
[![Codecov](https://codecov.io/gh/microsphere-projects/microsphere-spring-boot/branch/dev-1.x/graph/badge.svg)](https://app.codecov.io/gh/microsphere-projects/microsphere-spring-boot)
![Maven](https://img.shields.io/maven-central/v/io.github.microsphere-projects/microsphere-spring-boot.svg)
![License](https://img.shields.io/github/license/microsphere-projects/microsphere-spring-boot.svg)
[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/microsphere-projects/microsphere-spring-boot.svg)](http://isitmaintained.com/project/microsphere-projects/microsphere-spring-boot "Average time to resolve an issue")
[![Percentage of issues still open](http://isitmaintained.com/badge/open/microsphere-projects/microsphere-spring-boot.svg)](http://isitmaintained.com/project/microsphere-projects/microsphere-spring-boot "Percentage of issues still open")
44 changes: 44 additions & 0 deletions microsphere-core-spring-boot-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@
</dependency>

<!-- Testing Dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
Expand All @@ -62,4 +68,42 @@
</dependency>

</dependencies>

<profiles>
<profile>
<id>spring-boot-2.1</id>
<dependencies>
<!-- Compatible -->
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-spring-boot-compatible</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</profile>

<profile>
<id>spring-boot-2.2</id>
<dependencies>
<!-- Compatible -->
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-spring-boot-compatible</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</profile>

<profile>
<id>spring-boot-2.3</id>
<dependencies>
<!-- Compatible -->
<dependency>
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-spring-boot-compatible</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.springframework.core.env.Environment;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

import java.util.LinkedHashSet;
import java.util.Set;
Expand All @@ -19,6 +17,7 @@
import static java.util.Arrays.asList;
import static java.util.Collections.emptySet;
import static java.util.Collections.unmodifiableSet;
import static org.springframework.util.Assert.isInstanceOf;
import static org.springframework.util.StringUtils.collectionToCommaDelimitedString;
import static org.springframework.util.StringUtils.commaDelimitedListToSet;
import static org.springframework.util.StringUtils.hasText;
Expand Down Expand Up @@ -103,7 +102,7 @@ private static MutablePropertySources getPropertySources(Environment environment
}

private static ConfigurableEnvironment getConfigurableEnvironment(Environment environment) {
Assert.isInstanceOf(ConfigurableEnvironment.class, environment);
isInstanceOf(ConfigurableEnvironment.class, environment);
return (ConfigurableEnvironment) environment;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package io.microsphere.spring.boot.classloading;

import io.microsphere.classloading.BannedArtifactClassLoadingExecutor;
import io.microsphere.logging.Logger;
import io.microsphere.spring.boot.listener.SpringApplicationRunListenerAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationStartingEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.core.Ordered;
import org.springframework.util.ClassUtils;

import java.util.Arrays;

import static io.microsphere.logging.LoggerFactory.getLogger;
import static org.springframework.util.ClassUtils.isPresent;

/**
* {@link ApplicationStartingEvent ApplicationStartingEvent} {@link ApplicationListener Listener} bans
* the load of Artifacts collision class
Expand All @@ -21,15 +22,13 @@
*/
public class BannedArtifactClassLoadingListener extends SpringApplicationRunListenerAdapter implements Ordered {

private static final Logger logger = LoggerFactory.getLogger(BannedArtifactClassLoadingListener.class);
private static final Logger logger = getLogger(BannedArtifactClassLoadingListener.class);

private static final boolean artifactsBanned = Boolean.getBoolean("microsphere.artifacts.banned");

private static final String SPRING_BOOT_LAUNCHER_CLASS_NAME = "org.springframework.boot.loader.Launcher";

private static final ClassLoader defaultClassLoader = ClassUtils.getDefaultClassLoader();

static final boolean SPRING_BOOT_LAUNCHER_CLASS_PRESENT = ClassUtils.isPresent(SPRING_BOOT_LAUNCHER_CLASS_NAME, defaultClassLoader);
static final boolean SPRING_BOOT_LAUNCHER_CLASS_PRESENT = isPresent(SPRING_BOOT_LAUNCHER_CLASS_NAME, null);

private static boolean banned = false;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package io.microsphere.spring.boot.context;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.microsphere.logging.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.context.event.ApplicationPreparedEvent;
import org.springframework.context.ApplicationListener;
Expand All @@ -13,6 +12,8 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentSkipListSet;

import static io.microsphere.logging.LoggerFactory.getLogger;

/**
* Once execution {@link ApplicationPreparedEvent} {@link ApplicationListener}
*
Expand All @@ -24,7 +25,7 @@ public abstract class OnceApplicationPreparedEventListener implements Applicatio

private static Map<Class<? extends ApplicationListener>, Set<String>> listenerProcessedContextIds = new ConcurrentHashMap<>();

protected final Logger logger = LoggerFactory.getLogger(getClass());
protected final Logger logger = getLogger(getClass());

private final Set<String> processedContextIds;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.util.ClassUtils;

import java.util.List;

import static java.util.Arrays.asList;
import static org.springframework.util.ClassUtils.isPresent;


/**
Expand All @@ -25,7 +25,7 @@ public abstract class OnceMainApplicationPreparedEventListener extends OnceAppli

private static final String BOOTSTRAP_APPLICATION_LISTENER_ENABLED_PROPERTY_NAME = "spring.cloud.bootstrap.enabled";

private static final boolean BOOTSTRAP_APPLICATION_LISTENER_PRESENT = ClassUtils.isPresent(BOOTSTRAP_APPLICATION_LISTENER_CLASS_NAME, null);
private static final boolean BOOTSTRAP_APPLICATION_LISTENER_PRESENT = isPresent(BOOTSTRAP_APPLICATION_LISTENER_CLASS_NAME, null);

private static final String BOOTSTRAP_CONTEXT_ID = "bootstrap";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
package io.microsphere.spring.boot.context.properties.bind;

import io.microsphere.spring.core.convert.support.ConversionServiceResolver;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.source.ConfigurationProperty;
import org.springframework.boot.context.properties.source.ConfigurationPropertyName;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.convert.ConversionService;
import org.springframework.util.ClassUtils;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
Expand All @@ -34,6 +32,8 @@

import static io.microsphere.spring.boot.context.properties.source.util.ConfigurationPropertyUtils.toDashedForm;
import static org.springframework.beans.BeanUtils.copyProperties;
import static org.springframework.beans.BeanUtils.getPropertyDescriptors;
import static org.springframework.util.ClassUtils.isPrimitiveOrWrapper;

/**
* The context for the bean annotated {@link ConfigurationProperties @ConfigurationProperties}
Expand Down Expand Up @@ -95,7 +95,7 @@ private void initBinding(Object bean) {

private void initBinding(Class<?> beanClass, String prefix, Map<String, String> bindingPropertyNames, String nestedPath) {
if (isCandidateClass(beanClass)) {
PropertyDescriptor[] descriptors = BeanUtils.getPropertyDescriptors(beanClass);
PropertyDescriptor[] descriptors = getPropertyDescriptors(beanClass);
int descriptorSize = descriptors.length;
for (int i = 0; i < descriptorSize; i++) {
PropertyDescriptor descriptor = descriptors[i];
Expand All @@ -117,7 +117,7 @@ private boolean isCandidateProperty(PropertyDescriptor descriptor) {
}

private boolean isCandidateClass(Class<?> beanClass) {
if (ClassUtils.isPrimitiveOrWrapper(beanClass)) {
if (isPrimitiveOrWrapper(beanClass)) {
return false;
}
if (beanClass.isInterface() || beanClass.isEnum() || beanClass.isAnnotation() || beanClass.isArray() || beanClass.isSynthetic()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
package io.microsphere.spring.boot.context.properties.bind;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.microsphere.logging.Logger;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
Expand All @@ -30,17 +29,18 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.util.Assert;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;

import static io.microsphere.logging.LoggerFactory.getLogger;
import static io.microsphere.spring.boot.context.properties.bind.util.BindUtils.isBoundProperty;
import static io.microsphere.spring.boot.context.properties.bind.util.BindUtils.isConfigurationPropertiesBean;
import static io.microsphere.spring.boot.context.properties.source.util.ConfigurationPropertyUtils.getPrefix;
import static io.microsphere.spring.boot.context.properties.util.ConfigurationPropertiesUtils.CONFIGURATION_PROPERTIES_CLASS;
import static io.microsphere.spring.boot.context.properties.util.ConfigurationPropertiesUtils.findConfigurationProperties;
import static org.springframework.util.Assert.isInstanceOf;

/**
* A {@link BindListener} implementation of {@link ConfigurationProperties @ConfigurationProperties} Bean to publish
Expand All @@ -54,7 +54,7 @@
*/
public class EventPublishingConfigurationPropertiesBeanPropertyChangedListener implements BindListener, BeanFactoryPostProcessor, ApplicationContextAware, SmartInitializingSingleton {

private final static Logger logger = LoggerFactory.getLogger(EventPublishingConfigurationPropertiesBeanPropertyChangedListener.class);
private final static Logger logger = getLogger(EventPublishingConfigurationPropertiesBeanPropertyChangedListener.class);

private static final Class<ConfigurableApplicationContext> CONFIGURABLE_APPLICATION_CONTEXT_CLASS = ConfigurableApplicationContext.class;

Expand Down Expand Up @@ -126,7 +126,7 @@ private void initConfigurationPropertiesBeanContexts(ConfigurableListableBeanFac
@Override
public void setApplicationContext(ApplicationContext context) throws BeansException {
Class<ConfigurableApplicationContext> expectedType = CONFIGURABLE_APPLICATION_CONTEXT_CLASS;
Assert.isInstanceOf(expectedType, context, "The 'context' argument is not an instance of " + expectedType.getName());
isInstanceOf(expectedType, context, "The 'context' argument is not an instance of " + expectedType.getName());
this.context = expectedType.cast(context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ public Object onSuccess(ConfigurationPropertyName name, Bindable<?> target, Bind
return returnValue;
}

@Override
/**
* {@inheritDoc}
*
* @since Spring Boot 2.2.2
*/
public Object onCreate(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) {
Object returnValue = super.onCreate(name, target, context, result);
Object returnValue = result;
bindHandlers.onCreate(name, target, context, result);
return returnValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
package io.microsphere.spring.boot.context.properties.metadata;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.microsphere.logging.Logger;
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
import org.springframework.boot.configurationprocessor.metadata.JsonMarshaller;
import org.springframework.context.ResourceLoaderAware;
Expand All @@ -28,6 +27,7 @@

import java.io.IOException;

import static io.microsphere.logging.LoggerFactory.getLogger;
import static org.springframework.core.io.support.ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX;

/**
Expand All @@ -38,7 +38,7 @@
*/
public class ConfigurationMetadataReader implements ResourceLoaderAware {

private final static Logger logger = LoggerFactory.getLogger(ConfigurationMetadataReader.class);
private final static Logger logger = getLogger(ConfigurationMetadataReader.class);

public static final String METADATA_PATH = CLASSPATH_ALL_URL_PREFIX + "/META-INF/spring-configuration-metadata.json";

Expand Down
Loading

0 comments on commit ba4edef

Please sign in to comment.