diff --git a/pom.xml b/pom.xml
index c715765c02f61c6d1161020fce158564bba6115c..0970aa19b590cfb7a29c6397b463736fc7a26190 100644
--- a/pom.xml
+++ b/pom.xml
@@ -13,7 +13,7 @@
com.gitee.starblues
spring-brick-parent
pom
- 3.0.2
+ 3.0.3
spring-brick-common
diff --git a/spring-brick-bootstrap/pom.xml b/spring-brick-bootstrap/pom.xml
index 730adc0fc110be1b5e129d048858d46bf3b76dfb..cf32d07c87bc0dc4ffc13fbc594c07a843896f0b 100644
--- a/spring-brick-bootstrap/pom.xml
+++ b/spring-brick-bootstrap/pom.xml
@@ -7,7 +7,7 @@
spring-brick-parent
com.gitee.starblues
- 3.0.2
+ 3.0.3
spring-brick-bootstrap
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java
index 0321276c98ebb22c5e19fe62a551f7e2ff7018af..e4ddb241531c31ce5c4cac18e46fefd597cba2d3 100644
--- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java
@@ -25,7 +25,7 @@ import java.util.Set;
/**
* 空的MainApplicationContext实现
* @author starBlues
- * @version 3.0.1
+ * @version 3.0.3
*/
public class EmptyMainApplicationContext implements MainApplicationContext {
@@ -46,4 +46,14 @@ public class EmptyMainApplicationContext implements MainApplicationContext {
return Collections.emptyMap();
}
+ @Override
+ public boolean isResolveDependency(String packageName) {
+ return false;
+ }
+
+ @Override
+ public boolean isWebEnvironment() {
+ return false;
+ }
+
}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java
index 2ed37d010bff52beae6cdfe2b5745d590b5a3e35..b6c9cb144c2c80fdad11572076ff3854c6235e9c 100644
--- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java
@@ -20,12 +20,14 @@ import com.gitee.starblues.bootstrap.processor.ProcessorContext;
import com.gitee.starblues.core.descriptor.PluginDescriptor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.boot.web.context.WebServerApplicationContext;
+import org.springframework.boot.web.server.WebServer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
/**
* 插件ApplicationContext实现
* @author starBlues
- * @version 3.0.0
+ * @version 3.0.3
*/
public class PluginApplicationContext extends AnnotationConfigApplicationContext {
@@ -57,4 +59,5 @@ public class PluginApplicationContext extends AnnotationConfigApplicationContext
public void close() {
super.close();
}
+
}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginDisableAutoConfiguration.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginDisableAutoConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..7c69c391c44890ee45e68ad11c41df9d666c38af
--- /dev/null
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginDisableAutoConfiguration.java
@@ -0,0 +1,72 @@
+/**
+ * Copyright [2019-2022] [starBlues]
+ *
+ * Licensed 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.gitee.starblues.bootstrap;
+
+import com.gitee.starblues.utils.ObjectUtils;
+import org.springframework.boot.autoconfigure.AutoConfigurationImportFilter;
+import org.springframework.boot.autoconfigure.AutoConfigurationMetadata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 插件禁用的 AutoConfiguration
+ *
+ * @author starBlues
+ * @version 3.0.3
+ */
+public class PluginDisableAutoConfiguration implements AutoConfigurationImportFilter {
+
+ private static final List DISABLE_FUZZY_CLASSES = new ArrayList<>();
+
+ public PluginDisableAutoConfiguration(){
+ addDisableFuzzyClasses();
+ }
+
+ private void addDisableFuzzyClasses() {
+ DISABLE_FUZZY_CLASSES.add("org.springframework.boot.autoconfigure.http");
+ DISABLE_FUZZY_CLASSES.add("org.springframework.boot.autoconfigure.web");
+ DISABLE_FUZZY_CLASSES.add("org.springframework.boot.autoconfigure.websocket");
+ DISABLE_FUZZY_CLASSES.add("org.springframework.boot.autoconfigure.jackson");
+ DISABLE_FUZZY_CLASSES.add("org.springframework.boot.autoconfigure.webservices");
+ }
+
+ public static boolean isDisabled(String className){
+ if(ObjectUtils.isEmpty(className)){
+ return false;
+ }
+ for (String disableFuzzyClass : DISABLE_FUZZY_CLASSES) {
+ if (className.contains(disableFuzzyClass)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean[] match(String[] autoConfigurationClasses, AutoConfigurationMetadata autoConfigurationMetadata) {
+ boolean[] match = new boolean[autoConfigurationClasses.length];
+ for (int i = 0; i < autoConfigurationClasses.length; i++) {
+ String autoConfigurationClass = autoConfigurationClasses[i];
+ if(autoConfigurationClass == null || "".equals(autoConfigurationClass)){
+ continue;
+ }
+ match[i] = !isDisabled(autoConfigurationClass);
+ }
+ return match;
+ }
+}
diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java
index fda812953dfe96df79455ce6c412c62db5e3777f..5d1a8732f74a98926b76f87ae97be17f6df5b7d5 100644
--- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java
+++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java
@@ -21,25 +21,35 @@ import com.gitee.starblues.spring.MainApplicationContext;
import com.gitee.starblues.spring.SpringBeanFactory;
import com.gitee.starblues.utils.ObjectUtils;
import com.gitee.starblues.utils.ReflectionUtils;
+import lombok.AllArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.TypeConverter;
+import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+import org.springframework.beans.factory.ObjectFactory;
+import org.springframework.beans.factory.ObjectProvider;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.support.ScopeNotActiveException;
+import org.springframework.core.ResolvableType;
import org.springframework.lang.Nullable;
+import java.util.Map;
+import java.util.Optional;
import java.util.Set;
+import java.util.function.Consumer;
+import java.util.stream.Stream;
/**
* 插件BeanFactory实现
* @author starBlues
- * @version 3.0.0
+ * @version 3.0.3
*/
public class PluginListableBeanFactory extends DefaultListableBeanFactory {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
+ private final Logger logger = LoggerFactory.getLogger(PluginListableBeanFactory.class);
private final MainApplicationContext applicationContext;
@@ -47,20 +57,55 @@ public class PluginListableBeanFactory extends DefaultListableBeanFactory {
this.applicationContext = applicationContext;
}
+ @SuppressWarnings("unchecked")
@Override
public Object resolveDependency(DependencyDescriptor descriptor,
@Nullable String requestingBeanName,
@Nullable Set autowiredBeanNames,
@Nullable TypeConverter typeConverter) throws BeansException {
-
+ if(isDisabled(descriptor)){
+ return resolveDependencyFromMain(descriptor, false);
+ }
try {
- return super.resolveDependency(descriptor, requestingBeanName, autowiredBeanNames, typeConverter);
+ Object object = super.resolveDependency(descriptor, requestingBeanName, autowiredBeanNames,
+ typeConverter);
+
+ if(object instanceof ObjectProvider){
+ return new PluginObjectProviderWrapper((ObjectProvider