Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Contributor Code of Conduct

As contributors and maintainers of this project, and in the interest of
fostering an open and welcoming community, we pledge to respect all people who
contribute through reporting issues, posting feature requests, updating
documentation, submitting pull requests or patches, and other activities.

We are committed to making participation in this project a harassment-free
experience for everyone, regardless of level of experience, gender, gender
identity and expression, sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion, or nationality.

Examples of unacceptable behavior by participants include:

* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information, such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.

By adopting this Code of Conduct, project maintainers commit themselves to
fairly and consistently applying these principles to every aspect of managing
this project. Project maintainers who do not follow or enforce the Code of
Conduct may be permanently removed from the project team.

This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting a project maintainer at [[email protected]](mailto:[email protected]). All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. Maintainers are
obligated to maintain confidentiality with regard to the reporter of an
incident.


This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 1.3.0, available at https://www.contributor-covenant.org/version/1/3/0/code-of-conduct.html

[homepage]: https://www.contributor-covenant.org
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ pom.xml:

| **Branches** | **Purpose** | **Latest Version** |
|--------------|-------------------------------------------|--------------------|
| **0.2.x** | Compatible with Spring Boot 3.0.x - 3.2.x | 0.2.1 |
| **0.1.x** | Compatible with Spring Boot 2.0.x - 2.7.x | 0.1.1 |
| **0.2.x** | Compatible with Spring Boot 3.0.x - 3.5.x | 0.2.2 |
| **0.1.x** | Compatible with Spring Boot 2.0.x - 2.7.x | 0.1.2 |

Then add the specific modules you need:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ public void setBeanName(String name) {
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.context = applicationContext;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
*/
package io.microsphere.spring.boot.actuate.autoconfigure;

import io.microsphere.annotation.ConfigurationProperty;
import io.microsphere.spring.boot.actuate.MonitoredThreadPoolTaskScheduler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;

import static io.microsphere.annotation.ConfigurationProperty.APPLICATION_SOURCE;
import static io.microsphere.spring.boot.actuate.constants.PropertyConstants.TASK_SCHEDULER_PROPERTY_NAME_PREFIX;
import static org.springframework.core.Ordered.LOWEST_PRECEDENCE;

/**
Expand All @@ -35,20 +38,61 @@
@AutoConfigureOrder(LOWEST_PRECEDENCE)
public class ActuatorAutoConfiguration {

/**
* The default value of {@link ThreadPoolTaskScheduler#setPoolSize(int)} for Actuator : "1"
*/
static final String DEFAULT_TASK_SCHEDULER_POOL_SIZE = "1";

/**
* The property name of {@link ThreadPoolTaskScheduler#setPoolSize(int)} for Actuator :
* "microsphere.spring.boot.actuator.task-scheduler.pool-size"
*/
@ConfigurationProperty(
defaultValue = DEFAULT_TASK_SCHEDULER_POOL_SIZE,
source = APPLICATION_SOURCE
)
static final String TASK_SCHEDULER_POOL_SIZE_PROPERTY_NAME = TASK_SCHEDULER_PROPERTY_NAME_PREFIX + "pool-size";

/**
* The {@link Value @Value} expression of {@link ThreadPoolTaskScheduler#setPoolSize(int)} for Actuator :
* "${microsphere.spring.boot.actuator.task-scheduler.pool-size:1}"
*/
static final String TASK_SCHEDULER_POOL_SIZE_VALUE_EXPRESSION = "${" + TASK_SCHEDULER_POOL_SIZE_PROPERTY_NAME + ":" + DEFAULT_TASK_SCHEDULER_POOL_SIZE + "}";

/**
* The default thread name prefix of {@link ThreadPoolTaskScheduler} for Actuator : "microsphere-spring-boot-actuator-task-"
*/
static final String DEFAULT_TASK_SCHEDULER_THREAD_NAME_PREFIX = "microsphere-spring-boot-actuator-task-";

/**
* The property name of {@link ThreadPoolTaskScheduler#setThreadNamePrefix(String)} for Actuator :
* "microsphere.spring.boot.actuator.task-scheduler.thread-name-prefix"
*/
@ConfigurationProperty(
defaultValue = DEFAULT_TASK_SCHEDULER_THREAD_NAME_PREFIX,
source = APPLICATION_SOURCE
)
static final String TASK_SCHEDULER_THREAD_NAME_PREFIX_PROPERTY_NAME = TASK_SCHEDULER_PROPERTY_NAME_PREFIX + "thread-name-prefix";

/**
* The {@link Value @Value} expression of {@link ThreadPoolTaskScheduler#setThreadNamePrefix(String)} for Actuator :
* "${microsphere.spring.boot.actuator.task-scheduler.thread-name-prefix:microsphere-spring-boot-actuator-task-}"
*/
static final String TASK_SCHEDULER_THREAD_NAME_PREFIX_VALUE_EXPRESSION = "${" + TASK_SCHEDULER_THREAD_NAME_PREFIX_PROPERTY_NAME + ":" + DEFAULT_TASK_SCHEDULER_THREAD_NAME_PREFIX + "}";

/**
* The bean name of {@link ThreadPoolTaskScheduler} for Actuator : "actuatorTaskScheduler"
*/
public static final String ACTUATOR_TASK_SCHEDULER_SERVICE_BEAN_NAME = "actuatorTaskScheduler";

@Bean(name = ACTUATOR_TASK_SCHEDULER_SERVICE_BEAN_NAME, destroyMethod = "shutdown")
public ThreadPoolTaskScheduler actuatorTaskScheduler(
@Value("${microsphere.spring.boot.actuator.task-scheduler.pool-size:1}") int poolSize,
@Value("${microsphere.spring.boot.actuator.task-scheduler.prefix:microsphere-spring-boot-actuator-task-}") String threadNamePrefix) {
@Value(TASK_SCHEDULER_POOL_SIZE_VALUE_EXPRESSION) int poolSize,
@Value(TASK_SCHEDULER_THREAD_NAME_PREFIX_VALUE_EXPRESSION) String threadNamePrefix) {
MonitoredThreadPoolTaskScheduler threadPoolTaskScheduler = new MonitoredThreadPoolTaskScheduler();
threadPoolTaskScheduler.setPoolSize(poolSize);
threadPoolTaskScheduler.setDaemon(true);
threadPoolTaskScheduler.setThreadNamePrefix(threadNamePrefix);
return threadPoolTaskScheduler;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ public ConfigurationPropertiesEndpoint configurationPropertiesEndpoint(Configura
public void setBeanClassLoader(ClassLoader classLoader) {
this.classLoader = classLoader;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
@Documented
@ConditionalOnClass(name = "org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata")
public @interface ConditionalOnConfigurationProcessorPresent {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 io.microsphere.spring.boot.actuate.constants;

import static io.microsphere.spring.boot.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_PROPERTY_NAME_PREFIX;

/**
* The Property constants for Microsphere Spring Boot Actuator
*
* @author <a href="mailto:[email protected]">Mercy<a/>
* @since 1.0.0
*/
public interface PropertyConstants {

/**
* The property name prefix of Microsphere Spring Boot : "microsphere.spring.boot.actuator."
*/
String MICROSPHERE_SPRING_BOOT_ACTUATOR_PROPERTY_NAME_PREFIX = MICROSPHERE_SPRING_BOOT_PROPERTY_NAME_PREFIX + "actuator.";

/**
* The property name prefix of Microsphere Spring Boot Actuator Task Scheduler : "microsphere.spring.boot.actuator.task-scheduler."
*/
String TASK_SCHEDULER_PROPERTY_NAME_PREFIX = MICROSPHERE_SPRING_BOOT_ACTUATOR_PROPERTY_NAME_PREFIX + "task-scheduler.";
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public ArtifactsEndpoint(ClassLoader classLoader) {
public List<Artifact> getArtifactMetaInfoList() {
return artifactDetector.detect(false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ActuatorAutoConfigurationTest.class
}, properties = {
"microsphere.spring.boot.actuator.task-scheduler.pool-size=2",
"microsphere.spring.boot.actuator.task-scheduler.prefix=my-prefix",
"microsphere.spring.boot.actuator.task-scheduler.thread-name-prefix=my-prefix",

})
@EnableAutoConfiguration
Expand All @@ -52,7 +52,7 @@ class ActuatorAutoConfigurationTest {
@Value("${microsphere.spring.boot.actuator.task-scheduler.pool-size}")
private int poolSize;

@Value("${microsphere.spring.boot.actuator.task-scheduler.prefix}")
@Value("${microsphere.spring.boot.actuator.task-scheduler.thread-name-prefix}")
private String prefix;

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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 io.microsphere.spring.boot.actuate.constants;


import org.junit.jupiter.api.Test;

import static io.microsphere.spring.boot.actuate.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_ACTUATOR_PROPERTY_NAME_PREFIX;
import static io.microsphere.spring.boot.actuate.constants.PropertyConstants.TASK_SCHEDULER_PROPERTY_NAME_PREFIX;
import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* {@link PropertyConstants} Test
*
* @author <a href="mailto:[email protected]">Mercy</a>
* @see PropertyConstants
* @since 1.0.0
*/
class PropertyConstantsTest {

@Test
void testConstants() {
assertEquals("microsphere.spring.boot.actuator.", MICROSPHERE_SPRING_BOOT_ACTUATOR_PROPERTY_NAME_PREFIX);
assertEquals("microsphere.spring.boot.actuator.task-scheduler.", TASK_SCHEDULER_PROPERTY_NAME_PREFIX);
}
}
14 changes: 14 additions & 0 deletions microsphere-spring-boot-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@
<groupId>io.github.microsphere-projects</groupId>
<artifactId>microsphere-spring-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,19 @@
import static org.springframework.util.StringUtils.hasText;

/**
* Configurable {@link AutoConfigurationImportFilter}
* Configurable {@link AutoConfigurationImportFilter} for excluding specific Spring Boot auto-configuration classes.
*
* <h3>Example Usage</h3>
* <h4>Exclude auto-configuration classes via property</h4>
* <pre>{@code
* microsphere.autoconfigure.exclude=com.example.FooAutoConfiguration,com.example.BarAutoConfiguration
* }</pre>
*
* <h4>Programmatically exclude classes</h4>
* <pre>{@code
* ConfigurableAutoConfigurationImportFilter.addExcludedAutoConfigurationClass(environment, "com.example.FooAutoConfiguration");
* ConfigurableAutoConfigurationImportFilter.addExcludedAutoConfigurationClasses(environment, "com.example.BarAutoConfiguration", "com.example.BazAutoConfiguration");
* }</pre>
*
* @author <a href="mailto:[email protected]">Mercy<a/>
* @since 1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,21 @@
import static java.lang.Thread.currentThread;

/**
* {@link ApplicationStartingEvent ApplicationStartingEvent} {@link ApplicationListener Listener} bans
* the load of Artifacts collision class
* {@link ApplicationStartingEvent} {@link ApplicationListener} that bans loading of artifact collision classes.
* <h3>Example Usage</h3>
* <h4>Enable artifact banning via system property</h4>
* <pre>{@code
* -Dmicrosphere.spring.boot.banned-artifacts.enabled=true
* }</pre>
*
* <h4>Register listener in Spring Boot application</h4>
* <pre>{@code
* SpringApplication app = new SpringApplication(MyApplication.class);
* app.addListeners(new BannedArtifactClassLoadingListener(app));
* app.run(args);
* }</pre>
* <p>
* When enabled, this listener will prevent loading of banned artifacts during application startup.
*
* @author <a href="mailto:[email protected]">Mercy<a/>
* @since 1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@
/**
* {@link Conditional} that checks if the prefix of properties are found in environment..
*
* <h3>Example Usage</h3>
* <h4>Single prefix</h4>
* <pre>{@code
* @ConditionalOnPropertyPrefix("myapp.config")
* public class MyConfig {
* // This bean will only be loaded if any property with prefix "myapp.config." exists
* }
* }</pre>
*
* <h4>Multiple prefixes</h4>
* <pre>{@code
* @ConditionalOnPropertyPrefix( {"feature.alpha", "feature.beta"} )
* public class FeatureConfig {
* // Loaded if any property with prefix "feature.alpha." or "feature.beta." exists
* }
* }</pre>
*
* @author <a href="mailto:[email protected]">Mercy</a>
* @see OnPropertyPrefixCondition
* @since 1.0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
* @see ConditionalOnPropertyPrefix
* @since 1.0.0
*/
public class OnPropertyPrefixCondition extends SpringBootCondition {
class OnPropertyPrefixCondition extends SpringBootCondition {

@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
Expand All @@ -64,4 +64,4 @@ public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeM

return noMatched ? noMatch("The prefix values " + arrayToString(prefixValues) + " were not found in Environment!") : match();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public interface PropertyConstants {

/**
* The property name prefix of Microsphere Spring Boot
* The property name prefix of Microsphere Spring Boot : "microsphere.spring.boot."
*/
String MICROSPHERE_SPRING_BOOT_PROPERTY_NAME_PREFIX = MICROSPHERE_SPRING_PROPERTY_NAME_PREFIX + "boot.";

Expand All @@ -47,4 +47,4 @@ public interface PropertyConstants {
source = APPLICATION_SOURCE
)
String MICROSPHERE_SPRING_BOOT_LOGGING_LEVEL_PROPERTY_NAME = MICROSPHERE_SPRING_BOOT_PROPERTY_NAME_PREFIX + "logging.level";
}
}
Loading