diff --git a/README.md b/README.md index 7c72a13..f6b6a21 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ truthbean debbie cloud framework collections ## Note -Need java 11 or above \ No newline at end of file +Need java 17 or above \ No newline at end of file diff --git a/boot/cron/pom.xml b/boot/cron/pom.xml index 38846af..87243ac 100644 --- a/boot/cron/pom.xml +++ b/boot/cron/pom.xml @@ -12,9 +12,9 @@ debbie-cron - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/cron/src/main/java/com/truthbean/debbie/cron/DebbieCronModuleStarter.java b/boot/cron/src/main/java/com/truthbean/debbie/cron/DebbieCronModuleStarter.java index 00cf294..7f3ab84 100644 --- a/boot/cron/src/main/java/com/truthbean/debbie/cron/DebbieCronModuleStarter.java +++ b/boot/cron/src/main/java/com/truthbean/debbie/cron/DebbieCronModuleStarter.java @@ -9,13 +9,9 @@ */ package com.truthbean.debbie.cron; -import com.truthbean.debbie.bean.BeanInitialization; -import com.truthbean.debbie.bean.DebbieBeanInfo; -import com.truthbean.debbie.bean.MutableBeanInfo; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; -import org.quartz.Scheduler; import org.quartz.impl.StdSchedulerFactory; /** @@ -35,12 +31,8 @@ public int getOrder() { } @Override - public void registerBean(ApplicationContext applicationContext, BeanInitialization beanInitialization) { - MutableBeanInfo schedulerBeanInfo = new DebbieBeanInfo<>(Scheduler.class); - schedulerBeanInfo.addBeanName("scheduler"); - SchedulerBeanFactory schedulerBeanFactory = new SchedulerBeanFactory(); - schedulerBeanFactory.setEnvContent(applicationContext.getEnvContent()); - schedulerBeanInfo.setBeanFactory(schedulerBeanFactory); - beanInitialization.initSingletonBean(schedulerBeanInfo); + public void registerBean(ApplicationContext applicationContext, BeanInfoManager beanInitialization) { + SchedulerBeanFactory schedulerBeanFactory = new SchedulerBeanFactory("scheduler"); + beanInitialization.register(schedulerBeanFactory); } } diff --git a/boot/cron/src/main/java/com/truthbean/debbie/cron/DebbieSchedulerJobInfo.java b/boot/cron/src/main/java/com/truthbean/debbie/cron/DebbieSchedulerJobInfo.java index 9976c8d..614eaed 100644 --- a/boot/cron/src/main/java/com/truthbean/debbie/cron/DebbieSchedulerJobInfo.java +++ b/boot/cron/src/main/java/com/truthbean/debbie/cron/DebbieSchedulerJobInfo.java @@ -10,7 +10,6 @@ package com.truthbean.debbie.cron; import com.truthbean.debbie.task.MethodTaskInfo; -import com.truthbean.debbie.task.TaskInfo; /** * @author TruthBean/Rogar·Q diff --git a/boot/cron/src/main/java/com/truthbean/debbie/cron/SchedulerBeanFactory.java b/boot/cron/src/main/java/com/truthbean/debbie/cron/SchedulerBeanFactory.java index cf569f4..2be1453 100644 --- a/boot/cron/src/main/java/com/truthbean/debbie/cron/SchedulerBeanFactory.java +++ b/boot/cron/src/main/java/com/truthbean/debbie/cron/SchedulerBeanFactory.java @@ -12,8 +12,7 @@ import com.truthbean.Logger; import com.truthbean.debbie.bean.BeanCreatedException; import com.truthbean.debbie.bean.BeanFactory; -import com.truthbean.debbie.bean.GlobalBeanFactory; -import com.truthbean.debbie.env.EnvContentAware; +import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContent; import com.truthbean.LoggerFactory; import com.truthbean.debbie.env.EnvironmentContentHolder; @@ -21,28 +20,33 @@ import org.quartz.SchedulerException; import org.quartz.impl.StdSchedulerFactory; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + /** * @author TruthBean/Rogar·Q * @since 0.1.0 * Created on 2020-08-11 09:39 */ -public class SchedulerBeanFactory implements BeanFactory, EnvContentAware { +public class SchedulerBeanFactory implements BeanFactory { private volatile Scheduler scheduler; + private final Set beanNames; - private EnvironmentContent envContent; - - @Override - public void setEnvContent(EnvironmentContent envContent) { - this.envContent = envContent; + public SchedulerBeanFactory(String...names) { + this.beanNames = new HashSet<>(); + Collections.addAll(this.beanNames, names); } @Override - public Scheduler getBean() { + public Scheduler factoryBean(ApplicationContext applicationContext) { if (scheduler == null) { synchronized (SchedulerBeanFactory.class) { if (scheduler == null) { + EnvironmentContent envContent = applicationContext.getEnvContent(); if (envContent instanceof EnvironmentContentHolder) { - ((EnvironmentContentHolder)envContent).addProperty("org.quartz.threadPool.threadCount", "10"); + int i = Runtime.getRuntime().availableProcessors(); + ((EnvironmentContentHolder)envContent).addProperty("org.quartz.threadPool.threadCount", String.valueOf(i)); } try { StdSchedulerFactory factory = new StdSchedulerFactory(envContent.getProperties()); @@ -58,21 +62,42 @@ public Scheduler getBean() { } @Override - public Class getBeanType() { + public Scheduler factoryNamedBean(String name, ApplicationContext applicationContext) { + return factoryBean(applicationContext); + } + + @Override + public Set getBeanNames() { + return beanNames; + } + + @Override + public Scheduler getCreatedBean() { + return this.scheduler; + } + + @Override + public Class getBeanClass() { return Scheduler.class; } + @Override + public boolean isCreated() { + return this.scheduler != null; + } + @Override public boolean isSingleton() { return true; } @Override - public void destroy() { + public void destruct(ApplicationContext applicationContext) { if (this.scheduler != null) { try { - if (this.scheduler.isStarted() && !this.scheduler.isShutdown()) + if (this.scheduler.isStarted() && !this.scheduler.isShutdown()) { this.scheduler.shutdown(true); + } } catch (SchedulerException e) { LOGGER.error("", e); } @@ -80,8 +105,8 @@ public void destroy() { } @Override - public void setGlobalBeanFactory(GlobalBeanFactory globalBeanFactory) { - + public Logger getLogger() { + return LOGGER; } private static final Logger LOGGER = LoggerFactory.getLogger(SchedulerBeanFactory.class); diff --git a/boot/freemarker/pom.xml b/boot/freemarker/pom.xml index 215ff27..878a1c0 100644 --- a/boot/freemarker/pom.xml +++ b/boot/freemarker/pom.xml @@ -12,9 +12,9 @@ debbie-freemarker - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/DebbieFreemarkerConfiguration.java b/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/DebbieFreemarkerConfiguration.java deleted file mode 100644 index 8fc7df2..0000000 --- a/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/DebbieFreemarkerConfiguration.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2021 TruthBean(Rogar·Q) - * Debbie is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. - */ -package com.truthbean.debbie.freemarker; - -import com.truthbean.debbie.bean.BeanInitialization; -import com.truthbean.debbie.bean.DebbieBeanInfo; -import com.truthbean.debbie.core.ApplicationContext; -import freemarker.template.Configuration; - -/** - * @author TruthBean - * @since 0.0.2 - */ -public class DebbieFreemarkerConfiguration { - - public DebbieFreemarkerConfiguration() { - } - - public void register(ApplicationContext context) { - DebbieBeanInfo beanInfo = new DebbieBeanInfo<>(Configuration.class); - beanInfo.addBeanName("freemarkerConfiguration"); - DefaultConfigurationBeanFactory beanFactory = new DefaultConfigurationBeanFactory(); - beanFactory.setGlobalBeanFactory(context.getGlobalBeanFactory()); - beanFactory.setClassLoader(context.getClassLoader()); - beanInfo.setBeanFactory(beanFactory); - - BeanInitialization beanInitialization = context.getBeanInitialization(); - beanInitialization.initSingletonBean(beanInfo); - context.refreshBeans(); - } - - public void configure(ApplicationContext context) { - context.refreshBeans(); - } -} diff --git a/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/DefaultConfigurationBeanFactory.java b/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/DefaultConfigurationBeanFactory.java index a155c52..e50cffb 100644 --- a/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/DefaultConfigurationBeanFactory.java +++ b/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/DefaultConfigurationBeanFactory.java @@ -10,46 +10,59 @@ package com.truthbean.debbie.freemarker; import com.truthbean.debbie.bean.*; +import com.truthbean.debbie.core.ApplicationContext; import freemarker.template.Configuration; +import java.util.Collections; +import java.util.HashSet; import java.util.Locale; +import java.util.Set; /** * @author TruthBean * @since 0.0.2 */ -public class DefaultConfigurationBeanFactory implements BeanFactory, ClassLoaderAware { +public class DefaultConfigurationBeanFactory implements BeanFactory { private Configuration configuration; - private ClassLoader classLoader; - public DefaultConfigurationBeanFactory() { + private final Set names = new HashSet<>(); + + public DefaultConfigurationBeanFactory(String...names) { + if (names != null && names.length > 0) { + Collections.addAll(this.names, names); + } } @Override - public void setGlobalBeanFactory(GlobalBeanFactory beanFactory) { + public Configuration factoryBean(ApplicationContext applicationContext) { + if (configuration == null) { + configuration = new Configuration(Configuration.VERSION_2_3_30); + configuration.setClassLoaderForTemplateLoading(applicationContext.getClassLoader(), "/templates"); + configuration.setDefaultEncoding("UTF-8"); + configuration.setLocale(Locale.CHINA); + } + return configuration; } @Override - public void setClassLoader(ClassLoader classLoader) { - this.classLoader = classLoader; + public Configuration factoryNamedBean(String name, ApplicationContext applicationContext) { + return factoryBean(applicationContext); } @Override - public Configuration getBean() { - if (configuration == null) { - configuration = new Configuration(Configuration.VERSION_2_3_30); - configuration.setClassLoaderForTemplateLoading(this.classLoader, "/templates"); - configuration.setDefaultEncoding("UTF-8"); - configuration.setLocale(Locale.CHINA); - } + public boolean isCreated() { + return configuration != null; + } + @Override + public Configuration getCreatedBean() { return configuration; } @Override - public Class getBeanType() { + public Class getBeanClass() { return Configuration.class; } @@ -59,7 +72,12 @@ public boolean isSingleton() { } @Override - public void destroy() { + public Set getBeanNames() { + return names; + } + + @Override + public void destruct(ApplicationContext applicationContext) { if (configuration != null) { configuration.clearEncodingMap(); configuration.clearSharedVariables(); diff --git a/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/FreemarkerModuleStarter.java b/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/FreemarkerModuleStarter.java index 69200cf..2854257 100644 --- a/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/FreemarkerModuleStarter.java +++ b/boot/freemarker/src/main/java/com/truthbean/debbie/freemarker/FreemarkerModuleStarter.java @@ -9,11 +9,10 @@ */ package com.truthbean.debbie.freemarker; -import com.truthbean.debbie.bean.BeanInitialization; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContent; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; /** * @author TruthBean @@ -29,15 +28,13 @@ public boolean enable(EnvironmentContent envContent) { } @Override - public void registerBean(ApplicationContext context, BeanInitialization beanInitialization) { - var freemarkerConfiguration = new DebbieFreemarkerConfiguration(); - freemarkerConfiguration.register(context); + public void registerBean(ApplicationContext context, BeanInfoManager beanInfoManager) { + DefaultConfigurationBeanFactory beanFactory = new DefaultConfigurationBeanFactory("freemarkerConfiguration"); + beanInfoManager.register(beanFactory); } @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext context) { - var freemarkerConfiguration = new DebbieFreemarkerConfiguration(); - freemarkerConfiguration.configure(context); + public void configure(ApplicationContext context) { } @Override diff --git a/boot/freemarker/src/test/resources/templates/test01.ftl b/boot/freemarker/src/test/resources/template/test01.ftl similarity index 100% rename from boot/freemarker/src/test/resources/templates/test01.ftl rename to boot/freemarker/src/test/resources/template/test01.ftl diff --git a/boot/hikari/pom.xml b/boot/hikari/pom.xml index e1b02fc..def0134 100644 --- a/boot/hikari/pom.xml +++ b/boot/hikari/pom.xml @@ -12,8 +12,8 @@ debbie-hikari - 11 - 11 + 17 + 17 diff --git a/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariDataSourceFactory.java b/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariDataSourceFactory.java index 5553bde..ebd1740 100644 --- a/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariDataSourceFactory.java +++ b/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariDataSourceFactory.java @@ -9,6 +9,7 @@ */ package com.truthbean.debbie.hikari; +import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.jdbc.datasource.DataSourceConfiguration; import com.truthbean.debbie.jdbc.datasource.DataSourceDriverName; import com.truthbean.debbie.jdbc.datasource.DataSourceFactory; @@ -29,18 +30,20 @@ public class HikariDataSourceFactory implements DataSourceFactory { private HikariDataSource hikariDataSource; private DataSourceDriverName driverName; + private String name; + @Override public DataSourceFactory factory(DataSource dataSource) { if (dataSource instanceof HikariDataSource) { hikariDataSource = (HikariDataSource) dataSource; } + this.name = "defaultHikariDataSourceFactory"; return this; } @Override public DataSourceFactory factory(DataSourceConfiguration configuration) { - if (configuration instanceof HikariConfiguration) { - HikariConfiguration hikariConfiguration = (HikariConfiguration) configuration; + if (configuration instanceof HikariConfiguration hikariConfiguration) { HikariConfig config = hikariConfiguration.getHikariConfig(); DataSourceDriverName driverName = configuration.getDriverName(); if (hikariConfiguration.getDriverClassName() == null && driverName != null) { @@ -63,6 +66,7 @@ public DataSourceFactory factory(DataSourceConfiguration configuration) { config.setTransactionIsolation(configuration.getDefaultTransactionIsolationLevel().name()); } hikariDataSource = new HikariDataSource(config); + this.name = configuration.getName() + "HikariDataSourceFactory"; } else { throw new ConfigurationTypeNotMatchedException(); } @@ -70,6 +74,11 @@ public DataSourceFactory factory(DataSourceConfiguration configuration) { return this; } + @Override + public String getName() { + return name; + } + @Override public DataSource getDataSource() { return hikariDataSource; @@ -81,7 +90,12 @@ public DataSourceDriverName getDriverName() { } @Override - public void destroy() { + public void close() { + hikariDataSource.close(); + } + + @Override + public void destruct(ApplicationContext applicationContext) { hikariDataSource.close(); } diff --git a/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariModuleStarter.java b/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariModuleStarter.java index 05699df..3b2ec16 100644 --- a/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariModuleStarter.java +++ b/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariModuleStarter.java @@ -9,11 +9,12 @@ */ package com.truthbean.debbie.hikari; -import com.truthbean.debbie.bean.BeanInitialization; +import com.truthbean.debbie.bean.BeanInfoManager; +import com.truthbean.debbie.bean.DebbieReflectionBeanFactory; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContent; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.properties.PropertiesConfigurationBeanFactory; /** * @author truthbean @@ -29,13 +30,12 @@ public boolean enable(EnvironmentContent envContent) { } @Override - public void registerBean(ApplicationContext applicationContext, BeanInitialization beanInitialization) { - beanInitialization.init(HikariConfiguration.class); + public void registerBean(ApplicationContext applicationContext, BeanInfoManager beanInfoManager) { + beanInfoManager.register(new PropertiesConfigurationBeanFactory<>(new HikariProperties(), HikariConfiguration.class)); } @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { - configurationFactory.register(new HikariProperties(), HikariConfiguration.class); + public void configure(ApplicationContext applicationContext) { } @Override diff --git a/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariProperties.java b/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariProperties.java index 917558a..6a60bff 100644 --- a/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariProperties.java +++ b/boot/hikari/src/main/java/com/truthbean/debbie/hikari/HikariProperties.java @@ -9,13 +9,15 @@ */ package com.truthbean.debbie.hikari; -import com.truthbean.debbie.bean.GlobalBeanFactory; +import com.truthbean.debbie.bean.DebbieReflectionBeanFactory; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContentHolder; import com.truthbean.debbie.properties.DebbieProperties; import com.truthbean.common.mini.util.StringUtils; +import java.util.HashMap; import java.util.Map; +import java.util.Set; /** * @author TruthBean @@ -23,6 +25,8 @@ * Created on 2019/05/17 22:46. */ public class HikariProperties extends EnvironmentContentHolder implements DebbieProperties { + + private final Map map = new HashMap<>(); private HikariConfiguration configuration; //================================================================================================================= @@ -39,14 +43,26 @@ public HikariProperties() { } @Override - public HikariConfiguration toConfiguration(final ApplicationContext applicationContext) { + public Set getProfiles() { + return map.keySet(); + } + + @Override + public HikariConfiguration getConfiguration(String name, ApplicationContext applicationContext) { + if (StringUtils.hasText(name)) { + return map.get(name); + } + return map.get(DEFAULT_PROFILE); + } + + @Override + public HikariConfiguration getConfiguration(final ApplicationContext applicationContext) { if (configuration != null) { return configuration; } - applicationContext.getBeanInitialization().init(HikariConfiguration.class); - applicationContext.refreshBeans(); - GlobalBeanFactory globalBeanFactory = applicationContext.getGlobalBeanFactory(); - configuration = globalBeanFactory.factory(HikariConfiguration.class); + + var beanFactory = new DebbieReflectionBeanFactory<>(HikariConfiguration.class, new HikariConfiguration()); + configuration = beanFactory.factoryBean(applicationContext); final Map matchedKey = getMatchedKey(HIKARI_X_KEY_PREFIX); matchedKey.forEach((key, value) -> { @@ -54,6 +70,13 @@ public HikariConfiguration toConfiguration(final ApplicationContext applicationC k = StringUtils.snakeCaseToCamelCaseTo(k); configuration.getHikariConfig().addDataSourceProperty(k, value); }); + map.put(DEFAULT_PROFILE, configuration); return configuration; } + + @Override + public void close() { + map.clear(); + configuration = null; + } } diff --git a/boot/hikari/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-hikari/reflect-config.json b/boot/hikari/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-hikari/reflect-config.json index b1978fb..1ac2325 100644 --- a/boot/hikari/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-hikari/reflect-config.json +++ b/boot/hikari/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-hikari/reflect-config.json @@ -22,5 +22,57 @@ "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true + }, + { + "name": "com.truthbean.debbie.hikari.HikariDataSourceFactory", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "com.truthbean.debbie.hikari.HikariConfiguration", + "methods": [ + { "name": "", "parameterTypes": [] }, + { "name": "setDataSourceClassName", "parameterTypes": ["java.lang.String"] }, + { "name": "setJdbcUrl", "parameterTypes": ["java.lang.String"] }, + { "name": "setUsername", "parameterTypes": ["java.lang.String"] }, + { "name": "setHikariPassword", "parameterTypes": ["java.lang.String"] }, + { "name": "setHikariAutoCommit", "parameterTypes": ["java.lang.Boolean"] }, + { "name": "setDriverClassName", "parameterTypes": ["java.lang.String"] }, + { "name": "setTransactionIsolation", "parameterTypes": ["com.truthbean.debbie.jdbc.transaction.TransactionIsolationLevel"] }, + { "name": "setSchema", "parameterTypes": ["java.lang.String"] }, + { "name": "setDataSource", "parameterTypes": ["javax.sql.DataSource"] }, + { "name": "setConnectionTimeout", "parameterTypes": ["long"] }, + { "name": "setIdleTimeout", "parameterTypes": ["long"] }, + { "name": "setMaxLifetime", "parameterTypes": ["long"] }, + { "name": "setConnectionTestQuery", "parameterTypes": ["java.lang.String"] }, + { "name": "setMinimumIdle", "parameterTypes": ["int"] }, + { "name": "setMaximumPoolSize", "parameterTypes": ["int"] }, + { "name": "setMetricRegistry", "parameterTypes": ["java.lang.String"] }, + { "name": "setHealthCheckRegistry", "parameterTypes": ["java.lang.String"] }, + { "name": "setPoolName", "parameterTypes": ["java.lang.String"] }, + { "name": "setInitializationFailTimeout", "parameterTypes": ["long"] }, + { "name": "setIsolateInternalQueries", "parameterTypes": ["boolean"] }, + { "name": "setAllowPoolSuspension", "parameterTypes": ["boolean"] }, + { "name": "setReadOnly", "parameterTypes": ["boolean"] }, + { "name": "setRegisterMbeans", "parameterTypes": ["boolean"] }, + { "name": "setCatalog", "parameterTypes": ["java.lang.String"] }, + { "name": "setConnectionInitSql", "parameterTypes": ["java.lang.String"] }, + { "name": "setValidationTimeout", "parameterTypes": ["long"] }, + { "name": "setLeakDetectionThreshold", "parameterTypes": ["long"] }, + { "name": "setThreadFactory", "parameterTypes": ["java.util.concurrent.ThreadFactory"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true } ] \ No newline at end of file diff --git a/boot/javafx/pom.xml b/boot/javafx/pom.xml index 8498a62..caa7cfb 100644 --- a/boot/javafx/pom.xml +++ b/boot/javafx/pom.xml @@ -12,9 +12,9 @@ debbie-javafx - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/javafx/src/main/java/com/truthbean/debbie/javafx/DebbieJavaFxApplication.java b/boot/javafx/src/main/java/com/truthbean/debbie/javafx/DebbieJavaFxApplication.java index b4243fb..19751c2 100644 --- a/boot/javafx/src/main/java/com/truthbean/debbie/javafx/DebbieJavaFxApplication.java +++ b/boot/javafx/src/main/java/com/truthbean/debbie/javafx/DebbieJavaFxApplication.java @@ -9,7 +9,6 @@ */ package com.truthbean.debbie.javafx; -import com.truthbean.LoggerFactory; import com.truthbean.logger.LoggerConfig; import javafx.application.Application; import javafx.stage.Stage; diff --git a/boot/javafx/src/main/java/com/truthbean/debbie/javafx/JavaFxApplication.java b/boot/javafx/src/main/java/com/truthbean/debbie/javafx/JavaFxApplication.java index f8b0e9d..61620d7 100644 --- a/boot/javafx/src/main/java/com/truthbean/debbie/javafx/JavaFxApplication.java +++ b/boot/javafx/src/main/java/com/truthbean/debbie/javafx/JavaFxApplication.java @@ -17,13 +17,12 @@ import com.truthbean.debbie.concurrent.NamedThreadFactory; import com.truthbean.debbie.concurrent.ThreadPooledExecutor; import com.truthbean.debbie.core.ApplicationContext; -import com.truthbean.debbie.event.DefaultEventPublisher; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.env.EnvironmentContent; +import com.truthbean.debbie.event.DebbieEventPublisher; import com.truthbean.LoggerFactory; import javafx.application.Application; import javafx.stage.Stage; -import java.lang.management.ManagementFactory; import java.time.Instant; import java.util.concurrent.ThreadFactory; @@ -45,15 +44,19 @@ public static JavaFxApplication getApplication() { } @Override - public DebbieApplication init(DebbieConfigurationCenter configurationCenter, ApplicationContext applicationContext, - ClassLoader classLoader) { + public boolean isEnable(EnvironmentContent envContent) { + return super.isEnable(envContent) && envContent.getBooleanValue(JavaFxModuleStarter.ENABLE_KEY, true); + } + + @Override + public DebbieApplication init(ApplicationContext applicationContext, ClassLoader classLoader) { logger.trace("init ... "); GlobalBeanFactory globalBeanFactory = applicationContext.getGlobalBeanFactory(); PrimaryStage primaryStage = globalBeanFactory.factory(PrimaryStage.class); PrimaryStageHolder.set(primaryStage); - DefaultEventPublisher eventPublisher = globalBeanFactory.factory("eventPublisher"); + DebbieEventPublisher eventPublisher = globalBeanFactory.factory("eventPublisher"); WindowsCloseEventListener.createInstance(eventPublisher); super.setLogger(logger); @@ -65,7 +68,6 @@ public DebbieApplication init(DebbieConfigurationCenter configurationCenter, App @Override protected void start(Instant beforeStartTime, ApplicationArgs args) { - double uptime = ManagementFactory.getRuntimeMXBean().getUptime(); printStartTime(); postBeforeStart(); Runtime.getRuntime().addShutdownHook(new Thread(super::exit)); diff --git a/boot/javafx/src/main/java/com/truthbean/debbie/javafx/JavaFxModuleStarter.java b/boot/javafx/src/main/java/com/truthbean/debbie/javafx/JavaFxModuleStarter.java index 9d50e13..806dd1f 100644 --- a/boot/javafx/src/main/java/com/truthbean/debbie/javafx/JavaFxModuleStarter.java +++ b/boot/javafx/src/main/java/com/truthbean/debbie/javafx/JavaFxModuleStarter.java @@ -19,7 +19,7 @@ */ public class JavaFxModuleStarter implements DebbieModuleStarter { - private static final String ENABLE_KEY = "debbie.javafx.enable"; + static final String ENABLE_KEY = "debbie.javafx.enable"; @Override public boolean enable(EnvironmentContent envContent) { diff --git a/boot/javafx/src/main/java/module-info.java b/boot/javafx/src/main/java/module-info.java index 33a5836..8694ce8 100644 --- a/boot/javafx/src/main/java/module-info.java +++ b/boot/javafx/src/main/java/module-info.java @@ -18,10 +18,10 @@ requires transitive com.truthbean.debbie.core; requires transitive javafx.graphics; // requires javafx.controlsEmpty; - requires javafx.controls; + requires transitive javafx.controls; // requires javafx.graphicsEmpty; // requires javafx.baseEmpty; - requires javafx.fxml; + requires transitive javafx.fxml; exports com.truthbean.debbie.javafx; diff --git a/boot/javafx/src/main/resources/META-INF/native-image/com.truthbean.debbie/javafx/reflect-config.json b/boot/javafx/src/main/resources/META-INF/native-image/com.truthbean.debbie/javafx/reflect-config.json new file mode 100644 index 0000000..fc4757d --- /dev/null +++ b/boot/javafx/src/main/resources/META-INF/native-image/com.truthbean.debbie/javafx/reflect-config.json @@ -0,0 +1,26 @@ +[ + { + "name" : "com.truthbean.debbie.javafx.JavaFxApplication", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "com.truthbean.debbie.javafx.JavaFxModuleStarter", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + } +] \ No newline at end of file diff --git a/boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoApplication.java b/boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoApplication.java similarity index 95% rename from boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoApplication.java rename to boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoApplication.java index fd60224..3830fce 100644 --- a/boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoApplication.java +++ b/boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoApplication.java @@ -7,7 +7,7 @@ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ -package com.truthbean.debbie.javafx.check; +package com.truthbean.test.debbie.javafx.check; import com.truthbean.LoggerFactory; import com.truthbean.debbie.boot.DebbieApplication; diff --git a/boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoController.java b/boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoController.java similarity index 94% rename from boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoController.java rename to boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoController.java index 246dbbc..e10b2cc 100644 --- a/boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoController.java +++ b/boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoController.java @@ -7,7 +7,7 @@ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ -package com.truthbean.debbie.javafx.check; +package com.truthbean.test.debbie.javafx.check; import javafx.event.ActionEvent; import javafx.fxml.FXML; diff --git a/boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoJavaFx.java b/boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoJavaFx.java similarity index 96% rename from boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoJavaFx.java rename to boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoJavaFx.java index 56a06f8..09570b3 100644 --- a/boot/javafx/src/test/java/com/truthbean/debbie/javafx/check/DemoJavaFx.java +++ b/boot/javafx/src/test/java/com/truthbean/test/debbie/javafx/check/DemoJavaFx.java @@ -7,7 +7,7 @@ * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. * See the Mulan PSL v2 for more details. */ -package com.truthbean.debbie.javafx.check; +package com.truthbean.test.debbie.javafx.check; import com.truthbean.debbie.javafx.DebbieJavaFx; import com.truthbean.debbie.javafx.PrimaryStage; diff --git a/boot/javafx/src/test/java/module-info.java b/boot/javafx/src/test/java/module-info.java new file mode 100644 index 0000000..3d82400 --- /dev/null +++ b/boot/javafx/src/test/java/module-info.java @@ -0,0 +1,9 @@ +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/20 18:29. + */ +open module com.truthbean.debbie.javafx.test { + requires com.truthbean.logger.core; + requires com.truthbean.debbie.javafx; +} \ No newline at end of file diff --git a/boot/javafx/src/test/resources/com/truthbean/debbie/javafx/check/demo.fxml b/boot/javafx/src/test/resources/com/truthbean/test/debbie/javafx/check/demo.fxml similarity index 100% rename from boot/javafx/src/test/resources/com/truthbean/debbie/javafx/check/demo.fxml rename to boot/javafx/src/test/resources/com/truthbean/test/debbie/javafx/check/demo.fxml diff --git a/boot/javafx/src/test/resources/com/truthbean/debbie/javafx/check/styles.css b/boot/javafx/src/test/resources/com/truthbean/test/debbie/javafx/check/styles.css similarity index 100% rename from boot/javafx/src/test/resources/com/truthbean/debbie/javafx/check/styles.css rename to boot/javafx/src/test/resources/com/truthbean/test/debbie/javafx/check/styles.css diff --git a/boot/kafka/pom.xml b/boot/kafka/pom.xml index 9de1364..71a7617 100644 --- a/boot/kafka/pom.xml +++ b/boot/kafka/pom.xml @@ -12,9 +12,9 @@ debbie-kafka - 11 - 11 - 11 + 17 + 17 + 17 @@ -34,8 +34,9 @@ com.truthbean - slf4j-boot + stdout-boot ${truthbean.version} + test com.truthbean diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/ConsumerRecordsEventListener.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/ConsumerRecordsEventListener.java index fa1a89a..76e2449 100644 --- a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/ConsumerRecordsEventListener.java +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/ConsumerRecordsEventListener.java @@ -36,5 +36,10 @@ public void onEvent(ConsumerRecordsEvent event) { } } + @Override + public Class getEventType() { + return ConsumerRecordsEvent.class; + } + private static final Logger logger = LoggerFactory.getLogger(ConsumerRecordsEventListener.class); } diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/ConsumerRecordsEventListenerFactory.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/ConsumerRecordsEventListenerFactory.java index c383044..1c0de18 100644 --- a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/ConsumerRecordsEventListenerFactory.java +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/ConsumerRecordsEventListenerFactory.java @@ -10,7 +10,11 @@ package com.truthbean.debbie.kafka; import com.truthbean.debbie.bean.BeanFactory; -import com.truthbean.debbie.bean.GlobalBeanFactory; +import com.truthbean.debbie.core.ApplicationContext; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; /** * @author TruthBean/Rogar·Q @@ -19,39 +23,51 @@ */ public class ConsumerRecordsEventListenerFactory implements BeanFactory> { private final ConsumerRecordsEventListener eventListener; + private final Set beanNames = new HashSet<>(); - public ConsumerRecordsEventListenerFactory() { + public ConsumerRecordsEventListenerFactory(String... names) { this.eventListener = new ConsumerRecordsEventListener<>(); + if (names != null && names.length > 0) { + Collections.addAll(beanNames, names); + } } @Override - public ConsumerRecordsEventListener getBean() { + public ConsumerRecordsEventListener getCreatedBean() { return eventListener; } @Override - public ConsumerRecordsEventListener factoryBean() { - return eventListener; + public boolean isCreated() { + return true; } @Override - @SuppressWarnings("rawtypes") - public Class getBeanType() { - return ConsumerRecordsEventListener.class; + public ConsumerRecordsEventListener factoryBean(ApplicationContext applicationContext) { + return eventListener; } @Override - public boolean isSingleton() { - return true; + public ConsumerRecordsEventListener factoryNamedBean(String name, ApplicationContext applicationContext) { + return eventListener; } @Override - public void destroy() { + public Class getBeanClass() { + return ConsumerRecordsEventListener.class; + } + @Override + public Set getBeanNames() { + return beanNames; } @Override - public void setGlobalBeanFactory(GlobalBeanFactory globalBeanFactory) { + public boolean isSingleton() { + return true; + } + @Override + public void destruct(ApplicationContext applicationContext) { } } diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KaKafkaMessageConsumerInfo.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KaKafkaMessageConsumerInfo.java new file mode 100644 index 0000000..163fe89 --- /dev/null +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KaKafkaMessageConsumerInfo.java @@ -0,0 +1,95 @@ +package com.truthbean.debbie.kafka; + +import java.util.function.Consumer; + +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/25 19:24. + */ +public class KaKafkaMessageConsumerInfo implements KafkaMessageConsumer { + private String[] topics; + + private Object bean; + + private boolean async; + + private Consumer consumer; + + private Class parameterType; + + public String[] getTopics() { + return topics; + } + + @Override + public String[] topics() { + return topics; + } + + public void setTopics(String[] topics) { + this.topics = topics; + } + + public boolean containTopic(String topic) { + if (this.topics != null && this.topics.length > 0) { + for (String s : this.topics) { + if (s.equals(topic)) { + return true; + } + } + } + return false; + } + + public Object getBean() { + return bean; + } + + public void setBean(Object bean) { + this.bean = bean; + } + + public Consumer getConsumer() { + return consumer; + } + + public void setConsumer(Consumer consumer) { + this.consumer = consumer; + } + + @Override + public Consumer consumer() { + return consumer; + } + + public boolean isAsync() { + return async; + } + + public void setAsync(boolean async) { + this.async = async; + } + + @Override + public boolean async() { + return async; + } + + public Class getParameterType() { + return parameterType; + } + + public void setParameterType(Class parameterType) { + this.parameterType = parameterType; + } + + @Override + public Class parameterType() { + return parameterType; + } + + public void invoke(T param) { + consumer.accept(param); + } +} diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaConfiguration.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaConfiguration.java index ef79ac0..3a4bbec 100644 --- a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaConfiguration.java +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaConfiguration.java @@ -87,6 +87,9 @@ public static class Consumer { @PropertyInject("session-timeout") private Integer sessionTimeout; + @PropertyInject("pull-timeout") + private Long pullTimeout = 10000L; + public List getBootstrapServers() { return bootstrapServers; } @@ -159,6 +162,14 @@ public void setSessionTimeout(Integer sessionTimeout) { this.sessionTimeout = sessionTimeout; } + public Long getPullTimeout() { + return pullTimeout; + } + + public void setPullTimeout(Long pullTimeout) { + this.pullTimeout = pullTimeout; + } + public Properties toConsumerProperties() { Properties p = new Properties(); if (bootstrapServers != null && !bootstrapServers.isEmpty()) { @@ -201,6 +212,7 @@ public void setName(String name) { this.name = name; } + @Override public boolean isEnable() { return enable; } @@ -210,7 +222,7 @@ public void setEnable(boolean enable) { } @Override - public void reset() { + public void close() { this.bootstrapServers.clear(); } } diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaConsumerFactory.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaConsumerFactory.java index 1756714..a49b83d 100644 --- a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaConsumerFactory.java +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaConsumerFactory.java @@ -14,13 +14,17 @@ import com.truthbean.debbie.concurrent.ThreadPooledExecutor; import com.truthbean.debbie.event.DebbieEventPublisher; import com.truthbean.LoggerFactory; +import com.truthbean.debbie.reflection.ReflectionHelper; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; import org.apache.kafka.clients.consumer.KafkaConsumer; +import org.apache.kafka.common.serialization.Deserializer; +import org.apache.kafka.common.serialization.StringDeserializer; import java.io.Closeable; import java.time.Duration; import java.util.List; +import java.util.Properties; import java.util.Set; import java.util.concurrent.ThreadFactory; import java.util.concurrent.atomic.AtomicBoolean; @@ -36,22 +40,40 @@ public class KafkaConsumerFactory implements Closeable { private final AtomicBoolean running = new AtomicBoolean(false); private final ThreadFactory namedThreadFactory = new NamedThreadFactory("KafkaConsumer", true); - private final ThreadPooledExecutor taskThreadPool = new ThreadPooledExecutor(1, 1, namedThreadFactory); + private final ThreadPooledExecutor taskThreadPool = new ThreadPooledExecutor(1, 1, 10_0000, namedThreadFactory, 5000L); - public KafkaConsumerFactory(KafkaConfiguration configuration, DebbieEventPublisher eventPublisher) { - this.consumer = new KafkaConsumer<>(configuration.getConsumer().toConsumerProperties()); + @SuppressWarnings("unchecked") + public KafkaConsumerFactory(KafkaConfiguration configuration, Properties extraProperties, DebbieEventPublisher eventPublisher) { + KafkaConfiguration.Consumer consumer = configuration.getConsumer(); + Class keyDeserializerClass = consumer.getKeyDeserializer(); + Class valueDeserializerClass = consumer.getValueDeserializer(); + Deserializer keyDeserializer; + if (keyDeserializerClass != null) { + keyDeserializer = (Deserializer) ReflectionHelper.newInstance(keyDeserializerClass); + } else { + keyDeserializer = (Deserializer) new StringDeserializer(); + } + Deserializer valueDeserializer; + if (valueDeserializerClass != null) { + valueDeserializer = (Deserializer) ReflectionHelper.newInstance(valueDeserializerClass); + } else { + valueDeserializer = (Deserializer) new StringDeserializer(); + } + Properties properties = consumer.toConsumerProperties(); + properties.putAll(extraProperties); + this.consumer = new KafkaConsumer<>(properties, keyDeserializer, valueDeserializer); this.eventPublisher = eventPublisher; } public void consumer(final ThreadPooledExecutor executor, - final List list, final Set topics) { + final List list, final Set topics, long timeout) { try { taskThreadPool.execute(() -> { consumer.subscribe(topics); running.set(true); // ConsumerRecordsEvent event; while (running.get()) { - ConsumerRecords records = consumer.poll(Duration.ofMillis(1000)); + ConsumerRecords records = consumer.poll(Duration.ofMillis(timeout)); if (records != null && !records.isEmpty()) { // event = new ConsumerRecordsEvent<>(this, records); // eventPublisher.publishEvent(event); @@ -65,17 +87,17 @@ public void consumer(final ThreadPooledExecutor executor, executor.execute(() -> { Class type = info.getParameterType(); if (type.isInstance(value)) { - info.invokeMethod(value); + info.invoke(value); } else if (type == ConsumerRecord.class) { - info.invokeMethod(record); + info.invoke(record); } }); } else { Class type = info.getParameterType(); if (type.isInstance(value)) { - info.invokeMethod(value); + info.invoke(value); } else if (type == ConsumerRecord.class) { - info.invokeMethod(record); + info.invoke(record); } } } diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumer.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumer.java new file mode 100644 index 0000000..80b2dd6 --- /dev/null +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumer.java @@ -0,0 +1,21 @@ +package com.truthbean.debbie.kafka; + +import java.util.function.Consumer; + +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/25 19:34. + */ +public interface KafkaMessageConsumer { + + String[] topics(); + + default boolean async() { + return false; + } + + Consumer consumer(); + + Class parameterType(); +} diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumerBeanRegister.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumerBeanRegister.java new file mode 100644 index 0000000..cc5e515 --- /dev/null +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumerBeanRegister.java @@ -0,0 +1,31 @@ +package com.truthbean.debbie.kafka; + +import com.truthbean.debbie.bean.*; + +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/18 20:35. + */ +public class KafkaMessageConsumerBeanRegister implements BeanRegister { + + public KafkaMessageConsumerBeanRegister() { + } + + @Override + public boolean support(ClassBeanInfo beanInfo) { + Class beanClass = beanInfo.getBeanClass(); + return KafkaMessageConsumer.class.isAssignableFrom(beanClass); + } + + @SuppressWarnings("unchecked") + @Override + public BeanFactory getBeanFactory(ClassBeanInfo beanInfo) { + return new DebbieReflectionBeanFactory<>((Class) beanInfo.getBeanClass()); + } + + @Override + public int getOrder() { + return 11; + } +} diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumerResolver.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumerResolver.java new file mode 100644 index 0000000..6964314 --- /dev/null +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaMessageConsumerResolver.java @@ -0,0 +1,81 @@ +package com.truthbean.debbie.kafka; + +import com.truthbean.debbie.bean.BeanInfo; +import com.truthbean.debbie.bean.BeanInfoManager; +import com.truthbean.debbie.bean.DebbieReflectionBeanFactory; +import com.truthbean.debbie.bean.GlobalBeanFactory; +import com.truthbean.debbie.concurrent.Async; +import com.truthbean.debbie.concurrent.ThreadPooledExecutor; +import com.truthbean.debbie.core.ApplicationContext; +import com.truthbean.debbie.reflection.ReflectionHelper; + +import java.lang.reflect.Method; +import java.util.*; + +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/25 19:49. + */ +public class KafkaMessageConsumerResolver { + + private final ApplicationContext applicationContext; + + public KafkaMessageConsumerResolver(ApplicationContext applicationContext) { + this.applicationContext = applicationContext; + } + + public void resolve(KafkaConsumerFactory consumerFactory) { + BeanInfoManager beanInfoManager = applicationContext.getBeanInfoManager(); + Set> methodBean = beanInfoManager.getAnnotatedMethodsBean(KafkaConsumerListener.class); + List list = new ArrayList<>(); + Set topicSet = new HashSet<>(); + GlobalBeanFactory globalBeanFactory = applicationContext.getGlobalBeanFactory(); + final ThreadPooledExecutor executor = globalBeanFactory.factory("threadPooledExecutor"); + for (BeanInfo info : methodBean) { + if (info instanceof DebbieReflectionBeanFactory reflectionBeanFactory) { + Set methods = reflectionBeanFactory.getAnnotationMethod(KafkaConsumerListener.class); + for (Method method : methods) { + KafkaConsumerListener kafkaConsumerListener = method.getAnnotation(KafkaConsumerListener.class); + Async async = method.getAnnotation(Async.class); + String[] topics = kafkaConsumerListener.topics(); + topicSet.addAll(Arrays.asList(topics)); + KaKafkaMessageConsumerInfo methodInfo = new KaKafkaMessageConsumerInfo(); + methodInfo.setTopics(topics); + if (async != null) { + methodInfo.setAsync(true); + } else { + methodInfo.setAsync(kafkaConsumerListener.async()); + } + methodInfo.setBean(reflectionBeanFactory.factoryBean(applicationContext)); + int count = method.getParameterCount(); + if (count != 1) { + throw new KafkaConsumerMethodParameterIllegalException("parameter count > 1"); + } + var param = method.getParameters()[0]; + methodInfo.setParameterType(param.getType()); + methodInfo.setConsumer(o -> ReflectionHelper.invokeMethod(methodInfo.getBean(), method, param)); + list.add(methodInfo); + } + } + } + + Set beanList = globalBeanFactory.getBeanList(KafkaMessageConsumer.class); + if (beanList != null && !beanList.isEmpty()) { + for (KafkaMessageConsumer consumer : beanList) { + KaKafkaMessageConsumerInfo info = new KaKafkaMessageConsumerInfo(); + info.setConsumer(consumer.consumer()); + info.setAsync(consumer.async()); + info.setParameterType(consumer.parameterType()); + info.setTopics(consumer.topics()); + list.add(info); + Collections.addAll(topicSet, consumer.topics()); + } + } + + if (!topicSet.isEmpty()) { + KafkaConfiguration kafkaConfiguration = applicationContext.factory(KafkaConfiguration.class); + consumerFactory.consumer(executor, list, topicSet, kafkaConfiguration.getConsumer().getPullTimeout()); + } + } +} diff --git a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaModuleStarter.java b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaModuleStarter.java index ed66fbf..46909c0 100644 --- a/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaModuleStarter.java +++ b/boot/kafka/src/main/java/com/truthbean/debbie/kafka/KafkaModuleStarter.java @@ -1,14 +1,15 @@ -/** - * Copyright (c) 2021 TruthBean(Rogar·Q) - * Debbie is licensed under Mulan PSL v2. - * You can use this software according to the terms and conditions of the Mulan PSL v2. - * You may obtain a copy of Mulan PSL v2 at: - * http://license.coscl.org.cn/MulanPSL2 - * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. - * See the Mulan PSL v2 for more details. +/* + Copyright (c) 2021 TruthBean(Rogar·Q) + Debbie is licensed under Mulan PSL v2. + You can use this software according to the terms and conditions of the Mulan PSL v2. + You may obtain a copy of Mulan PSL v2 at: + http://license.coscl.org.cn/MulanPSL2 + THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. + See the Mulan PSL v2 for more details. */ package com.truthbean.debbie.kafka; +import com.truthbean.common.mini.util.StringUtils; import com.truthbean.debbie.bean.*; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.concurrent.Async; @@ -16,8 +17,7 @@ import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContent; import com.truthbean.debbie.event.DebbieEventPublisher; -import com.truthbean.debbie.event.EventListenerBeanRegister; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.reflection.ReflectionHelper; import java.lang.reflect.Method; import java.util.*; @@ -38,85 +38,46 @@ public boolean enable(EnvironmentContent envContent) { } @Override - public void registerBean(ApplicationContext applicationContext, BeanInitialization beanInitialization) { - DebbieClassBeanInfo debbieBeanInfo = new DebbieClassBeanInfo<>(KafkaConfiguration.class); + public void registerBean(ApplicationContext applicationContext, BeanInfoManager beanInfoManager) { + DebbieReflectionBeanFactory debbieBeanInfo = new DebbieReflectionBeanFactory<>(KafkaConfiguration.class); debbieBeanInfo.addBeanName("kafkaConfiguration"); - beanInitialization.initSingletonBean(debbieBeanInfo); + beanInfoManager.register(debbieBeanInfo); + + var beanFactory = new ConsumerRecordsEventListenerFactory<>("consumerRecordsEventListener"); + beanInfoManager.register(beanFactory); + + beanInfoManager.registerBeanRegister(new KafkaMessageConsumerBeanRegister()); } @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { - GlobalBeanFactory factory = applicationContext.getGlobalBeanFactory(); - BeanInitialization beanInitialization = applicationContext.getBeanInitialization(); - - BeanFactory> beanFactory = new ConsumerRecordsEventListenerFactory(); - beanFactory.setGlobalBeanFactory(factory); - DebbieBeanInfo> beanInfo = new DebbieBeanInfo(ConsumerRecordsEventListener.class); - beanInfo.setBeanType(BeanType.SINGLETON); - beanInfo.setBeanFactory(beanFactory); - beanInfo.addBeanName("consumerRecordsEventListener"); - beanInitialization.initSingletonBean(beanInfo); - applicationContext.refreshBeans(); + public void configure(ApplicationContext applicationContext) { } @Override - public void starter(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { + public void starter(ApplicationContext applicationContext) { GlobalBeanFactory factory = applicationContext.getGlobalBeanFactory(); - BeanInitialization beanInitialization = applicationContext.getBeanInitialization(); + BeanInfoManager beanInfoManager = applicationContext.getBeanInfoManager(); KafkaConfiguration kafkaConfiguration = factory.factory(KafkaConfiguration.class); DebbieEventPublisher eventPublisher = factory.factory(DebbieEventPublisher.class); - // event - BeanInfoFactory infoFactory = applicationContext.getBeanInfoFactory(); - EventListenerBeanRegister eventListenerBeanRegister = new EventListenerBeanRegister(applicationContext); - BeanInfo beanInfo = infoFactory.getBeanInfo("consumerRecordsEventListener", ConsumerRecordsEventListener.class, true); - eventListenerBeanRegister.register(ConsumerRecordsEvent.class, beanInfo.getBeanFactory()); // kafka consumer - KafkaConsumerFactory consumerFactory = new KafkaConsumerFactory<>(kafkaConfiguration, eventPublisher); - DebbieBeanInfo info = new DebbieBeanInfo<>(KafkaConsumerFactory.class); - info.setBean(consumerFactory); - info.setBeanType(BeanType.SINGLETON); - beanInitialization.initSingletonBean(info); - applicationContext.refreshBeans(); + EnvironmentContent envContent = applicationContext.getEnvContent(); + Map matchedKey = envContent.getMatchedKey("debbie.kafka.x"); + Properties properties = new Properties(); + matchedKey.forEach((key, value) -> { + var k = key.substring("debbie.kafka.x".length()); + properties.put(k, value); + }); + KafkaConsumerFactory consumerFactory = new KafkaConsumerFactory<>(kafkaConfiguration, properties, eventPublisher); + var beanFactory = new SimpleBeanFactory<>(consumerFactory, KafkaConsumerFactory.class); + beanInfoManager.register(beanFactory); this.consumerFactory = consumerFactory; } @Override public void postStarter(ApplicationContext applicationContext) { if (this.consumerFactory != null) { - BeanInitialization initialization = applicationContext.getBeanInitialization(); - Set> methodBean = initialization.getAnnotatedMethodBean(KafkaConsumerListener.class); - List list = new ArrayList<>(); - Set topicSet = new HashSet<>(); - GlobalBeanFactory globalBeanFactory = applicationContext.getGlobalBeanFactory(); - final ThreadPooledExecutor executor = globalBeanFactory.factory("threadPooledExecutor"); - for (DebbieClassBeanInfo info : methodBean) { - var bean = globalBeanFactory.factory(info); - Set methods = info.getAnnotationMethod(KafkaConsumerListener.class); - for (Method method : methods) { - KafkaConsumerListener kafkaConsumerListener = method.getAnnotation(KafkaConsumerListener.class); - Async async = method.getAnnotation(Async.class); - String[] topics = kafkaConsumerListener.topics(); - topicSet.addAll(Arrays.asList(topics)); - KafkaConsumerListenerMethodInfo methodInfo = new KafkaConsumerListenerMethodInfo(); - methodInfo.setTopics(topics); - if (async != null) { - methodInfo.setAsync(true); - } else { - methodInfo.setAsync(kafkaConsumerListener.async()); - } - methodInfo.setBean(bean); - int count = method.getParameterCount(); - if (count != 1) { - throw new KafkaConsumerMethodParameterIllegalException("parameter count > 1"); - } - var param = method.getParameters()[0]; - methodInfo.setParameterType(param.getType()); - methodInfo.setMethod(method); - list.add(methodInfo); - } - } - this.consumerFactory.consumer(executor, list, topicSet); + new KafkaMessageConsumerResolver(applicationContext).resolve(consumerFactory); } } @@ -126,7 +87,7 @@ public int getOrder() { } @Override - public void release(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { + public void release(ApplicationContext applicationContext) { if (this.consumerFactory != null) { this.consumerFactory.close(); } diff --git a/boot/kafka/src/main/java/module-info.java b/boot/kafka/src/main/java/module-info.java index 9a0d885..4f2f306 100644 --- a/boot/kafka/src/main/java/module-info.java +++ b/boot/kafka/src/main/java/module-info.java @@ -14,13 +14,13 @@ */ module com.truthbean.debbie.kafka { requires java.base; + requires java.management; requires transitive com.truthbean.debbie.core; requires static kafka.clients; // requires com.github.luben.zstd_jni; // requires org.lz4.java; requires com.fasterxml.jackson.datatype.jsr310; requires com.fasterxml.jackson.annotation; - requires com.truthbean.logger.slf4j.boot; exports com.truthbean.debbie.kafka; diff --git a/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/native-image.properties b/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/native-image.properties new file mode 100644 index 0000000..8606205 --- /dev/null +++ b/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/native-image.properties @@ -0,0 +1 @@ +Args = -J--add-exports=java.management/sun.management=ALL-UNNAMED \ No newline at end of file diff --git a/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/proxy-config.json b/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/proxy-config.json new file mode 100644 index 0000000..6f59364 --- /dev/null +++ b/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/proxy-config.json @@ -0,0 +1,4 @@ +[ + [], + ["com.truthbean.debbie.kafka.KafkaMessageConsumer"] +] \ No newline at end of file diff --git a/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/reflect-config.json b/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/reflect-config.json new file mode 100644 index 0000000..dc5a496 --- /dev/null +++ b/boot/kafka/src/main/resources/META-INF/native-image/com.truthbean/debbie-kafka/reflect-config.json @@ -0,0 +1,435 @@ +[ + { + "name": "com.truthbean.debbie.kafka.KafkaModuleStarter", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "com.truthbean.debbie.kafka.KafkaConfiguration", + "methods": [ + { "name": "", "parameterTypes": [] }, + { "name": "setBootstrapServers", "parameterTypes": ["java.util.List"] }, + { "name": "setConsumer", "parameterTypes": ["com.truthbean.debbie.kafka.KafkaConfiguration$Consumer"] }, + { "name": "setName", "parameterTypes": ["java.lang.String"] }, + { "name": "setEnable", "parameterTypes": ["boolean"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "com.truthbean.debbie.kafka.KafkaConfiguration$Consumer", + "methods": [ + { "name": "", "parameterTypes": [] }, + { "name": "setBootstrapServers", "parameterTypes": ["java.util.List"] }, + { "name": "setKeyDeserializer", "parameterTypes": ["java.lang.Class"] }, + { "name": "setValueDeserializer", "parameterTypes": ["java.lang.Class"] }, + { "name": "setGroupId", "parameterTypes": ["java.lang.String"] }, + { "name": "setClientId", "parameterTypes": ["java.lang.String"] }, + { "name": "setEnableAutocommit", "parameterTypes": ["java.lang.Boolean"] }, + { "name": "setAutoCommitInterval", "parameterTypes": ["java.lang.Integer"] }, + { "name": "setAutoOffsetReset", "parameterTypes": ["java.lang.String"] }, + { "name": "setSessionTimeout", "parameterTypes": ["java.lang.Integer"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.ByteArrayDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.ByteBufferDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.BytesDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.DoubleDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.FloatDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.IntegerDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.ListDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.LongDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.ShortDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.StringDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.UUIDDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.common.serialization.VoidDeserializer", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.clients.consumer.RangeAssignor", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.clients.consumer.RoundRobinAssignor", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.clients.consumer.StickyAssignor", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.clients.consumer.CooperativeStickyAssignor", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.clients.producer.RoundRobinPartitioner", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.clients.producer.UniformStickyPartitioner", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.kafka.clients.producer.internals.DefaultPartitioner", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.metrics.JmxReporter", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.ssl.DefaultSslEngineFactory", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.config.provider.FileConfigProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.authenticator.SaslClientCallbackHandler", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.authenticator.SaslServerCallbackHandler", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.kerberos.KerberosClientCallbackHandler", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.oauthbearer.internals.OAuthBearerSaslClientCallbackHandler", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerUnsecuredLoginCallbackHandler", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.oauthbearer.internals.unsecured.OAuthBearerUnsecuredValidatorCallbackHandler", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.plain.internals.PlainServerCallbackHandler", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.authenticator.DefaultLogin", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.kerberos.KerberosLogin", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "org.apache.kafka.common.security.oauthbearer.internals.OAuthBearerRefreshingLogin", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + } +] \ No newline at end of file diff --git a/boot/kafka/src/test/java/com/truthbean/debbie/kafka/test/KafkaMessageListener.java b/boot/kafka/src/test/java/com/truthbean/debbie/kafka/test/KafkaMessageListener.java index a5db586..cc49ebf 100644 --- a/boot/kafka/src/test/java/com/truthbean/debbie/kafka/test/KafkaMessageListener.java +++ b/boot/kafka/src/test/java/com/truthbean/debbie/kafka/test/KafkaMessageListener.java @@ -23,7 +23,7 @@ @BeanComponent public class KafkaMessageListener { - @KafkaConsumerListener(topics = "hkvs-alarm", async = true) + @KafkaConsumerListener(topics = "graalvm", async = true) public void onKafkaListener(ConsumerRecord record) { logger.info(() -> "topic: " + record.topic()); logger.info(() -> "offset: " + record.offset()); diff --git a/boot/kafka/src/test/java/module-info.java b/boot/kafka/src/test/java/module-info.java index 5580073..ff6679b 100644 --- a/boot/kafka/src/test/java/module-info.java +++ b/boot/kafka/src/test/java/module-info.java @@ -23,5 +23,5 @@ requires org.lz4.java; requires com.fasterxml.jackson.datatype.jsr310; requires com.fasterxml.jackson.annotation; - requires com.truthbean.logger.slf4j.boot; + requires com.truthbean.logger.stdout.boot; } \ No newline at end of file diff --git a/boot/kafka/src/test/resources/application.properties b/boot/kafka/src/test/resources/application.properties index 41e15f5..d9825ce 100644 --- a/boot/kafka/src/test/resources/application.properties +++ b/boot/kafka/src/test/resources/application.properties @@ -1,8 +1,8 @@ -debbie.kafka.bootstrap-servers: 192.168.1.12:19092 +debbie.kafka.bootstrap-servers: 192.168.1.13:19092 debbie.kafka.consumer.key-deserializer: org.apache.kafka.common.serialization.StringDeserializer debbie.kafka.consumer.value-deserializer: org.apache.kafka.common.serialization.StringDeserializer -debbie.kafka.consumer.group-id: hkvs -debbie.kafka.consumer.client-id: hkvs-ehome-consumer +debbie.kafka.consumer.group-id: graalvm +debbie.kafka.consumer.client-id: graalvm-consumer debbie.kafka.consumer.enable-auto-commit: true debbie.kafka.consumer.auto-commit-interval: 100 debbie.kafka.consumer.auto-offset-reset: earliest diff --git a/boot/lucene/pom.xml b/boot/lucene/pom.xml index c3a0952..21a6f1a 100644 --- a/boot/lucene/pom.xml +++ b/boot/lucene/pom.xml @@ -12,9 +12,9 @@ debbie-lucene - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/lucene/src/main/java/com/truthbean/debbie/lucene/DebbieLuceneModuleStarter.java b/boot/lucene/src/main/java/com/truthbean/debbie/lucene/DebbieLuceneModuleStarter.java index de223a3..8f00add 100644 --- a/boot/lucene/src/main/java/com/truthbean/debbie/lucene/DebbieLuceneModuleStarter.java +++ b/boot/lucene/src/main/java/com/truthbean/debbie/lucene/DebbieLuceneModuleStarter.java @@ -9,10 +9,12 @@ */ package com.truthbean.debbie.lucene; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContent; import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.properties.PropertiesConfigurationBeanFactory; /** * @author TruthBean/Rogar·Q @@ -34,7 +36,12 @@ public int getOrder() { } @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { - configurationFactory.register(LuceneProperties.class, LuceneConfiguration.class); + public void registerBean(ApplicationContext applicationContext, BeanInfoManager beanInfoManager) { + var beanFactory = new PropertiesConfigurationBeanFactory<>(new LuceneProperties(), LuceneConfiguration.class); + beanInfoManager.register(beanFactory); + } + + @Override + public void configure(ApplicationContext applicationContext) { } } diff --git a/boot/lucene/src/main/java/com/truthbean/debbie/lucene/LuceneConfiguration.java b/boot/lucene/src/main/java/com/truthbean/debbie/lucene/LuceneConfiguration.java index 1b0668d..feff9f7 100644 --- a/boot/lucene/src/main/java/com/truthbean/debbie/lucene/LuceneConfiguration.java +++ b/boot/lucene/src/main/java/com/truthbean/debbie/lucene/LuceneConfiguration.java @@ -18,6 +18,8 @@ */ public class LuceneConfiguration implements DebbieConfiguration { + private boolean enable; + private String name = "default"; private String dataPath; @@ -30,6 +32,15 @@ public void setDataPath(String dataPath) { this.dataPath = dataPath; } + @Override + public boolean isEnable() { + return enable; + } + + public void setEnable(boolean enable) { + this.enable = enable; + } + @Override public String getName() { return name; @@ -40,7 +51,7 @@ public void setName(String name) { } @Override - public void reset() { + public void close() { } } diff --git a/boot/lucene/src/main/java/com/truthbean/debbie/lucene/LuceneProperties.java b/boot/lucene/src/main/java/com/truthbean/debbie/lucene/LuceneProperties.java index 4c23541..13d9afe 100644 --- a/boot/lucene/src/main/java/com/truthbean/debbie/lucene/LuceneProperties.java +++ b/boot/lucene/src/main/java/com/truthbean/debbie/lucene/LuceneProperties.java @@ -14,6 +14,7 @@ import com.truthbean.debbie.properties.DebbieProperties; import java.net.URL; +import java.util.Set; /** * @author TruthBean/Rogar·Q @@ -33,7 +34,22 @@ public LuceneProperties() { } @Override - public LuceneConfiguration toConfiguration(ApplicationContext applicationContext) { + public Set getProfiles() { + return null; + } + + @Override + public LuceneConfiguration getConfiguration(String name, ApplicationContext applicationContext) { + return null; + } + + @Override + public LuceneConfiguration getConfiguration(ApplicationContext applicationContext) { return configuration; } + + @Override + public void close() throws Exception { + + } } diff --git a/boot/lucene/src/test/java/com/truthbean/debbie/lucene/DebbieLuceneTest.java b/boot/lucene/src/test/java/com/truthbean/debbie/lucene/DebbieLuceneTest.java index ef1805d..df1935d 100644 --- a/boot/lucene/src/test/java/com/truthbean/debbie/lucene/DebbieLuceneTest.java +++ b/boot/lucene/src/test/java/com/truthbean/debbie/lucene/DebbieLuceneTest.java @@ -9,7 +9,11 @@ */ package com.truthbean.debbie.lucene; +import com.truthbean.Logger; +import com.truthbean.LoggerFactory; import com.truthbean.debbie.bean.BeanInject; +import com.truthbean.debbie.jdbc.entity.EntityResolver; +import com.truthbean.debbie.jdbc.repository.JdbcTransactionRepository; import com.truthbean.transformer.text.DoubleArrayTransformer; import com.truthbean.debbie.jdbc.datasource.DataSourceFactory; import com.truthbean.debbie.jdbc.repository.DynamicRepository; @@ -40,7 +44,7 @@ void createIndex(@BeanInject("dataSourceFactory") DataSourceFactory factory) thr .select("id", "createTime as date", "feature") .from("face") .orderBy("id").desc() - .toList(Feature.class); + .toList(LOGGER, new JdbcTransactionRepository<>(), EntityResolver.getInstance(), Feature.class); for (Feature feature : list) { helper.createIndex(feature); } @@ -66,4 +70,6 @@ void search() throws IOException { DistanceFeature distanceFeature = helper.queryIndex(feature); System.out.println(distanceFeature); } + + private static final Logger LOGGER = LoggerFactory.getLogger(DebbieLuceneTest.class); } diff --git a/boot/metrics/pom.xml b/boot/metrics/pom.xml index 459be0b..5e31f7b 100644 --- a/boot/metrics/pom.xml +++ b/boot/metrics/pom.xml @@ -12,8 +12,8 @@ debbie-metrics - 11 - 11 + 17 + 17 diff --git a/boot/mybatis/pom.xml b/boot/mybatis/pom.xml index 4923a1a..fb854ab 100644 --- a/boot/mybatis/pom.xml +++ b/boot/mybatis/pom.xml @@ -12,9 +12,9 @@ debbie-mybatis - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/DebbieMapperFactory.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/DebbieMapperFactory.java index a49d5ae..9c73f26 100644 --- a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/DebbieMapperFactory.java +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/DebbieMapperFactory.java @@ -9,52 +9,71 @@ */ package com.truthbean.debbie.mybatis; +import com.truthbean.common.mini.util.StringUtils; import com.truthbean.debbie.bean.BeanFactory; import com.truthbean.debbie.bean.GlobalBeanFactory; +import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.mybatis.support.SqlSessionDebbieSupport; import org.apache.ibatis.session.SqlSessionFactory; +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + /** * @author TruthBean * @since 0.0.2 * Created on 2019/06/02 18:38. */ public class DebbieMapperFactory extends SqlSessionDebbieSupport implements BeanFactory { - private Class mapperInterface; + private final Class mapperInterface; - private SqlSessionFactoryHandler handler; + private final Set names = new HashSet<>(); - public DebbieMapperFactory() { - } + private final SqlSessionFactoryHandler handler; public DebbieMapperFactory(Class mapperInterface, SqlSessionFactoryHandler handler) { this.mapperInterface = mapperInterface; this.handler = handler; setSqlSessionFactory(); + + names.add(StringUtils.toFirstCharLowerCase(mapperInterface.getSimpleName())); + names.add(mapperInterface.getName()); + } + + private void setSqlSessionFactory() { + SqlSessionFactory sqlSessionFactory = handler.buildSqlSessionFactory(); + setSqlSessionFactory(sqlSessionFactory); } @Override - public void setGlobalBeanFactory(GlobalBeanFactory globalBeanFactory) { + public Set getBeanNames() { + return names; + } + @Override + public Mapper factoryBean(ApplicationContext applicationContext) { + return getSqlSession().getMapper(mapperInterface); } - public void setHandler(SqlSessionFactoryHandler handler) { - this.handler = handler; + @Override + public Mapper factoryNamedBean(String name, ApplicationContext applicationContext) { + return getSqlSession().getMapper(mapperInterface); } - private void setSqlSessionFactory() { - SqlSessionFactory sqlSessionFactory = handler.buildSqlSessionFactory(); - setSqlSessionFactory(sqlSessionFactory); + @Override + public boolean isCreated() { + return true; } @Override - public Mapper getBean() { + public Mapper getCreatedBean() { return getSqlSession().getMapper(mapperInterface); } @Override - public Class getBeanType() { + public Class getBeanClass() { return mapperInterface; } @@ -64,7 +83,30 @@ public boolean isSingleton() { } @Override - public void destroy() { - // do nothing + public boolean equals(Object o) { + if (!isEquals(o)) { + return false; + } + if (this == o) return true; + if (!(o instanceof DebbieMapperFactory that)) return false; + return Objects.equals(mapperInterface, that.mapperInterface) && Objects.equals(handler, that.handler); + } + + @Override + public int hashCode() { + Set beanNames = getBeanNames(); + // 重新计算hashcode + int h = 0; + for (String obj : beanNames) { + if (obj != null) { + h += obj.hashCode(); + } + } + return h + Objects.hash(mapperInterface, handler); + } + + @Override + public void destruct(ApplicationContext applicationContext) { + names.clear(); } } diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/MybatisModuleStarter.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/MybatisModuleStarter.java index 871ba16..a7e27de 100644 --- a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/MybatisModuleStarter.java +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/MybatisModuleStarter.java @@ -10,15 +10,17 @@ package com.truthbean.debbie.mybatis; import com.truthbean.debbie.bean.BeanComponentParser; -import com.truthbean.debbie.bean.BeanInitialization; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContent; import com.truthbean.debbie.mybatis.annotation.*; import com.truthbean.debbie.mybatis.configuration.MyBatisConfigurationSettings; +import com.truthbean.debbie.mybatis.configuration.MybatisConfiguration; import com.truthbean.debbie.mybatis.configuration.MybatisProperties; import com.truthbean.debbie.mybatis.configuration.transformer.*; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.properties.PropertiesConfigurationBeanFactory; +import com.truthbean.transformer.DataTransformerCenter; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.session.AutoMappingBehavior; import org.apache.ibatis.session.AutoMappingUnknownColumnBehavior; @@ -56,28 +58,27 @@ public Map, BeanComponentParser> getComponentAnnotat } @Override - public void registerBean(ApplicationContext context, BeanInitialization beanInitialization) { - beanInitialization.init(MyBatisConfigurationSettings.class); + public void registerBean(ApplicationContext context, BeanInfoManager beanInfoManager) { + beanInfoManager.register(MyBatisConfigurationSettings.class); + MybatisProperties mybatisProperties = new MybatisProperties(context); + var configurationBeanFactory = new PropertiesConfigurationBeanFactory<>(mybatisProperties, MybatisConfiguration.class); + beanInfoManager.register(configurationBeanFactory); + beanInfoManager.registerBeanRegister(new MappedBeanRegister(context, configurationBeanFactory.factoryBean(context))); + beanInfoManager.registerBeanRegister(new MybatisBeanRegister(context)); - registerTransformer(beanInitialization); - - // MethodProxyHandlerRegister methodProxyHandlerRegister = beanFactoryHandler.getMethodProxyHandlerRegister(); - // methodProxyHandlerRegister.register(JdbcTransactional.class, MybatisTransactionalHandler.class); + registerTransformer(); } - private void registerTransformer(BeanInitialization beanInitialization) { - beanInitialization.registerDataTransformer(new AutoMappingBehaviorTransformer(), AutoMappingBehavior.class, String.class); - beanInitialization.registerDataTransformer(new AutoMappingUnknownColumnBehaviorTransformer(), AutoMappingUnknownColumnBehavior.class, String.class); - beanInitialization.registerDataTransformer(new ExecutorTypeTransformer(), ExecutorType.class, String.class); - beanInitialization.registerDataTransformer(new JdbcTypeTransformer(), JdbcType.class, String.class); - beanInitialization.registerDataTransformer(new LocalCacheScopeTransformer(), LocalCacheScope.class, String.class); + private void registerTransformer() { + DataTransformerCenter.register(new AutoMappingBehaviorTransformer(), AutoMappingBehavior.class, String.class); + DataTransformerCenter.register(new AutoMappingUnknownColumnBehaviorTransformer(), AutoMappingUnknownColumnBehavior.class, String.class); + DataTransformerCenter.register(new ExecutorTypeTransformer(), ExecutorType.class, String.class); + DataTransformerCenter.register(new JdbcTypeTransformer(), JdbcType.class, String.class); + DataTransformerCenter.register(new LocalCacheScopeTransformer(), LocalCacheScope.class, String.class); } @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext context) { - MappedBeanRegister register = new MappedBeanRegister(configurationFactory, context); - register.registerMapper(); - register.registerSqlSessionFactory(); + public void configure(ApplicationContext context) { } @Override diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionFactoryBeanFactory.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionFactoryBeanFactory.java new file mode 100644 index 0000000..e60e22d --- /dev/null +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionFactoryBeanFactory.java @@ -0,0 +1,88 @@ +package com.truthbean.debbie.mybatis; + +import com.truthbean.debbie.bean.BeanFactory; +import com.truthbean.debbie.core.ApplicationContext; +import com.truthbean.debbie.mybatis.support.SqlSessionDebbieSupport; +import org.apache.ibatis.session.SqlSessionFactory; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/25 20:23. + */ +public class SqlSessionFactoryBeanFactory extends SqlSessionDebbieSupport implements BeanFactory { + + private final SqlSessionFactoryHandler handler; + + private final Set names = new HashSet<>(); + + public SqlSessionFactoryBeanFactory(SqlSessionFactoryHandler handler) { + this.handler = handler; + + setSqlSessionFactory(); + + names.add("org.apache.ibatis.session.SqlSessionFactory"); + names.add("sqlSessionFactory"); + } + + private void setSqlSessionFactory() { + SqlSessionFactory sqlSessionFactory = handler.buildSqlSessionFactory(); + setSqlSessionFactory(sqlSessionFactory); + } + + @Override + public Set getBeanNames() { + return names; + } + + @Override + public SqlSessionFactory factoryBean(ApplicationContext applicationContext) { + setSqlSessionFactory(); + return getSqlSessionFactory(); + } + + @Override + public SqlSessionFactory factoryNamedBean(String name, ApplicationContext applicationContext) { + setSqlSessionFactory(); + return getSqlSessionFactory(); + } + + @Override + public boolean isCreated() { + return true; + } + + @Override + public SqlSessionFactory getCreatedBean() { + setSqlSessionFactory(); + return getSqlSessionFactory(); + } + + @Override + public Class getBeanClass() { + return SqlSessionFactory.class; + } + + @Override + public boolean isSingleton() { + return false; + } + + @Override + public boolean equals(Object o) { + return isEquals(o); + } + + @Override + public int hashCode() { + return getHashCode(0); + } + + @Override + public void destruct(ApplicationContext applicationContext) { + names.clear(); + } +} diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionFactoryHandler.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionFactoryHandler.java index 68ec69d..ab1027b 100644 --- a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionFactoryHandler.java +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionFactoryHandler.java @@ -9,16 +9,15 @@ */ package com.truthbean.debbie.mybatis; -import com.truthbean.debbie.bean.BeanInitialization; -import com.truthbean.debbie.bean.DebbieBeanInfo; -import com.truthbean.debbie.bean.DebbieClassBeanInfo; +import com.truthbean.debbie.bean.BeanInfoManager; +import com.truthbean.debbie.bean.GlobalBeanFactory; +import com.truthbean.debbie.bean.SimpleBeanFactory; import com.truthbean.debbie.core.ApplicationContext; +import com.truthbean.debbie.io.ResourceResolver; import com.truthbean.debbie.jdbc.datasource.DataSourceFactory; -import com.truthbean.debbie.jdbc.datasource.DataSourceFactoryBeanRegister; import com.truthbean.debbie.mybatis.configuration.MybatisConfiguration; -import com.truthbean.debbie.mybatis.configuration.MybatisProperties; import com.truthbean.debbie.mybatis.transaction.DebbieManagedTransactionFactory; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.mybatis.transaction.MybatisTransactionFactory; import com.truthbean.debbie.reflection.ClassLoaderUtils; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.builder.xml.XMLMapperBuilder; @@ -35,6 +34,8 @@ import org.apache.ibatis.session.SqlSessionFactory; import org.apache.ibatis.session.SqlSessionFactoryBuilder; import org.apache.ibatis.transaction.TransactionFactory; +import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; +import org.apache.ibatis.transaction.managed.ManagedTransactionFactory; import org.apache.ibatis.type.*; import com.truthbean.Logger; import com.truthbean.LoggerFactory; @@ -57,23 +58,30 @@ public class SqlSessionFactoryHandler { private Configuration configuration; private InputStream mybatisConfigXmlInputStream; - private final ApplicationContext context; - private final BeanInitialization beanInitialization; + private final String prefix; - public SqlSessionFactoryHandler(DebbieConfigurationCenter configurationFactory, ApplicationContext context) { - this.context = context; - this.beanInitialization = context.getBeanInitialization(); - this.mybatisConfiguration = new MybatisProperties(context).loadConfiguration(); + public SqlSessionFactoryHandler(ApplicationContext context, MybatisConfiguration mybatisConfiguration, + MybatisTransactionFactory mybatisTransactionFactory) { + this.mybatisConfiguration = mybatisConfiguration; if (getMybatisConfigXmlInputStream() == null) { - buildConfiguration(configurationFactory); + buildConfiguration(context, mybatisTransactionFactory); } + prefix = mybatisTransactionFactory.name().toLowerCase(); + } + + public SqlSessionFactoryHandler(ApplicationContext context, MybatisConfiguration mybatisConfiguration) { + this.mybatisConfiguration = mybatisConfiguration; + if (getMybatisConfigXmlInputStream() == null) { + buildConfiguration(context, MybatisTransactionFactory.JDBC); + } + prefix = "jdbc"; } private SqlSessionFactory sqlSessionFactory; - public void onApplicationEvent() { + /*public void onApplicationEvent() { configuration.getMappedStatementNames(); - } + }*/ private InputStream getMybatisConfigXmlInputStream() { if (mybatisConfigXmlInputStream == null) { @@ -82,7 +90,7 @@ private InputStream getMybatisConfigXmlInputStream() { try { mybatisConfigXmlInputStream = Resources.getResourceAsStream(resource); } catch (IOException e) { - e.printStackTrace(); + LOGGER.error("", e); } } } @@ -95,21 +103,27 @@ private void buildSqlSessionFactoryByXml() { } } - private DataSourceFactory getDataSourceFactoryOrInitIfNull(DebbieConfigurationCenter configurationFactory) { - DataSourceFactory dataSourceFactory = beanInitialization.getRegisterBean(DataSourceFactory.class); + private DataSourceFactory getDataSourceFactoryOrInitIfNull(ApplicationContext context) { + GlobalBeanFactory globalBeanFactory = context.getGlobalBeanFactory(); + DataSourceFactory dataSourceFactory = globalBeanFactory.factoryIfPresent(DataSourceFactory.class); if (dataSourceFactory == null) { - var register = new DataSourceFactoryBeanRegister(configurationFactory, context); + /*var register = new DataSourceFactoryBeanRegister(configurationFactory, context); register.registerDataSourceFactory(); context.refreshBeans(); - dataSourceFactory = beanInitialization.getRegisterBean(DataSourceFactory.class); + dataSourceFactory = beanInitialization.getRegisterBean(DataSourceFactory.class);*/ } return dataSourceFactory; } - private void buildConfiguration(DebbieConfigurationCenter configurationFactory) { - DataSourceFactory dataSourceFactory = getDataSourceFactoryOrInitIfNull(configurationFactory); + private void buildConfiguration(ApplicationContext context, MybatisTransactionFactory mybatisTransactionFactory) { + DataSourceFactory dataSourceFactory = getDataSourceFactoryOrInitIfNull(context); DataSource dataSource = dataSourceFactory.getDataSource(); - TransactionFactory transactionFactory = new DebbieManagedTransactionFactory(dataSourceFactory.getDriverName()); + TransactionFactory transactionFactory; + switch (mybatisTransactionFactory) { + default -> transactionFactory = new DebbieManagedTransactionFactory(dataSourceFactory.getDriverName()); + case JDBC -> transactionFactory = new JdbcTransactionFactory(); + case MANAGED -> transactionFactory = new ManagedTransactionFactory(); + } Environment environment = new Environment(mybatisConfiguration.getEnvironment(), transactionFactory, dataSource); configuration = new Configuration(environment); mybatisConfiguration.getSettings().configTo(configuration); @@ -135,11 +149,32 @@ private void buildConfiguration(DebbieConfigurationCenter configurationFactory) } } - Set> alias = beanInitialization.getAnnotatedClass(Alias.class); + ResourceResolver resourceResolver = context.getResourceResolver(); + Set> classes = resourceResolver.getCachedClasses(); + + Set> alias = new HashSet<>(); + Set> mappedTypes = new HashSet<>(); + Set> mappedJdbcTypes = new HashSet<>(); + Set> mappers = new HashSet<>(); + + for (Class clazz : classes) { + if (clazz.isAnnotationPresent(Alias.class)) { + alias.add(clazz); + } + if (clazz.isAnnotationPresent(MappedTypes.class)) { + mappedTypes.add(clazz); + } + if (clazz.isAnnotationPresent(MappedJdbcTypes.class)) { + mappedJdbcTypes.add(clazz); + } + if (clazz.isAnnotationPresent(Mapper.class)) { + mappers.add(clazz); + } + } + TypeAliasRegistry typeAliasRegistry = configuration.getTypeAliasRegistry(); - if (alias != null && !alias.isEmpty()) { - for (DebbieClassBeanInfo typeAlias : alias) { - var typeAliasClass = typeAlias.getBeanClass(); + if (!alias.isEmpty()) { + for (Class typeAliasClass : alias) { typeAliasRegistry.registerAlias(typeAliasClass); LOGGER.trace("Registered type alias: '" + typeAliasClass + "'"); } @@ -154,18 +189,16 @@ private void buildConfiguration(DebbieConfigurationCenter configurationFactory) } } - Set> mapped = new HashSet<>(); - Set> mappedTypes = beanInitialization.getAnnotatedClass(MappedTypes.class); - if (mappedTypes != null && !mappedTypes.isEmpty()) { + Set> mapped = new HashSet<>(); + if (!mappedTypes.isEmpty()) { mapped.addAll(mappedTypes); } - Set> mappedJdbcTypes = beanInitialization.getAnnotatedClass(MappedJdbcTypes.class); - if (mappedJdbcTypes != null && !mappedJdbcTypes.isEmpty()) { + + if (!mappedJdbcTypes.isEmpty()) { mapped.addAll(mappedJdbcTypes); } if (!mapped.isEmpty()) { - for (DebbieClassBeanInfo mappedType : mapped) { - var mappedTypeClass = mappedType.getBeanClass(); + for (Class mappedTypeClass : mapped) { typeHandlerRegistry.register(mappedTypeClass); LOGGER.trace("Registered type handlers: '" + mappedTypeClass + "'"); } @@ -184,12 +217,15 @@ private void buildConfiguration(DebbieConfigurationCenter configurationFactory) configuration.addCache(cache); } - Set> mappers = beanInitialization.getAnnotatedClass(Mapper.class); - if (mappers != null && !mappers.isEmpty()) { - for (DebbieClassBeanInfo mapper : mappers) { - Class mapperClass = mapper.getBeanClass(); + if (!mappers.isEmpty()) { + for (Class mapperClass : mappers) { configuration.addMapper(mapperClass); LOGGER.trace("Registered type mapper: '" + mapperClass + "'"); + BeanInfoManager beanInfoManager = context.getBeanInfoManager(); + if (!beanInfoManager.isBeanRegistered(mapperClass)) { + var factory = new DebbieMapperFactory<>(mapperClass, this); + beanInfoManager.register(factory); + } } } @@ -229,4 +265,11 @@ public SqlSessionFactory buildSqlSessionFactory() { return sqlSessionFactory; } + public void registerMybatisConfiguration(BeanInfoManager beanInfoManager) { + beanInfoManager.register(new SimpleBeanFactory<>(configuration, true)); + } + + public String getPrefix() { + return prefix; + } } diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionTemplate.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionTemplate.java index 745f918..daf9227 100644 --- a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionTemplate.java +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/SqlSessionTemplate.java @@ -19,6 +19,7 @@ import java.util.Map; import com.truthbean.debbie.bean.BeanClosure; +import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.mybatis.support.SqlSessionDebbieSupport; import com.truthbean.debbie.util.Assert; import org.apache.ibatis.cursor.Cursor; @@ -357,7 +358,7 @@ public List flushStatements() { * } * *

- * The implementation of {@link BeanClosure} forces bean context to use {@link BeanClosure#destroy()} method + * The implementation of {@link BeanClosure} forces bean context to use {@link BeanClosure#destruct(ApplicationContext)} ()} method * instead of {@link SqlSessionTemplate#close()} to shutdown gently. * * @see SqlSessionTemplate#close() @@ -365,7 +366,7 @@ public List flushStatements() { * @see "org.springframework.beans.factory.support.DisposableBeanAdapter#CLOSE_METHOD_NAME" */ @Override - public void destroy() { + public void destruct(ApplicationContext applicationContext) { // This method forces spring disposer to avoid call of SqlSessionTemplate.close() which gives // UnsupportedOperationException } diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/annotation/MappedBeanRegister.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/annotation/MappedBeanRegister.java index 6f3fce7..f083eaa 100644 --- a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/annotation/MappedBeanRegister.java +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/annotation/MappedBeanRegister.java @@ -9,53 +9,48 @@ */ package com.truthbean.debbie.mybatis.annotation; -import com.truthbean.debbie.bean.BeanInitialization; -import com.truthbean.debbie.bean.DebbieBeanInfo; -import com.truthbean.debbie.bean.DebbieClassBeanInfo; +import com.truthbean.debbie.bean.BeanFactory; +import com.truthbean.debbie.bean.BeanInfoManager; +import com.truthbean.debbie.bean.BeanRegister; +import com.truthbean.debbie.bean.ClassBeanInfo; import com.truthbean.debbie.core.ApplicationContext; -import com.truthbean.debbie.jdbc.datasource.DataSourceFactoryBeanRegister; import com.truthbean.debbie.mybatis.DebbieMapperFactory; +import com.truthbean.debbie.mybatis.SqlSessionFactoryBeanFactory; import com.truthbean.debbie.mybatis.SqlSessionFactoryHandler; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.mybatis.configuration.MybatisConfiguration; +import com.truthbean.debbie.mybatis.transaction.MybatisTransactionFactory; import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.session.SqlSessionFactory; - -import java.util.Set; /** * @author TruthBean * @since 0.0.2 * Created on 2019/06/02 18:27. */ -public class MappedBeanRegister extends DataSourceFactoryBeanRegister { +public class MappedBeanRegister implements BeanRegister { private final SqlSessionFactoryHandler sqlSessionFactoryHandler; - private final BeanInitialization beanInitialization; - private final ApplicationContext context; - public MappedBeanRegister(DebbieConfigurationCenter configurationFactory, ApplicationContext context) { - super(configurationFactory, context); - this.context = context; - sqlSessionFactoryHandler = new SqlSessionFactoryHandler(configurationFactory, context); - beanInitialization = context.getBeanInitialization(); + public MappedBeanRegister(ApplicationContext context, MybatisConfiguration mybatisConfiguration) { + sqlSessionFactoryHandler = new SqlSessionFactoryHandler(context, mybatisConfiguration); + BeanInfoManager beanInfoManager = context.getBeanInfoManager(); + beanInfoManager.register(new SqlSessionFactoryBeanFactory(sqlSessionFactoryHandler)); + sqlSessionFactoryHandler.registerMybatisConfiguration(context.getBeanInfoManager()); + } + + @Override + public boolean support(ClassBeanInfo beanInfo) { + Class beanClass = beanInfo.getBeanClass(); + return beanClass.isInterface() && support(beanInfo, Mapper.class); } - @SuppressWarnings({"unchecked", "rawtypes"}) - public void registerMapper() { - Set> annotatedClass = beanInitialization.getAnnotatedClass(Mapper.class); - if (annotatedClass != null && !annotatedClass.isEmpty()) { - for (DebbieClassBeanInfo mapperBean : annotatedClass) { - DebbieMapperFactory mapperFactory = new DebbieMapperFactory<>(mapperBean.getBeanClass(), - sqlSessionFactoryHandler); - mapperFactory.setGlobalBeanFactory(context.getGlobalBeanFactory()); - mapperBean.setBeanFactory(mapperFactory); - beanInitialization.refreshBean(mapperBean); - context.refreshBeans(); - } - } + @SuppressWarnings("unchecked") + @Override + public BeanFactory getBeanFactory(ClassBeanInfo beanInfo) { + return new DebbieMapperFactory<>((Class) beanInfo.getBeanClass(), sqlSessionFactoryHandler); } - public void registerSqlSessionFactory() { - registerSingletonBean(sqlSessionFactoryHandler.buildSqlSessionFactory(), SqlSessionFactory.class, "sqlSessionFactory"); + @Override + public int getOrder() { + return 11; } } diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/annotation/MybatisBeanRegister.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/annotation/MybatisBeanRegister.java new file mode 100644 index 0000000..5a1d6af --- /dev/null +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/annotation/MybatisBeanRegister.java @@ -0,0 +1,40 @@ +package com.truthbean.debbie.mybatis.annotation; + +import com.truthbean.debbie.bean.*; +import com.truthbean.debbie.core.ApplicationContext; +import org.apache.ibatis.type.Alias; +import org.apache.ibatis.type.MappedJdbcTypes; +import org.apache.ibatis.type.MappedTypes; + +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/18 20:35. + */ +public class MybatisBeanRegister implements BeanRegister { + + private final BeanInfoManager beanInfoManager; + + public MybatisBeanRegister(ApplicationContext context) { + beanInfoManager = context.getBeanInfoManager(); + } + + @Override + public boolean support(ClassBeanInfo beanInfo) { + Class beanClass = beanInfo.getBeanClass(); + return beanClass.isInterface() + && (support(beanInfo, Alias.class) || support(beanInfo, MappedTypes.class) || support(beanInfo, MappedJdbcTypes.class)) + && !beanInfoManager.isBeanRegistered(beanClass); + } + + @SuppressWarnings("unchecked") + @Override + public BeanFactory getBeanFactory(ClassBeanInfo beanInfo) { + return new DebbieReflectionBeanFactory<>((Class) beanInfo.getBeanClass()); + } + + @Override + public int getOrder() { + return 11; + } +} diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/configuration/MybatisConfiguration.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/configuration/MybatisConfiguration.java index 2971557..985437f 100644 --- a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/configuration/MybatisConfiguration.java +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/configuration/MybatisConfiguration.java @@ -46,6 +46,11 @@ public class MybatisConfiguration implements DebbieConfiguration { private DatabaseIdProvider databaseIdProvider; private Cache cache; + @Override + public boolean isEnable() { + return true; + } + @Override public String getName() { return name; @@ -152,7 +157,7 @@ public void setCache(Cache cache) { } @Override - public void reset() { + public void close() { } } diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/configuration/MybatisProperties.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/configuration/MybatisProperties.java index 77bf186..461f6ca 100644 --- a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/configuration/MybatisProperties.java +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/configuration/MybatisProperties.java @@ -12,15 +12,15 @@ import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContentHolder; import com.truthbean.debbie.io.ResourceResolver; +import com.truthbean.debbie.properties.DebbieProperties; -import java.util.ArrayList; -import java.util.List; +import java.util.*; /** * @author truthbean * @since 0.0.2 */ -public class MybatisProperties extends EnvironmentContentHolder { +public class MybatisProperties extends EnvironmentContentHolder implements DebbieProperties { public static final String ENABLE_KEY = "debbie.mybatis.enable"; //=========================================================================== @@ -30,6 +30,7 @@ public class MybatisProperties extends EnvironmentContentHolder { private static final String MYBATIS_MAPPER_LOCATIONS = "debbie.mybatis.mapper-locations"; //=========================================================================== + private final Map map = new HashMap<>(); private final MybatisConfiguration configuration; private static MybatisProperties instance; @@ -47,6 +48,7 @@ public MybatisProperties(ApplicationContext context) { List list = getStringListValue(MYBATIS_MAPPER_LOCATIONS, ";"); ResourceResolver resourceResolver = context.getResourceResolver(); resolveMapperLocations(list, resourceResolver); + map.put(DEFAULT_PROFILE, configuration); } private void resolveMapperLocations(List patternList, ResourceResolver resourceResolver) { @@ -69,4 +71,20 @@ public static MybatisConfiguration toConfiguration(ApplicationContext context) { public MybatisConfiguration loadConfiguration() { return configuration; } + + @Override + public Set getProfiles() { + return map.keySet(); + } + + @Override + public MybatisConfiguration getConfiguration(String name, ApplicationContext applicationContext) { + return map.get(name); + } + + @Override + public void close() throws Exception { + map.clear(); + instance = null; + } } diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/transaction/MybatisTransactionFactory.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/transaction/MybatisTransactionFactory.java new file mode 100644 index 0000000..a78ed8a --- /dev/null +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/transaction/MybatisTransactionFactory.java @@ -0,0 +1,25 @@ +package com.truthbean.debbie.mybatis.transaction; + +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/26 18:15. + */ +public enum MybatisTransactionFactory { + /** + * org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory + */ + JDBC, + /** + * org.apache.ibatis.transaction.managed.ManagedTransactionFactory + */ + MANAGED, + /** + * spring-mybatis + */ + SPRING, + /** + * com.truthbean.debbie.mybatis.transaction.DebbieManagedTransactionFactory + */ + DEBBIE +} diff --git a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/transaction/MybatisTransactionalHandler.java b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/transaction/MybatisTransactionalHandler.java index 9f5b6e9..fd0f3d0 100644 --- a/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/transaction/MybatisTransactionalHandler.java +++ b/boot/mybatis/src/main/java/com/truthbean/debbie/mybatis/transaction/MybatisTransactionalHandler.java @@ -9,7 +9,6 @@ */ package com.truthbean.debbie.mybatis.transaction; -import com.truthbean.debbie.bean.BeanInitialization; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.jdbc.transaction.TransactionInfo; import com.truthbean.debbie.proxy.MethodProxyHandler; @@ -35,7 +34,7 @@ public class MybatisTransactionalHandler implements MethodProxyHandler", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "com.truthbean.debbie.mybatis.configuration.MyBatisConfigurationSettings", + "methods": [ + { "name": "", "parameterTypes": [] }, + { "name": "setCacheEnabled", "parameterTypes": ["boolean"] }, + { "name": "setLazyLoadingEnabled", "parameterTypes": ["boolean"] }, + { "name": "setAggressiveLazyLoading", "parameterTypes": ["boolean"] }, + { "name": "setMultipleResultSetsEnabled", "parameterTypes": ["boolean"] }, + { "name": "setUseColumnLabel", "parameterTypes": ["boolean"] }, + { "name": "setUseGeneratedKeys", "parameterTypes": ["boolean"] }, + { "name": "setAutoMappingBehavior", "parameterTypes": ["org.apache.ibatis.session.AutoMappingBehavior"] }, + { "name": "setAutoMappingUnknownColumnBehavior", "parameterTypes": ["org.apache.ibatis.session.AutoMappingUnknownColumnBehavior"] }, + { "name": "setDefaultExecutorType", "parameterTypes": ["org.apache.ibatis.session.ExecutorType"] }, + { "name": "setDefaultStatementTimeout", "parameterTypes": ["java.lang.Integer"] }, + { "name": "setDefaultFetchSize", "parameterTypes": ["java.lang.Integer"] }, + { "name": "setSafeRowBoundsEnabled", "parameterTypes": ["boolean"] }, + { "name": "setSafeResultHandlerEnabled", "parameterTypes": ["boolean"] }, + { "name": "setMapUnderscoreToCamelCase", "parameterTypes": ["boolean"] }, + { "name": "setLocalCacheScope", "parameterTypes": ["org.apache.ibatis.session.LocalCacheScope"] }, + { "name": "setJdbcTypeForNull", "parameterTypes": ["org.apache.ibatis.type.JdbcType"] }, + { "name": "setJdbcTypeForNull", "parameterTypes": ["org.apache.ibatis.type.JdbcType"] }, + { "name": "setLazyLoadTriggerMethods", "parameterTypes": ["java.util.Set"] }, + { "name": "setDefaultScriptingLanguage", "parameterTypes": ["java.lang.Class"] }, + { "name": "setDefaultEnumTypeHandler", "parameterTypes": ["java.lang.Class"] }, + { "name": "setCallSettersOnNulls", "parameterTypes": ["boolean"] }, + { "name": "setReturnInstanceForEmptyRow", "parameterTypes": ["boolean"] }, + { "name": "setLogPrefix", "parameterTypes": ["java.lang.String"] }, + { "name": "setLogImpl", "parameterTypes": ["java.lang.Class"] }, + { "name": "setProxyFactory", "parameterTypes": ["org.apache.ibatis.executor.loader.ProxyFactory"] }, + { "name": "setVfsImpl", "parameterTypes": ["java.lang.Class"] }, + { "name": "setUseActualParamName", "parameterTypes": ["boolean"] }, + { "name": "setConfigurationFactory", "parameterTypes": ["java.lang.Class"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name" : "javassist.util.proxy.ProxyFactory", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.javassist.util.proxy.ProxyFactory", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.logging.slf4j.Slf4jImpl", + "allDeclaredFields": true, + "allDeclaredConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true + }, + { + "name": "org.slf4j.Marker", + "allDeclaredFields": true, + "allDeclaredConstructors": true, + "allDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true + }, + { + "name": "org.apache.ibatis.logging.nologging.NoLoggingImpl", + "methods": [ + { "name": "", "parameterTypes": ["java.lang.String"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.logging.stdout.StdOutImpl", + "methods": [ + { "name": "", "parameterTypes": ["java.lang.String"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.logging.jdk14.Jdk14LoggingImpl", + "methods": [ + { "name": "", "parameterTypes": ["java.lang.String"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.logging.log4j2.Log4j2Impl", + "methods": [ + { "name": "", "parameterTypes": ["java.lang.String"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.logging.log4j.Log4jImpl", + "methods": [ + { "name": "", "parameterTypes": ["java.lang.String"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.logging.commons.JakartaCommonsLoggingImpl", + "methods": [ + { "name": "", "parameterTypes": ["java.lang.String"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.logging.slf4j.Slf4jImpl", + "methods": [ + { "name": "", "parameterTypes": ["java.lang.String"] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.io.JBoss6VFS", + "allPublicConstructors": true + }, + { + "name": "org.apache.ibatis.io.DefaultVFS", + "allPublicConstructors": true + }, + { + "name": "org.apache.ibatis.type.JdbcType", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "java.lang.invoke.MethodHandles", + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.scripting.xmltags.XMLLanguageDriver", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.apache.ibatis.scripting.defaults.RawLanguageDriver", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + } +] \ No newline at end of file diff --git a/boot/mybatis/src/main/resources/META-INF/native-image/com.truthbean.debbie/mybatis/resource-config.json b/boot/mybatis/src/main/resources/META-INF/native-image/com.truthbean.debbie/mybatis/resource-config.json new file mode 100644 index 0000000..caa30d8 --- /dev/null +++ b/boot/mybatis/src/main/resources/META-INF/native-image/com.truthbean.debbie/mybatis/resource-config.json @@ -0,0 +1,13 @@ +{ + "resources": [ + { + "pattern": ".*/*.*xml$" + }, + { + "pattern": ".*/*.*dtd$" + }, + { + "pattern": ".*/*.*xsd$" + } + ] +} \ No newline at end of file diff --git a/boot/mybatis/src/test/java/com/truthbean/debbie/check/mybatis/MybatisTest.java b/boot/mybatis/src/test/java/com/truthbean/debbie/check/mybatis/MybatisTest.java index d5b9c93..8632f11 100644 --- a/boot/mybatis/src/test/java/com/truthbean/debbie/check/mybatis/MybatisTest.java +++ b/boot/mybatis/src/test/java/com/truthbean/debbie/check/mybatis/MybatisTest.java @@ -13,7 +13,8 @@ import com.truthbean.debbie.core.ApplicationFactory; import com.truthbean.debbie.jdbc.datasource.DataSourceFactory; import com.truthbean.debbie.mybatis.SqlSessionFactoryHandler; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.mybatis.configuration.MybatisConfiguration; +import com.truthbean.debbie.mybatis.configuration.MybatisProperties; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.junit.jupiter.api.BeforeAll; @@ -25,19 +26,17 @@ public class MybatisTest { private static ApplicationContext applicationContext; - private static DebbieConfigurationCenter configurationFactory; @BeforeAll static void before() { ApplicationFactory applicationFactory = ApplicationFactory.configure(MybatisTest.class); applicationContext = applicationFactory.getApplicationContext(); DataSourceFactory dataSourceFactory = applicationContext.getGlobalBeanFactory().factory("dataSourceFactory"); - configurationFactory = applicationContext.getConfigurationCenter(); } @Test public void testSqlSessionFactory() throws IOException { - SqlSessionFactoryHandler handler = new SqlSessionFactoryHandler(configurationFactory, applicationContext); + SqlSessionFactoryHandler handler = new SqlSessionFactoryHandler(applicationContext, new MybatisProperties(applicationContext).loadConfiguration()); SqlSessionFactory sqlSessionFactory = handler.buildSqlSessionFactory(); System.out.println(sqlSessionFactory); @@ -45,7 +44,7 @@ public void testSqlSessionFactory() throws IOException { @Test public void testSelectOneSurname() throws IOException { - SqlSessionFactoryHandler handler = new SqlSessionFactoryHandler(configurationFactory, applicationContext); + SqlSessionFactoryHandler handler = new SqlSessionFactoryHandler(applicationContext, new MybatisProperties(applicationContext).loadConfiguration()); SqlSessionFactory sqlSessionFactory = handler.buildSqlSessionFactory(); try (SqlSession session = sqlSessionFactory.openSession()) { @@ -57,7 +56,7 @@ public void testSelectOneSurname() throws IOException { @Test public void testDataTimeMapper() throws IOException { - SqlSessionFactoryHandler handler = new SqlSessionFactoryHandler(configurationFactory, applicationContext); + SqlSessionFactoryHandler handler = new SqlSessionFactoryHandler(applicationContext, new MybatisProperties(applicationContext).loadConfiguration()); SqlSessionFactory sqlSessionFactory = handler.buildSqlSessionFactory(); try (SqlSession session = sqlSessionFactory.openSession()) { diff --git a/boot/pom.xml b/boot/pom.xml index 9cb068f..8e42258 100644 --- a/boot/pom.xml +++ b/boot/pom.xml @@ -32,9 +32,9 @@ - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/servlet/pom.xml b/boot/servlet/pom.xml index 0a8e17d..cb0a28b 100644 --- a/boot/servlet/pom.xml +++ b/boot/servlet/pom.xml @@ -12,9 +12,9 @@ debbie-servlet - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletApplicationInitializer.java b/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletApplicationInitializer.java index b2794de..aa83245 100644 --- a/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletApplicationInitializer.java +++ b/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletApplicationInitializer.java @@ -52,8 +52,9 @@ public void onStartup(Set> classes, ServletContext ctx) throws ServletE handler.registerFilter(ctx); // if run with war package - if (debbieApplication == null) - super.postCallStarter(); + if (debbieApplication == null) { + super.postCallStarter(this.factory()); + } } private static final Logger LOGGER = LoggerFactory.getLogger(ServletApplicationInitializer.class); diff --git a/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletContextHandler.java b/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletContextHandler.java index 3be7c55..ac97a01 100644 --- a/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletContextHandler.java +++ b/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletContextHandler.java @@ -9,7 +9,7 @@ */ package com.truthbean.debbie.servlet; -import com.truthbean.debbie.bean.BeanInitialization; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.mvc.csrf.CsrfFilter; import com.truthbean.debbie.mvc.filter.*; @@ -30,14 +30,14 @@ public class ServletContextHandler { private final ApplicationContext applicationContext; - private final BeanInitialization beanInitialization; + private final BeanInfoManager beanInitialization; private final ClassLoader classLoader; public ServletContextHandler(ServletContext servletContext, ApplicationContext handler) { setServletConfiguration(); - beanInitialization = handler.getBeanInitialization(); + beanInitialization = handler.getBeanInfoManager(); this.applicationContext = handler; this.classLoader = this.applicationContext.getClassLoader(); diff --git a/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletModuleStarter.java b/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletModuleStarter.java index 2f16df5..a621065 100644 --- a/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletModuleStarter.java +++ b/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletModuleStarter.java @@ -9,9 +9,10 @@ */ package com.truthbean.debbie.servlet; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.properties.PropertiesConfigurationBeanFactory; /** * @author truthbean @@ -20,8 +21,9 @@ public class ServletModuleStarter implements DebbieModuleStarter { @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { - configurationFactory.register(new ServletProperties(), ServletConfiguration.class); + public void registerBean(ApplicationContext applicationContext, BeanInfoManager beanInfoManager) { + var beanFactory = new PropertiesConfigurationBeanFactory<>(new ServletProperties(), ServletConfiguration.class); + beanInfoManager.register(beanFactory); } @Override diff --git a/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletProperties.java b/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletProperties.java index 4928422..d15eb37 100644 --- a/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletProperties.java +++ b/boot/servlet/src/main/java/com/truthbean/debbie/servlet/ServletProperties.java @@ -9,6 +9,7 @@ */ package com.truthbean.debbie.servlet; +import com.truthbean.common.mini.util.StringUtils; import com.truthbean.debbie.bean.BeanScanConfiguration; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContentHolder; @@ -17,6 +18,10 @@ import com.truthbean.debbie.properties.ClassesScanProperties; import com.truthbean.debbie.properties.DebbieProperties; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + /** * @author TruthBean * @since 0.0.1 @@ -28,6 +33,7 @@ public class ServletProperties extends EnvironmentContentHolder implements Debbi //======================================================================================== + private final Map map = new HashMap<>(); private static ServletConfiguration configuration; public static ServletConfiguration toConfiguration(ClassLoader classLoader) { if (configuration != null) { @@ -46,8 +52,27 @@ public static ServletConfiguration toConfiguration(ClassLoader classLoader) { } @Override - public ServletConfiguration toConfiguration(ApplicationContext applicationContext) { + public Set getProfiles() { + return map.keySet(); + } + + @Override + public ServletConfiguration getConfiguration(String name, ApplicationContext applicationContext) { + if (DEFAULT_PROFILE.equals(name) || !StringUtils.hasText(name)) { + return getConfiguration(applicationContext); + } + return map.get(name); + } + + @Override + public ServletConfiguration getConfiguration(ApplicationContext applicationContext) { ClassLoader classLoader = applicationContext.getClassLoader(); return toConfiguration(classLoader); } + + @Override + public void close() throws Exception { + map.clear(); + configuration = null; + } } diff --git a/boot/servlet/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-servlet/reflect-config.json b/boot/servlet/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-servlet/reflect-config.json index cc49654..e1df887 100644 --- a/boot/servlet/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-servlet/reflect-config.json +++ b/boot/servlet/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-servlet/reflect-config.json @@ -46,5 +46,17 @@ "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true + }, + { + "name": "org.apache.tomcat.util.modeler.modules.MbeansDescriptorsIntrospectionSource", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true } ] \ No newline at end of file diff --git a/boot/spring/pom.xml b/boot/spring/pom.xml index b970a78..17baca7 100644 --- a/boot/spring/pom.xml +++ b/boot/spring/pom.xml @@ -12,9 +12,9 @@ debbie-spring - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/spring/src/main/java/com/truthbean/debbie/spring/DebbieBeanRegistrar.java b/boot/spring/src/main/java/com/truthbean/debbie/spring/DebbieBeanRegistrar.java index 6d29c4a..234b134 100644 --- a/boot/spring/src/main/java/com/truthbean/debbie/spring/DebbieBeanRegistrar.java +++ b/boot/spring/src/main/java/com/truthbean/debbie/spring/DebbieBeanRegistrar.java @@ -10,10 +10,10 @@ package com.truthbean.debbie.spring; import com.truthbean.Logger; +import com.truthbean.debbie.bean.BeanFactory; import com.truthbean.debbie.bean.BeanInfo; -import com.truthbean.debbie.bean.BeanInfoFactory; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.bean.BeanScanConfiguration; -import com.truthbean.debbie.boot.DebbieApplication; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.core.ApplicationFactory; import com.truthbean.LoggerFactory; @@ -55,7 +55,7 @@ public DebbieBeanRegistrar() { @Override public void registerBeanDefinitions(@NonNull AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) { if (!registry.containsBeanDefinition(BEAN_INJECT_ANNOTATION_PROCESSOR_BEAN_NAME)) { - RootBeanDefinition definition = new RootBeanDefinition(DebbieBeanInjectAnnotationBeanPostProcessor.class); + RootBeanDefinition definition = new RootBeanDefinition(DebbieBeanInjectAnnotationBeanPostProcessor.class, DebbieBeanInjectAnnotationBeanPostProcessor::new); definition.setSource(null); definition.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); registry.registerBeanDefinition(BEAN_INJECT_ANNOTATION_PROCESSOR_BEAN_NAME, definition); @@ -78,15 +78,15 @@ public void registerBeanDefinitions(@NonNull AnnotationMetadata importingClassMe configuration.addScanExcludeClasses(excludeClasses); configuration.addScanExcludePackages(excludePackages); - applicationFactory.config(configuration); + applicationFactory.config(configuration).create().build(); ApplicationContext applicationContext = applicationFactory.getApplicationContext(); - BeanInfoFactory debbieBeanInfoFactory = applicationContext.getBeanInfoFactory(); - Set> allDebbieBeanInfo = debbieBeanInfoFactory.getAllDebbieBeanInfo(); + BeanInfoManager debbieBeanInfoFactory = applicationContext.getBeanInfoManager(); + Set allDebbieBeanInfo = debbieBeanInfoFactory.getAllBeanInfo(); for (BeanInfo beanInfo : allDebbieBeanInfo) { Class beanClass = beanInfo.getBeanClass(); - SpringDebbieBeanFactory factory = new SpringDebbieBeanFactory<>(debbieBeanInfoFactory, beanInfo); - factory.setGlobalBeanFactory(applicationContext.getGlobalBeanFactory()); - registry.registerBeanDefinition(beanInfo.getServiceName(), new RootBeanDefinition(beanClass, () -> factory)); + if (beanInfo instanceof BeanFactory beanFactory) { + registry.registerBeanDefinition(beanInfo.getServiceName(), new RootBeanDefinition(beanClass, () -> beanFactory.factoryBean(applicationContext))); + } } } } diff --git a/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringDebbieBeanFactory.java b/boot/spring/src/main/java/com/truthbean/debbie/spring/DebbieSpringBeanFactory.java similarity index 57% rename from boot/spring/src/main/java/com/truthbean/debbie/spring/SpringDebbieBeanFactory.java rename to boot/spring/src/main/java/com/truthbean/debbie/spring/DebbieSpringBeanFactory.java index c8740c3..92b073e 100644 --- a/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringDebbieBeanFactory.java +++ b/boot/spring/src/main/java/com/truthbean/debbie/spring/DebbieSpringBeanFactory.java @@ -11,11 +11,8 @@ import com.truthbean.Logger; import com.truthbean.LoggerFactory; -import com.truthbean.debbie.bean.BeanCreatedException; -import com.truthbean.debbie.bean.BeanFactory; -import com.truthbean.debbie.bean.BeanInfo; -import com.truthbean.debbie.bean.BeanInfoFactory; -import com.truthbean.debbie.bean.GlobalBeanFactory; +import com.truthbean.debbie.bean.*; +import com.truthbean.debbie.core.ApplicationContext; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactoryAware; import org.springframework.beans.factory.BeanNameAware; @@ -27,24 +24,24 @@ * @since 0.0.2 * Created on 2020-06-03 23:12 */ -public class SpringDebbieBeanFactory implements BeanFactory, +public abstract class DebbieSpringBeanFactory implements BeanFactory, // spring FactoryBean, BeanFactoryAware, BeanNameAware { - private GlobalBeanFactory globalBeanFactory; + private ApplicationContext applicationContext; private volatile Class beanClass; private volatile String name; - private boolean singleton = false; + private final boolean singleton = false; private org.springframework.beans.factory.BeanFactory springBeanFactory; private volatile Logger logger; - private volatile BeanInfoFactory debbieBeanInfoFactory; + private volatile BeanInfoManager debbieBeanInfoFactory; private final boolean isCreateBySpring; - public SpringDebbieBeanFactory() { + public DebbieSpringBeanFactory() { this.isCreateBySpring = true; } @@ -53,35 +50,32 @@ public void setBeanName(@NonNull String name) { this.name = name; } - public void setBeanClass(Class beanClass) { - this.beanClass = beanClass; - } - - public SpringDebbieBeanFactory(BeanInfoFactory debbieBeanInfoFactory, Class beanClass, String name) { - this.debbieBeanInfoFactory = debbieBeanInfoFactory; - this.beanClass = beanClass; - this.name = name; - this.logger = LoggerFactory.getLogger("com.truthbean.debbie.spring.SpringDebbieBeanFactory<" + beanClass.getName() + ">"); - this.isCreateBySpring = false; - } - - public SpringDebbieBeanFactory(BeanInfoFactory debbieBeanInfoFactory, BeanInfo beanInfo) { - this.debbieBeanInfoFactory = debbieBeanInfoFactory; - this.beanClass = beanInfo.getBeanClass(); + public DebbieSpringBeanFactory(ApplicationContext applicationContext, BeanInfo beanInfo) { + this.applicationContext = applicationContext; + this.debbieBeanInfoFactory = applicationContext.getBeanInfoManager(); + this.beanClass = (Class) beanInfo.getBeanClass(); this.name = beanInfo.getServiceName(); - this.logger = LoggerFactory.getLogger("com.truthbean.debbie.spring.SpringDebbieBeanFactory<" + beanClass.getName() + ">"); + this.logger = LoggerFactory.getLogger("com.truthbean.debbie.spring.DebbieSpringBeanFactory<" + beanClass.getName() + ">"); this.isCreateBySpring = false; } @Override - public void setGlobalBeanFactory(GlobalBeanFactory globalBeanFactory) { - this.globalBeanFactory = globalBeanFactory; + public Bean factoryBean(ApplicationContext applicationContext) { + if (springBeanFactory != null) { + return springBeanFactory.getBean(beanClass); + } + try { + return getObject(); + } catch (Exception e) { + logger.error("", e); + throw new BeanCreatedException(e); + } } @Override - public Bean getBean() { + public Bean factoryNamedBean(String name, ApplicationContext applicationContext) { if (springBeanFactory != null) { - return springBeanFactory.getBean(beanClass); + return springBeanFactory.getBean(name, beanClass); } try { return getObject(); @@ -92,7 +86,12 @@ public Bean getBean() { } @Override - public Class getBeanType() { + public boolean isCreated() { + return false; + } + + @Override + public Class getBeanClass() { return beanClass; } @@ -108,11 +107,9 @@ public void setBeanFactory(@NonNull org.springframework.beans.factory.BeanFactor @Override public Bean getObject() throws Exception { if (!isCreateBySpring) { - BeanInfo beanInfo = debbieBeanInfoFactory.getBeanInfo(name, getBeanType(), false, false); - if (beanInfo != null && beanInfo.getBeanClass().isInterface()) { - return globalBeanFactory.factoryBeanByDependenceProcessor(beanInfo, false); - } else if (beanInfo != null && !beanInfo.getBeanClass().isInterface()) { - return globalBeanFactory.factoryBeanByDependenceProcessor(beanInfo, true); + BeanInfo beanInfo = debbieBeanInfoFactory.getBeanInfo(name, getBeanClass(), false, false); + if (beanInfo instanceof BeanFactory beanFactory) { + return beanFactory.factoryNamedBean(name, applicationContext); } } return null; @@ -123,17 +120,13 @@ public Class getObjectType() { return beanClass; } - public void setSingleton(boolean singleton) { - this.singleton = singleton; - } - @Override public boolean isSingleton() { return singleton; } @Override - public void destroy() { + public void destruct(ApplicationContext applicationContext) { // destory } } diff --git a/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringBeanFactory.java b/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringBeanFactory.java new file mode 100644 index 0000000..4245666 --- /dev/null +++ b/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringBeanFactory.java @@ -0,0 +1,89 @@ +package com.truthbean.debbie.spring; + +import com.truthbean.debbie.bean.BeanFactory; +import com.truthbean.debbie.bean.BeanType; +import com.truthbean.debbie.bean.NonBean; +import com.truthbean.debbie.core.ApplicationContext; +import org.springframework.context.ConfigurableApplicationContext; + +import java.util.HashSet; +import java.util.Set; + +/** + * @author TruthBean + * @since 0.5.3 + * Created on 2021/12/19 00:47. + */ +@NonBean +public class SpringBeanFactory implements BeanFactory { + + private final ConfigurableApplicationContext applicationContext; + private final String name; + + public SpringBeanFactory(ConfigurableApplicationContext applicationContext, String name) { + this.applicationContext = applicationContext; + this.name = name; + } + + @Override + public Object factoryBean(ApplicationContext applicationContext) { + return this.applicationContext.getBean(name); + } + + @Override + public Object factoryNamedBean(String name, ApplicationContext applicationContext) { + return this.applicationContext.getBean(name); + } + + @Override + @SuppressWarnings("unchecked") + public Object factoryProxiedBean(String name, Class beanInterface, ApplicationContext applicationContext) { + return this.applicationContext.getBean(name, beanInterface); + } + + @Override + public boolean isCreated() { + return true; + } + + @Override + public Object getCreatedBean() { + return this.applicationContext.getBean(name); + } + + @Override + public BeanFactory copy() { + return new SpringBeanFactory(applicationContext, name); + } + + @Override + public Class getBeanClass() { + return this.applicationContext.getType(name); + } + + @Override + public boolean isLazyCreate() { + return false; + } + + @Override + public boolean isSingleton() { + return this.applicationContext.isSingleton(name); + } + + @Override + public BeanType getBeanType() { + if (isSingleton()) { + return BeanType.SINGLETON; + } else { + return BeanType.NO_LIMIT; + } + } + + @Override + public Set getBeanNames() { + Set names = new HashSet<>(); + names.add(name); + return names; + } +} diff --git a/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringModuleStarter.java b/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringModuleStarter.java index 8e9f34d..0c6d285 100644 --- a/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringModuleStarter.java +++ b/boot/spring/src/main/java/com/truthbean/debbie/spring/SpringModuleStarter.java @@ -9,14 +9,11 @@ */ package com.truthbean.debbie.spring; -import com.truthbean.debbie.bean.BeanInitialization; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.bean.BeanScanConfiguration; -import com.truthbean.debbie.bean.BeanType; -import com.truthbean.debbie.bean.DebbieBeanInfo; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; -import org.springframework.beans.factory.config.AutowireCapableBeanFactory; +import com.truthbean.debbie.env.EnvironmentContent; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; @@ -29,12 +26,18 @@ public class SpringModuleStarter implements DebbieModuleStarter { private volatile ConfigurableApplicationContext applicationContext; - @SuppressWarnings({"unchecked", "rawtypes"}) @Override - public void starter(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { - BeanInitialization beanInitialization = applicationContext.getBeanInitialization(); + public boolean enable(EnvironmentContent envContent) { + return envContent.getBooleanValue("debbie.spring.enable", true); + } - BeanScanConfiguration configuration = configurationFactory.factory(BeanScanConfiguration.class, applicationContext); + /** + * 放到starter注册是因为new AnnotationConfigApplicationContext的时候启动并完成了注册的过程 + */ + @Override + public void starter(ApplicationContext applicationContext) { + BeanInfoManager beanInfoManager = applicationContext.getBeanInfoManager(); + BeanScanConfiguration configuration = applicationContext.factory(BeanScanConfiguration.class); String scanBasePackage = configuration.getScanBasePackage(); Class applicationClass = configuration.getApplicationClass(); @@ -52,34 +55,24 @@ public void starter(DebbieConfigurationCenter configurationFactory, ApplicationC } String[] names = this.applicationContext.getBeanDefinitionNames(); for (String name : names) { - Object bean = this.applicationContext.getBean(name); - Class beanClass = bean.getClass(); - DebbieBeanInfo beanInfo = new DebbieBeanInfo<>(beanClass); - beanInfo.setBean(bean); - beanInfo.addBeanName(name); - if (this.applicationContext.isSingleton(name)) { - beanInfo.setBeanType(BeanType.SINGLETON); - } else { - beanInfo.setBeanType(BeanType.NO_LIMIT); - AutowireCapableBeanFactory autowireCapableBeanFactory = this.applicationContext.getAutowireCapableBeanFactory(); - SpringDebbieBeanFactory beanFactory = - new SpringDebbieBeanFactory<>(applicationContext.getBeanInfoFactory(), beanClass, name); - beanFactory.setSpringBeanFactory(autowireCapableBeanFactory); - beanFactory.setSingleton(false); - beanInfo.setBeanFactory(beanFactory); - } + beanInfoManager.register(new SpringBeanFactory(this.applicationContext, name)); + } + } - if (!applicationContext.getGlobalBeanFactory().containsBean(name)) { - beanInitialization.initBean(beanInfo); - } + @Override + public void postStarter(ApplicationContext applicationContext) { + // if spring application context is refreshed + if (!this.applicationContext.isActive()) { + // just call 'refresh' once + this.applicationContext.refresh(); } - applicationContext.refreshBeans(); } @Override - public void release(DebbieConfigurationCenter configurationFactory, ApplicationContext debbieApplicationContext) { - if (applicationContext != null) + public void release(ApplicationContext debbieApplicationContext) { + if (applicationContext != null) { applicationContext.close(); + } } @Override diff --git a/boot/spring/src/test/java/com/truthbean/debbie/spring/check/DebbieApplicationTest.java b/boot/spring/src/test/java/com/truthbean/debbie/spring/check/DebbieApplicationTest.java index 7174b4e..34b394d 100644 --- a/boot/spring/src/test/java/com/truthbean/debbie/spring/check/DebbieApplicationTest.java +++ b/boot/spring/src/test/java/com/truthbean/debbie/spring/check/DebbieApplicationTest.java @@ -11,7 +11,7 @@ public class DebbieApplicationTest { static { - System.setProperty(DebbieApplication.DISABLE_DEBBIE, "true"); + System.setProperty(DebbieApplication.DISABLE_DEBBIE, "false"); System.setProperty("logging.level.com.truthbean", "debug"); System.setProperty("logging.level.org.springframework", "debug"); } diff --git a/boot/spring/src/test/java/com/truthbean/debbie/spring/check/TruthBeanTypeFilter.java b/boot/spring/src/test/java/com/truthbean/debbie/spring/check/TruthBeanTypeFilter.java index 7699620..c45672d 100644 --- a/boot/spring/src/test/java/com/truthbean/debbie/spring/check/TruthBeanTypeFilter.java +++ b/boot/spring/src/test/java/com/truthbean/debbie/spring/check/TruthBeanTypeFilter.java @@ -35,6 +35,7 @@ public boolean match(@NonNull MetadataReader metadataReader, @NonNull MetadataRe Resource resource = metadataReader.getResource(); String className = classMetadata.getClassName(); - return className.startsWith("com.truthbean.debbie.spring."); + return !classMetadata.getClassName().equals("com.truthbean.debbie.spring.SpringBeanFactory") + && className.startsWith("com.truthbean.debbie.spring."); } } diff --git a/boot/swagger/pom.xml b/boot/swagger/pom.xml index 1460af9..0206cc4 100644 --- a/boot/swagger/pom.xml +++ b/boot/swagger/pom.xml @@ -12,9 +12,9 @@ debbie-swagger - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/swagger/src/main/java/com/truthbean/debbie/swagger/DebbieSwaggerConfiguration.java b/boot/swagger/src/main/java/com/truthbean/debbie/swagger/DebbieSwaggerConfiguration.java index b05b144..b011879 100644 --- a/boot/swagger/src/main/java/com/truthbean/debbie/swagger/DebbieSwaggerConfiguration.java +++ b/boot/swagger/src/main/java/com/truthbean/debbie/swagger/DebbieSwaggerConfiguration.java @@ -9,9 +9,11 @@ */ package com.truthbean.debbie.swagger; -import com.truthbean.debbie.bean.BeanInitialization; -import com.truthbean.debbie.bean.DebbieBeanInfo; +import com.truthbean.debbie.bean.BeanInfoManager; +import com.truthbean.debbie.bean.GlobalBeanFactory; +import com.truthbean.debbie.bean.SimpleBeanFactory; import com.truthbean.debbie.core.ApplicationContext; +import com.truthbean.debbie.proxy.BeanProxyType; import io.swagger.v3.oas.integration.GenericOpenApiContextBuilder; import io.swagger.v3.oas.integration.OpenApiConfigurationException; import io.swagger.v3.oas.integration.SwaggerConfiguration; @@ -32,20 +34,16 @@ public class DebbieSwaggerConfiguration { public void configure(ApplicationContext context) { OpenAPI oas = new OpenAPI(); - BeanInitialization beanInitialization = context.getBeanInitialization(); - beanInitialization.init(DebbieSwaggerRouter.class); + BeanInfoManager beanInitialization = context.getBeanInfoManager(); + beanInitialization.register(DebbieSwaggerRouter.class); + + GlobalBeanFactory globalBeanFactory = context.getGlobalBeanFactory(); - Info info = beanInitialization.getRegisterBean(Info.class); DebbieSwaggerProperties properties = new DebbieSwaggerProperties(); - if (info == null) { - info = properties.getInfo(); - } + Info info = globalBeanFactory.factoryIfPresentOrElse(Info.class, properties::getInfo); oas.info(info); - Server server = beanInitialization.getRegisterBean(Server.class); - if (server == null) { - server = properties.getServer(); - } + Server server = globalBeanFactory.factoryIfPresentOrElse(Server.class, properties::getServer); var servers = new ArrayList(); servers.add(server); oas.servers(servers); @@ -67,11 +65,8 @@ public void configure(ApplicationContext context) { result = oas; } - DebbieBeanInfo beanInfo = new DebbieBeanInfo<>(OpenAPI.class); - beanInfo.addBeanName("openApi"); - beanInfo.setBean(result); - beanInitialization.initSingletonBean(beanInfo); - context.refreshBeans(); + var beanFactory = new SimpleBeanFactory<>(result, OpenAPI.class, BeanProxyType.NO, "openApi"); + beanInitialization.register(beanFactory); } private static final Logger LOGGER = LoggerFactory.getLogger(DebbieSwaggerConfiguration.class); diff --git a/boot/swagger/src/main/java/com/truthbean/debbie/swagger/SwaggerModuleStarter.java b/boot/swagger/src/main/java/com/truthbean/debbie/swagger/SwaggerModuleStarter.java index 97f0083..5ebdb08 100644 --- a/boot/swagger/src/main/java/com/truthbean/debbie/swagger/SwaggerModuleStarter.java +++ b/boot/swagger/src/main/java/com/truthbean/debbie/swagger/SwaggerModuleStarter.java @@ -29,7 +29,7 @@ public boolean enable(EnvironmentContent envContent) { } @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext context) { + public void configure(ApplicationContext context) { DebbieSwaggerConfiguration configuration = new DebbieSwaggerConfiguration(); configuration.configure(context); } diff --git a/boot/swagger/src/test/java/com/truthbean/debbie/swagger/test/DebbieSwaggerTest.java b/boot/swagger/src/test/java/com/truthbean/debbie/swagger/test/DebbieSwaggerTest.java index c05130e..e09b46e 100644 --- a/boot/swagger/src/test/java/com/truthbean/debbie/swagger/test/DebbieSwaggerTest.java +++ b/boot/swagger/src/test/java/com/truthbean/debbie/swagger/test/DebbieSwaggerTest.java @@ -9,14 +9,11 @@ */ package com.truthbean.debbie.swagger.test; -import com.truthbean.debbie.bean.BeanInitialization; -import com.truthbean.debbie.boot.DebbieApplication; import com.truthbean.debbie.boot.DebbieBootApplication; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.core.ApplicationFactory; import com.truthbean.debbie.mvc.MvcConfiguration; import com.truthbean.debbie.mvc.router.MvcRouterRegister; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; import com.truthbean.debbie.swagger.SwaggerReader; import com.truthbean.debbie.util.JacksonUtils; import io.swagger.v3.oas.integration.GenericOpenApiContextBuilder; @@ -34,15 +31,12 @@ public static void main(String[] args) { ApplicationFactory factory = ApplicationFactory.configure(DebbieSwaggerTest.class); ApplicationContext context = factory.getApplicationContext(); - DebbieConfigurationCenter configurationFactory = context.getConfigurationCenter(); - MvcConfiguration configuration = configurationFactory.factory(MvcConfiguration.class, context); - - BeanInitialization beanInitialization = context.getBeanInitialization(); + MvcConfiguration configuration = context.factory(MvcConfiguration.class); MvcRouterRegister.registerRouter(configuration, context); OpenAPI oas = new OpenAPI(); - Info info = beanInitialization.getRegisterBean(Info.class); + Info info = context.factory(Info.class); oas.info(info); oas.servers(List.of(new Server().url("http://localhost:8090").description("debbie swagger example"))); diff --git a/boot/tomcat/pom.xml b/boot/tomcat/pom.xml index 0910964..ec09b21 100644 --- a/boot/tomcat/pom.xml +++ b/boot/tomcat/pom.xml @@ -12,9 +12,9 @@ debbie-tomcat - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletApplicationInitializer.java b/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletApplicationInitializer.java index 8b5b5d9..aa83245 100644 --- a/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletApplicationInitializer.java +++ b/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletApplicationInitializer.java @@ -9,18 +9,17 @@ */ package com.truthbean.debbie.servlet; -import com.truthbean.Logger; -import com.truthbean.LoggerFactory; import com.truthbean.debbie.core.AbstractApplicationFactory; import com.truthbean.debbie.core.ApplicationContext; -import com.truthbean.debbie.internal.DebbieApplicationFactory; import com.truthbean.debbie.mvc.router.Router; import com.truthbean.debbie.watcher.Watcher; +import com.truthbean.Logger; +import com.truthbean.LoggerFactory; + import jakarta.servlet.ServletContainerInitializer; import jakarta.servlet.ServletContext; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.HandlesTypes; - import java.util.Set; /** @@ -29,33 +28,33 @@ * Created on 2018-01-07 22:30. */ @HandlesTypes(value = {Watcher.class, Router.class}) -public class ServletApplicationInitializer extends DebbieApplicationFactory implements ServletContainerInitializer { +public class ServletApplicationInitializer extends AbstractApplicationFactory implements ServletContainerInitializer { private final ApplicationContext applicationContext; public ServletApplicationInitializer() { - LOGGER.info("ServletApplicationInitializer init ..."); + super(ServletApplicationInitializer.class); if (debbieApplication == null) { - debbieApplication = super.preInit().init(ServletApplicationInitializer.class).config().create().postCreate().build().factory(); LOGGER.debug("run servlet module without application"); - applicationContext = this.getApplicationContext(); + applicationContext = getApplicationContext(); super.config(ServletApplicationInitializer.class); super.callStarter(); } else { - applicationContext = debbieApplication.getApplicationContext(); + applicationContext = super.getApplicationContext(); } } @Override public void onStartup(Set> classes, ServletContext ctx) throws ServletException { LOGGER.info("ServletContainerInitializer onStartup ..."); - var handler = new ServletContextHandler(ctx, this.applicationContext); + var handler = new ServletContextHandler(ctx, applicationContext); handler.registerRouter(); handler.registerFilter(ctx); // if run with war package - if (debbieApplication == null) - super.postCallStarter(); + if (debbieApplication == null) { + super.postCallStarter(this.factory()); + } } private static final Logger LOGGER = LoggerFactory.getLogger(ServletApplicationInitializer.class); diff --git a/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletContextHandler.java b/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletContextHandler.java index c81cea0..3b0d756 100644 --- a/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletContextHandler.java +++ b/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletContextHandler.java @@ -9,7 +9,7 @@ */ package com.truthbean.debbie.servlet; -import com.truthbean.debbie.bean.BeanInitialization; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.mvc.csrf.CsrfFilter; import com.truthbean.debbie.mvc.filter.*; @@ -30,14 +30,14 @@ public class ServletContextHandler { private final ApplicationContext applicationContext; - private final BeanInitialization beanInitialization; + private final BeanInfoManager beanInitialization; private final ClassLoader classLoader; public ServletContextHandler(ServletContext servletContext, ApplicationContext handler) { setServletConfiguration(); - beanInitialization = handler.getBeanInitialization(); + beanInitialization = handler.getBeanInfoManager(); this.applicationContext = handler; this.classLoader = this.applicationContext.getClassLoader(); diff --git a/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletProperties.java b/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletProperties.java index 4928422..d15eb37 100644 --- a/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletProperties.java +++ b/boot/tomcat/src/main/java/com/truthbean/debbie/servlet/ServletProperties.java @@ -9,6 +9,7 @@ */ package com.truthbean.debbie.servlet; +import com.truthbean.common.mini.util.StringUtils; import com.truthbean.debbie.bean.BeanScanConfiguration; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContentHolder; @@ -17,6 +18,10 @@ import com.truthbean.debbie.properties.ClassesScanProperties; import com.truthbean.debbie.properties.DebbieProperties; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + /** * @author TruthBean * @since 0.0.1 @@ -28,6 +33,7 @@ public class ServletProperties extends EnvironmentContentHolder implements Debbi //======================================================================================== + private final Map map = new HashMap<>(); private static ServletConfiguration configuration; public static ServletConfiguration toConfiguration(ClassLoader classLoader) { if (configuration != null) { @@ -46,8 +52,27 @@ public static ServletConfiguration toConfiguration(ClassLoader classLoader) { } @Override - public ServletConfiguration toConfiguration(ApplicationContext applicationContext) { + public Set getProfiles() { + return map.keySet(); + } + + @Override + public ServletConfiguration getConfiguration(String name, ApplicationContext applicationContext) { + if (DEFAULT_PROFILE.equals(name) || !StringUtils.hasText(name)) { + return getConfiguration(applicationContext); + } + return map.get(name); + } + + @Override + public ServletConfiguration getConfiguration(ApplicationContext applicationContext) { ClassLoader classLoader = applicationContext.getClassLoader(); return toConfiguration(classLoader); } + + @Override + public void close() throws Exception { + map.clear(); + configuration = null; + } } diff --git a/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatModuleStarter.java b/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatModuleStarter.java index ac9a8bc..a3aae21 100644 --- a/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatModuleStarter.java +++ b/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatModuleStarter.java @@ -9,10 +9,11 @@ */ package com.truthbean.debbie.tomcat; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContent; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.properties.PropertiesConfigurationBeanFactory; import com.truthbean.debbie.servlet.ServletConfiguration; import com.truthbean.debbie.servlet.ServletProperties; @@ -24,13 +25,15 @@ public class TomcatModuleStarter implements DebbieModuleStarter { @Override public boolean enable(EnvironmentContent envContent) { - return envContent.getBooleanValue(TomcatProperties.ENABLE_KEY, false); + return envContent.getBooleanValue(TomcatProperties.ENABLE_KEY, true); } @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { - configurationFactory.register(new ServletProperties(), ServletConfiguration.class); - configurationFactory.register(new TomcatProperties(), TomcatConfiguration.class); + public void registerBean(ApplicationContext applicationContext, BeanInfoManager beanInfoManager) { + var servletBeanFactory = new PropertiesConfigurationBeanFactory<>(new ServletProperties(), ServletConfiguration.class); + beanInfoManager.register(servletBeanFactory); + var tomcatBeanFactory = new PropertiesConfigurationBeanFactory<>(new TomcatProperties(), TomcatConfiguration.class); + beanInfoManager.register(tomcatBeanFactory); } @Override diff --git a/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatProperties.java b/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatProperties.java index b983874..883355a 100644 --- a/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatProperties.java +++ b/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatProperties.java @@ -9,6 +9,7 @@ */ package com.truthbean.debbie.tomcat; +import com.truthbean.common.mini.util.StringUtils; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.reflection.ClassLoaderUtils; import com.truthbean.debbie.server.BaseServerProperties; @@ -17,6 +18,9 @@ import java.net.URL; import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; /** * @author TruthBean @@ -43,10 +47,24 @@ public class TomcatProperties extends BaseServerProperties private static final String TOMCAT_RESOURCES_MAX_CACHE = "debbie.server.tomcat.resources.max-cache"; //=========================================================================== + private final Map map = new HashMap<>(); private TomcatConfiguration configuration; @Override - public TomcatConfiguration toConfiguration(ApplicationContext applicationContext) { + public Set getProfiles() { + return map.keySet(); + } + + @Override + public TomcatConfiguration getConfiguration(String name, ApplicationContext applicationContext) { + if (DEFAULT_PROFILE.equals(name) || !StringUtils.hasText(name)) { + return getConfiguration(applicationContext); + } + return map.get(name); + } + + @Override + public TomcatConfiguration getConfiguration(ApplicationContext applicationContext) { if (configuration != null) { return configuration; } @@ -89,8 +107,16 @@ public TomcatConfiguration toConfiguration(ApplicationContext applicationContext configuration.setCachingAllowed(properties.getBooleanValue(TOMCAT_RESOURCES_CACHING_ALLOWED, true)); configuration.setCacheMaxSize(properties.getIntegerValue(TOMCAT_RESOURCES_MAX_CACHE, 102400)); + map.put(DEFAULT_PROTOCOL, configuration); + return configuration; } private static final Logger LOGGER = LoggerFactory.getLogger(TomcatProperties.class); + + @Override + public void close() throws Exception { + map.clear(); + configuration = null; + } } diff --git a/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatServerApplication.java b/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatServerApplication.java index 96753b4..32bc70c 100644 --- a/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatServerApplication.java +++ b/boot/tomcat/src/main/java/com/truthbean/debbie/tomcat/TomcatServerApplication.java @@ -13,6 +13,7 @@ import com.truthbean.debbie.boot.ApplicationArgs; import com.truthbean.debbie.boot.DebbieApplication; import com.truthbean.debbie.core.ApplicationContext; +import com.truthbean.debbie.env.EnvironmentContent; import com.truthbean.debbie.io.PathUtils; import com.truthbean.debbie.properties.DebbieConfigurationCenter; import com.truthbean.debbie.server.AbstractWebServerApplication; @@ -40,6 +41,7 @@ import java.nio.file.Path; import java.time.Instant; import java.util.List; +import java.util.Set; /** * @author TruthBean @@ -53,6 +55,11 @@ public boolean isWeb() { return true; } + @Override + public boolean isEnable(EnvironmentContent envContent) { + return super.isEnable(envContent) && envContent.getBooleanValue(TomcatProperties.ENABLE_KEY, true); + } + static { System.setProperty("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE", "true"); } @@ -116,7 +123,7 @@ private void customizeConnector(Connector connector) { // TODO ssl } - private void config(ClassLoader classLoader, List errorPages) { + private void config(ClassLoader classLoader, Set errorPages) { if (this.configuration.isDisableMBeanRegistry()) { Registry.disableRegistry(); } @@ -190,16 +197,15 @@ private void config(ClassLoader classLoader, List errorPages) { } @Override - public DebbieApplication init(DebbieConfigurationCenter factory, ApplicationContext applicationContext, - ClassLoader classLoader) { - this.configuration = factory.factory(TomcatConfiguration.class, applicationContext); + public DebbieApplication init(ApplicationContext applicationContext, ClassLoader classLoader) { + this.configuration = applicationContext.factory(TomcatConfiguration.class); if (this.configuration == null) { LOGGER.warn("debbie-tomcat module is disabled, debbie.tomcat.enable is false"); return null; } GlobalBeanFactory globalBeanFactory = applicationContext.getGlobalBeanFactory(); - List errorPages = globalBeanFactory.getBeanList(ErrorPage.class); + Set errorPages = globalBeanFactory.getBeanList(ErrorPage.class); config(classLoader, errorPages); super.setLogger(LOGGER); diff --git a/boot/tomcat/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-tomcat/reflect-config.json b/boot/tomcat/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-tomcat/reflect-config.json index 8409b27..30dee70 100644 --- a/boot/tomcat/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-tomcat/reflect-config.json +++ b/boot/tomcat/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-tomcat/reflect-config.json @@ -1,4 +1,16 @@ [ + { + "name": "org.apache.tomcat.util.modeler.modules.MbeansDescriptorsIntrospectionSource", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, { "name" : "com.truthbean.debbie.tomcat.TomcatServerApplication", "methods": [ diff --git a/boot/undertow/pom.xml b/boot/undertow/pom.xml index 8b1cbb1..f4f19e1 100644 --- a/boot/undertow/pom.xml +++ b/boot/undertow/pom.xml @@ -12,9 +12,9 @@ debbie-undertow - 11 - 11 - 11 + 17 + 17 + 17 diff --git a/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowModuleStarter.java b/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowModuleStarter.java index 35c5f7e..0370b4c 100644 --- a/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowModuleStarter.java +++ b/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowModuleStarter.java @@ -9,10 +9,12 @@ */ package com.truthbean.debbie.undertow; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.boot.DebbieModuleStarter; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.env.EnvironmentContent; import com.truthbean.debbie.properties.DebbieConfigurationCenter; +import com.truthbean.debbie.properties.PropertiesConfigurationBeanFactory; /** * @author truthbean @@ -26,8 +28,9 @@ public boolean enable(EnvironmentContent envContent) { } @Override - public void configure(DebbieConfigurationCenter configurationFactory, ApplicationContext applicationContext) { - configurationFactory.register(new UndertowProperties(), UndertowConfiguration.class); + public void registerBean(ApplicationContext applicationContext, BeanInfoManager beanInfoManager) { + var undertowBeanFactory = new PropertiesConfigurationBeanFactory<>(new UndertowProperties(), UndertowConfiguration.class); + beanInfoManager.register(undertowBeanFactory); } @Override diff --git a/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowProperties.java b/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowProperties.java index 256addd..f87c709 100644 --- a/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowProperties.java +++ b/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowProperties.java @@ -16,18 +16,36 @@ import com.truthbean.debbie.properties.ClassesScanProperties; import com.truthbean.debbie.server.BaseServerProperties; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + /** * @author TruthBean * @since 0.0.1 * Created on 2019/4/12 23:58. */ public class UndertowProperties extends BaseServerProperties { + private final Map map = new HashMap<>(); private UndertowConfiguration configuration; public static final String ENABLE_KEY = "debbie.undertow.enable"; @Override - public UndertowConfiguration toConfiguration(ApplicationContext applicationContext) { + public Set getProfiles() { + return map.keySet(); + } + + @Override + public UndertowConfiguration getConfiguration(String name, ApplicationContext applicationContext) { + if (map.isEmpty() && DEFAULT_PROFILE.equals(name)) { + return getConfiguration(applicationContext); + } + return map.get(name); + } + + @Override + public UndertowConfiguration getConfiguration(ApplicationContext applicationContext) { if (configuration != null) { return configuration; } @@ -44,6 +62,14 @@ public UndertowConfiguration toConfiguration(ApplicationContext applicationConte UndertowProperties properties = new UndertowProperties(); properties.loadAndSet(properties, configuration); + map.put(DEFAULT_PROFILE, configuration); + return configuration; } + + @Override + public void close() throws Exception { + map.clear(); + configuration = null; + } } diff --git a/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowServerApplication.java b/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowServerApplication.java index ba4f48d..036280a 100644 --- a/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowServerApplication.java +++ b/boot/undertow/src/main/java/com/truthbean/debbie/undertow/UndertowServerApplication.java @@ -9,14 +9,13 @@ */ package com.truthbean.debbie.undertow; -import com.truthbean.debbie.bean.BeanInitialization; +import com.truthbean.debbie.bean.BeanInfoManager; import com.truthbean.debbie.boot.ApplicationArgs; import com.truthbean.debbie.boot.DebbieApplication; import com.truthbean.debbie.core.ApplicationContext; import com.truthbean.debbie.mvc.filter.RouterFilterInfo; import com.truthbean.debbie.mvc.filter.RouterFilterManager; import com.truthbean.debbie.mvc.router.MvcRouterRegister; -import com.truthbean.debbie.properties.DebbieConfigurationCenter; import com.truthbean.debbie.server.AbstractWebServerApplication; import com.truthbean.debbie.undertow.handler.DispatcherHttpHandler; import com.truthbean.debbie.undertow.handler.HttpHandlerFilter; @@ -47,14 +46,13 @@ public boolean isWeb() { } @Override - public DebbieApplication init(DebbieConfigurationCenter factory, ApplicationContext applicationContext, - ClassLoader classLoader) { - this.configuration = factory.factory(UndertowConfiguration.class, applicationContext); + public DebbieApplication init(ApplicationContext applicationContext, ClassLoader classLoader) { + this.configuration = applicationContext.factory(UndertowConfiguration.class); if (this.configuration == null) { LOGGER.warn("debbie-undertow module is disabled, debbie.undertow.enable is false"); return null; } - BeanInitialization beanInitialization = applicationContext.getBeanInitialization(); + BeanInfoManager beanInitialization = applicationContext.getBeanInfoManager(); MvcRouterRegister.registerRouter(configuration, applicationContext); RouterFilterManager.registerFilter(configuration, beanInitialization); RouterFilterManager.registerCharacterEncodingFilter(configuration, "/**"); diff --git a/boot/undertow/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-undertow/reflect-config.json b/boot/undertow/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-undertow/reflect-config.json index 1705612..51d9957 100644 --- a/boot/undertow/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-undertow/reflect-config.json +++ b/boot/undertow/src/main/resources/META-INF/native-image/com.truthbean.debbie/debbie-undertow/reflect-config.json @@ -34,5 +34,1373 @@ "allPublicMethods" : true, "allDeclaredFields" : true, "allPublicFields" : true + }, + { + "name": "org.xnio.nio.Log_$logger", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.UndertowLogger_$logger", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.xnio._private.Messages_$logger", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "org.xnio.nio.NioXnioProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.protocol.http.HttpRequestParser$$generated", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RelativePathAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RemoteIPAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.LocalIPAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RequestProtocolAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.LocalPortAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.IdentUsernameAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RequestMethodAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.QueryStringAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RequestLineAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.BytesSentAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.DateTimeAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RemoteUserAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RequestURLAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.ThreadNameAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.LocalServerNameAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RequestHeaderAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.ResponseHeaderAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.CookieAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RequestCookieAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.ResponseCookieAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.ResponseCodeAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.PredicateContextAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.QueryParameterAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.SslClientCertAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.SslCipherAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.SslSessionIdAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.ResponseTimeAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.PathParameterAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.TransportProtocolAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RequestSchemeAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.HostAndPortAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.AuthenticationTypeExchangeAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.SecureExchangeAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RemoteHostAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RequestPathAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.ResolvedPathAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.NullAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.StoredResponse$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.ResponseReasonPhraseAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.attribute.RemoteObfuscatedIPAttribute$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.client.http.HttpClientProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.client.ajp.AjpClientProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.client.http2.Http2ClientProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.client.http2.Http2ClearClientProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.client.http2.Http2PriorKnowledgeClientProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.PathMatchPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.PathPrefixPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.ContainsPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.ExistsPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.RegularExpressionPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.PathSuffixPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.EqualsPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.PathTemplatePredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.MethodPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.AuthenticationRequiredPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.MaxContentSizePredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.MinContentSizePredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.SecurePredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.IdempotentPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.RequestLargerThanPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.RequestSmallerThanPredicate$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.protocols.ssl.SNIAlpnEngineManager", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.protocols.alpn.DefaultAlpnEngineManager", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.protocols.alpn.JDK9AlpnProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.protocols.alpn.OpenSSLAlpnProvider", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.builder.RewriteHandlerBuilder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.SetAttributeHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.SetAttributeHandler$ClearBuilder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.builder.ResponseCodeHandlerBuilder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.DisableCacheHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.ProxyPeerAddressHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.proxy.ProxyHandlerBuilder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.RedirectHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.accesslog.AccessLogHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.AllowedMethodsHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.BlockingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.CanonicalPathHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.DisallowedMethodsHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.error.FileErrorPageHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.HttpTraceHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.JvmRouteHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.PeerNameResolvingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.RequestDumpingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.RequestLimitingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.resource.ResourceHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.SSLHeaderHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.ResponseRateLimitingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.URLDecodingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.PathSeparatorHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.IPAddressAccessControlHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.ByteRangeHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.encoding.EncodingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.encoding.RequestEncodingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.LearningPushHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.SetHeaderHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.PredicatesHandler$DoneHandlerBuilder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.predicate.PredicatesHandler$RestartHandlerBuilder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.RequestBufferingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.StuckThreadDetectionHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.AccessControlListHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.JDBCLogHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.LocalNameResolvingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.StoredResponseHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.SecureCookieHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.ForwardedHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.HttpContinueAcceptingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.form.EagerFormParsingHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.SameSiteCookieHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true + }, + { + "name": "io.undertow.server.handlers.SetErrorHandler$Builder", + "methods": [ + { "name": "", "parameterTypes": [] } + ], + "allDeclaredConstructors" : true, + "allPublicConstructors" : true, + "allDeclaredMethods" : true, + "allPublicMethods" : true, + "allDeclaredFields" : true, + "allPublicFields" : true } ] \ No newline at end of file diff --git a/cloud/pom.xml b/cloud/pom.xml index c80b8af..dcf0c74 100644 --- a/cloud/pom.xml +++ b/cloud/pom.xml @@ -16,8 +16,8 @@ cloud - 11 - 11 + 17 + 17 diff --git a/cloud/simple-cloud/pom.xml b/cloud/simple-cloud/pom.xml index afea8ed..8a34fed 100644 --- a/cloud/simple-cloud/pom.xml +++ b/cloud/simple-cloud/pom.xml @@ -12,8 +12,8 @@ simple-cloud - 11 - 11 + 17 + 17 diff --git a/dependencies/pom.xml b/dependencies/pom.xml index 83cf8cd..badbea8 100644 --- a/dependencies/pom.xml +++ b/dependencies/pom.xml @@ -14,9 +14,9 @@ pom - 11 - 11 - 11 + 17 + 17 + 17 debbie-dependencies diff --git a/pom.xml b/pom.xml index 94ca2d2..7363cd0 100644 --- a/pom.xml +++ b/pom.xml @@ -26,9 +26,9 @@ https://github.com/TruthBean/debbie-cloud - 11 - 11 - 11 + 17 + 17 + 17 ${project.build.directory}/endorsed ${project.build.directory}/classes @@ -208,9 +208,9 @@ - 11 - 11 - 11 + 17 + 17 + 17 UTF-8 ${endorsed.dir}