diff --git a/.gitignore b/.gitignore index 7aa4af57275c953a574b8bd5f86213fbf972ec38..cee69c078dbc12799a26e5005339bca5c9d9b235 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ hs_err_pid* # custom springboot-plugin-framework-parent.zip springboot-plugin-framework-parent.zip + diff --git a/LICENSE b/LICENSE index 7fd89d0cd9f6534504279ae8b6bace45eb517f10..b6ed9b300edb6f317fe2a3edaf0e888b3ea75d95 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [2019-2022] [starBlues] + Copyright [2019-Present] [starBlues] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index 97615667863cff6e078355938bb96bb3d8c57cec..172287cdf95b7a95ad6152a04b1c0b5e8d28e860 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ The framework can be developed in the `spring-boot` project plugin, plugin can b ### Environment 1. jdk1.8+d 2. apache maven 3.6+ -3. spring-boot 2.0.0+ +3. spring-boot 2.3.1 ~ 2.7.6 ### Doc diff --git a/README_zh.md b/README_zh.md index 1d258e7dbaf91a981904040c3baffba4d27961ce..b19d744d8a8e70fdef959cfc4ff630f943279157 100644 --- a/README_zh.md +++ b/README_zh.md @@ -42,7 +42,7 @@ ### 运行环境 | Runtime Environment 1. jdk1.8+ 2. apache maven 3.6+ -3. spring-boot 2.0.0+ +3. spring-boot 2.3.1 ~ 2.7.6 ### 文档地址 | Document - [https://www.yuque.com/starblues/spring-brick-3.0.0](https://www.yuque.com/starblues/spring-brick-3.0.0) diff --git a/pom.xml b/pom.xml index c14f89711f0c10b51bc7eaec0ad7bd0633712234..9a9e053b048e23f346cc8b4cad80a8c04cc5c325 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.gitee.starblues spring-brick-parent pom - 3.1.0 + 3.1.1 spring-brick-common diff --git a/spring-brick-bootstrap/pom.xml b/spring-brick-bootstrap/pom.xml index d6cf302bfff1524883870ca43f6fbf5c2e8923c8..bb304105d883b017085f4a0b66cb9cc9c537376d 100644 --- a/spring-brick-bootstrap/pom.xml +++ b/spring-brick-bootstrap/pom.xml @@ -7,7 +7,7 @@ spring-brick-parent com.gitee.starblues - 3.1.0 + 3.1.1 spring-brick-bootstrap diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/AutowiredTypeDefinerConfig.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/AutowiredTypeDefinerConfig.java index 2481c0b13d52707841487cbd9432874bbeac31ea..68b9911ed550e8ac133094d87fbb2d19dee14441 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/AutowiredTypeDefinerConfig.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/AutowiredTypeDefinerConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/AutowiredTypeResolver.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/AutowiredTypeResolver.java index 3941f870e2027a347ee90f7502366d230dc9b417..b4eb84f4f4122c19fa773ad1f9aa85a7f17f75b5 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/AutowiredTypeResolver.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/AutowiredTypeResolver.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,8 @@ import java.util.Collections; import java.util.Set; /** + * 注入类型处理 + * * @author starBlues * @since 3.0.3 * @version 3.1.0 diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigurePluginEnvironment.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigurePluginEnvironment.java index 272d6a14bcd531b7add4885067b777a08e849d32..69433a07d299bf9e6df79c8183baaa105bd1cf91 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigurePluginEnvironment.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ConfigurePluginEnvironment.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,11 +19,10 @@ package com.gitee.starblues.bootstrap; import com.gitee.starblues.bootstrap.processor.ProcessorContext; import com.gitee.starblues.core.descriptor.InsidePluginDescriptor; import com.gitee.starblues.integration.AutoIntegrationConfiguration; +import com.gitee.starblues.integration.IntegrationConfiguration; import com.gitee.starblues.loader.launcher.DevelopmentModeSetting; -import com.gitee.starblues.utils.Assert; -import com.gitee.starblues.utils.FilesUtils; -import com.gitee.starblues.utils.ObjectUtils; -import com.gitee.starblues.utils.PluginFileUtils; +import com.gitee.starblues.spring.MainApplicationContext; +import com.gitee.starblues.utils.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ConfigurableApplicationContext; @@ -38,9 +37,10 @@ import java.util.Map; /** * 插件环境配置 + * * @author starBlues * @since 3.0.0 - * @version 3.1.0 + * @version 3.1.1 */ public class ConfigurePluginEnvironment { private final Logger logger = LoggerFactory.getLogger(ConfigurePluginEnvironment.class); @@ -51,6 +51,7 @@ public class ConfigurePluginEnvironment { private final static String SPRING_CONFIG_LOCATION = "spring.config.location"; private final static String SPRING_JMX_UNIQUE_NAMES = "spring.jmx.unique-names"; + private final static String SPRING_ADMIM_ENABLED = "spring.application.admin.enabled"; private final static String SPRING_ADMIN_JMX_NAME = "spring.application.admin.jmx-name"; private final static String SPRING_ADMIN_JMX_VALUE = "org.springframework.boot:type=Admin,name="; @@ -79,10 +80,13 @@ public class ConfigurePluginEnvironment { } env.put(AutoIntegrationConfiguration.ENABLE_STARTER_KEY, false); env.put(SPRING_JMX_UNIQUE_NAMES, true); + // 直接禁用插件的 spring-admin mbean + env.put(SPRING_ADMIM_ENABLED, false); env.put(SPRING_ADMIN_JMX_NAME, SPRING_ADMIN_JMX_VALUE + pluginId); env.put(REGISTER_SHUTDOWN_HOOK_PROPERTY, false); env.put(MBEAN_DOMAIN_PROPERTY_NAME, pluginId); + try{ // fix: https://gitee.com/starblues/springboot-plugin-framework-parent/issues/I57965 // 优先注册LiveBeansView对象,防止注册异常 @@ -92,11 +96,10 @@ public class ConfigurePluginEnvironment { } catch (Exception ex){ logger.error("LiveBeansView.registerApplicationContext失败. {}", ex.getMessage(), ex); } - if(DevelopmentModeSetting.coexist()){ env.put(AutoIntegrationConfiguration.ENABLE_STARTER_KEY, false); } - + configProfiles(environment); environment.getPropertySources().addFirst(new MapPropertySource(PLUGIN_PROPERTY_NAME, env)); } @@ -110,4 +113,28 @@ public class ConfigurePluginEnvironment { } } + private void configProfiles(ConfigurableEnvironment environment){ + IntegrationConfiguration configuration = processorContext.getConfiguration(); + if(!configuration.pluginFollowProfile()){ + return; + } + MainApplicationContext mainApplicationContext = processorContext.getMainApplicationContext(); + String[] activeProfiles = environment.getActiveProfiles(); + if(activeProfiles.length > 0){ + logger.info("Plugin[{}] following profiles are active: {}", + MsgUtils.getPluginUnique(pluginDescriptor), StringUtils.toStrByArray(activeProfiles)); + } else { + String[] mainActiveProfiles = mainApplicationContext.getActiveProfiles(); + if(mainActiveProfiles.length > 0){ + logger.info("Plugin[{}] following profiles are active from main: {}", + MsgUtils.getPluginUnique(pluginDescriptor), StringUtils.toStrByArray(mainActiveProfiles)); + environment.setActiveProfiles(mainActiveProfiles); + } else { + logger.info("Plugin[{}] No active profile set, falling back to default profiles: {}", + MsgUtils.getPluginUnique(pluginDescriptor), + StringUtils.toStrByArray(environment.getDefaultProfiles())); + } + } + } + } diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultAutowiredTypeResolver.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultAutowiredTypeResolver.java index ef58144198d37982036cc12b15b6a7f37fa7de2a..441c56ad9544faf708ea93a617013ae9b88044cb 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultAutowiredTypeResolver.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultAutowiredTypeResolver.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultSpringPluginHook.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultSpringPluginHook.java index bd3fdb21f6f94964df5e6f83d56009a6bf3eb139..ef3fdc2ba10299d5b5420c277bf24c3e425e278c 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultSpringPluginHook.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/DefaultSpringPluginHook.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import java.util.Map; /** * 默认的插件钩子器 + * * @author starBlues * @since 3.0.0 * @version 3.1.0 diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java index b83c3f826fec02e1f76840c37a7232b90ea89c8e..9bbfc0a9e06baae2d1c41a4903e1a90745fabb15 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptyMainApplicationContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ import com.gitee.starblues.spring.MainApplicationContext; import com.gitee.starblues.spring.SpringBeanFactory; import com.gitee.starblues.spring.environment.EmptyEnvironmentProvider; import com.gitee.starblues.spring.environment.EnvironmentProvider; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import java.util.Collections; import java.util.Map; @@ -27,8 +29,10 @@ import java.util.Set; /** * 空的MainApplicationContext实现 + * * @author starBlues - * @version 3.0.3 + * @since 3.0.0 + * @version 3.1.1 */ public class EmptyMainApplicationContext implements MainApplicationContext { @@ -59,6 +63,16 @@ public class EmptyMainApplicationContext implements MainApplicationContext { return new EmptyEnvironmentProvider(); } + @Override + public String[] getActiveProfiles() { + return new String[0]; + } + + @Override + public String[] getDefaultProfiles() { + return new String[0]; + } + @Override public Object resolveDependency(String requestingBeanName, Class dependencyType) { return null; @@ -74,4 +88,19 @@ public class EmptyMainApplicationContext implements MainApplicationContext { return null; } + @Override + public boolean isRegisterController() { + return false; + } + + @Override + public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { + return null; + } + + @Override + public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() { + return null; + } + } diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptySpringBeanFactory.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptySpringBeanFactory.java index b784bd5503633f70836893593d9e9ce8a399a855..a62a2142bfc7b20807beac4ba67f8f3c0eeaf411 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptySpringBeanFactory.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/EmptySpringBeanFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,9 @@ import java.util.Map; /** * 空的 SpringBeanFactory 实现 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class EmptySpringBeanFactory implements SpringBeanFactory { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java index be1181ad59ccd5fde0da0b3c6f24c3ca5ea679d3..722e1e6d7ee496bf9b823d45b0ade53a3c3b82c3 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginApplicationContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,9 @@ import org.springframework.context.annotation.AnnotationConfigApplicationContext /** * 插件ApplicationContext实现 + * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class PluginApplicationContext extends AnnotationConfigApplicationContext { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginContextHolder.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginContextHolder.java index 253c89496778d88012cf4cead27aa891c9267d5d..e38105454ca5b2834433113a20a3ae6eabf6805d 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginContextHolder.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginContextHolder.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import com.gitee.starblues.spring.environment.EnvironmentProvider; * 提供插件上下文的工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public abstract class PluginContextHolder { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginDisableAutoConfiguration.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginDisableAutoConfiguration.java index b1265330696c6f70c964fa6a21fa7550b3d39efc..3f2e9a0242f9d6d3b92283e22bee0b0814fecdae 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginDisableAutoConfiguration.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginDisableAutoConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java index b9ff5c4332bf037185d4b6ccaf8ab11a032cc415..e20d0e6a90e30eb7383c9e4cce0404c8046a6856 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginListableBeanFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import java.util.stream.Stream; /** * 插件BeanFactory实现 + * * @author starBlues * @since 3.0.3 * @version 3.0.3 diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginOneselfInteractive.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginOneselfInteractive.java index 6d13acabab20533e6b5f22f9a1c0ed5e05b62582..7fc0d3db5ce0911e449e4b145e6272557c1fe69e 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginOneselfInteractive.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginOneselfInteractive.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,9 @@ import java.nio.file.Paths; /** * 插件自己的Interactive + * * @author starBlues + * @since 3.0.0 * @version 3.1.0 */ public class PluginOneselfInteractive implements PluginInteractive { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginSpringApplication.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginSpringApplication.java index c21fc3fec436bfa1b2b5a15a0676ccd6f20717e3..c5a64e13213b9924e85e644102e2b29cf9304a17 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginSpringApplication.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginSpringApplication.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,6 +32,7 @@ import org.springframework.core.io.ResourceLoader; /** * 插件SpringApplication实现 + * * @author starBlues * @since 3.0.0 * @version 3.1.0 diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginWebApplicationContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginWebApplicationContext.java index 9539cb34c409ed7d05c6821a774d89946d98d194..5103b0daf6d7fec04998342ef60e44ed178983d2 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginWebApplicationContext.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/PluginWebApplicationContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.boot.web.server.WebServerException; * 主程序为 web 类型时创建的插件 ApplicationContext * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class PluginWebApplicationContext extends PluginApplicationContext implements WebServerApplicationContext { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ResolveHttpMessageConvertersConfiguration.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ResolveHttpMessageConvertersConfiguration.java index 5490027bf90da627fad94aae1ad6825628dd687e..4fda4dcafc9b01c90050bea0f574eb24a3f308d8 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ResolveHttpMessageConvertersConfiguration.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/ResolveHttpMessageConvertersConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import java.util.stream.Collectors; * resolve config HttpMessageConverters bean * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class ResolveHttpMessageConvertersConfiguration { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/SpringPluginBootstrap.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/SpringPluginBootstrap.java index 096984e5c775cba99f09f2617feba5c20964de39..6b7230272722b467c05a48fcbac40beda3c1a128 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/SpringPluginBootstrap.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/SpringPluginBootstrap.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import java.util.List; /** * 插件引导抽象类。插件入口需集成本抽象类 + * * @author starBlues * @since 3.0.0 * @version 3.0.3 diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/AutowiredType.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/AutowiredType.java index 1d9d583747e0a54d9936edecd2a1e43f8d56832f..fcf79236ae7701ffdfb546169b59af92a33fd2ab 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/AutowiredType.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/AutowiredType.java @@ -7,6 +7,7 @@ import java.lang.annotation.*; * 注入类型 * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ @Target({ElementType.FIELD, ElementType.PARAMETER}) diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/DisablePluginWeb.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/DisablePluginWeb.java index 9a4fba0dab474e6ae6ec8c4fd319ee53d5bb9de8..c4098d5b74bf2565b5fe36723134ab7bcea50428 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/DisablePluginWeb.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/DisablePluginWeb.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import java.lang.annotation.*; /** * 禁用web环境. 如果该注解加入到入口类上, 表示当前插件禁用web的功能。 * 包括:controller注册、拦截器注册、web静态资源访问、thymeleaf模板引擎 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Target(ElementType.TYPE) diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/OneselfConfig.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/OneselfConfig.java index 1af29cd5fb749b474a9191dea2c819a852bff514..d51fb67d2da7b6c9b8a6939df23e2e8bdb785f3a 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/OneselfConfig.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/OneselfConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import java.lang.annotation.*; /** * 插件自主运行配置 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Target(ElementType.TYPE) diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/ResolveClassLoader.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/ResolveClassLoader.java index a93ffe05005ed909aa9a85477101b625998360ed..f2617cd46340f0078fac56677dc114105695f2bf 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/ResolveClassLoader.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/annotation/ResolveClassLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/coexist/CoexistAllowAutoConfiguration.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/coexist/CoexistAllowAutoConfiguration.java index 73355f6aeda6787346e026f0d94be6c6d998a4d2..4d8628ccafe16d51dcd1fc4f8d61b6a8237cd416 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/coexist/CoexistAllowAutoConfiguration.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/coexist/CoexistAllowAutoConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/coexist/CoexistResolveClassLoaderAspect.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/coexist/CoexistResolveClassLoaderAspect.java index 0d1b1df8b493dd17d4e53cba6f59775b1d05d4ff..df9658470318301da3b339e572a7f42450192654 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/coexist/CoexistResolveClassLoaderAspect.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/coexist/CoexistResolveClassLoaderAspect.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/BootstrapLauncher.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/BootstrapLauncher.java index 994ecc01ebe73369c45e00c7ff90be5b06c16d18..128d093af6bafe8ad4ee85fa329f5daeda56b636 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/BootstrapLauncher.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/BootstrapLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/BootstrapLauncherFactory.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/BootstrapLauncherFactory.java index bc14d229eacbcd7259274c86781e1e50ff4b38a5..a40de52221ab0c75dcf84d80ff4d4489be6fd921 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/BootstrapLauncherFactory.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/BootstrapLauncherFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/CoexistBootstrapLauncher.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/CoexistBootstrapLauncher.java index 59868a6a8a057baee3f5f20cf65a6f4b7712f361..dc226e612210a4df0137f78fee47bd1b3a6c5c09 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/CoexistBootstrapLauncher.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/CoexistBootstrapLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/DefaultBootstrapLauncherFactory.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/DefaultBootstrapLauncherFactory.java index 5fb5cef7ea821a2cc32aad2903f5e93885074f73..6869072913c9e7ec860924038668b7b2064e66aa 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/DefaultBootstrapLauncherFactory.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/DefaultBootstrapLauncherFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/IsolationBootstrapLauncher.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/IsolationBootstrapLauncher.java index 661844390f051fdf33d84637c2de42e5a6f0def2..4a20305d587f7adfc6d4cf81a4fd544a7b9bf88d 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/IsolationBootstrapLauncher.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/launcher/IsolationBootstrapLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/listener/PluginApplicationWebEventListener.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/listener/PluginApplicationWebEventListener.java index 68654012d851656a095ff6246eb8d0f137d215b0..cccd4120e8882b3746b9079e05c39a62770bcf68 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/listener/PluginApplicationWebEventListener.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/listener/PluginApplicationWebEventListener.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import org.springframework.core.ResolvableType; * 插件监听器扩展 * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class PluginApplicationWebEventListener implements ApplicationListener { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ComposeSpringPluginProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ComposeSpringPluginProcessor.java index c21dc112733924b7e54964e9235b6e97bf0d4af9..1717f761ebda308e21e5293fe32d92579a8f5771 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ComposeSpringPluginProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ComposeSpringPluginProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,11 +26,14 @@ import com.gitee.starblues.bootstrap.processor.web.PluginStaticResourceProcessor import com.gitee.starblues.bootstrap.processor.web.thymeleaf.PluginThymeleafProcessor; import com.gitee.starblues.bootstrap.utils.AnnotationUtils; import com.gitee.starblues.bootstrap.utils.ProcessorUtils; +import com.gitee.starblues.spring.MainApplicationContext; import com.gitee.starblues.utils.OrderUtils; import com.gitee.starblues.utils.ObjectUtils; import com.gitee.starblues.utils.OrderPriority; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import java.util.ArrayList; import java.util.List; @@ -38,8 +41,10 @@ import java.util.stream.Collectors; /** * 组合的处理器 + * * @author starBlues - * @version 3.0.3 + * @since 3.0.0 + * @version 3.1.1 */ public class ComposeSpringPluginProcessor implements SpringPluginProcessor { @@ -162,7 +167,8 @@ public class ComposeSpringPluginProcessor implements SpringPluginProcessor { * @param processors 处理者容器集合 */ protected void addDefaultWebEnvProcessors(ProcessorContext context, List processors){ - if(!context.getMainApplicationContext().isWebEnvironment()){ + MainApplicationContext mainApplicationContext = context.getMainApplicationContext(); + if(!mainApplicationContext.isWebEnvironment()){ // 主程序不是web类型, 则不进行注册 return; } @@ -173,7 +179,9 @@ public class ComposeSpringPluginProcessor implements SpringPluginProcessor { return; } context.getWebConfig().setEnable(true); - processors.add(new PluginControllerProcessor()); + if(mainApplicationContext.isRegisterController()){ + processors.add(new PluginControllerProcessor()); + } processors.add(new PluginInterceptorsProcessor()); processors.add(new PluginStaticResourceProcessor()); processors.add(new PluginThymeleafProcessor()); diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/DefaultProcessorContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/DefaultProcessorContext.java index 8867f9083ebec9904859b42d0d6a5d9472750882..db6e4ef1aca3093c86318dbc9aa1eb26f93bd9f3 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/DefaultProcessorContext.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/DefaultProcessorContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,9 @@ import java.util.Map; /** * 默认的处理者上下文 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DefaultProcessorContext extends CacheRegistryInfo implements ProcessorContext{ diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ExtractBeanProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ExtractBeanProcessor.java index 0ed867c6488db5c29e1d8e6e1494e01ff11f2695..303f532b8999f8a66bb986a90a1ff83298279ef2 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ExtractBeanProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ExtractBeanProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,9 @@ import java.util.Map; /** * Extract 扩展Bean注册处理者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ExtractBeanProcessor implements SpringPluginProcessor { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/FrameDefineBeanProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/FrameDefineBeanProcessor.java index 5098ffc933ff2723687abc2eab20c7cda4853661..d61ecaed5e9d407831198dd026fd591a31629bee 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/FrameDefineBeanProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/FrameDefineBeanProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,9 @@ import org.springframework.context.support.GenericApplicationContext; /** * 框架内置bean注册 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class FrameDefineBeanProcessor implements SpringPluginProcessor { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/InvokeOtherPluginProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/InvokeOtherPluginProcessor.java index 6c12254fb5e464637b8ae4b1cf1ffdfcfb3b3726..38885130b045083f2f8626387329268103970e13 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/InvokeOtherPluginProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/InvokeOtherPluginProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,9 @@ import java.util.Set; /** * 反射调用其他插件的处理者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class InvokeOtherPluginProcessor implements SpringPluginProcessor { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorContext.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorContext.java index d7aba0235f3690610abc06aba649194da93e222e..15dd3df263ee58aa241ad022e4fa370c4db565c2 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorContext.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,9 @@ import org.springframework.core.io.ResourceLoader; /** * 处理者上下文 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface ProcessorContext extends RegistryInfo { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorException.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorException.java index c0f6306af7593b8a8517b05dae30dafbe40fa49d..8dd75323807c3b92d6ae2c3c4181110287c2cc07 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorException.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/ProcessorException.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.bootstrap.processor; /** * 处理者异常 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ProcessorException extends RuntimeException{ diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/SpringPluginProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/SpringPluginProcessor.java index ce593214bedc1ca9ead1a56cab218cdd213d28b0..5117f2bd3e0bbbe6501ac1e0538205756311deb2 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/SpringPluginProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/SpringPluginProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import com.gitee.starblues.utils.OrderPriority; /** * spring plugin 处理器 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface SpringPluginProcessor extends Order { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegister.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegister.java index 7d3454aede3b78cf7e0c9797a9ddb7b05f0e56ac..7cd194f29326a869586378418ebb3136f89005a5 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegister.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegister.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.bootstrap.processor.interceptor; /** * 插件拦截器注册者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PluginInterceptorRegister { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistration.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistration.java index 668ab01a7a0409e7cc1d8f28e061329c52d34105..6d32f853da2388c005087e30680b63bc8867cccc 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistration.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,9 @@ import java.util.List; /** * 插件拦截器注册的信息 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginInterceptorRegistration { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistry.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistry.java index 817bce85e2359741b59af3869eee4b5d91eba4b3..59dcadea6dea21050a9c6c3eda2e26562564ee63 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistry.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/interceptor/PluginInterceptorRegistry.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,9 @@ import java.util.stream.Collectors; /** * 插件拦截器添加者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginInterceptorRegistry { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/invoke/InvokeBeanFactory.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/invoke/InvokeBeanFactory.java index de9f62d38eb82ba9b08ed1f68f1a989b408c0fb7..84a98f9b7a144dd483aef2903f9f0df4d1011c21 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/invoke/InvokeBeanFactory.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/invoke/InvokeBeanFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,9 @@ import java.lang.reflect.Proxy; /** * 反射调用其他插件定义的接口bean工厂 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class InvokeBeanFactory implements FactoryBean { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/invoke/InvokeProxyHandler.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/invoke/InvokeProxyHandler.java index 9efd0e0d07f47ae362e50aa3c5a558e1fae2feb4..ece37358d4711383ea157fed487792744c140491 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/invoke/InvokeProxyHandler.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/invoke/InvokeProxyHandler.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,9 @@ import java.util.Objects; /** * 反射调用处理模块 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class InvokeProxyHandler implements InvocationHandler { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/oneself/ConfigureMainPluginEnvironment.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/oneself/ConfigureMainPluginEnvironment.java index 0471be38243a001a6d68898f1ed27f3b1e7ee705..ae81146463448bb5826de53d3b4bde7fb761cc9b 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/oneself/ConfigureMainPluginEnvironment.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/oneself/ConfigureMainPluginEnvironment.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,6 +38,7 @@ import java.util.*; /** * 插件环境配置 + * * @author starBlues * @version 3.0.0 * @since 3.0.0 diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/oneself/OneselfProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/oneself/OneselfProcessor.java index f320f7c44ee25c95f8728af05bb3b933677d0af3..06676434d06f2989e6f6841e7ff1c2cb1e5eea01 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/oneself/OneselfProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/oneself/OneselfProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/scanner/PluginClassPathBeanDefinitionScanner.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/scanner/PluginClassPathBeanDefinitionScanner.java index d8641804bf1ad885e4a9017c07bfcd56d157538a..045a9c08b9aabe01e55c5122da0ab55f18625e75 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/scanner/PluginClassPathBeanDefinitionScanner.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/scanner/PluginClassPathBeanDefinitionScanner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import org.springframework.context.annotation.ClassPathBeanDefinitionScanner; /** * 插件自定义 classpath bean 扫描 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginClassPathBeanDefinitionScanner extends ClassPathBeanDefinitionScanner { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginControllerProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginControllerProcessor.java index bfba726100dcbd1126f18933ee79ef81ed507005..f8a5819ef216e68a6aafd52e3f3b6172aa462a06 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginControllerProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginControllerProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.gitee.starblues.bootstrap.processor.SpringPluginProcessor; import com.gitee.starblues.bootstrap.utils.AnnotationUtils; import com.gitee.starblues.bootstrap.utils.DestroyUtils; import com.gitee.starblues.integration.IntegrationConfiguration; +import com.gitee.starblues.spring.MainApplicationContext; import com.gitee.starblues.spring.SpringBeanFactory; import com.gitee.starblues.utils.*; import lombok.AllArgsConstructor; @@ -49,8 +50,10 @@ import java.util.function.Predicate; /** * 插件Controller处理者 + * * @author starBlues - * @version 3.0.3 + * @since 3.0.0 + * @version 3.1.1 */ public class PluginControllerProcessor implements SpringPluginProcessor { @@ -67,10 +70,9 @@ public class PluginControllerProcessor implements SpringPluginProcessor { @Override public void initialize(ProcessorContext processorContext) throws ProcessorException { - SpringBeanFactory mainBeanFactory = processorContext.getMainBeanFactory(); - this.requestMappingHandlerMapping = mainBeanFactory.getBean(RequestMappingHandlerMapping.class); - this.handlerAdapter = SpringBeanCustomUtils.getExistBean(processorContext.getMainApplicationContext(), - RequestMappingHandlerAdapter.class); + MainApplicationContext mainApplicationContext = processorContext.getMainApplicationContext(); + this.requestMappingHandlerMapping = mainApplicationContext.getRequestMappingHandlerMapping(); + this.handlerAdapter = mainApplicationContext.getRequestMappingHandlerAdapter(); canRegistered.set(true); } diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginInterceptorsProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginInterceptorsProcessor.java index 1ecd40b72597b378be61c274161f94a127f3e38e..22bc9d3ce592fe7f755f2c48a15bf5cc0a014271 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginInterceptorsProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginInterceptorsProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,9 @@ import java.util.Map; /** * 插件拦截器处理者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginInterceptorsProcessor implements SpringPluginProcessor { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginSpringDocControllerProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginSpringDocControllerProcessor.java index 4b2ce0668264d6294a4ffa4886b42a8ef1b10cb3..0092b990ab81ecebb15a0f02de9fe69d417bd4f5 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginSpringDocControllerProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginSpringDocControllerProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,9 @@ import java.util.List; /** * spring doc + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginSpringDocControllerProcessor implements SpringPluginProcessor { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginStaticResourceProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginStaticResourceProcessor.java index 1d2413bb4c39597febf9c83156bf03739503f220..40e30a523e5c352297706eefd18cfd9e42239197 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginStaticResourceProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/PluginStaticResourceProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,9 @@ import java.util.Set; /** * 插件web资源处理器. 获取资源配置 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginStaticResourceProcessor implements SpringPluginProcessor { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/thymeleaf/PluginThymeleafProcessor.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/thymeleaf/PluginThymeleafProcessor.java index 0cca5ecd3719198f7ddedbeda216fd02678f2a43..ddc6723b07dd7a12a65a1ca9126e46990bffa434 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/thymeleaf/PluginThymeleafProcessor.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/thymeleaf/PluginThymeleafProcessor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,9 @@ import org.springframework.context.support.GenericApplicationContext; /** * 插件 Thymeleaf 注册 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginThymeleafProcessor implements SpringPluginProcessor { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/thymeleaf/ThymeleafConfigParse.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/thymeleaf/ThymeleafConfigParse.java index 411818b5276a6e8d5f35f9483442a4349d195bcf..ffc9b55ad5ec355264ee414aa53f446469d6fac8 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/thymeleaf/ThymeleafConfigParse.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/processor/web/thymeleaf/ThymeleafConfigParse.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import org.springframework.core.env.Environment; /** * 解析ThymeleafConfig配置 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ThymeleafConfigParse { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/AutowiredTypeDefiner.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/AutowiredTypeDefiner.java index a81d519d1c3ebc35aee7cf8eb08fa7a6f295908c..7926a3d5a2c5da66e8f4cc9dc6113060d45b6d4a 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/AutowiredTypeDefiner.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/AutowiredTypeDefiner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/PluginCloseListener.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/PluginCloseListener.java index c151abfcfcea9979024c050d22759ea440b34c66..b3401cdf4522af4b29a29dec8a01435cadd0d512 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/PluginCloseListener.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/PluginCloseListener.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import org.springframework.context.support.GenericApplicationContext; /** * 插件被停止监听者。用于自定义关闭资源 + * * @author starBlues * @since 3.0.0 * @version 3.1.0 diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/StopValidator.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/StopValidator.java index 54e58a0c927eef7fb39c09043dbd3dd9a0c366f6..2946e1d5f453679df2ca901605cfd40d89a7e9cf 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/StopValidator.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/realize/StopValidator.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.gitee.starblues.bootstrap.realize; /** * 插件停止校验器. 自主实现判断是否可卸载 + * * @author starBlues * @since 3.0.0 * @version 3.0.3 diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/AnnotationUtils.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/AnnotationUtils.java index aa778aec555b1ae756e4b321e78799fe8388b888..23a579a08476a8db15b8c4190d466ee99e15f88e 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/AnnotationUtils.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/AnnotationUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import java.lang.reflect.Method; /** * 注解工具类 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class AnnotationUtils { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/DestroyUtils.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/DestroyUtils.java index eec6ef1b4187a93f0a98549717512835207fafce..8b7763bf8192c62c948707c228570d7ccbd59db2 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/DestroyUtils.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/DestroyUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,9 @@ import java.util.Objects; /** * 销毁工具类 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DestroyUtils { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/ProcessorUtils.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/ProcessorUtils.java index 15a8e5a3b13e301807de69c048aad609819f35a2..9fb436773c4796730c05f7b1c5999cc150375fc1 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/ProcessorUtils.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/ProcessorUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ import java.util.function.Supplier; /** * ProcessorUtils + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ProcessorUtils { diff --git a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/SpringBeanUtils.java b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/SpringBeanUtils.java index db039fbfc9bd59a05b63f0da3cef5d0206114caa..54b4c7cd21b60bac5c0547080259adf8fe258378 100644 --- a/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/SpringBeanUtils.java +++ b/spring-brick-bootstrap/src/main/java/com/gitee/starblues/bootstrap/utils/SpringBeanUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,9 @@ import java.util.*; /** * 插件bean工具类 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class SpringBeanUtils { diff --git a/spring-brick-common/pom.xml b/spring-brick-common/pom.xml index 3a57ab0afeab6b19d93eaacd640f1e78c2f3890a..e3b63b278259259942b13e6f88165658ba9fdb77 100644 --- a/spring-brick-common/pom.xml +++ b/spring-brick-common/pom.xml @@ -7,7 +7,7 @@ spring-brick-parent com.gitee.starblues - 3.1.0 + 3.1.1 spring-brick-common diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/AbstractDependencyPlugin.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/AbstractDependencyPlugin.java index 4052ff79de05a768e8844afb0a30a4406974b408..f5d43917d2c4ebb39a4aee72b1365279091246ef 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/AbstractDependencyPlugin.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/AbstractDependencyPlugin.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.function.Supplier; * 依赖的插件 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class AbstractDependencyPlugin implements DependencyPlugin{ diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/Constants.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/Constants.java index 481b524d2f5180a2abc6736b6761b17746fc1720..e545c01bfc4e299fbb3ce0fa41fcea1a8b169a1a 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/Constants.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/Constants.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +16,12 @@ package com.gitee.starblues.common; -import java.io.File; /** * 静态常量 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class Constants { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/DependencyPlugin.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/DependencyPlugin.java index cb306a9108caff73b4a72570cfbade7a57eb7e57..0fae35c8e1d3daa3b24bece8bfc1368553f5a56a 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/DependencyPlugin.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/DependencyPlugin.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.common; * 依赖的插件 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface DependencyPlugin { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/ManifestKey.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/ManifestKey.java index c4b25f9812565cc755be85f1f00c183ea9c3e14d..0a33924f7a452e64789dd93c773b8361abae0867 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/ManifestKey.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/ManifestKey.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,8 @@ import java.util.jar.Attributes; * Manifest-Key * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class ManifestKey { @@ -31,6 +32,11 @@ public class ManifestKey { */ public static final String MANIFEST_VERSION = "Manifest-Version"; + /** + * Manifest Build Time + */ + public static final String BUILD_TIME = "Build-Time"; + /** * Manifest-version: 1.0 */ diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/PackageStructure.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/PackageStructure.java index 3a02c907df7efe3e4ee17a9e25ce70939a7b16f0..d1fbdaab4cbf906aa20f2239566602416708eb02 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/PackageStructure.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/PackageStructure.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.regex.Matcher; * 插件打包结构 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class PackageStructure { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/PackageType.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/PackageType.java index ce11a7746bcfb00372135a00d5b1b51d8b02e324..66c5ada52c60e89aef455b93eae9bdf98c893a44 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/PackageType.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/PackageType.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.common; * 打包类型 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PackageType { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/PluginDescriptorKey.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/PluginDescriptorKey.java index fab32471c14d9c1e61c1a03bbaf81d1c582b4d39..106e210f20858a8ed137a3dcd4be76db7bcaaa8f 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/PluginDescriptorKey.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/PluginDescriptorKey.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.common; * 插件描述文件配置key * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginDescriptorKey { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AbstractPluginCipher.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AbstractPluginCipher.java index a2bd2063154f3baa761e45e4b375702643baf98d..9233c3335ab7cb622899a142d77bea4c4a4b3207 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AbstractPluginCipher.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AbstractPluginCipher.java @@ -9,6 +9,7 @@ import java.util.Map; * 抽象的插件解密 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ public abstract class AbstractPluginCipher implements PluginCipher{ diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AesPluginCipher.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AesPluginCipher.java index 3d1548973db88fcd28e66b113810c21ff26991a4..76d6c8dc66a872fa606523cd95a10205bdcdb706 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AesPluginCipher.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/AesPluginCipher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import java.util.Base64; * AES 加密 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ public class AesPluginCipher extends AbstractPluginCipher{ diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/PluginCipher.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/PluginCipher.java index 257d09e58719142b2d2aab6d4591c078176fccc2..b6abc4e5302df72d5a9ff2416824081488f2de21 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/PluginCipher.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/PluginCipher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.common.cipher; * 插件密码接口 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ public interface PluginCipher { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/RsaPluginCipher.java b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/RsaPluginCipher.java index 26dbff2f9745394cc4a471bf10e8ff5ee44c823b..1c881296c283a272c4168ca281355bd964c01608 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/RsaPluginCipher.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/common/cipher/RsaPluginCipher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,6 +33,7 @@ import java.util.Base64; * 非对称插件加解密 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ public class RsaPluginCipher extends AbstractPluginCipher{ diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/Assert.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/Assert.java index 839a8ba19b28ff1c127745e0731aea15d6ef86b2..41f6ca3d27d4fcd2ba15d75b2271477f2ad10e4d 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/Assert.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/Assert.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.util.function.Supplier; * 参数校验工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class Assert { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/CompareClassTypeUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/CompareClassTypeUtils.java index 1901f57edf7437b95fe290a1fe2c660b4a831f80..550afe1a4e9643f88961cb54a384a31c384ece56 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/CompareClassTypeUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/CompareClassTypeUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.utils; * 比较两个类类型 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class CompareClassTypeUtils { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/FieldFilter.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/FieldFilter.java index 915882f8744061690ca37ca7d76f95e4fc0bc916..cdc5159a58a5417d243e6c4b6f2e828361563196 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/FieldFilter.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/FieldFilter.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.lang.reflect.Field; * 文过滤接口 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @FunctionalInterface diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/FilesUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/FilesUtils.java index 7235739fb6ac43e60909e17ac40bcbafd0faf50f..50c481dd4994f1de91f16b643d91300b40eabf0c 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/FilesUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/FilesUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/MapValueGetter.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/MapValueGetter.java index 813844c0f545a7f876e789298e61f2abb813921f..862a768f4f2945c1d6fea52f0b2bf0d792f0a51c 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/MapValueGetter.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/MapValueGetter.java @@ -8,6 +8,7 @@ import java.util.function.Function; * map 值获取者工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class MapValueGetter { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/ObjectUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/ObjectUtils.java index ba1baca9e73aeb386015fea1c5db717b40d0eb80..fede52009b99420940dc50fb38072eb3976a5fed 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/ObjectUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/ObjectUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.*; * Object 工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ObjectUtils { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/ObjectValueUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/ObjectValueUtils.java index 9f3472511754ebe47ac0d794be30f84833a4de0e..ad9274d3094fd1b9e229abd137482d1bac6dc37d 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/ObjectValueUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/ObjectValueUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.utils; * object value convert utils * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public abstract class ObjectValueUtils { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/PropertiesUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/PropertiesUtils.java index 22700c7aaf30d25fe0655fc3b455fc9c5abde682..d2c2d8641c07a9bb2f0452f52869f2520d727502 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/PropertiesUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/PropertiesUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.Properties; * 操作 Manifest 工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class PropertiesUtils { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/ReflectionUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/ReflectionUtils.java index a087e073721af99808894838eae32411dcbd4dad..4e7ec3d3d16bff6b4e54032b7f1c756bf21c26dd 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/ReflectionUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/ReflectionUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.*; * 反射工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class ReflectionUtils { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/ResourceUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/ResourceUtils.java index a75d3ec17ef3a4b76577879d90882d0422dc6478..b05979095e118adc6cbfa11c58750d427605d169 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/ResourceUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/ResourceUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import java.util.function.Consumer; * 资源工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ResourceUtils { diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/StringUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/StringUtils.java index fc2abbbaf72c1926f30e056bb69251046564deed..6961d3767c591e63c224c0a48276a74de58ac549 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/StringUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/StringUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.StringTokenizer; * String 工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class StringUtils { @@ -59,4 +60,20 @@ public class StringUtils { return (!ObjectUtils.isEmpty(collection) ? collection.toArray(EMPTY_STRING_ARRAY) : EMPTY_STRING_ARRAY); } + public static String toStrByArray(String[] str){ + if(str == null || str.length == 0){ + return ""; + } + int length = str.length; + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < length; i++) { + String s = str[i]; + stringBuilder.append(s); + if (i < length - 1) { + stringBuilder.append(","); + } + } + return stringBuilder.toString(); + } + } diff --git a/spring-brick-common/src/main/java/com/gitee/starblues/utils/UrlUtils.java b/spring-brick-common/src/main/java/com/gitee/starblues/utils/UrlUtils.java index e4c7bdd42b90cf4aa1b4637db663d5620f661112..568a198466e1bb98ad60ccd2979f5dada157c023 100644 --- a/spring-brick-common/src/main/java/com/gitee/starblues/utils/UrlUtils.java +++ b/spring-brick-common/src/main/java/com/gitee/starblues/utils/UrlUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/pom.xml b/spring-brick-loader/pom.xml index d453dab0cf4a460326c4600bf42576df9d27f2df..2eee617fecace8772dc73b6e22f752e6039e6137 100644 --- a/spring-brick-loader/pom.xml +++ b/spring-brick-loader/pom.xml @@ -5,7 +5,7 @@ spring-brick-parent com.gitee.starblues - 3.1.0 + 3.1.1 4.0.0 diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/DevelopmentMode.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/DevelopmentMode.java index 82d0029b426daed0a1d1d19ecd040fd337cec99c..347c0825e36e3b42a493a71801bef75761bf12d2 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/DevelopmentMode.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/DevelopmentMode.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/LoaderConstant.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/LoaderConstant.java index 94f65c44261b96653694d1cebec20b9fcb495d72..cf9da2c35fe4bdc8ad5cdcea566195f1028ca71e 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/LoaderConstant.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/LoaderConstant.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.loader; * 常量统一定义 * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public class LoaderConstant { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/PluginResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/PluginResourceStorage.java index c32edec64e966c5b5a9a63707410e49191e888a8..7af081ca39cde513b3da6c32fcded1894c76c773 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/PluginResourceStorage.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/PluginResourceStorage.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,9 @@ import java.util.concurrent.ConcurrentHashMap; /** * 插件资源存储者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginResourceStorage { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/archive/Archive.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/archive/Archive.java index 8c351afdde32cb6e50257858c150a7a435ff9a4f..11f95d667424ccd35dd1c7d73b1edf7dcf334c19 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/archive/Archive.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/archive/Archive.java @@ -25,8 +25,7 @@ import java.util.function.Consumer; import java.util.jar.Manifest; /** - * copy from spring-boot-loader - * An archive that can be launched by the {@link Launcher}. + * An archive that can be launched * * @author Phillip Webb * @since 1.0.0 diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/ClassLoaderTranslator.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/ClassLoaderTranslator.java index 3030b1708c00ec1f5a135589f91fb69425719110..9a24c09a99a4db784935f69c119fda2f5903bd7f 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/ClassLoaderTranslator.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/ClassLoaderTranslator.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/GeneralUrlClassLoader.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/GeneralUrlClassLoader.java index c7a07e61651eaf606fcb82521c0774ce0d1452b4..8fcd39e096ade1d29ca214a1256d2b16baae59e1 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/GeneralUrlClassLoader.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/GeneralUrlClassLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/GenericClassLoader.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/GenericClassLoader.java index a186c847774530ef36bbc8ed78c3cdd4dc36d773..aaf7841cd3a7ce947d71616a006efe8aa4fdd527 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/GenericClassLoader.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/GenericClassLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,11 +28,14 @@ import java.net.URL; import java.net.URLClassLoader; import java.nio.file.Path; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; /** * 基本的 ClassLoader + * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class GenericClassLoader extends URLClassLoader implements ResourceLoaderFactory{ @@ -43,6 +46,8 @@ public class GenericClassLoader extends URLClassLoader implements ResourceLoader private final ResourceLoaderFactory classLoaderTranslator; + private final Map> pluginClassCache = new ConcurrentHashMap<>(); + public GenericClassLoader(String name, ResourceLoaderFactory resourceLoaderFactory) { this(name, null, resourceLoaderFactory); } @@ -59,6 +64,10 @@ public class GenericClassLoader extends URLClassLoader implements ResourceLoader return name; } + public ClassLoader getParentClassLoader(){ + return parent; + } + @Override public void addResource(String path) throws Exception { resourceLoaderFactory.addResource(path); @@ -116,6 +125,76 @@ public class GenericClassLoader extends URLClassLoader implements ResourceLoader } } + @Override + public URL[] getURLs() { + List urlList = resourceLoaderFactory.getUrls(); + URL[] urls = new URL[urlList.size()]; + for (int i = 0; i < urlList.size(); i++) { + urls[i] = urlList.get(i); + } + return urls; + } + + @Override + public InputStream getResourceAsStream(String name) { + name = formatResourceName(name); + InputStream inputStream = findInputStreamFromParent(name); + if(inputStream != null){ + return inputStream; + } + return findInputStreamFromLocal(name); + } + + @Override + public URL getResource(String name) { + name = formatResourceName(name); + URL url = findResourceFromParent(name); + if(url != null){ + return url; + } + return findResourceFromLocal(name); + } + + @Override + public Enumeration getResources(String name) throws IOException { + name = formatResourceName(name); + Enumeration parentResources = findResourcesFromParent(name); + Enumeration localResources = findResourcesFromLocal(name); + return new Enumeration() { + + private int index = 0; + + @Override + public boolean hasMoreElements() { + if(parentResources != null && parentResources.hasMoreElements()){ + return true; + } + index = 1; + return localResources.hasMoreElements(); + } + + @Override + public URL nextElement() { + if(index == 0){ + return parentResources.nextElement(); + } else { + return localResources.nextElement(); + } + } + }; + } + + @Override + public void close() throws IOException { + super.close(); + IOUtils.closeQuietly(resourceLoaderFactory); + } + + @Override + public void release() { + ResourceUtils.release(resourceLoaderFactory); + } + @Override protected Class findClass(String className) throws ClassNotFoundException { Class loadedClass = findClassFromParent(className); @@ -147,6 +226,12 @@ public class GenericClassLoader extends URLClassLoader implements ResourceLoader protected Class findClassFromLocal(String name) { Class aClass; String formatClassName = formatClassName(name); + + aClass = pluginClassCache.get(formatClassName); + if (aClass != null) { + return aClass; + } + Resource resource = resourceLoaderFactory.findFirstResource(formatClassName); byte[] bytes = null; if(resource != null){ @@ -168,72 +253,10 @@ public class GenericClassLoader extends URLClassLoader implements ResourceLoader super.definePackage(packageName, null, null, null, null, null, null, null ); } + pluginClassCache.put(name, aClass); return aClass; } - private byte[] getClassByte(String formatClassName){ - InputStream inputStream = resourceLoaderFactory.getInputStream(formatClassName); - if(inputStream == null){ - return null; - } - ByteArrayOutputStream output = new ByteArrayOutputStream(); - try { - byte[] buffer = new byte[4096]; - int n = 0; - while (-1 != (n = inputStream.read(buffer))) { - output.write(buffer, 0, n); - } - return output.toByteArray(); - } catch (Exception e){ - e.printStackTrace(); - return null; - } finally { - IOUtils.closeQuietly(inputStream); - IOUtils.closeQuietly(output); - } - } - - @Override - public URL[] getURLs() { - List urlList = resourceLoaderFactory.getUrls(); - URL[] urls = new URL[urlList.size()]; - for (int i = 0; i < urlList.size(); i++) { - urls[i] = urlList.get(i); - } - return urls; - } - - @Override - public InputStream getResourceAsStream(String name) { - name = formatResourceName(name); - InputStream inputStream = findInputStreamFromParent(name); - if(inputStream != null){ - return inputStream; - } - return findInputStreamFromLocal(name); - } - - protected InputStream findInputStreamFromParent(String name){ - if(parent != null){ - return parent.getResourceAsStream(name); - } - return null; - } - - protected InputStream findInputStreamFromLocal(String name){ - return resourceLoaderFactory.getInputStream(name); - } - - @Override - public URL getResource(String name) { - name = formatResourceName(name); - URL url = findResourceFromParent(name); - if(url != null){ - return url; - } - return findResourceFromLocal(name); - } - protected URL findResourceFromParent(String name){ if(parent != null){ return parent.getResource(name); @@ -249,33 +272,16 @@ public class GenericClassLoader extends URLClassLoader implements ResourceLoader return resource.getUrl(); } - @Override - public Enumeration getResources(String name) throws IOException { - name = formatResourceName(name); - Enumeration parentResources = findResourcesFromParent(name); - Enumeration localResources = findResourcesFromLocal(name); - return new Enumeration() { - - private int index = 0; - @Override - public boolean hasMoreElements() { - if(parentResources != null && parentResources.hasMoreElements()){ - return true; - } - index = 1; - return localResources.hasMoreElements(); - } + protected InputStream findInputStreamFromParent(String name){ + if(parent != null){ + return parent.getResourceAsStream(name); + } + return null; + } - @Override - public URL nextElement() { - if(index == 0){ - return parentResources.nextElement(); - } else { - return localResources.nextElement(); - } - } - }; + protected InputStream findInputStreamFromLocal(String name){ + return resourceLoaderFactory.getInputStream(name); } protected Enumeration findResourcesFromParent(String name) throws IOException{ @@ -300,10 +306,19 @@ public class GenericClassLoader extends URLClassLoader implements ResourceLoader }; } - @Override - public void close() throws IOException { - super.close(); - IOUtils.closeQuietly(resourceLoaderFactory); + private byte[] getClassByte(String formatClassName){ + InputStream inputStream = resourceLoaderFactory.getInputStream(formatClassName); + if(inputStream == null){ + return null; + } + try { + return IOUtils.read(inputStream); + } catch (Exception e){ + e.printStackTrace(); + return null; + } finally { + IOUtils.closeQuietly(inputStream); + } } private String formatResourceName(String name) { @@ -317,5 +332,4 @@ public class GenericClassLoader extends URLClassLoader implements ResourceLoader return className; } - } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/filter/ExcludeResource.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/filter/ExcludeResource.java index 237c4de9497db5dd25d7e785ff6e466f9afbbd77..06ca2ca1e0dfd59fe9fa7a51cbb8d7f0e8e40492 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/filter/ExcludeResource.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/filter/ExcludeResource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/filter/IncludeResource.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/filter/IncludeResource.java index e0091231553f84937e36ec58cd12b12ebd925104..5068fd12af492b43358c912bf2f3d3bc80c8e743 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/filter/IncludeResource.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/filter/IncludeResource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/Resource.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/Resource.java index a2c4d0132075b744d186d22f2d249a70a3d1974e..283ed3dd5b76f242dd9d313167a3a0bb6a001ba5 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/Resource.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/Resource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +16,17 @@ package com.gitee.starblues.loader.classloader.resource; +import com.gitee.starblues.loader.utils.Release; + import java.net.URL; /** * 资源信息 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ -public interface Resource extends AutoCloseable{ +public interface Resource extends AutoCloseable, Release { String PACKAGE_SPLIT = "/"; @@ -52,11 +55,9 @@ public interface Resource extends AutoCloseable{ byte[] getBytes(); /** - * 设置字节数 - * @param byteGetter byteGetter - * @throws Exception set byte 异常 + * 解决byte + * @throws Exception 处理资源字节异常 */ - void setBytes(ResourceByteGetter byteGetter) throws Exception; - + void resolveByte() throws Exception; } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/ResourceByteGetter.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/ResourceByteGetter.java index e8b78f806f12c94cb6a46a055b49062414f288af..beab785adac7b6b0e5b754b23a6527ed2b202cce 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/ResourceByteGetter.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/ResourceByteGetter.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.loader.classloader.resource; * 资源 byte 得到者 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface ResourceByteGetter { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/Cache.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/Cache.java new file mode 100644 index 0000000000000000000000000000000000000000..6e0fd832a60fe8c9dbd464e3b80d33c5ce0d6945 --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/Cache.java @@ -0,0 +1,92 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.cache; + + +import java.util.function.Consumer; +import java.util.function.Supplier; + +/** + * 缓存接口 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +public interface Cache { + + /** + * 缓存数据 + * @param key 缓存的key + * @param value 缓存的值 + */ + void put(K key, V value); + + /** + * 缓存大小 + * @return int + */ + int size(); + + /** + * 是否存在缓存 + * @param key 缓存key + * @return true: 存在, false: 不存在 + */ + boolean containsKey(K key); + + /** + * 获取缓存值 + * @param key 缓存的key + * @return 缓存值, 不存在返回 null + */ + V get(K key); + + /** + * 得到缓存值。如果不存在放默认的 + * @param key 缓存的key + * @param supplier 默认值 + * @param defaultAdded 如果不存在, 默认的释放添加进入缓存中 + * @return V + */ + V getOrDefault(K key, Supplier supplier, boolean defaultAdded); + + /** + * 移除缓存 + * @param key 缓存的key + * @return 移除的值 + */ + V remove(K key); + + /** + * 清理过期的缓存 + * @return 清除的个数 + */ + int cleanExpired(); + + /** + * 清除全部缓存 + */ + void clear(); + + /** + * 依次删除 + * @param consumer 消费 + */ + void clear(Consumer consumer); + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/CacheExpirationTrigger.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/CacheExpirationTrigger.java new file mode 100644 index 0000000000000000000000000000000000000000..6aa88559a6503311143ba65c7e477bc535339f53 --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/CacheExpirationTrigger.java @@ -0,0 +1,63 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.cache; + +import java.util.function.Supplier; + +/** + * 缓存过期调度接口 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +public interface CacheExpirationTrigger { + + /** + * 添加缓存过期调度 + * @param key 缓存的key + * @param cache 缓存对象 + */ + void addCache(String key, Cache cache); + + /*** + * 获取缓存 + * @param key 缓存的key + * @param cacheSupplier 不存在时提供, 并add到缓存中 + * @return 缓存 + * @param K + * @param V + */ + Cache getCache(String key, Supplier> cacheSupplier); + + /** + * 移除缓存过期调度 + * @param key 缓存的key + */ + void removeCache(String key); + + /** + * 启动调度 + */ + void start(); + + /** + * 停止调度 + */ + void stop(); + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/CacheLinkedHashMap.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/CacheLinkedHashMap.java new file mode 100644 index 0000000000000000000000000000000000000000..df76398df0999876f5a24249890c1419e4fd8d46 --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/CacheLinkedHashMap.java @@ -0,0 +1,54 @@ +package com.gitee.starblues.loader.classloader.resource.cache; + +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 注释 + * + * @author starBlues + * @since 1.0.0 + * @version 1.0.0 + */ +public class CacheLinkedHashMap extends LinkedHashMap { + + private final int size; + private final RemoveListener removeListener; + + public CacheLinkedHashMap(int size) { + this(size, null); + } + + public CacheLinkedHashMap(int size, RemoveListener removeListener) { + super(size + 1, 1.0f, true); + this.size = size; + this.removeListener = removeListener; + } + + @Override + protected boolean removeEldestEntry(Map.Entry eldest) { + if (size == 0) { + return false; + } + int removeSize = size() - size; + if(removeSize > 0){ + if(removeListener != null){ + try { + removeListener.remove(eldest); + } catch (Exception e){ + // 忽略 + } + } + return true; + } + return false; + } + + @FunctionalInterface + public interface RemoveListener{ + + void remove(Map.Entry eldest); + + } + +} \ No newline at end of file diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/DefaultCacheExpirationTrigger.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/DefaultCacheExpirationTrigger.java new file mode 100644 index 0000000000000000000000000000000000000000..5b5b5e73bbaa757d201a85f6505bb255418e4364 --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/DefaultCacheExpirationTrigger.java @@ -0,0 +1,112 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.cache; + +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +/** + * 默认缓存过期调度实现 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +public class DefaultCacheExpirationTrigger implements CacheExpirationTrigger{ + + private final Map> cacheMap = new ConcurrentHashMap<>(); + + private ScheduledExecutorService scheduledExecutor; + + private static volatile DefaultCacheExpirationTrigger TRIGGER; + + private final long delay; + private final TimeUnit unit; + + private DefaultCacheExpirationTrigger(long delay, TimeUnit unit){ + this.delay = delay; + this.unit = unit; + start(); + } + + public static CacheExpirationTrigger getCacheExpirationTrigger(long delay, TimeUnit unit){ + if (TRIGGER == null){ + synchronized(DefaultCacheExpirationTrigger.class){ + TRIGGER = new DefaultCacheExpirationTrigger(delay, unit); + } + } + return TRIGGER; + } + + @Override + public synchronized void addCache(String key, Cache cache) { + if(cacheMap.containsKey(key)){ + throw new IllegalStateException(key + " already exists!"); + } + cacheMap.put(key, cache); + } + + @SuppressWarnings("unchecked") + @Override + public synchronized Cache getCache(String key, Supplier> cacheSupplier) { + Cache cache = cacheMap.get(key); + if(cache == null){ + Cache supplier = cacheSupplier.get(); + if(supplier == null){ + return null; + } + cacheMap.put(key, supplier); + return supplier; + } else { + return (Cache) cache; + } + } + + @Override + public synchronized void removeCache(String key) { + cacheMap.remove(key); + } + + @Override + public synchronized void start() { + scheduledExecutor = Executors.newSingleThreadScheduledExecutor(); + scheduledExecutor.scheduleWithFixedDelay(this::cleanUp, delay, delay, unit); + } + + @Override + public synchronized void stop() { + scheduledExecutor.shutdownNow(); + } + + private void cleanUp(){ + if(cacheMap.isEmpty()){ + return; + } + cacheMap.forEach((k,v)->{ + try { + v.cleanExpired(); + } catch (Exception e){ + // log.warn("Checking clean cache:{} Exceptions. {}", k, e.getMessage()); + } + }); + } + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/Entity.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/Entity.java new file mode 100644 index 0000000000000000000000000000000000000000..10eed19bbebf522f63050e4f907b15baa8b94b09 --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/Entity.java @@ -0,0 +1,51 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.cache; + +/** + * 缓存元素 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +public class Entity { + + protected final V value; + protected final long ttl; + protected long lastAccessTimestamp; + + public Entity(V value, long ttl) { + this.value = value; + this.ttl = ttl; + + this.lastAccessTimestamp = System.currentTimeMillis(); + } + + public boolean isExpired() { + if (ttl == 0) { + return false; + } + return lastAccessTimestamp + ttl < System.currentTimeMillis(); + } + + public V getValue() { + lastAccessTimestamp = System.currentTimeMillis(); + return value; + } + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMapCache.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMapCache.java new file mode 100644 index 0000000000000000000000000000000000000000..e4ee7ede91f2c07c1ff112e73d3b364a40e92c8d --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMapCache.java @@ -0,0 +1,227 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.cache; + +import java.util.Iterator; +import java.util.LinkedHashMap; + +import java.util.Map; +import java.util.concurrent.locks.StampedLock; +import java.util.function.Consumer; +import java.util.function.Supplier; + +/** + * LRU 缓存实现 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +public class LRUMapCache implements Cache{ + + private final Map> cacheMap; + + private final StampedLock lock = new StampedLock(); + + private final int size; + private final long timeout; + + public LRUMapCache(int size, long timeout){ + this.size = size; + this.timeout = timeout; + this.cacheMap = new CacheLinkedHashMap>(size); + } + + @Override + public void put(K key, V value) { + long stamp = lock.writeLock(); + try { + Entity entity = new Entity<>(value, timeout); + if (isFull(key)) { + cleanExpired(false); + } + cacheMap.put(key, entity); + } finally { + lock.unlockWrite(stamp); + } + } + + @Override + public int size() { + long stamp = lock.tryOptimisticRead(); + int size = cacheMap.size(); + if(!lock.validate(stamp)){ + stamp = lock.readLock(); + try { + size = cacheMap.size(); + } finally { + lock.unlockRead(stamp); + } + } + return size; + } + + @Override + public boolean containsKey(K key) { + return get(key) != null; + } + + @Override + public V get(K key) { + long stamp = lock.tryOptimisticRead(); + Entity entity = cacheMap.get(key); + if(!lock.validate(stamp)){ + stamp = lock.readLock(); + try { + entity = cacheMap.get(key); + } finally { + lock.unlockRead(stamp); + } + } + if(entity != null){ + if(entity.isExpired()){ + remove(key); + return null; + } + return entity.getValue(); + } + return null; + } + + @Override + public V getOrDefault(K key, Supplier supplier, boolean defaultAdded) { + long stamp = lock.tryOptimisticRead(); + Entity entity = cacheMap.get(key); + if(!lock.validate(stamp)){ + stamp = lock.readLock(); + try { + entity = cacheMap.get(key); + } finally { + lock.unlockRead(stamp); + } + } + if(entity != null){ + if(entity.isExpired()){ + remove(key); + } else { + return entity.getValue(); + } + } + + V v = supplier.get(); + if(v != null){ + if(defaultAdded){ + put(key, v); + } + } + return v; + } + + @Override + public V remove(K key) { + long stamp = lock.writeLock(); + try { + Entity cacheValue = cacheMap.remove(key); + if (cacheValue != null) { + return cacheValue.getValue(); + } else { + return null; + } + } finally { + lock.unlockWrite(stamp); + } + } + + @Override + public void clear() { + clear(null); + } + + @Override + public void clear(Consumer consumer) { + long stamp = lock.writeLock(); + try { + if(consumer == null){ + cacheMap.clear(); + return; + } + Iterator>> iterator = cacheMap.entrySet().iterator(); + while (iterator.hasNext()){ + try { + Map.Entry> entityEntry = iterator.next(); + Entity value = entityEntry.getValue(); + if(value == null){ + iterator.remove(); + continue; + } + V v = value.getValue(); + if(v == null){ + iterator.remove(); + continue; + } + consumer.accept(v); + } catch (Exception e){ + // 忽略 + } + } + } finally { + lock.unlockWrite(stamp); + } + } + + @Override + public int cleanExpired() { + return cleanExpired(true); + } + + private boolean isFull(K key) { + if (size == 0) { + return false; + } + if(cacheMap.size() < size){ + return false; + } + return !cacheMap.containsKey(key); + } + + public int cleanExpired(boolean isLock) { + if(!isLock){ + return actualCleanExpired(); + } + long stamp = lock.writeLock(); + try { + return actualCleanExpired(); + } finally { + lock.unlockWrite(stamp); + } + } + + private int actualCleanExpired(){ + Iterator>> cacheMapIterator = cacheMap.entrySet().iterator(); + int removeCount = 0; + while (cacheMapIterator.hasNext()){ + Map.Entry> entityMap = cacheMapIterator.next(); + Entity value = entityMap.getValue(); + if(value == null || value.isExpired()){ + cacheMapIterator.remove(); + removeCount++; + } + } + return removeCount; + } + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMultiMapListCache.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMultiMapListCache.java new file mode 100644 index 0000000000000000000000000000000000000000..f331106858669c5e85dab42ed11a6cc6b904c6fb --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMultiMapListCache.java @@ -0,0 +1,289 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.cache; + +import com.gitee.starblues.loader.utils.ObjectUtils; + +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.StampedLock; +import java.util.function.Consumer; +import java.util.function.Supplier; +import java.util.stream.Collectors; + +/** + * LRU MultiMap List 缓存实现。list 集合中的元素单个过期 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +@Deprecated +public class LRUMultiMapListCache implements MultiCache{ + + private final Map>> cacheMap; + + private final StampedLock lock = new StampedLock(); + + private final int maxSize; + private final long timeout; + + private final AtomicInteger size = new AtomicInteger(0); + + public LRUMultiMapListCache(int maxSize, long timeout){ + this.maxSize = maxSize; + this.timeout = timeout; + this.cacheMap = new CacheLinkedHashMap>>(maxSize, entry->{ + List> value = entry.getValue(); + if(value != null){ + size.addAndGet(-value.size()); + } + }); + } + + @Override + public void put(K key, Collection value) { + if(ObjectUtils.isEmpty(value)){ + return; + } + long stamp = lock.writeLock(); + try { + List> entityAddedList = value.stream() + .map(v-> new Entity<>(v, timeout)) + .collect(Collectors.toList()); + if (isFull(key)) { + cleanExpired(false); + } + List> entityList = cacheMap.computeIfAbsent(key, k -> new ArrayList<>()); + entityList.addAll(entityAddedList); + size.addAndGet(value.size()); + } finally { + lock.unlockWrite(stamp); + } + } + + @SuppressWarnings("unchecked") + @Override + public void putSingle(K key, V value) { + put(key, ObjectUtils.toList(value)); + } + + @Override + public V getFirst(K key) { + long stamp = lock.tryOptimisticRead(); + List> entityList = cacheMap.get(key); + if(!lock.validate(stamp)){ + stamp = lock.readLock(); + try { + entityList = cacheMap.get(key); + } finally { + lock.unlockRead(stamp); + } + } + if(ObjectUtils.isEmpty(entityList)){ + return null; + } + Iterator> iterator = entityList.iterator(); + while (iterator.hasNext()){ + Entity entity = iterator.next(); + if(entity.isExpired()){ + iterator.remove(); + size.addAndGet(-1); + } else { + return entity.getValue(); + } + } + return null; + } + + @Override + public int size() { + long stamp = lock.tryOptimisticRead(); + int s = size.get(); + if(!lock.validate(stamp)){ + stamp = lock.readLock(); + try { + s = size.get(); + } finally { + lock.unlockRead(stamp); + } + } + return s; + } + + @Override + public boolean containsKey(K key) { + return get(key) != null; + } + + @Override + public Collection get(K key) { + long stamp = lock.tryOptimisticRead(); + List> entityList = cacheMap.get(key); + if(!lock.validate(stamp)){ + stamp = lock.readLock(); + try { + entityList = cacheMap.get(key); + } finally { + lock.unlockRead(stamp); + } + } + if(ObjectUtils.isEmpty(entityList)){ + return null; + } + Iterator> iterator = entityList.iterator(); + List result = new ArrayList<>(entityList.size()); + while (iterator.hasNext()){ + Entity entity = iterator.next(); + if(entity.isExpired()){ + iterator.remove(); + size.addAndGet(-1); + } else { + result.add(entity.getValue()); + } + } + return result; + } + + @Override + public Collection getOrDefault(K key, Supplier> supplier, boolean defaultAdded) { + Collection collection = get(key); + if(!ObjectUtils.isEmpty(collection)){ + return collection; + } + Collection addCollection = supplier.get(); + if(ObjectUtils.isEmpty(addCollection)){ + return null; + } + if(defaultAdded){ + put(key, addCollection); + return addCollection; + } + return null; + } + + + + @Override + public Collection remove(K key) { + long stamp = lock.writeLock(); + try { + List> cacheValue = cacheMap.remove(key); + if (cacheValue == null) { + return null; + } + size.addAndGet(-cacheValue.size()); + return cacheValue.stream() + .map(Entity::getValue) + .collect(Collectors.toList()); + } finally { + lock.unlockWrite(stamp); + } + } + + @Override + public void clear() { + clear(null); + } + + @Override + public void clear(Consumer> consumer) { + long stamp = lock.writeLock(); + try { + if(consumer == null){ + cacheMap.clear(); + return; + } + Iterator>>> iterator = cacheMap.entrySet().iterator(); + while (iterator.hasNext()){ + try { + Map.Entry>> entityMap = iterator.next(); + List> entityList = entityMap.getValue(); + if(entityList == null){ + iterator.remove(); + continue; + } + List values = entityList.stream().map(Entity::getValue).collect(Collectors.toList()); + consumer.accept(values); + iterator.remove(); + } catch (Exception e){ + // 忽略 + } + } + } finally { + size.set(0); + lock.unlockWrite(stamp); + } + } + + @Override + public int cleanExpired() { + return cleanExpired(true); + } + + private boolean isFull(K key) { + if (maxSize == 0) { + return false; + } + if(size.get() < maxSize){ + return false; + } + return !cacheMap.containsKey(key); + } + + public int cleanExpired(boolean isLock) { + if(!isLock){ + return actualCleanExpired(); + } + long stamp = lock.writeLock(); + try { + return actualCleanExpired(); + } finally { + lock.unlockWrite(stamp); + } + } + + private int actualCleanExpired(){ + Iterator>>> cacheMapIterator = cacheMap.entrySet().iterator(); + int removeCount = 0; + while (cacheMapIterator.hasNext()){ + Map.Entry>> entityMap = cacheMapIterator.next(); + List> value = entityMap.getValue(); + if(ObjectUtils.isEmpty(value)){ + cacheMapIterator.remove(); + continue; + } + int valueSize = value.size(); + Iterator> entityIterator = value.iterator(); + int removeSize = 0; + while (entityIterator.hasNext()){ + Entity entity = entityIterator.next(); + if(entity == null || entity.isExpired()){ + entityIterator.remove(); + removeSize++; + } + } + if(valueSize == removeSize){ + cacheMapIterator.remove(); + } + size.addAndGet(-removeSize); + removeCount = removeCount + removeSize; + } + return removeCount; + } + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMultiMapUnifiedListCache.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMultiMapUnifiedListCache.java new file mode 100644 index 0000000000000000000000000000000000000000..6185ef69e1b22fa3c995aeb912a4c257637e2188 --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/LRUMultiMapUnifiedListCache.java @@ -0,0 +1,288 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.cache; + +import com.gitee.starblues.loader.utils.ObjectUtils; + +import java.util.*; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.locks.StampedLock; +import java.util.function.Consumer; +import java.util.function.Supplier; + +/** + * LRU MultiMap List 缓存实现。list 集合中的元素统一过期 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +public class LRUMultiMapUnifiedListCache implements MultiCache{ + + private final Map cacheMap; + + private final StampedLock lock = new StampedLock(); + + private final int maxSize; + private final long timeout; + + private final AtomicInteger size = new AtomicInteger(0); + + public LRUMultiMapUnifiedListCache(int maxSize, long timeout){ + this.maxSize = maxSize; + this.timeout = timeout; + this.cacheMap = new CacheLinkedHashMap(maxSize, entry->{ + EntityList value = entry.getValue(); + if(value != null){ + size.addAndGet(-value.size()); + } else { + size.addAndGet(-1); + } + }); + } + + @Override + public void put(K key, Collection value) { + if(ObjectUtils.isEmpty(value)){ + return; + } + long stamp = lock.writeLock(); + try { + if (isFull(key)) { + cleanExpired(false); + } + EntityList entityList = cacheMap.computeIfAbsent(key, k -> new EntityList(timeout)); + entityList.add(value); + } finally { + lock.unlockWrite(stamp); + } + } + + @SuppressWarnings("unchecked") + @Override + public void putSingle(K key, V value) { + put(key, ObjectUtils.toList(value)); + } + + @Override + public V getFirst(K key) { + Collection collection = get(key); + return ObjectUtils.getFirst(collection); + } + + @Override + public int size() { + long stamp = lock.tryOptimisticRead(); + int s = size.get(); + if(!lock.validate(stamp)){ + stamp = lock.readLock(); + try { + s = size.get(); + } finally { + lock.unlockRead(stamp); + } + } + return s; + } + + @Override + public boolean containsKey(K key) { + return get(key) != null; + } + + @Override + public Collection get(K key) { + long stamp = lock.tryOptimisticRead(); + EntityList entityList = cacheMap.get(key); + if(!lock.validate(stamp)){ + stamp = lock.readLock(); + try { + entityList = cacheMap.get(key); + } finally { + lock.unlockRead(stamp); + } + } + if(entityList == null){ + return null; + } + if(entityList.isExpired()){ + remove(key); + return null; + } + return Collections.unmodifiableList(entityList.getValue()); + } + + @Override + public Collection getOrDefault(K key, Supplier> supplier, boolean defaultAdded) { + Collection collection = get(key); + if(!ObjectUtils.isEmpty(collection)){ + return collection; + } + Collection addCollection = supplier.get(); + if(ObjectUtils.isEmpty(addCollection)){ + return null; + } + if(defaultAdded){ + put(key, addCollection); + return addCollection; + } + return null; + } + + @Override + public Collection remove(K key) { + long stamp = lock.writeLock(); + try { + EntityList cacheValue = cacheMap.remove(key); + if (cacheValue == null) { + return null; + } + size.addAndGet(-cacheValue.size()); + return cacheValue.getValue(); + } finally { + lock.unlockWrite(stamp); + } + } + + @Override + public void clear() { + clear(null); + } + + @Override + public void clear(Consumer> consumer) { + long stamp = lock.writeLock(); + try { + if(consumer == null){ + cacheMap.clear(); + return; + } + Iterator> iterator = cacheMap.entrySet().iterator(); + while (iterator.hasNext()){ + try { + Map.Entry entityMap = iterator.next(); + EntityList entityList = entityMap.getValue(); + if(entityList == null){ + iterator.remove(); + continue; + } + List value = entityList.getValue(); + if(value != null){ + consumer.accept(value); + } + iterator.remove(); + } catch (Exception e){ + // 忽略 + } + } + } finally { + size.set(0); + lock.unlockWrite(stamp); + } + } + + @Override + public int cleanExpired() { + return cleanExpired(true); + } + + private boolean isFull(K key) { + if (maxSize == 0) { + return false; + } + if(cacheMap.size() < maxSize){ + return false; + } + return !cacheMap.containsKey(key); + } + + public int cleanExpired(boolean isLock) { + if(!isLock){ + return actualCleanExpired(); + } + long stamp = lock.writeLock(); + try { + return actualCleanExpired(); + } finally { + lock.unlockWrite(stamp); + } + } + + private int actualCleanExpired(){ + Iterator> cacheMapIterator = cacheMap.entrySet().iterator(); + int removeCount = 0; + while (cacheMapIterator.hasNext()){ + Map.Entry entityMap = cacheMapIterator.next(); + EntityList value = entityMap.getValue(); + if(value == null){ + cacheMapIterator.remove(); + } else { + if(value.isExpired()){ + int valueSize = value.size(); + cacheMapIterator.remove(); + size.addAndGet(-valueSize); + removeCount = removeCount + valueSize; + } + } + } + return removeCount; + } + + private class EntityList extends Entity> implements AutoCloseable{ + + public EntityList(long ttl) { + super(new ArrayList<>(), ttl); + } + + public EntityList(List list, long ttl) { + super(list, ttl); + } + + public synchronized void add(V v){ + getValue().add(v); + size.addAndGet(1); + } + + public synchronized void add(Collection list){ + if(ObjectUtils.isEmpty(list)){ + return; + } + getValue().addAll(list); + size.addAndGet(list.size()); + } + + public synchronized V getFirst(){ + List list = getValue(); + if(ObjectUtils.isEmpty(list)){ + return null; + } + return list.get(0); + } + + public synchronized int size(){ + return getValue().size(); + } + + @Override + public synchronized void close() throws Exception { + List value = getValue(); + size.addAndGet(-value.size()); + value.clear(); + } + } + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/SameRootResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/MultiCache.java similarity index 50% rename from spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/SameRootResourceStorage.java rename to spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/MultiCache.java index b53b93504e51fa4a795fd9e1d78610aec7629e34..6529323da2aedc1eb5e0bd12e265b3996d5b2e51 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/SameRootResourceStorage.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/cache/MultiCache.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,31 +14,36 @@ * limitations under the License. */ -package com.gitee.starblues.loader.classloader.resource.storage; +package com.gitee.starblues.loader.classloader.resource.cache; -import java.net.URL; + +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Supplier; /** - * 抽象的资源存储 + * 缓存接口 * * @author starBlues - * @version 3.0.0 + * @since 3.1.1 + * @version 3.1.1 */ -public abstract class SameRootResourceStorage implements ResourceStorage { - - protected final URL baseUrl; - - public SameRootResourceStorage(URL baseUrl) { - this.baseUrl = baseUrl; - } +public interface MultiCache extends Cache>{ /** - * 获取 base url - * @return URL + * put 一个值 + * @param key 缓存的key + * @param value 缓存的值 */ - public URL getBaseUrl() { - return baseUrl; - } + void putSingle(K key, V value); + /** + * 得到第一个value + * @param key 缓存的key + * @return 第一个value + */ + V getFirst(K key); } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/AbstractResourceLoader.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/AbstractResourceLoader.java index b3ec9ecd2e394120d638ec2a3c1af95bb6cc1e36..68a5fa5bbf6eb77dbb802081f44c2f3bb37a0f51 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/AbstractResourceLoader.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/AbstractResourceLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,14 +19,14 @@ package com.gitee.starblues.loader.classloader.resource.loader; import com.gitee.starblues.loader.classloader.resource.storage.ResourceStorage; import com.gitee.starblues.loader.utils.IOUtils; -import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.URL; /** * 抽象的资源加载者 * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public abstract class AbstractResourceLoader implements ResourceLoader{ @@ -55,8 +55,8 @@ public abstract class AbstractResourceLoader implements ResourceLoader{ throw new Exception(this.getClass().getName()+": 已经初始化了, 不能再初始化!"); } try { - // 添加root 路径 - resourceStorage.add("/", baseUrl); + // 添加root 资源 + resourceStorage.add(new DefaultResource("/", baseUrl, baseUrl)); loadOfChild(resourceStorage); } finally { loaded = true; @@ -74,15 +74,12 @@ public abstract class AbstractResourceLoader implements ResourceLoader{ if(!isClass(path)){ return null; } - final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); try { - IOUtils.copy(inputStream, byteArrayOutputStream); - return byteArrayOutputStream.toByteArray(); + return IOUtils.read(inputStream); } finally { if(isClose){ IOUtils.closeQuietly(inputStream); } - IOUtils.closeQuietly(byteArrayOutputStream); } } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/CacheResource.java similarity index 36% rename from spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheResourceStorage.java rename to spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/CacheResource.java index a24a7c93682af71080c1eb418591302024553aa7..e042678e66284f636c79fdc3e72245f7b7ad9c6a 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheResourceStorage.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/CacheResource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,61 +14,58 @@ * limitations under the License. */ -package com.gitee.starblues.loader.classloader.resource.storage; +package com.gitee.starblues.loader.classloader.resource.loader; -import com.gitee.starblues.loader.classloader.resource.loader.DefaultResource; -import com.gitee.starblues.loader.classloader.resource.Resource; import com.gitee.starblues.loader.classloader.resource.ResourceByteGetter; import java.net.URL; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import java.util.Arrays; /** - * 可缓存的资源存储者 + * 可缓存的资源 * * @author starBlues - * @version 3.0.0 + * @since 3.1.1 + * @version 3.1.1 */ -public class CacheResourceStorage extends DefaultResourceStorage{ +public class CacheResource extends DefaultResource { - public CacheResourceStorage(URL baseUrl) { - super(baseUrl); - } + protected byte[] bytes; + private ResourceByteGetter byteGetter; - @Override - public void add(String name, URL url, ResourceByteGetter byteGetter) throws Exception{ - name = formatResourceName(name); - if(resourceStorage.containsKey(name)){ - return; - } - CacheResource cacheResource = new CacheResource(name, baseUrl, url); - cacheResource.setBytes(byteGetter); - addResource(name, cacheResource); + public CacheResource(String name, URL baseUrl, URL url) { + this(name, baseUrl, url, null); } - private static class CacheResource extends DefaultResource { + public CacheResource(String name, URL baseUrl, URL url, ResourceByteGetter byteGetter) { + super(name, baseUrl, url); + setBytes(byteGetter); + } - private byte[] bytes; + public void setBytes(ResourceByteGetter byteGetter) { + this.byteGetter = byteGetter; + } - public CacheResource(String name, URL baseUrl, URL url) { - super(name, baseUrl, url); - } + @Override + public byte[] getBytes() { + return bytes; + } - @Override - public void setBytes(ResourceByteGetter byteGetter) throws Exception{ - if(byteGetter == null){ - return; - } - // 忽略 + @Override + public void resolveByte() throws Exception{ + if(byteGetter != null){ bytes = byteGetter.get(); } - - @Override - public byte[] getBytes() { - return bytes; - } } + @Override + public void close() throws Exception { + release(); + } + @Override + public void release() { + Arrays.fill(bytes, (byte) 0); + bytes = null; + } } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ClassPathLoader.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ClassPathLoader.java index 24048c04b7dc7fa5836dae840fb26b889e5f341d..3ba8b84709d19e4d5634a7400ba7f16ce5f4496e 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ClassPathLoader.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ClassPathLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,16 +19,17 @@ import com.gitee.starblues.loader.classloader.resource.Resource; import com.gitee.starblues.loader.classloader.resource.storage.ResourceStorage; import java.io.File; -import java.io.FileInputStream; import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Files; import java.nio.file.Path; import java.util.Objects; /** * classpath 资源加载者 * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class ClassPathLoader extends AbstractResourceLoader { @@ -86,13 +87,15 @@ public class ClassPathLoader extends AbstractResourceLoader { } private void addResource(ResourceStorage resourceStorage, File file, String packageName) throws Exception { - resourceStorage.add(packageName, new URL(url.toString() + packageName), ()->{ + CacheResource cacheResource = new CacheResource(packageName, url, new URL(url.toString() + packageName)); + cacheResource.setBytes(()->{ if(file.exists() && file.isFile()){ - return getClassBytes(file.getPath(), new FileInputStream(file), true); + return getClassBytes(file.getPath(), Files.newInputStream(file.toPath()), true); } else { return null; } }); + resourceStorage.add(cacheResource); } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/DefaultResource.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/DefaultResource.java index d8f53f9f714309ce6ce93dee5de7628a32a71742..3eeebe8e78e292e17bd546a7aece374a525bfc1a 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/DefaultResource.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/DefaultResource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,14 @@ package com.gitee.starblues.loader.classloader.resource.loader; import com.gitee.starblues.loader.classloader.resource.Resource; -import com.gitee.starblues.loader.classloader.resource.ResourceByteGetter; import java.net.URL; /** * 默认的资源信息 * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class DefaultResource implements Resource { @@ -59,12 +59,17 @@ public class DefaultResource implements Resource { } @Override - public void setBytes(ResourceByteGetter byteGetter) throws Exception{ - // 忽略 + public void resolveByte() throws Exception{ + } @Override public void close() throws Exception { } + + @Override + public void release() { + + } } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/DefaultResourceLoaderFactory.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/DefaultResourceLoaderFactory.java index 566652169dd685977bcd4e9ac2a60572f1530199..87a051def9618dbbec02a0c7b063f94df986a5f0 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/DefaultResourceLoaderFactory.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/DefaultResourceLoaderFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,7 @@ package com.gitee.starblues.loader.classloader.resource.loader; import com.gitee.starblues.loader.classloader.resource.Resource; import com.gitee.starblues.loader.classloader.resource.storage.ResourceStorage; -import com.gitee.starblues.loader.classloader.resource.storage.SameRootResourceStorage; import com.gitee.starblues.loader.launcher.isolation.ResourceLoaderFactoryGetter; -import com.gitee.starblues.loader.utils.IOUtils; import com.gitee.starblues.loader.utils.ResourceUtils; import java.io.File; @@ -30,25 +28,22 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; -import java.util.concurrent.ConcurrentHashMap; /** * 默认的资源加载工厂 * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class DefaultResourceLoaderFactory implements ResourceLoaderFactory{ - private final Map resourceLoaderMap = new ConcurrentHashMap<>(); - - private final String classLoaderName; + private final ResourceStorage resourceStorage; public DefaultResourceLoaderFactory(String classLoaderName) { - this.classLoaderName = classLoaderName; + resourceStorage = ResourceLoaderFactoryGetter.getResourceStorage(classLoaderName); } - @Override public void addResource(String path) throws Exception{ if(path == null || "".equals(path)){ @@ -97,14 +92,8 @@ public class DefaultResourceLoaderFactory implements ResourceLoaderFactory{ @Override public void addResource(Resource resource) throws Exception { - SameRootResourceStorage resourceStorage = resourceLoaderMap.get(resource.getBaseUrl()); - if (resourceStorage == null) { - resourceStorage = ResourceLoaderFactoryGetter.getResourceStorage( - classLoaderName, - resource.getBaseUrl()); - resourceLoaderMap.put(resource.getBaseUrl(), resourceStorage); - } - resourceStorage.add(resource.getName(), resource.getUrl(), resource::getBytes); + resourceStorage.addBaseUrl(resource.getBaseUrl()); + resourceStorage.add(resource); } @Override @@ -112,99 +101,37 @@ public class DefaultResourceLoaderFactory implements ResourceLoaderFactory{ if(resourceLoader == null){ return; } - SameRootResourceStorage resourceStorage = resourceLoaderMap.get(resourceLoader.getBaseUrl()); - if (resourceStorage == null) { - resourceStorage = ResourceLoaderFactoryGetter.getResourceStorage( - classLoaderName, - resourceLoader.getBaseUrl()); - resourceLoaderMap.put(resourceLoader.getBaseUrl(), resourceStorage); - } + resourceStorage.addBaseUrl(resourceLoader.getBaseUrl()); resourceLoader.load(resourceStorage); } @Override public Resource findFirstResource(String name) { - for (Map.Entry entry : resourceLoaderMap.entrySet()) { - ResourceStorage resourceStorage = entry.getValue(); - Resource resource = resourceStorage.get(name); - if(resource != null){ - return resource; - } - } - return null; + return resourceStorage.getFirst(name); } @Override public Enumeration findAllResource(String name) { - return new Enumeration() { - private final List list = new ArrayList<>(resourceLoaderMap.values()); - private int index = 0; - private Resource resource = null; - - @Override - public boolean hasMoreElements() { - return next(); - } - - @Override - public Resource nextElement() { - if (!next()) { - throw new NoSuchElementException(); - } - Resource r = resource; - resource = null; - return r; - } - - private boolean next() { - if (resource != null) { - return true; - } else { - SameRootResourceStorage resourceStorage; - while (index < list.size()){ - resourceStorage = list.get(index++); - resource = getResource(resourceStorage); - if(resource != null){ - return true; - } - } - return false; - } - } - - private Resource getResource(SameRootResourceStorage resourceStorage){ - resource = resourceStorage.get(name); - if(resource != null){ - return resource; - } - return null; - } - }; + return resourceStorage.get(name); } @Override public InputStream getInputStream(String name) { - for (Map.Entry entry : resourceLoaderMap.entrySet()) { - ResourceStorage resourceStorage = entry.getValue(); - InputStream inputStream = resourceStorage.getInputStream(name); - if(inputStream != null){ - return inputStream; - } - } - return null; + return resourceStorage.getFirstInputStream(name); } @Override public List getUrls() { - return new ArrayList<>(resourceLoaderMap.keySet()); + return resourceStorage.getBaseUrl(); } @Override public void close() throws Exception { - for (ResourceStorage resourceStorage : resourceLoaderMap.values()) { - IOUtils.closeQuietly(resourceStorage); - } - resourceLoaderMap.clear(); + resourceStorage.close(); } + @Override + public void release() throws Exception{ + resourceStorage.release(); + } } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/JarResourceLoader.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/JarResourceLoader.java index 5984b42d35357cb3cdc99a2d3773e5a0a3d64ce8..48c4132ac50c221208e3b2c115e8753fd823081c 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/JarResourceLoader.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/JarResourceLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,11 +28,12 @@ import java.util.jar.JarInputStream; /** * jar 资源加载者 * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class JarResourceLoader extends AbstractResourceLoader { - private final JarInputStream jarInputStream; + private JarInputStream jarInputStream; private ExcludeResource excludeResource = (jarEntry)->false; private IncludeResource includeResource = (jarEntry)->true; @@ -79,9 +80,10 @@ public class JarResourceLoader extends AbstractResourceLoader { if(includeResource.include(jarEntry)){ String name = resolveName(jarEntry.getName()); URL url = new URL(baseUrl.toString() + name); - resourceStorage.add(name, url, ()->{ + CacheResource cacheResource = new CacheResource(name, baseUrl, url, ()->{ return getClassBytes(name, jarInputStream, false); }); + resourceStorage.add(cacheResource); jarInputStream.closeEntry(); } } @@ -90,6 +92,12 @@ public class JarResourceLoader extends AbstractResourceLoader { } } + @Override + public void close() throws Exception { + super.close(); + jarInputStream = null; + } + protected String resolveName(String name){ return name; } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/MainJarResourceLoader.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/MainJarResourceLoader.java index c1675b0fe550d0e93d3a91f9a3d5a5cebb9ee77b..f9330de008656483e1ad2edcfa695c00598df94d 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/MainJarResourceLoader.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/MainJarResourceLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ResourceLoader.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ResourceLoader.java index 7b722d740325b39c17cbb3d4ec75c812d3c53cda..a5262ad0fd4f1838882a375c4bc05c2b34e59a75 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ResourceLoader.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ResourceLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ResourceLoaderFactory.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ResourceLoaderFactory.java index 60cedc88f997300f3664e38086249e4eba537b91..203686182c72365806d6181fcde987ac428444e4 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ResourceLoaderFactory.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/loader/ResourceLoaderFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,7 @@ package com.gitee.starblues.loader.classloader.resource.loader; import com.gitee.starblues.loader.classloader.resource.Resource; -import com.gitee.starblues.loader.classloader.resource.storage.ResourceStorage; +import com.gitee.starblues.loader.utils.Release; import java.io.File; import java.io.InputStream; @@ -30,9 +30,10 @@ import java.util.List; * 资源加载工厂 * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ -public interface ResourceLoaderFactory extends AutoCloseable { +public interface ResourceLoaderFactory extends AutoCloseable, Release { /** * 根据路径字符串添加资源 diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/AbstractResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/AbstractResourceStorage.java new file mode 100644 index 0000000000000000000000000000000000000000..924633d6050ff17789deff95231aea31c83d80f2 --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/AbstractResourceStorage.java @@ -0,0 +1,245 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.storage; + +import com.gitee.starblues.loader.classloader.resource.Resource; +import com.gitee.starblues.loader.classloader.resource.loader.DefaultResource; +import com.gitee.starblues.loader.utils.IOUtils; +import com.gitee.starblues.loader.utils.ObjectUtils; +import com.gitee.starblues.loader.utils.ResourceUtils; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.*; + +/** + * 抽象的资源存储 + * + * @author starBlues + * @since 3.0.0 + * @version 3.1.1 + */ +public abstract class AbstractResourceStorage implements ResourceStorage { + + private final Set baseUrls = new HashSet<>(); + private final ArrayDeque hotUrls = new ArrayDeque<>(); + private final List inputStreams = new ArrayList<>(); + + @Override + public void addBaseUrl(URL url){ + if(url == null){ + return; + } + synchronized (baseUrls){ + baseUrls.add(url); + } + } + + @Override + public List getBaseUrl(){ + synchronized (baseUrls){ + return Collections.unmodifiableList(new ArrayList<>(baseUrls)); + } + } + + + @Override + public final void add(Resource resource) throws Exception { + addResource(resource); + } + + @Override + public void close() throws Exception { + for (InputStream inputStream : inputStreams) { + IOUtils.closeQuietly(inputStream); + } + inputStreams.clear(); + baseUrls.clear(); + } + + /** + * 子类添加资源 + * @param resource 资源 + * @throws Exception 添加移除 + */ + protected abstract void addResource(Resource resource) throws Exception; + + /** + * 格式化资源名称 + * @param name 资源名称 + * @return String + */ + protected final String formatResourceName(String name) { + return ResourceUtils.formatStandardName(name); + } + + protected final InputStream openStream(Resource resource){ + if(resource == null){ + return null; + } + try { + InputStream inputStream = resource.getUrl().openStream(); + inputStreams.add(inputStream); + return inputStream; + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + protected final Enumeration openStream(Enumeration resources){ + if(resources == null){ + return Collections.emptyEnumeration(); + } + return new Enumeration() { + @Override + public boolean hasMoreElements() { + return resources.hasMoreElements(); + } + + @Override + public InputStream nextElement() { + Resource resource = resources.nextElement(); + return openStream(resource); + } + }; + } + + protected final void closeResources(List resources){ + if(ObjectUtils.isEmpty(resources)){ + return; + } + for (Resource resource : resources) { + IOUtils.closeQuietly(resource); + } + resources.clear(); + } + + protected final synchronized Resource searchResource(String name) { + Set searchUrl = new HashSet<>(); + URL matchBaseUrl = null; + URL matchExistUrl = null; + // TODO 还需优化 + while (true){ + URL baseUrl = hotUrls.pollFirst(); + if(baseUrl == null){ + break; + } + searchUrl.add(baseUrl); + URL existUrl = ResourceUtils.getExistUrl(baseUrl, name); + if(existUrl != null){ + matchBaseUrl = baseUrl; + matchExistUrl = existUrl; + hotUrls.addFirst(baseUrl); + break; + } + } + + if(matchBaseUrl == null){ + List baseUrls = getBaseUrl(); + for (URL baseUrl : baseUrls) { + if(searchUrl.contains(baseUrl)){ + continue; + } + URL existUrl = ResourceUtils.getExistUrl(baseUrl, name); + if(existUrl != null){ + matchBaseUrl = baseUrl; + matchExistUrl = existUrl; + hotUrls.addFirst(baseUrl); + break; + } + } + } + if(matchBaseUrl != null){ + try { + Resource resource = new DefaultResource(name, matchBaseUrl, matchExistUrl); + addResource(resource); + return resource; + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + return null; + } + + protected final Enumeration searchResources(String name){ + List baseUrls = getBaseUrl(); + return new InternalEnumeration(baseUrls, name); + } + + + private class InternalEnumeration implements Enumeration{ + + private final List baseUrls; + private final String name; + + private int index = 0; + private Resource resource = null; + + private InternalEnumeration(List baseUrls, String name) { + this.baseUrls = baseUrls; + this.name = name; + } + + @Override + public boolean hasMoreElements() { + return next(); + } + @Override + public Resource nextElement() { + if (!next()) { + throw new NoSuchElementException(); + } + Resource r = resource; + resource = null; + return r; + } + private boolean next() { + if (resource != null) { + return true; + } else { + URL baseUrl; + while (index < baseUrls.size()){ + baseUrl = baseUrls.get(index++); + resource = getResource(baseUrl); + if(resource != null){ + return true; + } + } + return false; + } + } + + private Resource getResource(URL baseUrl){ + URL existUrl = ResourceUtils.getExistUrl(baseUrl, name); + if(existUrl == null){ + return null; + } + Resource resource = new DefaultResource(name, baseUrl, existUrl); + try { + addResource(resource); + } catch (Exception e){ + // 忽略异常 + } + return resource; + } + } + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheFastResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheFastResourceStorage.java new file mode 100644 index 0000000000000000000000000000000000000000..121ded3396f067825e7dff9731fa707f6d0aaa1b --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheFastResourceStorage.java @@ -0,0 +1,146 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.storage; + +import com.gitee.starblues.loader.classloader.resource.Resource; +import com.gitee.starblues.loader.classloader.resource.cache.*; +import com.gitee.starblues.loader.utils.IOUtils; +import com.gitee.starblues.loader.utils.ObjectUtils; +import com.gitee.starblues.loader.utils.ResourceUtils; + +import java.io.InputStream; +import java.util.*; +import java.util.concurrent.TimeUnit; + +/** + * 快速且可缓存的资源存储者 + * 优点: 释放前速度比较快, 释放后可根据LRU缓存机制进行缓存 + * 缺点: 释放前占用内存比较高 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +public class CacheFastResourceStorage extends AbstractResourceStorage { + + protected final MultiCache resourceStorage; + private final ResourceStorage cacheResourceStorage; + + private final List inputStreams = new ArrayList<>(); + + private volatile boolean release = false; + + @SuppressWarnings("all") + public CacheFastResourceStorage(String key) { + this.cacheResourceStorage = new CachePerpetualResourceStorage(); + // 最大 1000 个, 最长 3 分钟 + CacheExpirationTrigger trigger = DefaultCacheExpirationTrigger + .getCacheExpirationTrigger(3, TimeUnit.MINUTES); + resourceStorage = (MultiCache) trigger.getCache(key, + () -> new LRUMultiMapUnifiedListCache(1000, 180000)); + } + + @Override + protected void addResource(Resource resource) throws Exception { + if(!release){ + cacheResourceStorage.add(resource); + return; + } + resource.resolveByte(); + String name = formatResourceName(resource.getName()); + resourceStorage.putSingle(name, resource); + } + + @Override + public boolean exist(String name) { + if(!release){ + return cacheResourceStorage.exist(name); + } + return getFirst(name) != null; + } + + @Override + public Resource getFirst(String name) { + if(!release){ + return cacheResourceStorage.getFirst(name); + } + if(ObjectUtils.isEmpty(name)){ + return null; + } + name = formatResourceName(name); + Resource firstResource = resourceStorage.getFirst(name); + if(firstResource != null){ + return firstResource; + } + return searchResource(name); + } + + @Override + public Enumeration get(String name) { + if(!release){ + return cacheResourceStorage.get(name); + } + if(ObjectUtils.isEmpty(name)){ + return Collections.emptyEnumeration(); + } + name = formatResourceName(name); + Collection resources = resourceStorage.get(name); + if(!ObjectUtils.isEmpty(resources)){ + return Collections.enumeration(resources); + } + return searchResources(name); + } + + @Override + public InputStream getFirstInputStream(String name) { + Resource resource = getFirst(name); + return openStream(resource); + } + + @Override + public Enumeration getInputStream(String name) { + if(!release){ + return cacheResourceStorage.getInputStream(name); + } + Enumeration resources = get(name); + if(!ObjectUtils.isEmpty(resources)){ + return openStream(resources); + } + Enumeration searchResources = searchResources(name); + return openStream(searchResources); + } + + @Override + public synchronized void release() throws Exception { + if(!release){ + IOUtils.closeQuietly(cacheResourceStorage); + } + resourceStorage.cleanExpired(); + release = true; + } + + @Override + public void close() throws Exception { + resourceStorage.clear(ResourceUtils::release); + for (InputStream inputStream : inputStreams) { + IOUtils.closeQuietly(inputStream); + } + inputStreams.clear(); + } + + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheLowMemoryResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheLowMemoryResourceStorage.java new file mode 100644 index 0000000000000000000000000000000000000000..df36f3170ffd7a1aae6a2b57b67774f7757033e3 --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CacheLowMemoryResourceStorage.java @@ -0,0 +1,149 @@ +/** + * Copyright [2019-Present] [starBlues] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.gitee.starblues.loader.classloader.resource.storage; + +import com.gitee.starblues.loader.classloader.resource.Resource; +import com.gitee.starblues.loader.classloader.resource.cache.Cache; +import com.gitee.starblues.loader.classloader.resource.cache.DefaultCacheExpirationTrigger; +import com.gitee.starblues.loader.classloader.resource.cache.LRUMapCache; +import com.gitee.starblues.loader.utils.ObjectUtils; +import com.gitee.starblues.loader.utils.ResourceUtils; + +import java.io.InputStream; +import java.net.URL; +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + +/** + * 直接可缓存的资源存储, + * 优点: 释放前占用内存做了限制, 不会占用太高, 处于占用内存比较低, 且可根据LRU缓存机制进行缓存 + * 缺点: 如果缓存未命中, 速度比较慢 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + * @deprecated 暂时遗弃 + */ +@Deprecated +public class CacheLowMemoryResourceStorage extends AbstractResourceStorage { + + protected final Map>> resourceStorage = new ConcurrentHashMap<>(); + + public CacheLowMemoryResourceStorage(String key) { + } + + @Override + public void addBaseUrl(URL url) { + super.addBaseUrl(url); + String key = url.toString(); + if(!resourceStorage.containsKey(key)){ + Cache> cache = DefaultCacheExpirationTrigger.getCacheExpirationTrigger(3, TimeUnit.MINUTES) + .getCache(key, () -> new LRUMapCache>(10000, 180000)); + resourceStorage.put(key, cache); + } + } + + private Cache> getCache(URL baseUrl){ + String key = baseUrl.toString(); + Cache> cache = resourceStorage.get(key); + if(cache != null){ + return cache; + } + cache = DefaultCacheExpirationTrigger.getCacheExpirationTrigger(3, TimeUnit.MINUTES) + .getCache(key, () -> new LRUMapCache>(1000, 180000)); + resourceStorage.put(key, cache); + return cache; + } + + @Override + protected void addResource(Resource resource) throws Exception { + String name = formatResourceName(resource.getName()); + List resources = getCache(resource.getBaseUrl()).getOrDefault(name, ArrayList::new, true); + resources.add(resource); + } + + @Override + public boolean exist(String name) { + return get(name) != null; + } + + @Override + public Resource getFirst(String name) { + if(ObjectUtils.isEmpty(name)){ + return null; + } + name = formatResourceName(name); + for (Cache> cache : resourceStorage.values()) { + List resources = cache.get(name); + if(!ObjectUtils.isEmpty(resources)){ + return resources.get(0); + } + } + return searchResource(name); + } + + @Override + public Enumeration get(String name) { + List resources1 = new ArrayList<>(); + for (Cache> cache : resourceStorage.values()) { + List resources = cache.get(name); + if(!ObjectUtils.isEmpty(resources)){ + resources1.addAll(resources); + } + } + if(!resources1.isEmpty()){ + return Collections.enumeration(resources1); + } + return searchResources(name); + } + + @Override + public InputStream getFirstInputStream(String name) { + Resource resource = getFirst(name); + if(resource == null){ + return null; + } + return openStream(resource); + } + + @Override + public Enumeration getInputStream(String name) { + Enumeration resources = searchResources(name); + return openStream(resources); + } + + @Override + public synchronized void release() throws Exception { + for (Cache> value : resourceStorage.values()) { + value.clear(ResourceUtils::release); + } + resourceStorage.clear(); + } + + @Override + public void close() throws Exception { + //resourceStorage.clear(ResourceUtils::release); + super.close(); + release(); +// for (List resources : resourceStorage.values()) { +// ResourceUtils.release(resources); +// } + } + + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/DefaultResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CachePerpetualResourceStorage.java similarity index 36% rename from spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/DefaultResourceStorage.java rename to spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CachePerpetualResourceStorage.java index a1f230d8aa19a8ff40645ec74ddf0a77cd6ee42e..bebd31086d71fe3b7415c2ad5381d578935d3ca2 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/DefaultResourceStorage.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/CachePerpetualResourceStorage.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,56 +16,31 @@ package com.gitee.starblues.loader.classloader.resource.storage; -import com.gitee.starblues.loader.classloader.resource.loader.DefaultResource; import com.gitee.starblues.loader.classloader.resource.Resource; -import com.gitee.starblues.loader.classloader.resource.ResourceByteGetter; -import com.gitee.starblues.loader.utils.Assert; -import com.gitee.starblues.loader.utils.IOUtils; import com.gitee.starblues.loader.utils.ObjectUtils; -import com.gitee.starblues.loader.utils.ResourceUtils; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ConcurrentHashMap; /** - * 默认的资源存储者 + * 永久缓存 + * 优点: 速度快 + * 缺点: 占用内存很高 * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ -public class DefaultResourceStorage extends SameRootResourceStorage{ - - protected final Map resourceStorage = new ConcurrentHashMap<>(); +public class CachePerpetualResourceStorage extends AbstractResourceStorage { - public DefaultResourceStorage(URL baseUrl) { - super(baseUrl); - } - - @Override - public void add(String name, URL url, ResourceByteGetter byteGetter) throws Exception{ - if(ObjectUtils.isEmpty(name) || url == null){ - return; - } - name = formatResourceName(name); - if(resourceStorage.containsKey(name)){ - return; - } - DefaultResource defaultResource = new DefaultResource(name, baseUrl, url); - resourceStorage.put(name, defaultResource); - } + protected final Map> resourceStorage = new ConcurrentHashMap<>(); @Override - public void add(String name, URL url) throws Exception{ - if(ObjectUtils.isEmpty(name) || url == null){ - return; - } - this.add(name, url, null); + public void addResource(Resource resource) throws Exception { + resource.resolveByte(); + String name = formatResourceName(resource.getName()); + List resources = resourceStorage.computeIfAbsent(name, k -> new ArrayList<>()); + resources.add(resource); } @Override @@ -77,63 +52,54 @@ public class DefaultResourceStorage extends SameRootResourceStorage{ return resourceStorage.containsKey(name); } - protected void addResource(String name, Resource resource){ - if(ObjectUtils.isEmpty(name) || resource == null){ - return; - } - resourceStorage.put(name, resource); - } - @Override - public Resource get(String name) { + public Resource getFirst(String name) { if(ObjectUtils.isEmpty(name)){ return null; } name = formatResourceName(name); - return resourceStorage.get(name); + List resources = resourceStorage.get(name); + if(ObjectUtils.isEmpty(resources)){ + return null; + } + return resources.get(0); } @Override - public InputStream getInputStream(String name) { + public Enumeration get(String name) { if(ObjectUtils.isEmpty(name)){ - return null; + return Collections.emptyEnumeration(); } name = formatResourceName(name); - Resource resourceInfo = resourceStorage.get(name); - if (resourceInfo != null) { - try (InputStream inputStream = resourceInfo.getUrl().openStream(); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()){ - IOUtils.copy(inputStream, byteArrayOutputStream); - return new ByteArrayInputStream(byteArrayOutputStream.toByteArray()); - } catch (Exception e){ - e.printStackTrace(); - return null; - } - } else { - return null; + List resources = resourceStorage.get(name); + if(ObjectUtils.isEmpty(resources)){ + return Collections.emptyEnumeration(); } + return Collections.enumeration(resources); } @Override - public List getAll() { - return new ArrayList<>(resourceStorage.values()); + public InputStream getFirstInputStream(String name) { + Resource resource = getFirst(name); + return openStream(resource); } @Override - public boolean isEmpty() { - return resourceStorage.isEmpty(); + public Enumeration getInputStream(String name) { + Enumeration resources = get(name); + if(ObjectUtils.isEmpty(resources)){ + return Collections.emptyEnumeration(); + } + return openStream(resources); } @Override public void close() throws Exception { - for (Resource resource : resourceStorage.values()) { - IOUtils.closeQuietly(resource); + super.close(); + for (List resourceList : resourceStorage.values()) { + closeResources(resourceList); } resourceStorage.clear(); } - protected final String formatResourceName(String name) { - return ResourceUtils.formatStandardName(name); - } - } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/EmptyResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/EmptyResourceStorage.java index 72b1984ef324b15742e943277e9050b3dd29b013..2808931f731fc363a6722387110af08b6619b702 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/EmptyResourceStorage.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/EmptyResourceStorage.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,27 +17,33 @@ package com.gitee.starblues.loader.classloader.resource.storage; import com.gitee.starblues.loader.classloader.resource.Resource; -import com.gitee.starblues.loader.classloader.resource.ResourceByteGetter; import java.io.InputStream; import java.net.URL; +import java.util.Enumeration; import java.util.List; /** * 空的资源存储 * * @author starBlues - * @version 3.1.0 * @since 3.0.4 + * @version 3.1.1 */ public class EmptyResourceStorage implements ResourceStorage{ + @Override - public void add(String name, URL url, ResourceByteGetter byteGetter) throws Exception { + public void addBaseUrl(URL baseUrl) { } @Override - public void add(String name, URL url) throws Exception { + public List getBaseUrl() { + return null; + } + + @Override + public void add(Resource resource) throws Exception { } @@ -47,23 +53,23 @@ public class EmptyResourceStorage implements ResourceStorage{ } @Override - public Resource get(String name) { + public Resource getFirst(String name) { return null; } @Override - public InputStream getInputStream(String name) { + public Enumeration get(String name) { return null; } @Override - public List getAll() { + public InputStream getFirstInputStream(String name) { return null; } @Override - public boolean isEmpty() { - return false; + public Enumeration getInputStream(String name) { + return null; } @Override diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/ResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/ResourceStorage.java index 0720a4ea47fd4798a7b0344545cea78ed3430fd1..aafd31d9e864c3d5ca86bc44e76671489c6d7101 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/ResourceStorage.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/ResourceStorage.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,36 +17,40 @@ package com.gitee.starblues.loader.classloader.resource.storage; import com.gitee.starblues.loader.classloader.resource.Resource; -import com.gitee.starblues.loader.classloader.resource.ResourceByteGetter; +import com.gitee.starblues.loader.utils.Release; import java.io.InputStream; import java.net.URL; +import java.util.Enumeration; import java.util.List; /** * 资源存储者 * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ -public interface ResourceStorage extends AutoCloseable{ +public interface ResourceStorage extends AutoCloseable, Release { /** - * 添加资源 - * @param name 资源名称 - * @param url 资源url - * @param byteGetter 资源字节获取者 - * @throws Exception 添加资源异常 + * 添加根url + * @param baseUrl url */ - void add(String name, URL url, ResourceByteGetter byteGetter) throws Exception; + void addBaseUrl(URL baseUrl); + + /** + * 获取根url + * @return url list + */ + List getBaseUrl(); /** * 添加资源 - * @param name 资源名称 - * @param url 资源url + * @param resource 资源名称 * @throws Exception 添加资源异常 */ - void add(String name, URL url) throws Exception; + void add(Resource resource) throws Exception; /** * 存在资源 @@ -56,30 +60,31 @@ public interface ResourceStorage extends AutoCloseable{ boolean exist(String name); /** - * 获取资源 + * 获取第一个资源 * @param name 资源名称 * @return Resource */ - Resource get(String name); + Resource getFirst(String name); /** - * 获取资源的 InputStream + * 获取所有资源 * @param name 资源名称 - * @return InputStream + * @return Resource */ - InputStream getInputStream(String name); + Enumeration get(String name); /** - * 得到全部资源 - * @return 全部资源列表 + * 获取第一个资源的 InputStream + * @param name 资源名称 + * @return Resource */ - List getAll(); + InputStream getFirstInputStream(String name); /** - * 是否为空 - * @return boolean + * 获取所有资源的 InputStream + * @param name 资源名称 + * @return InputStream */ - boolean isEmpty(); - + Enumeration getInputStream(String name); } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/ShareResourceStorage.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/ShareResourceStorage.java deleted file mode 100644 index ec61cf9e16beb43c9b0345db12e6e78e27dbf058..0000000000000000000000000000000000000000 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/classloader/resource/storage/ShareResourceStorage.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright [2019-2022] [starBlues] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.gitee.starblues.loader.classloader.resource.storage; - -import com.gitee.starblues.loader.classloader.resource.loader.DefaultResource; -import com.gitee.starblues.loader.classloader.resource.ResourceByteGetter; -import com.gitee.starblues.loader.utils.Assert; - -import java.net.URL; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * 共享资源存储者 - * - * @author starBlues - * @version 3.0.0 - */ -public class ShareResourceStorage extends DefaultResourceStorage{ - - private final String key; - - public ShareResourceStorage(String key, URL baseUrl) { - super(baseUrl); - this.key = key; - } - - @Override - public void add(String name, URL url, ResourceByteGetter byteGetter) throws Exception{ - name = formatResourceName(name); - if(resourceStorage.containsKey(name)){ - return; - } - ShareResource shareResource = new ShareResource(key, name, baseUrl, url); - shareResource.setBytes(byteGetter); - super.addResource(name, shareResource); - } - - @Override - public void close() throws Exception { - super.close(); - } - - private static class ShareResource extends DefaultResource { - - private final static Map BYTE_STORE_MAP = new ConcurrentHashMap<>(); - private final String key; - - public ShareResource(String key, String name, URL baseUrl, URL url) { - super(name, baseUrl, url); - this.key = key; - } - - @Override - public void setBytes(ResourceByteGetter byteGetter) throws Exception{ - if(byteGetter == null){ - return; - } - byte[] bytes = byteGetter.get(); - String name = getName(); - ByteStore byteStore = BYTE_STORE_MAP.get(name); - if(byteStore == null){ - byteStore = new ByteStore(name); - byteStore.addByte(key, bytes); - BYTE_STORE_MAP.put(name, byteStore); - } else { - byteStore.addByte(key, bytes); - } - } - - @Override - public byte[] getBytes() { - String name = getName(); - ByteStore byteStore = BYTE_STORE_MAP.get(name); - if(byteStore == null){ - return null; - } - return byteStore.getByte(key); - } - - @Override - public void close() throws Exception { - String name = getName(); - ByteStore byteStore = BYTE_STORE_MAP.get(name); - if(byteStore == null){ - return; - } - if(byteStore.remove(key)){ - BYTE_STORE_MAP.remove(name); - } - } - } - - private static class ByteStore{ - - private final String commonByteKey; - - private final Map bytesMap = new HashMap<>(); - - private ByteStore(String resourceName) { - this.commonByteKey = resourceName + "_ByteStoreCommon"; - } - - public synchronized void addByte(String key, byte[] bytes){ - Assert.isNotEmpty(key, "classLoaderName 不能为空"); - if(bytes == null || bytes.length == 0){ - return; - } - byte[] bytesOfMap = bytesMap.get(commonByteKey); - if(bytesOfMap != null && bytesOfMap.length > 0){ - if(Arrays.equals(bytesOfMap, bytes)){ - bytesMap.put(key, new byte[]{}); - } else { - bytesMap.put(key, bytes); - } - return; - } - // common 不存在, 则往 common 存储一份 - bytesMap.put(commonByteKey, bytes); - bytesMap.put(key, new byte[]{}); - } - - public synchronized byte[] getByte(String classLoaderName){ - byte[] bytes = bytesMap.get(classLoaderName); - if(bytes == null || bytes.length == 0){ - bytes = bytesMap.get(commonByteKey); - } - return bytes; - } - - public boolean remove(String classLoaderName){ - bytesMap.remove(classLoaderName); - if(bytesMap.size() == 1 && bytesMap.containsKey(commonByteKey)){ - // 只存在一个common - bytesMap.clear(); - return true; - } else { - return false; - } - } - } - -} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/AbstractLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/AbstractLauncher.java index a44ab55492ec712354471e79004fbfb499db62de..e1dc6d5aff76a878120be9eaa166197e35eb1921 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/AbstractLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/AbstractLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.loader.launcher; /** * 抽象的启动引导者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public abstract class AbstractLauncher implements Launcher { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/AbstractMainLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/AbstractMainLauncher.java index 3860e838475913b6c1ef2bbdd14716b2f12e5201..0b1adcbdb3f60f43b4ce0f7fed37c16ef7b9811a 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/AbstractMainLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/AbstractMainLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import com.gitee.starblues.loader.DevelopmentMode; /** * 抽象的启动引导者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public abstract class AbstractMainLauncher extends AbstractLauncher { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/DevLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/DevLauncher.java index 2cac0c76c0068e1327d38e2c29ff6fc9e69b52ec..170bdf14db170f50a5b2e695f2bc34a59b60281c 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/DevLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/DevLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/DevelopmentModeSetting.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/DevelopmentModeSetting.java index 2d2ee5dce216d51f93a7856cae2c72a68257e367..439cdb5fbed9c958dba184cba2165b2f4d14b950 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/DevelopmentModeSetting.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/DevelopmentModeSetting.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/Launcher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/Launcher.java index 3a996ee8456abe21262d3ca832a9e714ef13dfc3..5739bcf7c32b278e7302f4eeecebabef1aaf77d4 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/Launcher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/Launcher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.loader.launcher; /** * 启动引导器 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface Launcher { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/LauncherContext.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/LauncherContext.java index 6f3f1c8d4a1db7ecf8008d7206245201b6ad55eb..6ab88597717d2edc49d8ab541641f19ff56c52d7 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/LauncherContext.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/LauncherContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,9 +17,10 @@ package com.gitee.starblues.loader.launcher; /** - * LauncherContext + * 启动上下文 * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public class LauncherContext { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/ProdLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/ProdLauncher.java index 33d34ea4eed0cc665192f1f683eb20911f87e977..09bbce719e6ad344dc4c5e938d6e5ee4a0096778 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/ProdLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/ProdLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringBootstrap.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringBootstrap.java index 8a86ddf0d67e766f6ec4777701f045c41f966dbc..9335b0718c1a4eb98157a7f10063ba8149d4bf5b 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringBootstrap.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringBootstrap.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import com.gitee.starblues.loader.DevelopmentMode; /** * 主程序实现该接口引导启动SpringBoot + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface SpringBootstrap { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringMainBootstrap.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringMainBootstrap.java index bfcf712209b2702225e3a90a0841e00378edd5ab..d627ec8868ef3ea479161d83623c88718ec5e682 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringMainBootstrap.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringMainBootstrap.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,9 @@ import java.util.concurrent.CountDownLatch; /** * 主程序引导器 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class SpringMainBootstrap { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringMainProdBootstrap.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringMainProdBootstrap.java index 6e34e2b22e009dfad541618915ab527b406c31b2..b47de022363d904227dceb9f3d4827932b5b3020 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringMainProdBootstrap.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/SpringMainProdBootstrap.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import com.gitee.starblues.loader.jar.JarFile; /** * 主程序生成环境启动引导器 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class SpringMainProdBootstrap { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/ClasspathResource.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/ClasspathResource.java index cd296e5281fd333470ddd8ed4b0940cb64d2c4c1..a96cb2e7818724eae45f5ce0c5897218f1191047 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/ClasspathResource.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/ClasspathResource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/FastJarClasspathResource.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/FastJarClasspathResource.java index a15ad9dbd574749942c239ea5737e54caf74685a..b7dcaf2b42af53bf474f2bda7c8e20f8fe6f4ee1 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/FastJarClasspathResource.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/FastJarClasspathResource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/JarOutClasspathResource.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/JarOutClasspathResource.java index 69dab01b4ad405118926df5950a9841552cd1de6..3d382a3171079197f02b2880fe0fbe5706b2f08c 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/JarOutClasspathResource.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/classpath/JarOutClasspathResource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistBaseLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistBaseLauncher.java index c7fffbff9be3b1be4b84d234e90ebb8d5f8108eb..311af4dff51f0ec1e2c51cc0feeb1b77fd42ff42 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistBaseLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistBaseLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistFastJarLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistFastJarLauncher.java index f882a1792e8cf0c0a8eb3f9e31bacc682f19a7aa..8750fe9a7cc3a4851a2e03388822dba93a49fb93 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistFastJarLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistFastJarLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,9 @@ import java.util.Objects; /** * 主程序jar in jar 模式启动者 + * * @author starBlues + * @since 3.0.2 * @version 3.0.2 */ public class CoexistFastJarLauncher extends CoexistBaseLauncher { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistJarOuterLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistJarOuterLauncher.java index f3ee5ac9fce95f5363aa9d0e9576313fb59ed2f5..5adca6df8928342420162c4caa1337e577de2557 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistJarOuterLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/coexist/CoexistJarOuterLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import java.util.Objects; * 主程序jar-outer 模式启动者 * * @author starBlues + * @since 3.0.2 * @version 3.0.2 */ public class CoexistJarOuterLauncher extends CoexistBaseLauncher { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationBaseLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationBaseLauncher.java index 9cb11d53539eb428673bbe7e082a3b5c9447e72f..75341e71cecdadd9771c01463fa80a4e71c4f774 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationBaseLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationBaseLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,15 +21,22 @@ import com.gitee.starblues.loader.classloader.resource.loader.ResourceLoaderFact import com.gitee.starblues.loader.launcher.AbstractMainLauncher; import com.gitee.starblues.loader.launcher.runner.MethodRunner; import com.gitee.starblues.loader.utils.ObjectUtils; +import com.gitee.starblues.loader.utils.ResourceUtils; import java.lang.management.ManagementFactory; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; /** * 主程序启动者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class IsolationBaseLauncher extends AbstractMainLauncher { @@ -47,15 +54,14 @@ public class IsolationBaseLauncher extends AbstractMainLauncher { @Override protected ClassLoader createClassLoader(String... args) throws Exception { - GenericClassLoader classLoader = new GenericClassLoader(MAIN_CLASS_LOADER_NAME, getParentClassLoader(), + return new GenericClassLoader(MAIN_CLASS_LOADER_NAME, getParentClassLoader(), getResourceLoaderFactory(args)); - addResource(classLoader); - return classLoader; } @Override protected ClassLoader launch(ClassLoader classLoader, String... args) throws Exception { methodRunner.run(classLoader); + ResourceUtils.release(classLoader); return classLoader; } @@ -67,22 +73,26 @@ public class IsolationBaseLauncher extends AbstractMainLauncher { return IsolationBaseLauncher.class.getClassLoader(); } - protected void addResource(GenericClassLoader classLoader) throws Exception{ + protected Set getBaseResource() { + Set urls = new HashSet<>(); String classPath = ManagementFactory.getRuntimeMXBean().getClassPath(); if(!ObjectUtils.isEmpty(classPath)){ String[] classPathStr = classPath.split(";"); for (String path : classPathStr) { - classLoader.addResource(path); + try { + urls.add(new URL(path)); + } catch (MalformedURLException e) { + // 忽略 + } } } ClassLoader sourceClassLoader = Thread.currentThread().getContextClassLoader(); if(sourceClassLoader instanceof URLClassLoader){ URLClassLoader urlClassLoader = (URLClassLoader) sourceClassLoader; final URL[] urLs = urlClassLoader.getURLs(); - for (URL url : urLs) { - classLoader.addResource(url); - } + urls.addAll(Arrays.asList(urLs)); } + return urls; } } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationFastJarLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationFastJarLauncher.java index 8b4928f96c4296be7508940f3147117ce47efbcf..de16b587310a790e365ad116e934428b6a53635d 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationFastJarLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationFastJarLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,12 +27,15 @@ import java.io.File; import java.net.URL; import java.util.List; import java.util.Objects; +import java.util.Set; import static com.gitee.starblues.loader.LoaderConstant.*; /** * 主程序jar in jar 模式启动者 + * * @author starBlues + * @since 3.0.2 * @version 3.0.2 */ public class IsolationFastJarLauncher extends IsolationBaseLauncher { @@ -45,16 +48,25 @@ public class IsolationFastJarLauncher extends IsolationBaseLauncher { this.classpathResource = new FastJarClasspathResource(rootJarFile); } + @Override + protected ClassLoader createClassLoader(String... args) throws Exception { + GenericClassLoader classLoader = (GenericClassLoader) super.createClassLoader(args); + addResource(classLoader); + return classLoader; + } + @Override protected boolean resolveThreadClassLoader() { return true; } - @Override - protected void addResource(GenericClassLoader classLoader) throws Exception { - super.addResource(classLoader); + private void addResource(GenericClassLoader classLoader) throws Exception { + Set baseResource = getBaseResource(); List classpath = classpathResource.getClasspath(); - for (URL url : classpath) { + if(classpath != null){ + baseResource.addAll(classpath); + } + for (URL url : baseResource) { String path = url.getPath(); if(path.contains(PROD_CLASSES_URL_SIGN)){ classLoader.addResource(new MainJarResourceLoader(url)); diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationJarOuterLauncher.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationJarOuterLauncher.java index f06013f3f0be07c94be106a312f6b93af43434a2..3519c760476c6d8aa058cc6b8e3a50def988b975 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationJarOuterLauncher.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/IsolationJarOuterLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ package com.gitee.starblues.loader.launcher.isolation; import com.gitee.starblues.loader.classloader.GenericClassLoader; +import com.gitee.starblues.loader.classloader.resource.loader.JarResourceLoader; +import com.gitee.starblues.loader.classloader.resource.loader.MainJarResourceLoader; import com.gitee.starblues.loader.launcher.classpath.ClasspathResource; import com.gitee.starblues.loader.launcher.classpath.JarOutClasspathResource; import com.gitee.starblues.loader.launcher.runner.MethodRunner; @@ -25,12 +27,16 @@ import java.io.File; import java.net.URL; import java.util.List; import java.util.Objects; +import java.util.Set; + +import static com.gitee.starblues.loader.LoaderConstant.PROD_CLASSES_URL_SIGN; /** * 主程序jar-outer 模式启动者 * * @author starBlues + * @since 3.0.2 * @version 3.0.2 */ public class IsolationJarOuterLauncher extends IsolationBaseLauncher { @@ -43,16 +49,25 @@ public class IsolationJarOuterLauncher extends IsolationBaseLauncher { this.classpathResource = new JarOutClasspathResource(rootJarFile); } + @Override + protected ClassLoader createClassLoader(String... args) throws Exception { + GenericClassLoader classLoader = (GenericClassLoader) super.createClassLoader(args); + addResource(classLoader); + return classLoader; + } + @Override protected boolean resolveThreadClassLoader() { return true; } - @Override - protected void addResource(GenericClassLoader classLoader) throws Exception { - super.addResource(classLoader); + private void addResource(GenericClassLoader classLoader) throws Exception { + Set baseResource = getBaseResource(); List classpath = classpathResource.getClasspath(); - for (URL url : classpath) { + if(classpath != null){ + baseResource.addAll(classpath); + } + for (URL url : baseResource) { classLoader.addResource(url); } } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/ResourceLoaderFactoryGetter.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/ResourceLoaderFactoryGetter.java index 719f2a5a3f23ff7729a27026a6242a4b911bb8b7..c69f16c003d5344e54c4c93978efa1e59d6e3a5c 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/ResourceLoaderFactoryGetter.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/isolation/ResourceLoaderFactoryGetter.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,14 +20,14 @@ import com.gitee.starblues.loader.classloader.resource.loader.DefaultResourceLoa import com.gitee.starblues.loader.classloader.resource.loader.ResourceLoaderFactory; import com.gitee.starblues.loader.classloader.resource.storage.*; -import java.net.URL; import java.util.Objects; /** * 获取ResourceLoaderFactory * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class ResourceLoaderFactoryGetter { @@ -35,15 +35,20 @@ public class ResourceLoaderFactoryGetter { /** - * 资源模式--缓存隔离模式 + * 资源存储模式-永久缓存。速度最快, 但启动前后占用都比较内存高 */ - private static final String RESOURCE_MODE_CACHE_ISOLATION = "cache-isolation"; + private static final String RESOURCE_MODE_PERPETUAL = "perpetual"; + + /** + * 资源存储模式-快速模式且内存相对较低。启动占用内存稍高, 速度比较高, 启动完成后占用内存会降低 + */ + private static final String RESOURCE_MODE_FAST_LOW = "fast-low"; /** - * 资源模式--缓存共享模式 + * 资源存储模式--缓存可释放模式 */ - private static final String RESOURCE_MODE_CACHE_SHARE = "cache-share"; + private static final String RESOURCE_MODE_CACHE_RELEASED = "cache-released"; private static volatile String resourceMode; @@ -73,16 +78,12 @@ public class ResourceLoaderFactoryGetter { return null; } - public static SameRootResourceStorage getResourceStorage(String key, URL baseUrl){ - SameRootResourceStorage resourceStorage = null; - if(Objects.equals(resourceMode, RESOURCE_MODE_CACHE_ISOLATION)){ - // 资源可缓存, 且隔离 - resourceStorage = new CacheResourceStorage(baseUrl); + public static AbstractResourceStorage getResourceStorage(String key){ + if(Objects.equals(resourceMode, RESOURCE_MODE_PERPETUAL)){ + return new CachePerpetualResourceStorage(); } else { - // 资源可缓存, 共享式 - resourceStorage = new ShareResourceStorage(key, baseUrl); + return new CacheFastResourceStorage(key); } - return resourceStorage; } } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/runner/MainMethodRunner.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/runner/MainMethodRunner.java index 2695ac3fcde070748749e21057c20e58ed4bacce..370df2507d51975a2fcd1122f6e1d17947d9e2ca 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/runner/MainMethodRunner.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/runner/MainMethodRunner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.loader.launcher.runner; /** * 主程序方法启动者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class MainMethodRunner extends MethodRunner{ diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/runner/MethodRunner.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/runner/MethodRunner.java index 06e4adbbb2d1164759b18f2fa03b83bacb3dc605..502e012bb611ed839d21066e44ba3e9cb66bde98 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/runner/MethodRunner.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/launcher/runner/MethodRunner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,9 @@ import java.util.Objects; /** * 反射运行方法 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class MethodRunner { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/Assert.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/Assert.java index bf8d51c63267a8957e9131d5ef10bbe1930dc0e0..26aa30b08008dd6f0e2ee92f3ae22d75d5b1b078 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/Assert.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/Assert.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import java.util.function.Supplier; /** * 参数校验工具类 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class Assert { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/CompareClassTypeUtils.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/CompareClassTypeUtils.java index 2b0d7465f4453d421167e5f16bb0077fea34e2e9..c1ea6e9c9ae4230d2f893e0fb736f5028254fccb 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/CompareClassTypeUtils.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/CompareClassTypeUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ package com.gitee.starblues.loader.utils; * 比较两个类类型 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class CompareClassTypeUtils { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/FilesUtils.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/FilesUtils.java index 1b17a8b2434e8d85c9d02e926f613e5db6297da4..ada15d73d480c907b67af8575caf1727751cd7ce 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/FilesUtils.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/FilesUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.io.IOException; * 文件工具类 * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public class FilesUtils { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/IOUtils.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/IOUtils.java index 483cda56cf8191815ad8871b18312b0cae008954..20cec128bb8d9a2eade77d6b1ecc817260fd2f8b 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/IOUtils.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/IOUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.function.Consumer; * io utils * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class IOUtils { @@ -47,13 +48,18 @@ public class IOUtils { if(inputStream == null){ throw new IllegalArgumentException("参数inputStream不能为空"); } - ByteArrayOutputStream output = new ByteArrayOutputStream(); - byte[] buffer = new byte[4096]; - int n = 0; - while (-1 != (n = inputStream.read(buffer))) { - output.write(buffer, 0, n); + if(!(inputStream instanceof BufferedInputStream)){ + inputStream = new BufferedInputStream(inputStream); + } + try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()){ + int len = 0; + byte[] buffer = new byte[1024]; + while (-1 != (len = inputStream.read(buffer))) { + outputStream.write(buffer, 0, len); + } + outputStream.flush(); + return outputStream.toByteArray(); } - return output.toByteArray(); } public static void closeQuietly(final AutoCloseable closeable) { diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/ObjectUtils.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/ObjectUtils.java index 8490c72b7a964f18d14309f8ee3deb62726a176a..de58e4976352ac9c788433a42cae348f0ac5cfc2 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/ObjectUtils.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/ObjectUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,14 +17,13 @@ package com.gitee.starblues.loader.utils; import java.lang.reflect.Array; -import java.util.Collection; -import java.util.Map; -import java.util.Optional; +import java.util.*; /** * object utils * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ObjectUtils { @@ -58,4 +57,25 @@ public class ObjectUtils { return false; } + public static List toList(T... array){ + if(array.length == 0){ + return new ArrayList<>(0); + } + List list = new ArrayList<>(array.length); + for (T t : array) { + list.add(t); + } + return list; + } + + public static T getFirst(Collection collection){ + if(ObjectUtils.isEmpty(collection)){ + return null; + } + for (T t : collection) { + return t; + } + return null; + } + } diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/Release.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/Release.java new file mode 100644 index 0000000000000000000000000000000000000000..e4a9a2140740846bc383e5a68de342b196e12b5f --- /dev/null +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/Release.java @@ -0,0 +1,17 @@ +package com.gitee.starblues.loader.utils; + +/** + * 可释放资源接口 + * + * @author starBlues + * @since 3.1.1 + * @version 3.1.1 + */ +public interface Release { + + /** + * 释放资源 + */ + default void release() throws Exception{} + +} diff --git a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/ResourceUtils.java b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/ResourceUtils.java index d128670638488f86f1c97e112ef390730c52e6c3..6af067155676d520903eb10ece5c632f3baf6a19 100644 --- a/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/ResourceUtils.java +++ b/spring-brick-loader/src/main/java/com/gitee/starblues/loader/utils/ResourceUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,11 +17,19 @@ package com.gitee.starblues.loader.utils; import java.io.File; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.net.URL; +import java.net.URLConnection; +import java.util.Objects; +import java.util.function.Consumer; /** * 资源工具 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ResourceUtils { @@ -36,6 +44,8 @@ public class ResourceUtils { public static final String PACKAGE_SPLIT = "/"; + public static final String CLASS_FILE_EXTENSION = ".class"; + private ResourceUtils(){} /** @@ -119,4 +129,81 @@ public class ResourceUtils { return newPath.toString(); } + /** + * 释放资源 + * @param object 释放资源的对象 + */ + public static void release(final Object object) { + release(object, null); + } + + /** + * 释放资源 + * @param object 释放资源的对象 + * @param consumer 释放异常消费 + */ + public static void release(final Object object, final Consumer consumer) { + if (object instanceof Release) { + try { + ((Release)object).release(); + } catch (final Exception e) { + if (consumer != null) { + consumer.accept(e); + } + } + } + } + + /** + * 获取存在的url + * @param url url + * @return 存在的URL, 不存在返回nulll + */ + public static URL getExistUrl(URL url){ + return getExistUrl(url, null); + } + + /** + * 获取存在的url + * @param baseUrl 根url + * @param name 资源名称 + * @return 存在的URL, 不存在返回nulll + */ + public static URL getExistUrl(URL baseUrl, String name){ + URL url; + try { + if(ObjectUtils.isEmpty(name)){ + url = baseUrl; + } else { + url = new URL(baseUrl, name); + } + } catch (MalformedURLException e) { + throw new IllegalArgumentException("非法:" + name); + } + try { + URLConnection uc = url.openConnection(); + if (uc instanceof HttpURLConnection) { + HttpURLConnection hconn = (HttpURLConnection)uc; + hconn.setRequestMethod("HEAD"); + if (hconn.getResponseCode() >= HttpURLConnection.HTTP_BAD_REQUEST) { + return null; + } + } else { + uc.setUseCaches(false); + InputStream is = uc.getInputStream(); + is.close(); + } + return url; + } catch (Exception e) { + return null; + } + } + + public static boolean isClass(String path){ + if(ObjectUtils.isEmpty(path)){ + return false; + } + return path.toLowerCase().endsWith(CLASS_FILE_EXTENSION); + } + } diff --git a/spring-brick-maven-packager/pom.xml b/spring-brick-maven-packager/pom.xml index cacdf5d7e5617b97b06a8b101a91bbe95828ca32..8756df06dd46a6163f50f2cb35647feaba865986 100644 --- a/spring-brick-maven-packager/pom.xml +++ b/spring-brick-maven-packager/pom.xml @@ -7,7 +7,7 @@ spring-brick-parent com.gitee.starblues - 3.1.0 + 3.1.1 spring-brick-maven-packager diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/AbstractDependencyFilterMojo.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/AbstractDependencyFilterMojo.java index 19505ea54d8096d971639df0c3c82253d747e5ad..ff061cfd14ccc6d8366da2c2d52fe8e1a98c2140 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/AbstractDependencyFilterMojo.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/AbstractDependencyFilterMojo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,9 @@ import java.util.Set; /** * 抽象可过滤依赖的 mojo + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @EqualsAndHashCode(callSuper = true) diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/AbstractPackagerMojo.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/AbstractPackagerMojo.java index bfd403724e3464b84b24ed343bc37dab2760b1c9..629649d583a68087e47a8a6b6bca056df6b228d9 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/AbstractPackagerMojo.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/AbstractPackagerMojo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +29,10 @@ import java.util.Set; /** * 抽象的重新打包 mojo + * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ @EqualsAndHashCode(callSuper = true) @Data @@ -81,7 +83,8 @@ public abstract class AbstractPackagerMojo extends AbstractDependencyFilterMojo{ protected abstract void pack() throws MojoExecutionException, MojoFailureException; public final Set getFilterDependencies() throws MojoExecutionException { - return filterDependencies(project.getArtifacts(), getFilters()); + Set artifacts = project.getArtifacts(); + return filterDependencies(artifacts, getFilters()); } public final Set getSourceDependencies() throws MojoExecutionException { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/BasicRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/BasicRepackager.java index 0c55181a92707531d9bcf42e62d3b3dc0eff3ef3..dc8cb5e63022b71226c5865ac5f99513824b6476 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/BasicRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/BasicRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.gitee.starblues.utils.FilesUtils; import com.gitee.starblues.utils.ObjectUtils; import lombok.Getter; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -36,6 +37,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.*; import java.util.jar.Attributes; +import java.util.jar.JarFile; import java.util.jar.Manifest; import static com.gitee.starblues.common.PackageStructure.*; @@ -43,8 +45,10 @@ import static com.gitee.starblues.common.PluginDescriptorKey.*; /** * 基础打包 + * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class BasicRepackager implements Repackager{ @@ -57,6 +61,7 @@ public class BasicRepackager implements Repackager{ protected File resourcesDefineFile; protected final RepackageMojo repackageMojo; + protected JarFile sourceJarFile; public BasicRepackager(RepackageMojo repackageMojo) { this.repackageMojo = repackageMojo; @@ -64,6 +69,7 @@ public class BasicRepackager implements Repackager{ @Override public void repackage() throws MojoExecutionException, MojoFailureException { + sourceJarFile = CommonUtils.getSourceJarFile(repackageMojo.getProject()); checkPluginInfo(); rootDir = createRootDir(); relativeManifestPath = getRelativeManifestPath(); @@ -75,6 +81,8 @@ public class BasicRepackager implements Repackager{ } catch (Exception e) { repackageMojo.getLog().error(e.getMessage(), e); throw new MojoFailureException(e); + } finally { + IOUtils.closeQuietly(sourceJarFile); } } @@ -155,15 +163,21 @@ public class BasicRepackager implements Repackager{ } protected Manifest getManifest() throws Exception{ - Manifest manifest = new Manifest(); + Manifest manifest = null; + if(sourceJarFile != null){ + manifest = sourceJarFile.getManifest(); + } else { + manifest = new Manifest(); + } Attributes attributes = manifest.getMainAttributes(); attributes.putValue(ManifestKey.MANIFEST_VERSION, ManifestKey.MANIFEST_VERSION_1_0); + attributes.putValue(ManifestKey.BUILD_TIME, CommonUtils.getDateTime()); attributes.putValue(ManifestKey.PLUGIN_META_PATH, getPluginMetaInfoPath()); attributes.putValue(ManifestKey.PLUGIN_PACKAGE_TYPE, PackageType.PLUGIN_PACKAGE_TYPE_DEV); // 增加jar包title和version属性 MavenProject mavenProject = this.repackageMojo.getProject(); - attributes.putValue(ManifestKey.IMPLEMENTATION_TITLE,mavenProject.getArtifactId()); - attributes.putValue(ManifestKey.IMPLEMENTATION_VERSION,mavenProject.getVersion()); + attributes.putValue(ManifestKey.IMPLEMENTATION_TITLE, mavenProject.getArtifactId()); + attributes.putValue(ManifestKey.IMPLEMENTATION_VERSION, mavenProject.getVersion()); return manifest; } diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Constant.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Constant.java index ce11f06dd41fca3c294383f42b69fffe34a5c1b3..0225ae53ed86b58459f079a9bc6e27802d7dd688 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Constant.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Constant.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import org.apache.maven.artifact.Artifact; /** * 静态类 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class Constant { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Dependency.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Dependency.java index 109a27e06fdba2cf273ffda6345befe1f68d1838..7e2b1e018ffdc1bec3d4a977b66839c49e81d56d 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Dependency.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Dependency.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import org.apache.maven.plugins.annotations.Parameter; /** * 依赖Bean + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Data diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/DependencyPlugin.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/DependencyPlugin.java index 10c916c8ffbb8ff5b3c7eb468e6b9124b711f768..44dfcdf20cc2ccf21dda88a65138c6d3f95fda7d 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/DependencyPlugin.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/DependencyPlugin.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import org.apache.maven.plugins.annotations.Parameter; /** * 依赖的插件 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DependencyPlugin extends AbstractDependencyPlugin { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/LoadMainResourcePattern.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/LoadMainResourcePattern.java index ed826269e45bc968149f529f4b553b316c6ed200..a9a3b7ab459fa9bd690be72a914bedff13f22988 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/LoadMainResourcePattern.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/LoadMainResourcePattern.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import org.apache.maven.plugins.annotations.Parameter; /** * 从主程序加载资源配置 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Data diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/LoadToMain.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/LoadToMain.java index 2cc7e26f207d7dd2573735c44c77be7a8624aa4e..9892b9806b131abad0e6f96b558b18a615f6e56d 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/LoadToMain.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/LoadToMain.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import java.util.List; /** * 定义依赖加载到主程序中 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Data diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/PluginInfo.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/PluginInfo.java index 5d5066f2d8bc1f06ee79b374d872c567c908a341..7265f0b127fc196e84870f932eb877e00f53e14b 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/PluginInfo.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/PluginInfo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ import java.util.List; /** * 插件信息 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Data diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/RepackageMojo.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/RepackageMojo.java index 1aa220a665745354bfd8355c5c1449356f6e1ece..97b7e201d5f01a6213695894b19301ba887dc838 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/RepackageMojo.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/RepackageMojo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import com.gitee.starblues.plugin.pack.main.MainConfig; import com.gitee.starblues.plugin.pack.main.MainRepackager; import com.gitee.starblues.plugin.pack.prod.ProdConfig; import com.gitee.starblues.plugin.pack.prod.ProdRepackager; +import com.gitee.starblues.plugin.pack.utils.CommonUtils; import com.gitee.starblues.utils.ObjectUtils; import lombok.Getter; import org.apache.maven.artifact.Artifact; @@ -40,8 +41,10 @@ import java.util.Set; /** * 重新打包 mojo + * * @author starBlues - * @version 3.0.1 + * @since 3.0.0 + * @version 3.1.1 */ @Mojo(name = "repackage", defaultPhase = LifecyclePhase.PACKAGE, requiresProject = true, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME, diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Repackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Repackager.java index d1ea896f9a40371099e0a95251dcd1fccb4c6aa6..1877f9ea658c5f681064209664299f878b3c53ca 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Repackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/Repackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,10 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; /** - * 重新打包j接口 + * 重新打包接口 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface Repackager { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/Dependency.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/Dependency.java index 4e61d928f843373488f9d5d752d7c547e17ea2ef..a99bba69b221f1ada2db41b246011e885d74390a 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/Dependency.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/Dependency.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import org.apache.maven.plugins.annotations.Parameter; /** * 开发环境下配置本地依赖的Bean + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Data diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/DevConfig.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/DevConfig.java index 9070a6eb3116748360fe06f741cac5a85127977e..74d6440e03643161dcf38fd1c55a2f0169661a10 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/DevConfig.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/DevConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import java.util.List; /** * 开发模式配置 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Data diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/DevRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/DevRepackager.java index 6540b3f7daffb010f8dff037c70c6460943beed3..2880f022c0b45ea56f9a01a9f274d34b458c4a96 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/DevRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/dev/DevRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,9 @@ import java.util.*; /** * 开发环境打包 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DevRepackager extends BasicRepackager { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesConfig.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesConfig.java index 44cf434931c0a34835b1b78effc45bd74d524367..a7d4afd3059c5260be296ce814134eebca945f5f 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesConfig.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import lombok.Data; * aes 加密配置 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ @Data diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesEncryptPlugin.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesEncryptPlugin.java index 2201d3d492903a74fbd3878e8bda9f913030a203..4b2b0f6ba860ef5223676bcd29ba50d2dfb109ad 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesEncryptPlugin.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/AesEncryptPlugin.java @@ -13,6 +13,7 @@ import java.util.Map; * rsa 加密者 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ public class AesEncryptPlugin implements EncryptPlugin{ diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptConfig.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptConfig.java index 8aa5b2233ab0b57b0aaeb294dd068eb7e5fa65fb..769b8db1c0679d4a6993f7d0c0ddf1be10174571 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptConfig.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +22,20 @@ import lombok.Data; * 加密配置 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ @Data public class EncryptConfig { + /** + * rsa 配置 + */ private RsaConfig rsa; + + /** + * aes 配置 + */ private AesConfig aes; } diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPlugin.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPlugin.java index b995f9d73d18cacc6e33e5d337f15dfdd6cc5b6c..5a22feee1ce85890cef88aafbeb468d2e8cc5805 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPlugin.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPlugin.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.gitee.starblues.plugin.pack.PluginInfo; * 加密插件 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ public interface EncryptPlugin { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPluginFactory.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPluginFactory.java index f8a2c5b41adf0b9e138024550f89a871f8ae017e..c52148ca55eb8ae3e34085eb252abfcb2fcc7e70 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPluginFactory.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/EncryptPluginFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.List; * 加密插件工厂 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ public class EncryptPluginFactory implements EncryptPlugin { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaConfig.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaConfig.java index 18b7e9a1f943cc301108f2f8d4b91c812cfa785b..09a8597244b310cdb25f4132b1731d1ba20ff5df 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaConfig.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,15 @@ import lombok.Data; * rsa 加密配置 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ @Data public class RsaConfig { + /** + * rsa 公钥 + */ private String publicKey; } diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaEncryptPlugin.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaEncryptPlugin.java index b8f4e5d6e04e9091b802db9ef5a911187df1b9e0..2e1f19041bdc4d650ab11f795915351c652f51f1 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaEncryptPlugin.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/encrypt/RsaEncryptPlugin.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import java.util.Map; * rsa 算法插件加密 * * @author starBlues + * @since 3.0.1 * @version 3.0.1 */ public class RsaEncryptPlugin implements EncryptPlugin{ diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/DependencyFilter.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/DependencyFilter.java index f26792d572a7ae2aaeae4acc0f280dd209cdade5..f0d3ea04b232a05a290060ea5ddbccac73a83d2c 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/DependencyFilter.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/DependencyFilter.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,9 @@ import java.util.Set; /** * 依赖过滤 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class DependencyFilter extends AbstractArtifactsFilter { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/Exclude.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/Exclude.java index 5679c55a38dc3e26d4481ff40a403c6044aa2559..0aaff1f27e2040d7d85008c52a2b7e4cd490af28 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/Exclude.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/Exclude.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.plugin.pack.filter; /** * 排除的依赖定义 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class Exclude extends FilterableDependency{ diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/ExcludeFilter.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/ExcludeFilter.java index dce74ece1a175bf738ae9507c4887d97a256bb4c..cb564bf75413fbe988d328b1dd1ade278431f793 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/ExcludeFilter.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/ExcludeFilter.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ import java.util.List; /** * 排除过滤 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ExcludeFilter extends DependencyFilter { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/FilterableDependency.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/FilterableDependency.java index 7f24259cf9b45c6dcf1a56ef35a5c9604c5dea42..d51b60328d97b1538aa65db7db3320b7fe695dab 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/FilterableDependency.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/FilterableDependency.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import org.apache.maven.plugins.annotations.Parameter; /** * 可过滤依赖bean + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Data diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/Include.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/Include.java index 55ae558077176ec7581fc898c97a71dc3c45d91d..c2bfb7a2e96bb4be879ad3d194bd77e9ed3586f8 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/Include.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/Include.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.plugin.pack.filter; /** * 包含的依赖定义 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class Include extends FilterableDependency{ diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/IncludeFilter.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/IncludeFilter.java index 1ab20ea4633c9a65f0b090f7e99f290281ceef1b..c9e83858049d6ad4a0b2e2e44413112ae655faf2 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/IncludeFilter.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/filter/IncludeFilter.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import java.util.List; /** * 包含过滤器 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class IncludeFilter extends DependencyFilter { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/JarNestPackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/JarNestPackager.java index 3b9eeb972f16bb9f066b0261c6643a4187fc0f21..804d778cb76254087090fd56de7deab4e21289ff 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/JarNestPackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/JarNestPackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,8 +29,10 @@ import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; import java.io.File; +import java.util.List; import java.util.Set; import java.util.jar.Attributes; +import java.util.jar.JarFile; import java.util.jar.Manifest; import static com.gitee.starblues.common.PackageStructure.*; @@ -38,8 +40,10 @@ import static com.gitee.starblues.common.ManifestKey.*; /** * 嵌套jar打包 + * * @author starBlues - * @version 3.0.2 + * @since 3.0.0 + * @version 3.1.1 */ public class JarNestPackager implements Repackager { @@ -48,6 +52,8 @@ public class JarNestPackager implements Repackager { protected PackageJar packageJar; + private JarFile sourceJarFile; + public JarNestPackager(MainRepackager mainRepackager) { this.mainConfig = mainRepackager.getMainConfig(); this.repackageMojo = mainRepackager.getRepackageMojo(); @@ -56,6 +62,7 @@ public class JarNestPackager implements Repackager { @Override public void repackage() throws MojoExecutionException, MojoFailureException { try { + sourceJarFile = CommonUtils.getSourceJarFile(repackageMojo.getProject()); packageJar = new PackageJar(mainConfig.getOutputDirectory(), mainConfig.getFileName()); writeClasses(); writeDependencies(); @@ -64,9 +71,8 @@ public class JarNestPackager implements Repackager { repackageMojo.getLog().error(e.getMessage(), e); throw new MojoFailureException(e); } finally { - if(packageJar != null){ - IOUtils.closeQuietly(packageJar); - } + IOUtils.closeQuietly(packageJar); + IOUtils.closeQuietly(sourceJarFile); } } @@ -77,9 +83,15 @@ public class JarNestPackager implements Repackager { } protected Manifest getManifest() throws Exception{ - Manifest manifest = new Manifest(); + Manifest manifest = null; + if(sourceJarFile != null){ + manifest = sourceJarFile.getManifest(); + } else { + manifest = new Manifest(); + } Attributes attributes = manifest.getMainAttributes(); attributes.putValue(MANIFEST_VERSION, MANIFEST_VERSION_1_0); + attributes.putValue(BUILD_TIME, CommonUtils.getDateTime()); attributes.putValue(START_CLASS, mainConfig.getMainClass()); attributes.putValue(MAIN_CLASS, MAIN_CLASS_VALUE); attributes.putValue(MAIN_PACKAGE_TYPE, PackageType.MAIN_PACKAGE_TYPE_JAR); diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/JarOuterPackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/JarOuterPackager.java index f4db7cad9e194472b89e3f63145acb79ed931879..54dc6aa933da0afb09a3961dc6d7c53e9fa07b90 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/JarOuterPackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/JarOuterPackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,9 @@ import static com.gitee.starblues.common.ManifestKey.*; /** * jar 外置包 + * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public class JarOuterPackager extends JarNestPackager { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/MainConfig.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/MainConfig.java index 1640483757c6b36b8abcaac5e15ddc0c1cc4b6d7..8b9101f7a6af4b8721f0c72cb86037160ecd033b 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/MainConfig.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/MainConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import org.apache.maven.plugins.annotations.Parameter; /** * 主程序打包配置 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @Data @@ -35,7 +37,6 @@ public class MainConfig { /** * 打包类型。默认:jar - * * {@link com.gitee.starblues.common.PackageType#MAIN_PACKAGE_TYPE_JAR} * {@link com.gitee.starblues.common.PackageType#MAIN_PACKAGE_TYPE_JAR_OUTER} */ diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/MainRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/MainRepackager.java index e0d73f293a4f076108426a37b50ae729ea5e7e98..f46ac0c576d43bca0780f2c5e78fc5a1e3542bd1 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/MainRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/main/MainRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import com.gitee.starblues.common.PackageType; import com.gitee.starblues.plugin.pack.Constant; import com.gitee.starblues.plugin.pack.RepackageMojo; import com.gitee.starblues.plugin.pack.Repackager; +import com.gitee.starblues.plugin.pack.utils.CommonUtils; import com.gitee.starblues.utils.ObjectUtils; import com.gitee.starblues.utils.ReflectionUtils; import lombok.Getter; @@ -37,8 +38,10 @@ import java.util.Set; /** * 主程序打包 + * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ @Getter public class MainRepackager implements Repackager { @@ -56,13 +59,15 @@ public class MainRepackager implements Repackager { checkConfig(); setDevelopmentMode(); String packageType = mainConfig.getPackageType(); + Repackager repackager = null; if(PackageType.MAIN_PACKAGE_TYPE_JAR.equalsIgnoreCase(packageType)){ - new JarNestPackager(this).repackage(); + repackager = new JarNestPackager(this); } else if(PackageType.MAIN_PACKAGE_TYPE_JAR_OUTER.equalsIgnoreCase(packageType)){ - new JarOuterPackager(this).repackage(); + repackager = new JarOuterPackager(this); } else { throw new MojoFailureException("Not found packageType : " + packageType); } + repackager.repackage(); } private void checkConfig() throws MojoFailureException { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/DirProdRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/DirProdRepackager.java index bd819f686206019d3ed04f1ea2f31226ca0b203f..b9728e520362b2e1c512aa9ae13b5baf88a8aa89 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/DirProdRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/DirProdRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,8 +39,10 @@ import static com.gitee.starblues.common.PackageStructure.*; /** * 文件夹包生成 + * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class DirProdRepackager extends DevRepackager { @@ -57,12 +59,17 @@ public class DirProdRepackager extends DevRepackager { super.repackage(); try { resolveClasses(); + logSuccess(); } catch (Exception e) { repackageMojo.getLog().error(e.getMessage(), e); throw new MojoFailureException(e); } } + protected void logSuccess(){ + repackageMojo.getLog().info("Success package prod dir file : " + getRootDir()); + } + @Override protected String createRootDir() throws MojoFailureException { String fileName = prodConfig.getFileName(); diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/JarNestedProdRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/JarNestedProdRepackager.java index 7fc9cf4a9369ce88a707a57b94231ec5c6d06be6..052eaf2cf1ac2c58e2a14d84f46521065e0890ba 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/JarNestedProdRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/JarNestedProdRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,8 +38,10 @@ import static com.gitee.starblues.common.PackageStructure.PROD_RESOURCES_DEFINE_ /** * jar包生成 + * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class JarNestedProdRepackager extends ZipProdRepackager { @@ -53,6 +55,11 @@ public class JarNestedProdRepackager extends ZipProdRepackager { super.repackage(); } + protected void logSuccess(){ + repackageMojo.getLog().info("Success package prod jar file : " + + packageZip.getFile().getPath()); + } + @Override protected PackageZip getPackageZip() throws Exception { return new PackageJar(prodConfig.getOutputDirectory(), prodConfig.getFileName()); diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/JarOuterProdRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/JarOuterProdRepackager.java index c6951b850355713919b323cedb7a011c39e7addf..4d1eaf072b9ebb0e428bed203945036a8d9a8363 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/JarOuterProdRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/JarOuterProdRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,9 @@ import java.util.jar.Manifest; /** * jar-outer包生成 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class JarOuterProdRepackager extends ZipOuterProdRepackager { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ProdConfig.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ProdConfig.java index 529f03fbb834c9258010dfb042623e154d1ebb1a..10c334b915d961e2ffc83dbf09e944c087111d28 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ProdConfig.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ProdConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import org.apache.maven.plugins.annotations.Parameter; /** * 生产环境打包配置 + * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ @Data @@ -30,7 +32,6 @@ public class ProdConfig { /** * 打包类型。默认jar包 - * * {@link com.gitee.starblues.common.PackageType#PLUGIN_PACKAGE_TYPE_JAR} * {@link com.gitee.starblues.common.PackageType#PLUGIN_PACKAGE_TYPE_JAR_OUTER} * {@link com.gitee.starblues.common.PackageType#PLUGIN_PACKAGE_TYPE_ZIP} diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ProdRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ProdRepackager.java index 0ff7d34e7f8e6d00a1f74f264769b6f65e4a01ea..629d81605dc46beeb7f7aeb63ce93582adffbb1d 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ProdRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ProdRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,9 @@ import org.apache.maven.plugin.MojoFailureException; /** * 生产环境打包 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ProdRepackager implements Repackager { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ZipOuterProdRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ZipOuterProdRepackager.java index 7b84adae340d5b775a10aef4f002b8b609151c84..87b1f134fd9e18e3c89e4ad37336d7b51b7eceb4 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ZipOuterProdRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ZipOuterProdRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,9 @@ import static com.gitee.starblues.common.PackageStructure.*; /** * zip-outer 包生成 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ZipOuterProdRepackager extends DirProdRepackager { diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ZipProdRepackager.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ZipProdRepackager.java index 55ca1548b9a9ccdfe3620300e10dc76bc479cf70..5da4b4f6dc99a81413f656242daa8ae5d881776f 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ZipProdRepackager.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/prod/ZipProdRepackager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -47,7 +47,9 @@ import static com.gitee.starblues.common.PackageStructure.*; /** * zip 打包 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ZipProdRepackager extends DevRepackager { @@ -75,8 +77,7 @@ public class ZipProdRepackager extends DevRepackager { } catch (IOException e) { // 忽略 } - repackageMojo.getLog().info("Success package prod zip file : " - + packageZip.getFile().getPath()); + logSuccess(); } catch (Exception e){ repackageMojo.getLog().error(e.getMessage(), e); throw new MojoFailureException(e); @@ -87,6 +88,11 @@ public class ZipProdRepackager extends DevRepackager { } } + protected void logSuccess(){ + repackageMojo.getLog().info("Success package prod zip file : " + + packageZip.getFile().getPath()); + } + protected PackageZip getPackageZip() throws Exception { return new PackageZip(prodConfig.getOutputDirectory(), prodConfig.getFileName()); } diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/CommonUtils.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/CommonUtils.java index 09ac0a0c30ee2d2b4340cfe5f0539e52e16a09f3..f3dfdd6b5e6a74c44dffe34e19a321ac761ac31e 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/CommonUtils.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/CommonUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,13 +20,23 @@ import com.gitee.starblues.plugin.pack.filter.Exclude; import org.apache.commons.io.FileUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.nio.file.StandardCopyOption; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.Objects; +import java.util.jar.JarFile; /** * Object 工具类 + * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class CommonUtils { @@ -36,6 +46,9 @@ public class CommonUtils { public final static String PLUGIN_FRAMEWORK_LOADER_ARTIFACT_ID = "spring-brick-loader"; + public static final String PATTERN = "yyyy-MM-dd HH:mm:ss"; + public static final DateTimeFormatter DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern(PATTERN); + private CommonUtils(){} public static Exclude getPluginFrameworkExclude(){ @@ -52,6 +65,19 @@ public class CommonUtils { && Objects.equals(artifact.getArtifactId(), PLUGIN_FRAMEWORK_LOADER_ARTIFACT_ID); } + public static JarFile getSourceJarFile(MavenProject mavenProject) { + File file = mavenProject.getArtifact().getFile(); + try { + return new JarFile(file); + } catch (Exception e){ + return null; + } + } + + public static String getDateTime() { + return DATE_TIME_FORMATTER.format(LocalDateTime.now()); + } + public static void deleteFile(File rootFile) throws MojoFailureException { try { if(rootFile == null){ @@ -70,4 +96,5 @@ public class CommonUtils { throw new MojoFailureException("Delete file '" + rootFile.getPath() + "' failure. " + e.getMessage()); } } + } diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/PackageJar.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/PackageJar.java index cf3012241a5e28a0afe33925f3826ecdfed1400f..7fa1c46edd78b0d999d59598bc70c2563430fbeb 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/PackageJar.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/PackageJar.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,9 @@ import java.nio.file.Files; /** * jar 打包工具 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PackageJar extends PackageZip{ diff --git a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/PackageZip.java b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/PackageZip.java index f7aa974c010845db067e1736af06516456f5fdf6..96df2df9ef94ecc759cdeb7a2a873948a1f34767 100644 --- a/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/PackageZip.java +++ b/spring-brick-maven-packager/src/main/java/com/gitee/starblues/plugin/pack/utils/PackageZip.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,7 +38,9 @@ import static com.gitee.starblues.common.PackageStructure.*; /** * zip 打包工具 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PackageZip implements Closeable{ diff --git a/spring-brick-maven-packager/src/main/resources/META-INF/maven/com.gitee.starblues.springboot-plugin-maven-packager/plugin-help.xml b/spring-brick-maven-packager/src/main/resources/META-INF/maven/com.gitee.starblues.springboot-plugin-maven-packager/plugin-help.xml index 0e203ae57eaeed9b4893fdbd89c11fa31e7563db..7579b252d6b359c8b0445e482659ad732cbd53dc 100644 --- a/spring-brick-maven-packager/src/main/resources/META-INF/maven/com.gitee.starblues.springboot-plugin-maven-packager/plugin-help.xml +++ b/spring-brick-maven-packager/src/main/resources/META-INF/maven/com.gitee.starblues.springboot-plugin-maven-packager/plugin-help.xml @@ -4,7 +4,7 @@ Spring Boot Plugin Maven Packager com.gitee.starblues spring-brick-maven-packager - 3.1.0 + 3.1.1 spring-brick-packager false true diff --git a/spring-brick-maven-packager/src/main/resources/META-INF/maven/plugin.xml b/spring-brick-maven-packager/src/main/resources/META-INF/maven/plugin.xml index 0e203ae57eaeed9b4893fdbd89c11fa31e7563db..7579b252d6b359c8b0445e482659ad732cbd53dc 100644 --- a/spring-brick-maven-packager/src/main/resources/META-INF/maven/plugin.xml +++ b/spring-brick-maven-packager/src/main/resources/META-INF/maven/plugin.xml @@ -4,7 +4,7 @@ Spring Boot Plugin Maven Packager com.gitee.starblues spring-brick-maven-packager - 3.1.0 + 3.1.1 spring-brick-packager false true diff --git a/spring-brick/pom.xml b/spring-brick/pom.xml index 9118a928c57c778e8fee5426008634a78e6362f5..312573dbee59d04abead6807a49328ae02297744 100644 --- a/spring-brick/pom.xml +++ b/spring-brick/pom.xml @@ -7,7 +7,7 @@ spring-brick-parent com.gitee.starblues - 3.1.0 + 3.1.1 spring-brick @@ -16,7 +16,6 @@ 核心集成包, 用于框架集成 - 2.10.1 1.7.7 2.11.0 diff --git a/spring-brick/src/main/java/com/gitee/starblues/annotation/Caller.java b/spring-brick/src/main/java/com/gitee/starblues/annotation/Caller.java index 49badbfa85c246a7c6a08e87c8780fe6627a3845..c043b032fc57877cd16b7b0d6266ebcc2b85dfd3 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/annotation/Caller.java +++ b/spring-brick/src/main/java/com/gitee/starblues/annotation/Caller.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.lang.annotation.*; * * @author starBlues * @version 2.4.0 + * @version 2.4.0 */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) diff --git a/spring-brick/src/main/java/com/gitee/starblues/annotation/Extract.java b/spring-brick/src/main/java/com/gitee/starblues/annotation/Extract.java index 2e465b1ffc0ff386687379d20e697ba470f4aee7..90f44609a76471a6cb99431f65695ee53c56ddee 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/annotation/Extract.java +++ b/spring-brick/src/main/java/com/gitee/starblues/annotation/Extract.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ import java.lang.annotation.*; /** * 基于业务的扩展注解 + * * @author starBlues + * @since 2.4.4 * @version 2.4.4 */ @Target(ElementType.TYPE) diff --git a/spring-brick/src/main/java/com/gitee/starblues/annotation/Supplier.java b/spring-brick/src/main/java/com/gitee/starblues/annotation/Supplier.java index 44959b2ea05bcc0a7668866f5bbaae65d148e3ab..1eba7e45542ae1ecd37d0263f9a798ca61defd88 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/annotation/Supplier.java +++ b/spring-brick/src/main/java/com/gitee/starblues/annotation/Supplier.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.lang.annotation.*; * 被调用类的提供者。配合 @Caller 注解使用, 两者结合实现插件中的方法调用。 * * @author starBlues + * @since 2.4.0 * @version 2.4.0 */ @Target(ElementType.TYPE) diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginInsideInfo.java b/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginInsideInfo.java index 1fdaf5b512febb835bffe435bf39454d51306874..136e22c95d7ea0c6f054455b52bf38cf81391c2b 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginInsideInfo.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginInsideInfo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,9 @@ import java.util.function.Supplier; /** * 默认的内部PluginWrapperInside实现 * @author starBlues - * @version 3.0.0 + * + * @since 3.0.0 + * @version 3.1.1 */ public class DefaultPluginInsideInfo implements PluginInsideInfo { @@ -42,6 +44,8 @@ public class DefaultPluginInsideInfo implements PluginInsideInfo { private Supplier> extensionInfoSupplier = Collections::emptyMap; + private ClassLoader classLoader = null; + public DefaultPluginInsideInfo(InsidePluginDescriptor pluginDescriptor) { this.pluginId = pluginDescriptor.getPluginId(); this.pluginDescriptor = pluginDescriptor; @@ -63,6 +67,11 @@ public class DefaultPluginInsideInfo implements PluginInsideInfo { this.extensionInfoSupplier = supplier; } + @Override + public void setClassLoader(ClassLoader classLoader) { + this.classLoader = classLoader; + } + @Override public Supplier> getExtensionInfoSupplier() { return extensionInfoSupplier; @@ -113,6 +122,11 @@ public class DefaultPluginInsideInfo implements PluginInsideInfo { return extensionInfoSupplier.get(); } + @Override + public ClassLoader getClassLoader() { + return classLoader; + } + private void resolveTime(PluginState pluginState){ if(pluginState == PluginState.STARTED || pluginState == PluginState.STARTED_FAILURE){ startTime = new Date(); diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginManager.java b/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginManager.java index d7ab7bbe3e8630ab51ca3fd000ec7c187def5276..66dcd019366c33ed5841c8ee00eed5e1dad881ff 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginManager.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/DefaultPluginManager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/DefaultRealizeProvider.java b/spring-brick/src/main/java/com/gitee/starblues/core/DefaultRealizeProvider.java index d06e538fae4dd14b4277d78f2e2554bce57c3ef9..f716d411961659af55a48fd8eff77e16793b21fc 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/DefaultRealizeProvider.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/DefaultRealizeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,6 +37,7 @@ import org.springframework.context.ApplicationContext; * 默认的RealizeProvider实现 * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class DefaultRealizeProvider implements RealizeProvider { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/PluginInfo.java b/spring-brick/src/main/java/com/gitee/starblues/core/PluginInfo.java index 9cf4d18bec3e8e7419876517be5399aea62dd0ed..aa43f41e49aca07ad0e4073419f43f8fcd2ddd41 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/PluginInfo.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/PluginInfo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,9 @@ package com.gitee.starblues.core; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonIgnoreType; import com.gitee.starblues.core.descriptor.PluginDescriptor; import java.util.Date; @@ -23,8 +26,10 @@ import java.util.Map; /** * 插件信息 + * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public interface PluginInfo { @@ -76,4 +81,11 @@ public interface PluginInfo { */ Map getExtensionInfo(); + /** + * 获取插件的Classloader + * @return ClassLoader + */ + @JsonIgnore + ClassLoader getClassLoader(); + } diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/PluginInfoFace.java b/spring-brick/src/main/java/com/gitee/starblues/core/PluginInfoFace.java index d0d53d793cf31bc30c16c87b1dee9a04d0f92e03..72e11449810a366071a95041dc82fb90ff522d4c 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/PluginInfoFace.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/PluginInfoFace.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,8 +25,10 @@ import java.util.function.Supplier; /** * 外部 PluginWrapperFace + * * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class PluginInfoFace implements PluginInfo { @@ -34,6 +36,7 @@ public class PluginInfoFace implements PluginInfo { private final PluginState pluginState; private final boolean followSystem; private final Supplier> extensionInfoSupplier; + private final ClassLoader classLoader; private final Date startTime; private final Date stopTime; @@ -46,6 +49,7 @@ public class PluginInfoFace implements PluginInfo { this.extensionInfoSupplier = pluginInsideInfo.getExtensionInfoSupplier(); this.startTime = pluginInsideInfo.getStartTime(); this.stopTime = pluginInsideInfo.getStopTime(); + this.classLoader = pluginInsideInfo.getClassLoader(); } @Override @@ -87,4 +91,9 @@ public class PluginInfoFace implements PluginInfo { public Map getExtensionInfo() { return extensionInfoSupplier.get(); } + + @Override + public ClassLoader getClassLoader() { + return classLoader; + } } diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/PluginInsideInfo.java b/spring-brick/src/main/java/com/gitee/starblues/core/PluginInsideInfo.java index 0d7d7d6c7be6b3f1b6c934c73f9eb6a10e26fd79..849940404ad20253e73a30c077fc472c53d2feb3 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/PluginInsideInfo.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/PluginInsideInfo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,9 +24,9 @@ import java.util.function.Supplier; /** * 内部的 PluginInfo * - * @since 3.0.0 - * @version 3.1.0 * @author starBlues + * @since 3.0.0 + * @version 3.1.1 */ public interface PluginInsideInfo extends PluginInfo { @@ -47,6 +47,12 @@ public interface PluginInsideInfo extends PluginInfo { */ void setExtensionInfoSupplier(Supplier> supplier); + /** + * 设置插件的 classLoader + * @param classLoader ClassLoader + */ + void setClassLoader(ClassLoader classLoader); + /** * 获取插件信息提供者 * @return 插件扩展信息自主提供者 diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/PluginLauncherManager.java b/spring-brick/src/main/java/com/gitee/starblues/core/PluginLauncherManager.java index bb153015db28139855f0eda69ebc2072efe6d30b..d48c543b8ea6f5fdb98e5e2e0e81b933a011752f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/PluginLauncherManager.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/PluginLauncherManager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/PluginManager.java b/spring-brick/src/main/java/com/gitee/starblues/core/PluginManager.java index b1da15f3be369153970253903ba6394d09ee12c2..5641ef1319eccd9816f32b8c30188ed2c9f48e68 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/PluginManager.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/PluginManager.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.List; /** * 插件管理者 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PluginManager { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/PluginState.java b/spring-brick/src/main/java/com/gitee/starblues/core/PluginState.java index 1af14d03f0a5e07006c49f1b61693e95ac327673..02ac658c08e2ca31cc4d9c5c2e38398425dbd824 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/PluginState.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/PluginState.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ package com.gitee.starblues.core; /** * 插件状态枚举 * @author starBlues + * + * @since 3.0.0 * @version 3.0.0 */ public enum PluginState { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/RealizeProvider.java b/spring-brick/src/main/java/com/gitee/starblues/core/RealizeProvider.java index 59417d2de124b2e5e820bdd9f3e64e09ddc4c499..a874db3eed84b085e74de6c83cf6c12eddba074f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/RealizeProvider.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/RealizeProvider.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import com.gitee.starblues.core.version.VersionInspector; /** * 插件扩展配置 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface RealizeProvider { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/RuntimeMode.java b/spring-brick/src/main/java/com/gitee/starblues/core/RuntimeMode.java index ebd126abd240a6a9325e4277f2feaae94b1b3348..592df1cd25efbf6efe3b4337e34227c33bd3f277 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/RuntimeMode.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/RuntimeMode.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package com.gitee.starblues.core; /** * 插件运行环境 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public enum RuntimeMode { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/checker/ComposePluginBasicChecker.java b/spring-brick/src/main/java/com/gitee/starblues/core/checker/ComposePluginBasicChecker.java index de0bd8e5c2c41ae5a5fea64ff596c91609a86f3c..925e3b7f405edb5dcf07f68bcca8d7b0d3fea293 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/checker/ComposePluginBasicChecker.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/checker/ComposePluginBasicChecker.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,9 @@ import java.util.List; /** * 组合插件检查者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ComposePluginBasicChecker implements PluginBasicChecker { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/checker/ComposePluginLauncherChecker.java b/spring-brick/src/main/java/com/gitee/starblues/core/checker/ComposePluginLauncherChecker.java index 716f788874c4c8196ffc606ef803540441e34f5e..feab2ae5276d188e0f1ff77aecc265fd9de94c28 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/checker/ComposePluginLauncherChecker.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/checker/ComposePluginLauncherChecker.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,9 @@ import java.util.List; /** * 组合插件检查者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ComposePluginLauncherChecker implements PluginLauncherChecker { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/checker/DefaultPluginBasicChecker.java b/spring-brick/src/main/java/com/gitee/starblues/core/checker/DefaultPluginBasicChecker.java index 846ab7e30017f8074448d8d621e8c324702bb2a8..b63fc6d4aaa5bda4c741f8b50b90dca61f316fcc 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/checker/DefaultPluginBasicChecker.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/checker/DefaultPluginBasicChecker.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,9 @@ import java.nio.file.Path; /** * 默认的基本检查者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DefaultPluginBasicChecker implements PluginBasicChecker { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/checker/DefaultPluginLauncherChecker.java b/spring-brick/src/main/java/com/gitee/starblues/core/checker/DefaultPluginLauncherChecker.java index f2590e56d616902bd10be7748857c3f4a409c039..2c9efde98c566fb1fe5a1e15a3b3e7f97a34a4d5 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/checker/DefaultPluginLauncherChecker.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/checker/DefaultPluginLauncherChecker.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,7 @@ import com.gitee.starblues.utils.ObjectUtils; * 默认插件启动检查者 * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class DefaultPluginLauncherChecker implements PluginLauncherChecker { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/checker/DependencyPluginLauncherChecker.java b/spring-brick/src/main/java/com/gitee/starblues/core/checker/DependencyPluginLauncherChecker.java index 3691f2c0336925fdb68527043cc18fdf86a84807..a944545193303e3dada9a3dbc2dcaa5caa668bf2 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/checker/DependencyPluginLauncherChecker.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/checker/DependencyPluginLauncherChecker.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,9 @@ import java.util.Objects; /** * 插件依赖的插件检查者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DependencyPluginLauncherChecker implements PluginLauncherChecker { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/checker/PluginBasicChecker.java b/spring-brick/src/main/java/com/gitee/starblues/core/checker/PluginBasicChecker.java index 100c878f4fbb56b71cdc8e0d44becbd038b72ff3..69756106eac55b2cb7a76744275226c70349588d 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/checker/PluginBasicChecker.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/checker/PluginBasicChecker.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ import java.nio.file.Path; /** * 插件基本检查者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PluginBasicChecker { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/checker/PluginLauncherChecker.java b/spring-brick/src/main/java/com/gitee/starblues/core/checker/PluginLauncherChecker.java index c44f9ae02c1fe14749b1fff2b2704d99ce97bc6a..14f01c5a052fac143385fbda42e390dfdf70f26e 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/checker/PluginLauncherChecker.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/checker/PluginLauncherChecker.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,9 @@ import com.gitee.starblues.core.exception.PluginException; /** * 插件启动检查者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PluginLauncherChecker { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/CacheMainResourceMatcher.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/CacheMainResourceMatcher.java index 84c2a4f3114566c2f3e3a33e71addfc207e591f8..41edbd977996d0e585e81f075bcaac7bc8fbc03f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/CacheMainResourceMatcher.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/CacheMainResourceMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.concurrent.ConcurrentHashMap; /** * 可缓存的 ResourceMatcher + * * @author starBlues * @since 3.0.0 * @version 3.0.3 diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/ComposeMainResourceMatcher.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/ComposeMainResourceMatcher.java index e8206bfbef7b2a47c1e72a933c06d23668f42405..ee30103c56b97d9979305cb7c56bf4a036408b78 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/ComposeMainResourceMatcher.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/ComposeMainResourceMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.List; * 组合的 MainResourcePatternDefiner * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class ComposeMainResourceMatcher implements MainResourceMatcher, AutoCloseable{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/DefaultMainResourceMatcher.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/DefaultMainResourceMatcher.java index 1dc02c3e090c1f41dac844985ff74beea94b2b3b..11f206fd5839dd02f2bd8f303272fed3b5af5f2a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/DefaultMainResourceMatcher.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/DefaultMainResourceMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.Set; /** * 默认的主程序资源匹配者 + * * @author starBlues * @since 3.0.0 * @version 3.0.3 diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/EmptyMainResourcePatternDefiner.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/EmptyMainResourcePatternDefiner.java index 57ca80a10ac5c4951cfee8c96e70ef309f970bd8..3024418af022e46552f2dcc412b0edb54374345f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/EmptyMainResourcePatternDefiner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/EmptyMainResourcePatternDefiner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import java.util.Set; /** * 空的 MainResourceDefiner + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class EmptyMainResourcePatternDefiner implements MainResourcePatternDefiner { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/MainResourceMatcher.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/MainResourceMatcher.java index 9b94955686905aa9d88c9c6b1e22d7d1a45e65fc..059f74942cf29485105a046d157219d110b8f6f6 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/MainResourceMatcher.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/MainResourceMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.core.classloader; /** * 主程序资源匹配者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public interface MainResourceMatcher { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/MainResourcePatternDefiner.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/MainResourcePatternDefiner.java index 1a56fe38f1e925f7858b7f5b0f4d963db9bc532f..b8fb11dce4f959c3165412f15696abf9fa02d9c7 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/MainResourcePatternDefiner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/MainResourcePatternDefiner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import java.util.Set; /** * 主程序定义者, 从主程序加载资源的定义者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface MainResourcePatternDefiner { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/NestedPluginJarResourceLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/NestedPluginJarResourceLoader.java index c09c2ccc808df814f4a5d0f5ac9ae506dabf6a46..cce11fcb20155cbdba6ca4eb176f1042db3552c4 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/NestedPluginJarResourceLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/NestedPluginJarResourceLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ import java.util.zip.ZipEntry; /** * 嵌套插件jar加载者 + * * @author starBlues * @since 3.0.0 * @version 3.1.0 @@ -83,9 +84,9 @@ public class NestedPluginJarResourceLoader extends AbstractResourceLoader { String realName = jarEntry.getName().replace(classesPath, ""); URL url = new URL(baseUrl.toString() + jarEntry.getName()); resourceLoaderFactory.addResource(new DefaultResource(realName, baseUrl, url)); - resourceStorage.add(realName, url, ()->{ + resourceStorage.add(new CacheResource(realName, baseUrl, url, ()->{ return getClassBytes(realName, jarFile.getInputStream(jarEntry), true); - }); + })); } } diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginClassLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginClassLoader.java index 11ab94c518bb4b0df8e8bc99e590e8cc98521e2a..116900a5474a68c49d2f52d9cbc69c9fb01c7a5f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginClassLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginClassLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ import java.util.Set; /** * 插件 classLoader + * * @author starBlues * @version 3.0.3 * @since 3.0.0 @@ -51,9 +52,10 @@ public class PluginClassLoader extends GenericClassLoader implements PluginResou private final PluginResourceLoaderFactory proxy; public PluginClassLoader(String name, GenericClassLoader parentClassLoader, + ClassLoader classLoader, ResourceLoaderFactory resourceLoaderFactory, MainResourceMatcher mainResourceMatcher) { - super(name, parentClassLoader, resourceLoaderFactory); + super(name, classLoader, resourceLoaderFactory); this.mainResourceMatcher = mainResourceMatcher; this.proxy = new PluginResourceLoaderFactoryProxy(resourceLoaderFactory, parentClassLoader); } @@ -114,6 +116,4 @@ public class PluginClassLoader extends GenericClassLoader implements PluginResou } } } - - } diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginGeneralUrlClassLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginGeneralUrlClassLoader.java index 1326662d8c65b9d8d569e75ce3bda8a742551430..11e525902ea0e0cf0bd48fd7c9bdf6a1ac25b831 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginGeneralUrlClassLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginGeneralUrlClassLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginResourceLoaderFactory.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginResourceLoaderFactory.java index 3be839a39c608c32040a244166bc2174bac1f2db..815631338dd679a341bb2a3101294ef5940aa783 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginResourceLoaderFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginResourceLoaderFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginResourceLoaderFactoryProxy.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginResourceLoaderFactoryProxy.java index 10143b86ea6b90afaa8b01b3c5df2209caffb7a2..594b73851bf98b5b0196f3cb97162791c798c858 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginResourceLoaderFactoryProxy.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/PluginResourceLoaderFactoryProxy.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,8 +40,8 @@ import java.util.Set; * 插件资源加载工厂代理 * * @author starBlues - * @version 3.1.0 - * @since 13.0.4 + * @since 3.0.4 + * @version 3.1.1 */ @Slf4j public class PluginResourceLoaderFactoryProxy implements PluginResourceLoaderFactory { @@ -179,4 +179,9 @@ public class PluginResourceLoaderFactoryProxy implements PluginResourceLoaderFac public void close() throws Exception { target.close(); } + + @Override + public void release() throws Exception { + target.release(); + } } diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/ProhibitMainResourceMatcher.java b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/ProhibitMainResourceMatcher.java index cba6d62277f62f9a292c84a6cc3a6438b98bbfa7..3ba396465dfe88afaed31489f4475d8aa4da36ac 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/classloader/ProhibitMainResourceMatcher.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/classloader/ProhibitMainResourceMatcher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,9 @@ package com.gitee.starblues.core.classloader; /** * 禁止匹配所有主程序资源 + * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class ProhibitMainResourceMatcher implements MainResourceMatcher{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/AbstractPluginDescriptorLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/AbstractPluginDescriptorLoader.java index 49e3cda9867c72f8ebda429d623d7d91ee17f5cb..90f216482ed5a63215b97b6a22b678c7966bf191 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/AbstractPluginDescriptorLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/AbstractPluginDescriptorLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ComposeDescriptorLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ComposeDescriptorLoader.java index 5445d05ce6ec01dd28bd5918821b3d19d10278f3..f8aa2412a03437af5c93698d4fbe53e6eebb707e 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ComposeDescriptorLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ComposeDescriptorLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import java.util.List; /** * 组合插件描述加载者 * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class ComposeDescriptorLoader implements PluginDescriptorLoader{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultDependencyPlugin.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultDependencyPlugin.java index bc5fdee4cfa4397bcc053c80ff51043ac72ea230..1ee12011bed5019d5c1e61f1fcf7b4b9b421304f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultDependencyPlugin.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultDependencyPlugin.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.gitee.starblues.common.AbstractDependencyPlugin; /** * 依赖的插件信息 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DefaultDependencyPlugin extends AbstractDependencyPlugin { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultInsidePluginDescriptor.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultInsidePluginDescriptor.java index f5cdd9219de0664360d48843a709e1169841e0a7..93c93f2817a111366aeebdb3630696629b3f10cb 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultInsidePluginDescriptor.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultInsidePluginDescriptor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.jar.Manifest; /** * 内部的默认插件描述者 * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public class DefaultInsidePluginDescriptor extends DefaultPluginDescriptor implements InsidePluginDescriptor { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultPluginDescriptor.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultPluginDescriptor.java index d642dbd707f12f7029e87d19d8981edc2f9fdcc4..8e2e330fc006118b4ff6f3a4c1f1468806d9d0db 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultPluginDescriptor.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DefaultPluginDescriptor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import static com.gitee.starblues.common.PluginDescriptorKey.*; * 默认插件描述者 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DefaultPluginDescriptor implements PluginDescriptor { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DevPluginDescriptorLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DevPluginDescriptorLoader.java index f7591775c063fdae5756274093c9f2387938d0f0..2b9b29c5f2d7beb271a7465030211b7053ed29f6 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DevPluginDescriptorLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/DevPluginDescriptorLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,9 @@ import java.util.Properties; /** * 开发环境 PluginDescriptorLoader 加载者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ @Slf4j diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/InsidePluginDescriptor.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/InsidePluginDescriptor.java index 369af7825329b865f629c21960c2e79ac638f448..472125e797851c90469ef3ccad000c750c9ab20e 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/InsidePluginDescriptor.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/InsidePluginDescriptor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ import java.util.jar.Manifest; /** * 内部的PluginDescriptor + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface InsidePluginDescriptor extends PluginDescriptor{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginDescriptor.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginDescriptor.java index 4e125bbf2c913526cc3f44f66bae7b419f0ffa40..7d4b572011e396f95c0b1d74961f503094eee45a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginDescriptor.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginDescriptor.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import java.util.List; /** * 插件信息 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PluginDescriptor { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginDescriptorLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginDescriptorLoader.java index e69c34ea7a871500af7140b9b08ae40f4e086cc1..6e122b366577e3ddfe03cdd2e31ca04abab645b9 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginDescriptorLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginDescriptorLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,9 @@ import java.nio.file.Path; /** * 插件描述加载者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PluginDescriptorLoader extends AutoCloseable{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginLibInfo.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginLibInfo.java index dbfa29e9a42a760a5af4b2074dbae6f932702338..f3e9d7ff920ec3f0dac48af4b8819baf56357bf0 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginLibInfo.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginLibInfo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ import lombok.ToString; /** * 插件依赖包信息 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ @AllArgsConstructor diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginResourcesConfig.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginResourcesConfig.java index 5dc88a6ab62739ac6a464a6f7653974b3f36a0a4..ca3401da9a8057f534b08830b4c574d5102903be 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginResourcesConfig.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginResourcesConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,9 @@ import java.util.Set; /** * 插件 ResourcesDefine 文件定义 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginResourcesConfig { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginType.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginType.java index eb42c15142531231fca6aedab7ff9679ba6d14a1..86e2bbbe02c98962ce29b8ab6374fad7a3308a2c 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginType.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/PluginType.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,10 @@ import com.gitee.starblues.core.exception.PluginException; import java.util.Objects; /** + * 插件类型 + * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public enum PluginType { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdDirPluginDescriptorLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdDirPluginDescriptorLoader.java index 541fcbbff5f2c589885a12107da28286da77a269..bd0f7d7bc707cc4b1dec280dfb60bca0cc0c4709 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdDirPluginDescriptorLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdDirPluginDescriptorLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,9 @@ import static com.gitee.starblues.common.PackageStructure.*; /** * 生产环境目录式插件 PluginDescriptorLoader 加载者 * 解析生产的dir + * * @author starBlues + * @since 3.0.0 * @version 3.0.2 */ public class ProdDirPluginDescriptorLoader extends AbstractPluginDescriptorLoader{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdPackagePluginDescriptorLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdPackagePluginDescriptorLoader.java index 7a4d0b98177c13bc6bc2ae38b3b5dab7fb896af0..103e482adcfe12083b0a320cefb8f0e9165a129a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdPackagePluginDescriptorLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdPackagePluginDescriptorLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,6 +41,7 @@ import static com.gitee.starblues.common.PluginDescriptorKey.PLUGIN_RESOURCES_CO /** * 生产环境打包好的插件 PluginDescriptorLoader 加载者 * 解析 jar、zip + * * @author starBlues * @since 3.0.0 * @version 3.1.0 diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdPluginDescriptorLoader.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdPluginDescriptorLoader.java index 17ba28f22c14792f59debdd7aa8cec2cc29f159f..b8c1bb1045e7cb3bb88be74e333394af0b59d604 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdPluginDescriptorLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/ProdPluginDescriptorLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,7 +26,9 @@ import java.nio.file.Path; /** * 生产环境插件描述加载者 + * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class ProdPluginDescriptorLoader implements PluginDescriptorLoader{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/DefaultPluginDescriptorDecrypt.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/DefaultPluginDescriptorDecrypt.java index e273f583e3b4698a44059f33998913552de7c359..d2a476121b6641d3f16f2543af4734a8ba9edbae 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/DefaultPluginDescriptorDecrypt.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/DefaultPluginDescriptorDecrypt.java @@ -19,6 +19,7 @@ import java.util.*; * 默认的 PluginDescriptorDecrypt * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class DefaultPluginDescriptorDecrypt implements PluginDescriptorDecrypt{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/EmptyPluginDescriptorDecrypt.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/EmptyPluginDescriptorDecrypt.java index bdf89c13dcdd48bb23f127c79fa8dc9f8c045dac..8bf02b4ac4b6dc2c59efeb92aebb7ca531b0a790 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/EmptyPluginDescriptorDecrypt.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/EmptyPluginDescriptorDecrypt.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.Properties; * 空的插件解密 * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class EmptyPluginDescriptorDecrypt implements PluginDescriptorDecrypt{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/PluginDescriptorDecrypt.java b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/PluginDescriptorDecrypt.java index df444de8e3ce659e79de46ab58b47c51910040b6..6b3490e610c9c5d41a072b4c75b35cef8beb46a2 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/PluginDescriptorDecrypt.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/descriptor/decrypt/PluginDescriptorDecrypt.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.Properties; * 插件描述文件解密器 * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public interface PluginDescriptorDecrypt { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginDecryptException.java b/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginDecryptException.java index 8b5def0785b7012470b11f43c574b3f481fd8ada..ea133c3e69aeaf64ee53d0da98ef836cf8a281ed 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginDecryptException.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginDecryptException.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.gitee.starblues.core.descriptor.PluginDescriptor; * 插件解密异常 * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class PluginDecryptException extends PluginException{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginDisabledException.java b/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginDisabledException.java index 25a6bb52e5bb84984f9f1e2dca14d63162e75893..0d998d9bfbd316655458502b23de423c1a45800b 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginDisabledException.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginDisabledException.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import com.gitee.starblues.utils.ObjectUtils; /** * 插件被禁用异常 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginDisabledException extends PluginException { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginException.java b/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginException.java index 92b79a1d48f8093a892d984eaf850c3ab5b1daf5..617d5b9e44f02c5c2b19aaf87f8f5b67ab86f752 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginException.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginException.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.function.Supplier; /** * 插件异常 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginException extends RuntimeException{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginProhibitStopException.java b/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginProhibitStopException.java index a5095d52335a58374840b7a0c313d142cc3fbf5d..7718c135bfff13ed5eed50a8a3ed62ec595331d2 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginProhibitStopException.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/exception/PluginProhibitStopException.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.gitee.starblues.utils.MsgUtils; /** * 插件禁止停止异常 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginProhibitStopException extends PluginException { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/JavaMainResourcePatternDefiner.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/JavaMainResourcePatternDefiner.java index 4e46c7efd223d356fe402803fb0258f2afcb2d3d..2ae933ad269be3b69c062751276de69cef29d5b4 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/JavaMainResourcePatternDefiner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/JavaMainResourcePatternDefiner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import java.util.Set; /** * java 内部包匹配定义 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class JavaMainResourcePatternDefiner implements MainResourcePatternDefiner { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/AbstractPluginLauncher.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/AbstractPluginLauncher.java new file mode 100644 index 0000000000000000000000000000000000000000..1d7c251cebbfb4676e82db6eb30bb61b78bc9b60 --- /dev/null +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/AbstractPluginLauncher.java @@ -0,0 +1,62 @@ +package com.gitee.starblues.core.launcher.plugin; + +import com.gitee.starblues.core.PluginInsideInfo; +import com.gitee.starblues.core.exception.PluginException; +import com.gitee.starblues.core.launcher.plugin.involved.PluginLaunchInvolved; +import com.gitee.starblues.loader.launcher.AbstractLauncher; +import com.gitee.starblues.spring.SpringPluginHook; + +/** + * 插件启动者 + * + * @author starBlues + * @version 3.1.1 + * @since 3.1.1 + */ +public abstract class AbstractPluginLauncher extends AbstractLauncher { + + protected final PluginInteractive pluginInteractive; + protected final PluginLaunchInvolved pluginLaunchInvolved; + + public AbstractPluginLauncher(PluginInteractive pluginInteractive, + PluginLaunchInvolved pluginLaunchInvolved) { + this.pluginInteractive = pluginInteractive; + this.pluginLaunchInvolved = pluginLaunchInvolved; + } + + @Override + protected final ClassLoader createClassLoader(String... args) throws Exception { + ClassLoader pluginClassLoader = createPluginClassLoader(args); + pluginInteractive.getPluginInsideInfo().setClassLoader(pluginClassLoader); + return pluginClassLoader; + } + + @Override + protected SpringPluginHook launch(ClassLoader classLoader, String... args) throws Exception { + PluginInsideInfo pluginInsideInfo = pluginInteractive.getPluginInsideInfo(); + pluginLaunchInvolved.before(pluginInsideInfo, classLoader); + try { + SpringPluginHook springPluginHook = (SpringPluginHook) new PluginMethodRunner(pluginInteractive) + .run(classLoader); + if(springPluginHook == null){ + throw new PluginException("插件返回的 SpringPluginHook 不能为空"); + } + pluginLaunchInvolved.after(pluginInsideInfo, classLoader, springPluginHook); + return new SpringPluginHookWrapper(springPluginHook, pluginInsideInfo, pluginLaunchInvolved, classLoader); + } catch (Throwable throwable){ + pluginLaunchInvolved.failure(pluginInsideInfo,classLoader, throwable); + throw throwable; + } + } + + /** + * 创建插件的classloader + * @param args 参数 + * @return ClassLoader + * @throws Exception 创建ClassLoader异常 + */ + protected abstract ClassLoader createPluginClassLoader(String... args) throws Exception; + + + +} diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/BasicMainResourcePatternDefiner.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/BasicMainResourcePatternDefiner.java index 461a5ca27482da906c19ab52eab3a29d0c6a3277..37b1e93c555f96cb0926b020f1473886c2bec654 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/BasicMainResourcePatternDefiner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/BasicMainResourcePatternDefiner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.Set; /** * 基本的主程序资源匹配定义 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class BasicMainResourcePatternDefiner implements MainResourcePatternDefiner { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/CacheRegistryInfo.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/CacheRegistryInfo.java index 341680b9352a9cb7aa9077986abf676acbb4a5c0..e925ffe1ef3d357dc68a7637ec3ea789a11c0735 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/CacheRegistryInfo.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/CacheRegistryInfo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +23,7 @@ import java.util.function.Supplier; /** * 可缓存的注册信息 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class CacheRegistryInfo implements RegistryInfo { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/DefaultMainResourcePatternDefiner.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/DefaultMainResourcePatternDefiner.java index ac6014e6e25c5b0d81e4def7af6859a5836cdfeb..2525e8e01e79ea31c103d97f601c5cd3b48db9e3 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/DefaultMainResourcePatternDefiner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/DefaultMainResourcePatternDefiner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package com.gitee.starblues.core.launcher.plugin; import com.gitee.starblues.core.classloader.MainResourcePatternDefiner; import com.gitee.starblues.core.launcher.JavaMainResourcePatternDefiner; +import com.gitee.starblues.integration.IntegrationConfiguration; import com.gitee.starblues.utils.ObjectUtils; import com.gitee.starblues.utils.SpringBeanUtils; import org.springframework.context.ApplicationContext; @@ -30,6 +31,7 @@ import java.util.Set; * 主程序资源匹配定义 * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class DefaultMainResourcePatternDefiner extends JavaMainResourcePatternDefiner { @@ -39,10 +41,12 @@ public class DefaultMainResourcePatternDefiner extends JavaMainResourcePatternDe public static final String FACTORIES_RESOURCE_LOCATION = "META-INF/spring.factories"; private final String mainPackage; + private final IntegrationConfiguration configuration; private final ApplicationContext applicationContext; - public DefaultMainResourcePatternDefiner(String mainPackage, ApplicationContext applicationContext) { - this.mainPackage = mainPackage; + public DefaultMainResourcePatternDefiner(IntegrationConfiguration configuration, ApplicationContext applicationContext) { + this.mainPackage = configuration.mainPackage(); + this.configuration = configuration; this.applicationContext = applicationContext; } @@ -56,8 +60,10 @@ public class DefaultMainResourcePatternDefiner extends JavaMainResourcePatternDe addWebIncludeResourcePatterns(includeResourcePatterns); addApiDoc(includeResourcePatterns); addDbDriver(includeResourcePatterns); + addMainDependencyFramework(includeResourcePatterns); addIdea(includeResourcePatterns); + addLog(includeResourcePatterns); // add extension List extensionPatternDefiners = getExtensionPatternDefiners(); @@ -135,9 +141,20 @@ public class DefaultMainResourcePatternDefiner extends JavaMainResourcePatternDe patterns.add("jdbc/h2/**"); } - private void addIdea(Set includeResourcePatterns) { + protected void addMainDependencyFramework(Set patterns) { + patterns.add("com/github/benmanes/caffeine/cache/**"); + } + + protected void addIdea(Set patterns) { // idea debug agent - includeResourcePatterns.add("com/intellij/rt/debugger/agent/**"); + patterns.add("com/intellij/rt/debugger/agent/**"); + } + + protected void addLog(Set patterns) { + if(Boolean.FALSE.equals(configuration.pluginFollowLog())){ + return; + } + patterns.add("org/slf4j/**"); } diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/DefaultPluginInteractive.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/DefaultPluginInteractive.java index a9249b830ca748e4569e53bafd956fd9336756f3..ef3960116f7c1bc0c377ff3d4ba09b67df0c4dc4 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/DefaultPluginInteractive.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/DefaultPluginInteractive.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import com.gitee.starblues.spring.invoke.InvokeSupperCache; /** * 默认的插件交互实现 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DefaultPluginInteractive implements PluginInteractive{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginCoexistLauncher.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginCoexistLauncher.java index 3bb4d27d308ba0c58a56996d5fca42320a8a148d..cbf321bb398ce53b84f51920e88972fb513758fd 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginCoexistLauncher.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginCoexistLauncher.java @@ -1,25 +1,14 @@ package com.gitee.starblues.core.launcher.plugin; import com.gitee.starblues.core.PluginInsideInfo; -import com.gitee.starblues.core.classloader.NestedPluginJarResourceLoader; import com.gitee.starblues.core.classloader.PluginGeneralUrlClassLoader; -import com.gitee.starblues.core.descriptor.InsidePluginDescriptor; -import com.gitee.starblues.core.descriptor.PluginLibInfo; -import com.gitee.starblues.core.descriptor.PluginType; import com.gitee.starblues.core.exception.PluginException; import com.gitee.starblues.core.launcher.plugin.involved.PluginLaunchInvolved; import com.gitee.starblues.loader.classloader.GeneralUrlClassLoader; -import com.gitee.starblues.loader.launcher.AbstractLauncher; import com.gitee.starblues.loader.launcher.LauncherContext; import com.gitee.starblues.spring.SpringPluginHook; -import com.gitee.starblues.utils.FilesUtils; -import com.gitee.starblues.utils.MsgUtils; -import com.gitee.starblues.utils.ObjectUtils; import lombok.extern.slf4j.Slf4j; -import java.io.File; -import java.util.Set; - /** * 插件共享式启动引导 * @@ -28,19 +17,16 @@ import java.util.Set; * @version 3.1.0 */ @Slf4j -public class PluginCoexistLauncher extends AbstractLauncher { +public class PluginCoexistLauncher extends AbstractPluginLauncher { - protected final PluginInteractive pluginInteractive; - protected final PluginLaunchInvolved pluginLaunchInvolved; public PluginCoexistLauncher(PluginInteractive pluginInteractive, PluginLaunchInvolved pluginLaunchInvolved) { - this.pluginInteractive = pluginInteractive; - this.pluginLaunchInvolved = pluginLaunchInvolved; + super(pluginInteractive, pluginLaunchInvolved); } @Override - protected ClassLoader createClassLoader(String... args) throws Exception { + protected ClassLoader createPluginClassLoader(String... args) throws Exception { PluginGeneralUrlClassLoader classLoader = new PluginGeneralUrlClassLoader( pluginInteractive.getPluginDescriptor().getPluginId(), getParentClassLoader()); @@ -48,25 +34,6 @@ public class PluginCoexistLauncher extends AbstractLauncher { return classLoader; } - @Override - protected SpringPluginHook launch(ClassLoader classLoader, String... args) throws Exception { - InsidePluginDescriptor pluginDescriptor = pluginInteractive.getPluginDescriptor(); - PluginInsideInfo pluginInsideInfo = pluginInteractive.getPluginInsideInfo(); - pluginLaunchInvolved.before(pluginInsideInfo, classLoader); - try { - SpringPluginHook springPluginHook = (SpringPluginHook) new PluginMethodRunner(pluginInteractive) - .run(classLoader); - if(springPluginHook == null){ - throw new PluginException("插件返回的 SpringPluginHook 不能为空"); - } - pluginLaunchInvolved.after(pluginInsideInfo, classLoader, springPluginHook); - return new SpringPluginHookWrapper(springPluginHook, pluginInsideInfo, pluginLaunchInvolved, classLoader); - } catch (Throwable throwable){ - pluginLaunchInvolved.failure(pluginInsideInfo,classLoader, throwable); - throw throwable; - } - } - protected GeneralUrlClassLoader getParentClassLoader() throws Exception { ClassLoader contextClassLoader = LauncherContext.getMainClassLoader(); if(contextClassLoader instanceof GeneralUrlClassLoader){ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginInteractive.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginInteractive.java index 2278ca55740455e47a0b26ee4622bdc02942f0e5..f9c2f6e0fed250ef13da8ba4dde9ffac2feea727 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginInteractive.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginInteractive.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import com.gitee.starblues.spring.invoke.InvokeSupperCache; /** * 插件交互接口 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PluginInteractive { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginIsolationLauncher.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginIsolationLauncher.java index 90412335992ab5751b9f63b311fb7feab68baaf1..dffc257df55b5af3d5cd93b23d72ea7f91475735 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginIsolationLauncher.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginIsolationLauncher.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,13 +18,12 @@ package com.gitee.starblues.core.launcher.plugin; import com.gitee.starblues.core.PluginInsideInfo; import com.gitee.starblues.core.classloader.*; -import com.gitee.starblues.core.descriptor.InsidePluginDescriptor; import com.gitee.starblues.core.launcher.plugin.involved.PluginLaunchInvolved; import com.gitee.starblues.loader.classloader.GenericClassLoader; import com.gitee.starblues.loader.classloader.resource.loader.DefaultResourceLoaderFactory; import com.gitee.starblues.loader.classloader.resource.loader.ResourceLoaderFactory; -import com.gitee.starblues.loader.launcher.AbstractLauncher; import com.gitee.starblues.loader.launcher.LauncherContext; +import com.gitee.starblues.loader.utils.ResourceUtils; import com.gitee.starblues.spring.MainApplicationContext; import com.gitee.starblues.spring.SpringPluginHook; import com.gitee.starblues.utils.MsgUtils; @@ -42,22 +41,18 @@ import java.util.WeakHashMap; * @since 3.0.0 * @version 3.1.0 */ -public class PluginIsolationLauncher extends AbstractLauncher { +public class PluginIsolationLauncher extends AbstractPluginLauncher { private static final Map CLASS_LOADER_CACHE = new WeakHashMap<>(); - protected final PluginInteractive pluginInteractive; protected final PluginInsideInfo pluginInsideInfo; protected final MainResourceMatcher mainResourceMatcher; - protected final PluginLaunchInvolved pluginLaunchInvolved; - public PluginIsolationLauncher(PluginInteractive pluginInteractive, PluginLaunchInvolved pluginLaunchInvolved) { - this.pluginInteractive = pluginInteractive; + super(pluginInteractive, pluginLaunchInvolved); this.pluginInsideInfo = pluginInteractive.getPluginInsideInfo(); this.mainResourceMatcher = getMainResourceMatcher(pluginInteractive); - this.pluginLaunchInvolved = pluginLaunchInvolved; } protected MainResourceMatcher getMainResourceMatcher(PluginInteractive pluginInteractive){ @@ -75,12 +70,19 @@ public class PluginIsolationLauncher extends AbstractLauncher } @Override - protected ClassLoader createClassLoader(String... args) throws Exception { + protected ClassLoader createPluginClassLoader(String... args) throws Exception { PluginClassLoader pluginClassLoader = getPluginClassLoader(); pluginClassLoader.addResource(pluginInsideInfo.getPluginDescriptor()); return pluginClassLoader; } + @Override + protected SpringPluginHook launch(ClassLoader classLoader, String... args) throws Exception { + SpringPluginHook springPluginHook = super.launch(classLoader, args); + ResourceUtils.release(classLoader); + return springPluginHook; + } + protected synchronized PluginClassLoader getPluginClassLoader() throws Exception { String pluginId = pluginInsideInfo.getPluginId(); String key = MsgUtils.getPluginUnique(pluginInsideInfo.getPluginDescriptor()); @@ -89,7 +91,8 @@ public class PluginIsolationLauncher extends AbstractLauncher return classLoader; } PluginClassLoader pluginClassLoader = new PluginClassLoader( - pluginId, getParentClassLoader(), getResourceLoaderFactory(), mainResourceMatcher + pluginId, getParentClassLoader(), getParentClassLoader(), getResourceLoaderFactory(), + mainResourceMatcher ); CLASS_LOADER_CACHE.put(key, pluginClassLoader); return pluginClassLoader; @@ -108,18 +111,4 @@ public class PluginIsolationLauncher extends AbstractLauncher } } - @Override - protected SpringPluginHook launch(ClassLoader classLoader, String... args) throws Exception { - pluginLaunchInvolved.before(pluginInsideInfo, classLoader); - try { - SpringPluginHook springPluginHook = (SpringPluginHook) new PluginMethodRunner(pluginInteractive) - .run(classLoader); - pluginLaunchInvolved.after(pluginInsideInfo, classLoader, springPluginHook); - return new SpringPluginHookWrapper(springPluginHook, pluginInsideInfo, pluginLaunchInvolved, classLoader); - } catch (Throwable throwable){ - pluginLaunchInvolved.failure(pluginInsideInfo,classLoader, throwable); - throw throwable; - } - } - } diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginMainResourcePatternDefiner.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginMainResourcePatternDefiner.java index f32c6b0381f90e03a9e9949825b06fe9eb79c98b..d4696579aeb9659309af125e8d00e22873e63a30 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginMainResourcePatternDefiner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginMainResourcePatternDefiner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.Set; /** * 定义插件从主程序加载资源的匹配 * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ public class PluginMainResourcePatternDefiner implements MainResourcePatternDefiner { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginMethodRunner.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginMethodRunner.java index e91403f2eb45bf06c3ec1d34835b5f1b032ed46f..593518641b0c0aebfcaeaaad34c2642bf322b3c8 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginMethodRunner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/PluginMethodRunner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +30,7 @@ import java.lang.reflect.Method; /** * 插件方法运行器。 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginMethodRunner extends MethodRunner { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/RegistryInfo.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/RegistryInfo.java index b604517822509eaa6335d5c05bea3ed97efb0c1d..ddea6327e52e5e3d3662a75940dc90d8a6a416f5 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/RegistryInfo.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/RegistryInfo.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.util.function.Supplier; /** * 注册的信息接口 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface RegistryInfo { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/SpringPluginHookWrapper.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/SpringPluginHookWrapper.java index a2c6b95f6569f39500e31d66cf7cb5cd03ae26bb..6b977ea695c3e0d1d4e785ae11f78a5f4bc22c5e 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/SpringPluginHookWrapper.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/SpringPluginHookWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/DefaultPluginLaunchInvolved.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/DefaultPluginLaunchInvolved.java index 4e25965d05cde366b9ff971580bd6fbf637f278e..25184b1dedefbbe7484da74dc782888e52a6e569 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/DefaultPluginLaunchInvolved.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/DefaultPluginLaunchInvolved.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginApplicationContextGetter.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginApplicationContextGetter.java index 165db50b1ab748175ec892f6f035c9a4762537db..a1296c833c08bd536851a3c44f03e84171a4eeff 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginApplicationContextGetter.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginApplicationContextGetter.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,8 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; /** + * 插件 applicationContext 获取者 + * * @author starBlues * @since 3.0.0 * @version 3.1.0 diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginLaunchInvolved.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginLaunchInvolved.java index 5e3bbe641f4ca49d2b6ccfc9d1b9a30d5dd21a80..5ff3d5e5756e940eeaeb840e85234c52a2b04d6c 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginLaunchInvolved.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginLaunchInvolved.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import org.springframework.context.support.GenericApplicationContext; /** * 插件启动前后介入 + * * @author starBlues * @since 3.0.0 * @version 3.1.0 diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginLaunchInvolvedFactory.java b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginLaunchInvolvedFactory.java index 67bc9cceb4a47855002cadf8883872ca8e31eb78..dbbcd94e248728565ef0284aa551b16dacba1c6c 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginLaunchInvolvedFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/launcher/plugin/involved/PluginLaunchInvolvedFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/BasePluginScanner.java b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/BasePluginScanner.java index a17c7563e106c0c918a20bee8c86845c5c67721b..47ffca1c7c8dc8791dce44c761e85fcfc34b575e 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/BasePluginScanner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/BasePluginScanner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,7 @@ import java.util.List; /** * 基本的插件扫描者 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class BasePluginScanner implements PluginScanner{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/ComposePathResolve.java b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/ComposePathResolve.java index 56cee67bc727ed49ea371d56d61f237efa5df9a0..71ef46c6023691c08cfc25b1abeeda7d1de5bb6a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/ComposePathResolve.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/ComposePathResolve.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +26,7 @@ import java.util.List; /** * 组合的PathResolve * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ComposePathResolve implements PathResolve{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/DevPathResolve.java b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/DevPathResolve.java index 6c1e9444b0f679846ee2c8312212b6dcdac5a0df..9d68489711396ac633d5adf18ea6b6d1d626e93b 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/DevPathResolve.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/DevPathResolve.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import java.util.List; /** * 开发环境路径解决器 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class DevPathResolve implements PathResolve{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/PathResolve.java b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/PathResolve.java index e6be248da5150300ac25cdb41f44124ea9127aad..810484a09d19d80dc9500506ba3c53b507afd51a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/PathResolve.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/PathResolve.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import java.nio.file.Path; /** * 从路径中发现合适的插件 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PathResolve { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/PluginScanner.java b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/PluginScanner.java index 32b4069cf62a068e0603350c1de342cf647d7987..04ee682c6f1aa5fc0d552d3d042bc9682050e80a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/PluginScanner.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/PluginScanner.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.util.List; /** * 插件扫描者 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public interface PluginScanner { diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/ProdPathResolve.java b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/ProdPathResolve.java index 9a8f7a73f3891bb66beec839327116b7ce850927..c1efa789c98ea8ed7f602289d77499b5bd8453e4 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/scanner/ProdPathResolve.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/scanner/ProdPathResolve.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import java.util.List; /** * 生产环境目录解决器 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class ProdPathResolve implements PathResolve{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/version/SemverVersionInspector.java b/spring-brick/src/main/java/com/gitee/starblues/core/version/SemverVersionInspector.java index 70dfde34696f175790e7ce88a725001c014dd0bb..9c7247315a032cdf8c6c2bac713a97c0b5d23194 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/version/SemverVersionInspector.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/version/SemverVersionInspector.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,9 @@ import com.github.zafarkhaja.semver.Version; /** * Semver标准版本检查 + * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public class SemverVersionInspector implements VersionInspector{ diff --git a/spring-brick/src/main/java/com/gitee/starblues/core/version/VersionInspector.java b/spring-brick/src/main/java/com/gitee/starblues/core/version/VersionInspector.java index b1e1dd8aa60ed85a8049529ef79bac55c763460f..87d95c524c1069275f98381c89f64eb521f3aac9 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/core/version/VersionInspector.java +++ b/spring-brick/src/main/java/com/gitee/starblues/core/version/VersionInspector.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,9 @@ import com.gitee.starblues.core.exception.PluginException; /** * 版本检查 + * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public interface VersionInspector { diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/AutoIntegrationConfiguration.java b/spring-brick/src/main/java/com/gitee/starblues/integration/AutoIntegrationConfiguration.java index 39e3af8d19f5c50d0ac994b1d7969c0aba1e8a84..b0847e3ebaba9cc6fc22de91a1370e3d85bada29 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/AutoIntegrationConfiguration.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/AutoIntegrationConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,9 @@ import java.util.Set; /** * 自动集成的配置 + * * @author starBlues + * @since 3.0.0 * @version 3.0.3 */ @EqualsAndHashCode(callSuper = true) @@ -127,13 +129,32 @@ public class AutoIntegrationConfiguration extends DefaultIntegrationConfiguratio @Value("${exactVersion:false}") private Boolean exactVersion; + /** + * 插是否扫描 swagger 接口 + */ + @Value("${pluginSwaggerScan:true}") + private Boolean pluginSwaggerScan; + + + /** + * 插件的配置文件 Profile 是否跟随主程序的 Profile 配置动态切换 + */ + @Value("${pluginFollowProfile:false}") + private Boolean pluginFollowProfile; + + /** + * 插件日志打印是否跟随主程序 + */ + @Value("${pluginFollowLog:false}") + private Boolean pluginFollowLog; + /** * 对插件启动时进行解密校验配置。默认为不启用 */ private DecryptConfiguration decrypt; @Override - public boolean enable() { + public Boolean enable() { if(enable == null){ return true; } @@ -181,7 +202,7 @@ public class AutoIntegrationConfiguration extends DefaultIntegrationConfiguratio } @Override - public boolean enablePluginIdRestPathPrefix() { + public Boolean enablePluginIdRestPathPrefix() { if(enablePluginIdRestPathPrefix == null){ return super.enablePluginIdRestPathPrefix(); } else { @@ -210,10 +231,34 @@ public class AutoIntegrationConfiguration extends DefaultIntegrationConfiguratio } @Override - public boolean exactVersion() { + public Boolean exactVersion() { return exactVersion; } + @Override + public Boolean pluginSwaggerScan() { + if(pluginSwaggerScan == null){ + return super.pluginSwaggerScan(); + } + return pluginSwaggerScan; + } + + @Override + public Boolean pluginFollowProfile() { + if(pluginFollowProfile == null){ + return super.pluginFollowProfile(); + } + return pluginFollowProfile; + } + + @Override + public Boolean pluginFollowLog() { + if(pluginFollowLog == null){ + return super.pluginFollowLog(); + } + return pluginFollowLog; + } + @Override public DecryptConfiguration decrypt() { if(decrypt == null){ diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/DefaultIntegrationConfiguration.java b/spring-brick/src/main/java/com/gitee/starblues/integration/DefaultIntegrationConfiguration.java index b99e55e558570910fed25ffe1c8bf1363b9841ac..bd069748f76317e7c157b28b08a7f562c04de261 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/DefaultIntegrationConfiguration.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/DefaultIntegrationConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,7 @@ import com.gitee.starblues.integration.decrypt.DecryptConfiguration; import com.gitee.starblues.utils.Assert; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Set; @@ -28,16 +29,17 @@ import java.util.Set; * 默认的插件集成配置。给非必须配置设置了默认值 * * @author starBlues + * @since 3.0.0 * @version 3.0.1 */ public abstract class DefaultIntegrationConfiguration implements IntegrationConfiguration{ public static final String DEFAULT_PLUGIN_REST_PATH_PREFIX = "plugins"; - public static final boolean DEFAULT_ENABLE_PLUGIN_ID_REST_PATH_PREFIX = true; + public static final Boolean DEFAULT_ENABLE_PLUGIN_ID_REST_PATH_PREFIX = Boolean.TRUE; @Override - public boolean enable() { - return true; + public Boolean enable() { + return Boolean.TRUE; } @Override @@ -63,23 +65,23 @@ public abstract class DefaultIntegrationConfiguration implements IntegrationConf } @Override - public boolean enablePluginIdRestPathPrefix() { + public Boolean enablePluginIdRestPathPrefix() { return DEFAULT_ENABLE_PLUGIN_ID_REST_PATH_PREFIX; } @Override public Set enablePluginIds() { - return null; + return Collections.emptySet(); } @Override public Set disablePluginIds() { - return null; + return Collections.emptySet(); } @Override public List sortInitPluginIds() { - return null; + return Collections.emptyList(); } @Override @@ -88,8 +90,23 @@ public abstract class DefaultIntegrationConfiguration implements IntegrationConf } @Override - public boolean exactVersion() { - return false; + public Boolean exactVersion() { + return Boolean.FALSE; + } + + @Override + public Boolean pluginSwaggerScan() { + return Boolean.TRUE; + } + + @Override + public Boolean pluginFollowProfile() { + return Boolean.FALSE; + } + + @Override + public Boolean pluginFollowLog() { + return Boolean.FALSE; } @Override diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/ExtendPointConfiguration.java b/spring-brick/src/main/java/com/gitee/starblues/integration/ExtendPointConfiguration.java index 1d0f5d77eac0274d8400b622535f65aa12d3b75f..ec930b65855a7c509533a1147aaf0d7d7bc1e37a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/ExtendPointConfiguration.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/ExtendPointConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -86,7 +86,7 @@ public class ExtendPointConfiguration { @Bean public MainResourceMatcher mainResourceMatcher(){ return new DefaultMainResourceMatcher(new DefaultMainResourcePatternDefiner( - configuration.mainPackage(), + configuration, applicationContext )); } diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/ExtendPointWebConfiguration.java b/spring-brick/src/main/java/com/gitee/starblues/integration/ExtendPointWebConfiguration.java index 9c198e3793606b04624cba07dff84ccddc9ef354..dd65b8aa050b79ccaa5989096b3891251e7d9db4 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/ExtendPointWebConfiguration.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/ExtendPointWebConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -76,6 +76,7 @@ public class ExtendPointWebConfiguration { } @ConditionalOnClass({ DocumentationPluginsBootstrapper.class }) + @ConditionalOnProperty(name = "plugin.pluginSwaggerScan", havingValue = "true", matchIfMissing = true) public static class SwaggerListenerConfiguration { private final GenericApplicationContext applicationContext; diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/IntegrationConfiguration.java b/spring-brick/src/main/java/com/gitee/starblues/integration/IntegrationConfiguration.java index a866e79bf057d036cdc681dd45f867371a6fde5b..65b4cacb7dcc8d1c6148d6e1ae177b2d9b96a515 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/IntegrationConfiguration.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/IntegrationConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -37,7 +37,7 @@ public interface IntegrationConfiguration { * 是否启用该插件框架 * @return true 启用, false 禁用 */ - boolean enable(); + Boolean enable(); /** * 运行环境。运行项目时的模式。分为开发环境(Dev)、生产环境(Prod) @@ -82,7 +82,7 @@ public interface IntegrationConfiguration { * 即为: /pathPrefix/pluginId/** * @return boolean */ - boolean enablePluginIdRestPathPrefix(); + Boolean enablePluginIdRestPathPrefix(); /** * 启用的插件id @@ -116,7 +116,25 @@ public interface IntegrationConfiguration { * 默认为false * @return true or false */ - boolean exactVersion(); + Boolean exactVersion(); + + /** + * 是否扫描插件 swagger 接口 + * @return true 启动, false 禁用。默认启用 + */ + Boolean pluginSwaggerScan(); + + /** + * 插件的配置文件 Profile 是否跟随主程序的 Profile 配置动态切换 + * @return true: 跟随, false: 不跟随 + */ + Boolean pluginFollowProfile(); + + /** + * 插件日志打印是否跟随主程序 + * @return true: 跟随, false: 不跟随 + */ + Boolean pluginFollowLog(); /** * 解密配置 diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/SpringBootPluginStarter.java b/spring-brick/src/main/java/com/gitee/starblues/integration/SpringBootPluginStarter.java index bf12f778f6c8dcd2054a5b5262f7641c8d1682c9..497f3e71fa9d1b90c2a1e453d4505604de3bb46c 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/SpringBootPluginStarter.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/SpringBootPluginStarter.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/application/AbstractPluginApplication.java b/spring-brick/src/main/java/com/gitee/starblues/integration/application/AbstractPluginApplication.java index b666cfb8d660ca027723f7f62326f6839c7effca..0f8fce9c79046a62814e145cbafd67ac3901641f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/application/AbstractPluginApplication.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/application/AbstractPluginApplication.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/application/AutoPluginApplication.java b/spring-brick/src/main/java/com/gitee/starblues/integration/application/AutoPluginApplication.java index 3d54fefeb82e2b4658f309734eb579eea0fc13f2..c0589698ae13a23323f5ac1b47c0a005e9fcf966 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/application/AutoPluginApplication.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/application/AutoPluginApplication.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/application/DefaultPluginApplication.java b/spring-brick/src/main/java/com/gitee/starblues/integration/application/DefaultPluginApplication.java index f0c46ce24ab14a3518b45980e81a80d06d2c72ba..f0346b154c0691d0354af36d4bc89cd5688dd938 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/application/DefaultPluginApplication.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/application/DefaultPluginApplication.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/application/PluginApplication.java b/spring-brick/src/main/java/com/gitee/starblues/integration/application/PluginApplication.java index e41550329b70214d81eea7251313a3b3de5d4ca4..38d5194d74bd5bebf2306cdbaefb9b782b1f297a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/application/PluginApplication.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/application/PluginApplication.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptConfiguration.java b/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptConfiguration.java index 111210212c5e126773d76821832427e5d3e65687..eafb1b880474ec82851798144428a59e9f533864 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptConfiguration.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptPluginConfiguration.java b/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptPluginConfiguration.java index 5b769f89d1673f548a179c7fef4c0c394feca621..d77e26c38740442394cebabee49b6f5ce38b34c1 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptPluginConfiguration.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/decrypt/DecryptPluginConfiguration.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/DefaultInitializerListener.java b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/DefaultInitializerListener.java index 43ca5c09d195d52be66e101dc8b152e9b737c173..4513a9a7371bafd4fa4f4e351d5da593ad4b06f0 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/DefaultInitializerListener.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/DefaultInitializerListener.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/DefaultPluginListenerFactory.java b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/DefaultPluginListenerFactory.java index bce94ea8b3c3aa4e7958eb8c3d0f0240f7988048..78bdbb39a0a9a5e73e33800665a1f0cd286c990a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/DefaultPluginListenerFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/DefaultPluginListenerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginInitializerListener.java b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginInitializerListener.java index 1da690a262457dd461cd8e8f9c1a7f8597bf2904..134e115cac2ceaa80b52c9dfbab934867664185f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginInitializerListener.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginInitializerListener.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginInitializerListenerFactory.java b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginInitializerListenerFactory.java index 01d869836d515e82a2589b31b2e18c8ce94050e9..677d9555266cbb612d408ef94f2b729e917a0a18 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginInitializerListenerFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginInitializerListenerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginListener.java b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginListener.java index 53bd629af9ac749769a090c3361f259b729a085c..bcf9ceb97fe59e4a8b84abdd779b7ce79dc7b43c 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginListener.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginListener.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginListenerFactory.java b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginListenerFactory.java index e5292627f761dd334256216516c9a2b6502378ef..9beafdc80fce05b9c24e19e8bc3742d6ed1f6dab 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginListenerFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/PluginListenerFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/SwaggerListener.java b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/SwaggerListener.java index a75d6fbadfa07cd2fee27ba68cf37c2899310357..6d07ada522e6644e01bfd1c6bc479c92792c9d2d 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/listener/SwaggerListener.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/listener/SwaggerListener.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,8 @@ package com.gitee.starblues.integration.listener; import com.gitee.starblues.core.PluginInfo; import com.gitee.starblues.core.descriptor.PluginDescriptor; +import com.gitee.starblues.integration.AutoIntegrationConfiguration; +import com.gitee.starblues.integration.IntegrationConfiguration; import com.gitee.starblues.loader.utils.ObjectUtils; import com.gitee.starblues.utils.MsgUtils; import com.gitee.starblues.utils.SpringBeanUtils; @@ -51,7 +53,6 @@ public class SwaggerListener implements PluginListener{ private final Logger log = LoggerFactory.getLogger(this.getClass()); private final ApplicationContext mainApplicationContext; - private static List parameterList = new ArrayList<>(); /** @@ -76,19 +77,20 @@ public class SwaggerListener implements PluginListener{ @Override public void startSuccess(PluginInfo pluginInfo) { PluginDescriptor descriptor = pluginInfo.getPluginDescriptor(); - Docket docket = this.createDocket(descriptor); - String groupName = docket.getGroupName(); - PluginRegistry pluginRegistry = this.getPluginRegistry(); - List plugins = pluginRegistry.getPlugins(); - List newPlugins = new ArrayList<>(); - for(DocumentationPlugin plugin : plugins){ - if(plugin.getGroupName().equals(groupName)){ - continue; - } - newPlugins.add(plugin); - } - newPlugins.add(docket); try { + Docket docket = this.createDocket(descriptor); + String groupName = docket.getGroupName(); + PluginRegistry pluginRegistry = this.getPluginRegistry(); + List plugins = pluginRegistry.getPlugins(); + List newPlugins = new ArrayList<>(); + for(DocumentationPlugin plugin : plugins){ + if(plugin.getGroupName().equals(groupName)){ + continue; + } + newPlugins.add(plugin); + } + newPlugins.add(docket); + Field field = PluginRegistrySupport.class.getDeclaredField("plugins"); field.setAccessible(true); field.set(pluginRegistry, newPlugins); @@ -96,9 +98,9 @@ public class SwaggerListener implements PluginListener{ if(!pluginInfo.isFollowSystem() || pluginInfo.getStopTime() != null){ this.refresh(); } - log.debug("插件[{}]注册到 Swagger 成功", pluginInfo.getPluginId()); - } catch (NoSuchFieldException | IllegalAccessException e) { - log.error("插件[{}]注册到 Swagger 失败,错误为:{}", pluginInfo.getPluginId(),e.getMessage()); + log.debug("插件[{}]注册到 Swagger 成功", MsgUtils.getPluginUnique(descriptor)); + } catch (Exception e) { + log.error("插件[{}]注册到 Swagger 失败,错误为:{}", MsgUtils.getPluginUnique(descriptor) ,e.getMessage()); } } @@ -106,25 +108,24 @@ public class SwaggerListener implements PluginListener{ public void stopSuccess(PluginInfo pluginInfo) { PluginDescriptor descriptor = pluginInfo.getPluginDescriptor(); String groupName = getGroupName(descriptor); - - PluginRegistry pluginRegistry = this.getPluginRegistry(); - List plugins = pluginRegistry.getPlugins(); - List newPlugins = new ArrayList<>(); - for(DocumentationPlugin plugin : plugins){ - if(groupName.equalsIgnoreCase(plugin.getGroupName())){ - continue; - } - newPlugins.add(plugin); - } try{ + PluginRegistry pluginRegistry = this.getPluginRegistry(); + List plugins = pluginRegistry.getPlugins(); + List newPlugins = new ArrayList<>(); + for(DocumentationPlugin plugin : plugins){ + if(groupName.equalsIgnoreCase(plugin.getGroupName())){ + continue; + } + newPlugins.add(plugin); + } + Field field = PluginRegistrySupport.class.getDeclaredField("plugins"); field.setAccessible(true); field.set(pluginRegistry, newPlugins); this.refresh(); log.debug("插件[{}]从 Swagger 移除成功", MsgUtils.getPluginUnique(descriptor)); - } - catch (NoSuchFieldException | IllegalAccessException e) { + } catch (Exception e) { log.error("插件[{}]从 Swagger 移除失败,错误为:{}", MsgUtils.getPluginUnique(descriptor), e.getMessage()); } } @@ -157,7 +158,12 @@ public class SwaggerListener implements PluginListener{ * @return PluginRegistry */ private PluginRegistry getPluginRegistry(){ - return SpringBeanUtils.getExistBean(mainApplicationContext,"documentationPluginRegistry"); + PluginRegistry registry = + SpringBeanUtils.getExistBean(mainApplicationContext, "documentationPluginRegistry"); + if(registry != null){ + return registry; + } + throw new IllegalStateException("项目依赖的 Swagger 版本不支持刷新插件接口, 请切换版本"); } /** diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/DefaultPluginOperator.java b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/DefaultPluginOperator.java index 11e1c827df0312327657f1d1d0b80cb9a4189059..a82bb51fb3e819d98ec9d738c10ae65563e8058d 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/DefaultPluginOperator.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/DefaultPluginOperator.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/PluginOperator.java b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/PluginOperator.java index c16758bbd0be56f9d4f81f9fc46450a2fe58da50..787b548b90b366db5de85209047a29842afea5a0 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/PluginOperator.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/PluginOperator.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/PluginOperatorWrapper.java b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/PluginOperatorWrapper.java index c96554b47d626b5a8d31f6cadd3fc9c4bdd7dc05..e8a5bab33f073368d06c92d6a94d945796c58fc1 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/PluginOperatorWrapper.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/PluginOperatorWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadByInputStreamParam.java b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadByInputStreamParam.java index 356356d8739f5e928eb355c3fa6675f077d7fc5c..97b3dd4f067e14d3566f6a38cf17e6792702c130 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadByInputStreamParam.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadByInputStreamParam.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadByMultipartFileParam.java b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadByMultipartFileParam.java index b9b7c47aa6a8dfd29214ceeab400d760bd60abde..5be7fd79bf241ab76944a052fa01aba4c903769a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadByMultipartFileParam.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadByMultipartFileParam.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadParam.java b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadParam.java index 0f2b418ce87aeaeb13d381d9b95403d0ae9e0a87..a9576ab3dd71b709761c651500a87c9128f394e2 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadParam.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/operator/upload/UploadParam.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/user/BeanWrapper.java b/spring-brick/src/main/java/com/gitee/starblues/integration/user/BeanWrapper.java index 6fb78a4664ec0bb170363eafdf6ee0658e46f6eb..73f9d5d2d5a8a054509a042333b1facc5dd52641 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/user/BeanWrapper.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/user/BeanWrapper.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/user/DefaultPluginUser.java b/spring-brick/src/main/java/com/gitee/starblues/integration/user/DefaultPluginUser.java index a4a1389c20c3a34842a1d4d158dfab9dfe61b872..7639555096dd051475763fe85b304ae9e6ddeb6d 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/user/DefaultPluginUser.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/user/DefaultPluginUser.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public class DefaultPluginUser implements PluginUser{ applicationContexts.forEach((k,v)->{ Object existBean = SpringBeanCustomUtils.getExistBean(v, name); if(existBean != null){ - pluginBeans.put(k, v); + pluginBeans.put(k, existBean); } }); return new BeanWrapper<>(mainBean, pluginBeans); diff --git a/spring-brick/src/main/java/com/gitee/starblues/integration/user/PluginUser.java b/spring-brick/src/main/java/com/gitee/starblues/integration/user/PluginUser.java index 1864e8a8feca6c9e9372c4db926bd1e1b5935c6c..c786e1ac56204bfe6ab9e7044734109e1b500adf 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/integration/user/PluginUser.java +++ b/spring-brick/src/main/java/com/gitee/starblues/integration/user/PluginUser.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/ApplicationContext.java b/spring-brick/src/main/java/com/gitee/starblues/spring/ApplicationContext.java index af30214e2908262d5a889b97bdb0d76e0f62d960..e9ad3361bb3ec866650880f2edf13189d560a82d 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/ApplicationContext.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/ApplicationContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/ApplicationContextProxy.java b/spring-brick/src/main/java/com/gitee/starblues/spring/ApplicationContextProxy.java index 88e6ea5c5940e616c8557996727e317fb3f3a559..1330a08d641677d57f3ad6b175c6b067d092d96d 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/ApplicationContextProxy.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/ApplicationContextProxy.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/CacheJdkSameTypeParamProxyFactory.java b/spring-brick/src/main/java/com/gitee/starblues/spring/CacheJdkSameTypeParamProxyFactory.java index 5c3f7f76091a3e4e48a59b5a1b7c056540a6d3c8..910c9f577790e9b22ea97f9758f507813e397401 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/CacheJdkSameTypeParamProxyFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/CacheJdkSameTypeParamProxyFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/GenericApplicationContext.java b/spring-brick/src/main/java/com/gitee/starblues/spring/GenericApplicationContext.java index 71590fa1283666f8d0c175262fa9ff517f3f90ba..6dd021b293fe0a784eba0e434749ad8e8abe9b1f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/GenericApplicationContext.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/GenericApplicationContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/JdkSameTypeParamProxyFactory.java b/spring-brick/src/main/java/com/gitee/starblues/spring/JdkSameTypeParamProxyFactory.java index 2e9cfd0a2883e0729429b49e7b535eae6d6c26f6..ffef67f922e8331952e0cb5f48724158e6403478 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/JdkSameTypeParamProxyFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/JdkSameTypeParamProxyFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/MainApplicationContext.java b/spring-brick/src/main/java/com/gitee/starblues/spring/MainApplicationContext.java index b6d6dec7441d4ef5a58f0635261580edbb344531..cdedc064ea7094ffc34cb92727056bf64e179a94 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/MainApplicationContext.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/MainApplicationContext.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,6 +17,8 @@ package com.gitee.starblues.spring; import com.gitee.starblues.spring.environment.EnvironmentProvider; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import java.util.Map; import java.util.Objects; @@ -35,13 +37,23 @@ public interface MainApplicationContext extends ApplicationContext { */ Map> getConfigurableEnvironment(); - /** * 得到主程序配置的 Provider * @return EnvironmentProvider */ EnvironmentProvider getEnvironmentProvider(); + /** + * 返回主程序配置的Profile配置 + * @return String 数组 + */ + String[] getActiveProfiles(); + + /** + * 返回主程序默认的Profile配置 + * @return String 数组 + */ + String[] getDefaultProfiles(); /** * 从主程序获取依赖 @@ -64,4 +76,23 @@ public interface MainApplicationContext extends ApplicationContext { */ Object getSourceApplicationContext(); + /** + * 是否能注册Controller + * @return boolean + */ + boolean isRegisterController(); + + /** + * 获取主程序的 RequestMappingHandlerMapping + * @return RequestMappingHandlerMapping + */ + RequestMappingHandlerMapping getRequestMappingHandlerMapping(); + + /** + * 获取主程序的 RequestMappingHandlerAdapter + * @return RequestMappingHandlerAdapter + */ + RequestMappingHandlerAdapter getRequestMappingHandlerAdapter(); + + } diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/MainApplicationContextProxy.java b/spring-brick/src/main/java/com/gitee/starblues/spring/MainApplicationContextProxy.java index f876ffece57eb64796cfb6b325e24f45f4f884f8..96f7b583388b7d9b68340dacaf320e45bf1a2231 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/MainApplicationContextProxy.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/MainApplicationContextProxy.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,8 @@ package com.gitee.starblues.spring; import com.gitee.starblues.spring.environment.EnvironmentProvider; import com.gitee.starblues.spring.environment.MainSpringBootEnvironmentProvider; import com.gitee.starblues.utils.ObjectUtils; +import com.gitee.starblues.utils.SpringBeanUtils; +import lombok.extern.slf4j.Slf4j; import org.springframework.boot.web.reactive.context.AnnotationConfigReactiveWebServerApplicationContext; import org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext; import org.springframework.context.support.GenericApplicationContext; @@ -26,25 +28,31 @@ import org.springframework.core.env.ConfigurableEnvironment; import org.springframework.core.env.EnumerablePropertySource; import org.springframework.core.env.MutablePropertySources; import org.springframework.core.env.PropertySource; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; +import java.util.*; /** * 主程序 ApplicationContext 的实现 * @author starBlues * @version 3.0.1 */ +@Slf4j public class MainApplicationContextProxy extends ApplicationContextProxy implements MainApplicationContext{ + private final static String REQUEST_MAPPING_BANE_NAME = "requestMappingHandlerMapping"; + private final static String REQUEST_MAPPING_ADAPTER_BANE_NAME = "requestMappingHandlerAdapter"; + private final GenericApplicationContext applicationContext; private final boolean isWebEnvironment; + private final boolean isRegisterController; + private final RequestMappingHandlerMapping requestMappingHandlerMapping; + private final RequestMappingHandlerAdapter requestMappingHandlerAdapter; + public MainApplicationContextProxy(GenericApplicationContext applicationContext) { - super(applicationContext.getBeanFactory()); - this.applicationContext = applicationContext; - this.isWebEnvironment = getIsWebEnvironment(applicationContext); + this(applicationContext, null); } public MainApplicationContextProxy(GenericApplicationContext applicationContext, @@ -52,6 +60,22 @@ public class MainApplicationContextProxy extends ApplicationContextProxy impleme super(applicationContext.getBeanFactory(), autoCloseable); this.applicationContext = applicationContext; this.isWebEnvironment = getIsWebEnvironment(applicationContext); + if(isWebEnvironment){ + this.requestMappingHandlerMapping = SpringBeanUtils.getExistBean( + applicationContext, REQUEST_MAPPING_BANE_NAME, RequestMappingHandlerMapping.class); + this.requestMappingHandlerAdapter = SpringBeanUtils.getExistBean( + applicationContext, REQUEST_MAPPING_ADAPTER_BANE_NAME, RequestMappingHandlerAdapter.class); + if(this.requestMappingHandlerMapping == null || this.requestMappingHandlerAdapter == null){ + log.error("主程序环境异常, 插件不能注册 Controller 接口!"); + isRegisterController = false; + } else { + isRegisterController = true; + } + } else { + this.isRegisterController = false; + this.requestMappingHandlerMapping = null; + this.requestMappingHandlerAdapter = null; + } } @Override @@ -81,6 +105,16 @@ public class MainApplicationContextProxy extends ApplicationContextProxy impleme return new MainSpringBootEnvironmentProvider(applicationContext.getEnvironment()); } + @Override + public String[] getActiveProfiles() { + return applicationContext.getEnvironment().getActiveProfiles(); + } + + @Override + public String[] getDefaultProfiles() { + return applicationContext.getEnvironment().getDefaultProfiles(); + } + @Override public Object resolveDependency(String requestingBeanName, Class dependencyType) { try { @@ -100,6 +134,21 @@ public class MainApplicationContextProxy extends ApplicationContextProxy impleme return applicationContext; } + @Override + public boolean isRegisterController() { + return isRegisterController; + } + + @Override + public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { + return requestMappingHandlerMapping; + } + + @Override + public RequestMappingHandlerAdapter getRequestMappingHandlerAdapter() { + return requestMappingHandlerAdapter; + } + @Override public Object getSourceBeanFactory() { return applicationContext.getBeanFactory(); diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/ProxyFactory.java b/spring-brick/src/main/java/com/gitee/starblues/spring/ProxyFactory.java index 9ff2087a7692412a1f49d82f6462ed8a9503f303..e2c9db3501e7d00bc71514e010f2b6cacff8f882 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/ProxyFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/ProxyFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/ResolvePluginThreadClassLoader.java b/spring-brick/src/main/java/com/gitee/starblues/spring/ResolvePluginThreadClassLoader.java index f2191e979eb299e02512579b140d724fb94bbe41..dfd84e5ea32cb92a8a49831134066695463d38b0 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/ResolvePluginThreadClassLoader.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/ResolvePluginThreadClassLoader.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/SpringBeanFactory.java b/spring-brick/src/main/java/com/gitee/starblues/spring/SpringBeanFactory.java index 545728f1059c6cbed658b04aed8c874d46d27cee..fed6f7ca4a0c9712e41eb79d487ed15b472a515c 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/SpringBeanFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/SpringBeanFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/SpringPluginHook.java b/spring-brick/src/main/java/com/gitee/starblues/spring/SpringPluginHook.java index 54a121df0a5fb8439b6e6a676ae504e9e2bf0985..bda373f27ca2dda141f095fe86e0615463f614f0 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/SpringPluginHook.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/SpringPluginHook.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/WebConfig.java b/spring-brick/src/main/java/com/gitee/starblues/spring/WebConfig.java index a056f33bce5d528d3ecd856b10967bca3f265814..1cc006e35ed7c99854af31ffba1f383396c25b3f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/WebConfig.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/WebConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/environment/EmptyEnvironmentProvider.java b/spring-brick/src/main/java/com/gitee/starblues/spring/environment/EmptyEnvironmentProvider.java index 69ca692d1c4d327f9d42bcdf4cbba9f9c4f65922..a9ed7b725d44516718d268b8a9cb94b06f766ea2 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/environment/EmptyEnvironmentProvider.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/environment/EmptyEnvironmentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/environment/EnvironmentProvider.java b/spring-brick/src/main/java/com/gitee/starblues/spring/environment/EnvironmentProvider.java index a4e1facb83aa4f4340098a90b66e4d9b5c90abc8..8ab6be9991fe45c98e2e7e8211997cca1dcc12ed 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/environment/EnvironmentProvider.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/environment/EnvironmentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/environment/MainSpringBootEnvironmentProvider.java b/spring-brick/src/main/java/com/gitee/starblues/spring/environment/MainSpringBootEnvironmentProvider.java index 84106b311e1410101e580cb9460a4cc1130fcae4..e126ba748df852439dfe8555dfe8980c1612305f 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/environment/MainSpringBootEnvironmentProvider.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/environment/MainSpringBootEnvironmentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/environment/MapEnvironmentProvider.java b/spring-brick/src/main/java/com/gitee/starblues/spring/environment/MapEnvironmentProvider.java index 6a25cb14b55eba3eeafdd791377eacab9c3ec777..095462c908eee3b9ea5cb86fe84a4898fb6b9bd8 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/environment/MapEnvironmentProvider.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/environment/MapEnvironmentProvider.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/DefaultExtractFactory.java b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/DefaultExtractFactory.java index ed5d69bf75d92e0e6a5479c461c272b8296985fb..93d846f1108bea6de16c4fd10b1de6098268e55d 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/DefaultExtractFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/DefaultExtractFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/DefaultOpExtractFactory.java b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/DefaultOpExtractFactory.java index 73096b2efb8095f2253046cb674d08978dea14ea..0aacb0c658390578b25cce2511b465bf51bf9df2 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/DefaultOpExtractFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/DefaultOpExtractFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/ExtractCoordinate.java b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/ExtractCoordinate.java index 813998354556bd7a86614165948136db91aef11c..01755e9a2403833a654844bdc95b44b44a2c92f3 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/ExtractCoordinate.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/ExtractCoordinate.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/ExtractFactory.java b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/ExtractFactory.java index 898c5727d5de2495740a9db4bc30a857aa2010f4..7090fa97ba1ffd11165bf024159b9d4c87b92367 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/ExtractFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/ExtractFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/OpExtractFactory.java b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/OpExtractFactory.java index 0a934b63208a618113673302d04cdad9e69a16ca..1ac04fae67b40d648f7beade0a4dad6c4addcf30 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/extract/OpExtractFactory.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/extract/OpExtractFactory.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/DefaultInvokeSupperCache.java b/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/DefaultInvokeSupperCache.java index 2917f8d79c6326c14f2fe7b024f4fe1fc472bd32..e993667373b2e8952a6be5e0526501d73c47f9d5 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/DefaultInvokeSupperCache.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/DefaultInvokeSupperCache.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/InvokeSupperCache.java b/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/InvokeSupperCache.java index 8422c5c8ca00eb1dc78430fed22960e2d435af7b..5e8d9234435712ba5b91e238549a3bbdb2e41d91 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/InvokeSupperCache.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/InvokeSupperCache.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/SupperCache.java b/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/SupperCache.java index de290f06ff7a3fb3ebc56d63cfe07089cd876be3..019aed04f12ebc3fdd2fd8f20ce633099e8d6e7b 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/SupperCache.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/invoke/SupperCache.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginResource.java b/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginResource.java index d7e9bf9c75c09c0c7c2c3321a521eb5b7442fa34..533137fc3b917b050d81fc2aea3fa9a5cdf8cf7d 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginResource.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginResource.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceConfig.java b/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceConfig.java index 75eeafd646c33b6c343bfb15105dc5d60bf60a9f..5be0e766a95f89b426d37abd4ce3419368e70133 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceConfig.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceResolver.java b/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceResolver.java index 09232f34992a652bd63a0fb90586a5d6b5fe753f..2d4243b453dd5b54d65f1234124ef3933fea8838 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceResolver.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceResolver.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceWebMvcConfigurer.java b/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceWebMvcConfigurer.java index 984a1984307cd2304c39292fae0d82474c2d371f..c04dc7f4435039499dd9e046eeb7821798303892 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceWebMvcConfigurer.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/web/PluginStaticResourceWebMvcConfigurer.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/web/thymeleaf/PluginThymeleafInvolved.java b/spring-brick/src/main/java/com/gitee/starblues/spring/web/thymeleaf/PluginThymeleafInvolved.java index 333f0afc32f9ef5ef10763dc1bea74b93b2ffaa0..350a3f92cae8389ef40f0336149eb205d43434d8 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/web/thymeleaf/PluginThymeleafInvolved.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/web/thymeleaf/PluginThymeleafInvolved.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/spring/web/thymeleaf/ThymeleafConfig.java b/spring-brick/src/main/java/com/gitee/starblues/spring/web/thymeleaf/ThymeleafConfig.java index 479b1c7f62cb478f44df27e8587891683e51e058..a76ceadef1b3c2daeb2d02f61e20abeedd3095bd 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/spring/web/thymeleaf/ThymeleafConfig.java +++ b/spring-brick/src/main/java/com/gitee/starblues/spring/web/thymeleaf/ThymeleafConfig.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/AnnotationsUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/AnnotationsUtils.java index 134725801d8b3f10615928b4d1dd49a191a82869..def02b2e5e24180a0025bbcce399cf3c88bb023a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/AnnotationsUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/AnnotationsUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.lang.annotation.Annotation; * 注解工具 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class AnnotationsUtils { diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/ClassUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/ClassUtils.java index 4ca552718d4e1f74c5a205ad3317caed9b5b6a16..3cb31897a7d4b0cca0798b412d11f2e4aeb1b1c4 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/ClassUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/ClassUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] *

* Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,6 +28,7 @@ import java.util.Map; * 类工具类 * * @author starBlues + * @since 2.4.0 * @version 2.4.0 */ public class ClassUtils { diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/LogUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/LogUtils.java index c637552d6c06fff9f3d8b7e4638a2129e54a1a4d..ac9f5474065741d146e051669eab6e2c798c0543 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/LogUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/LogUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,10 @@ import com.gitee.starblues.core.descriptor.PluginDescriptor; import org.slf4j.Logger; /** + * 日志打印工具 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class LogUtils { diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/MsgUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/MsgUtils.java index ed4da06086fddbb1ad0529b4a8773ff8e26f0af5..16628b248cad110bc0cdbd1d0f8cd258666b3641 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/MsgUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/MsgUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,10 @@ package com.gitee.starblues.utils; import com.gitee.starblues.core.descriptor.PluginDescriptor; /** + * msg 工具 + * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public abstract class MsgUtils { diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/Order.java b/spring-brick/src/main/java/com/gitee/starblues/utils/Order.java index 904c60ede569b2ea4f24a05d01994b4a5f085809..8f3e076b4f805c007a84aae5282bb3b418b8e8e4 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/Order.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/Order.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,8 @@ package com.gitee.starblues.utils; /** * 排序接口 * @author starBlues - * @version 1.0 + * @since 1.0.0 + * @version 1.0.0 */ public interface Order { diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/OrderPriority.java b/spring-brick/src/main/java/com/gitee/starblues/utils/OrderPriority.java index e96f4eb3c73696f6fc766a4eab8a605164d968db..bf4126fd8310d9e9628937e18ae888c3686e627a 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/OrderPriority.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/OrderPriority.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,8 @@ package com.gitee.starblues.utils; * 顺序优先级 * * @author starBlues - * @version 1.0 + * @since 1.0.0 + * @version 1.0.0 */ public class OrderPriority { /** diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/OrderUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/OrderUtils.java index ed154202dd626ba6c2e95270a0cf2e1dac103001..89720e81db70953ae435517e5565418805fe85dd 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/OrderUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/OrderUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.function.Function; * 通用工具 * * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class OrderUtils { diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/PluginConfigUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/PluginConfigUtils.java index 961ce0946b727253e1f9d3eac01ae047d6c61007..d6d8657fbcfe88f636ff5fe864ddaf5b815c8714 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/PluginConfigUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/PluginConfigUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import com.gitee.starblues.integration.IntegrationConfiguration; /** * 插件配置工具类 * @author starBlues + * @since 3.0.0 * @version 3.0.0 */ public class PluginConfigUtils { diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/PluginFileUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/PluginFileUtils.java index fb01b0d94854edc0c23520f51455b7f13398b486..d3ee7843c869197b60ece580b81ccaeaf7263563 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/PluginFileUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/PluginFileUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/ScanUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/ScanUtils.java index d80fed911a473b5fccb8a342983b9cd388644a02..0fb3bd1a7d2f004b1c3fd6fb53b1725d4c7f7551 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/ScanUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/ScanUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ import java.util.stream.Stream; * * @author starBlues * @version 2.2.2 + * @version 2.2.2 */ public class ScanUtils { diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/SpringBeanCustomUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/SpringBeanCustomUtils.java index f44d7455d3dce7f3750a43aa9fa12a2bf260fc7a..2593e82a793e5857c81cb3803b7b3a888fff32d2 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/SpringBeanCustomUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/SpringBeanCustomUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package com.gitee.starblues.utils; import com.gitee.starblues.spring.ApplicationContext; import com.gitee.starblues.spring.SpringBeanFactory; import org.springframework.util.ClassUtils; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; import java.lang.annotation.Annotation; import java.util.*; @@ -26,7 +27,8 @@ import java.util.*; /** * 自定义插件bean工具类 * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class SpringBeanCustomUtils { @@ -94,6 +96,31 @@ public class SpringBeanCustomUtils { } } + /** + * 获取存在的Bean。名称和类型任意批量即可返回 + * @param applicationContext applicationContext + * @param beanName bean名称 + * @param beanClass bean class + * @return T + * @param bean 类型 + */ + public static T getExistBean(ApplicationContext applicationContext, String beanName, Class beanClass){ + SpringBeanFactory springBeanFactory = applicationContext.getSpringBeanFactory(); + Map beansOfTypeMap = springBeanFactory.getBeansOfType(beanClass); + if(ObjectUtils.isEmpty(beansOfTypeMap)){ + return null; + } + Set> entries = beansOfTypeMap.entrySet(); + for (Map.Entry entry : entries) { + String key = entry.getKey(); + T value = entry.getValue(); + if(Objects.equals(beanName, key) || Objects.equals(value.getClass().getName(), beanClass.getName())){ + return value; + } + } + return null; + } + /** * 通过注解获取bean * @param applicationContext applicationContext diff --git a/spring-brick/src/main/java/com/gitee/starblues/utils/SpringBeanUtils.java b/spring-brick/src/main/java/com/gitee/starblues/utils/SpringBeanUtils.java index 8a971c90a7660d0c9007273215a3a3ff01cd53c5..5f4a9561a7888aad6912673a55d245567da37533 100644 --- a/spring-brick/src/main/java/com/gitee/starblues/utils/SpringBeanUtils.java +++ b/spring-brick/src/main/java/com/gitee/starblues/utils/SpringBeanUtils.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,8 @@ import java.util.*; /** * 插件bean工具类 * @author starBlues - * @version 3.0.0 + * @since 3.0.0 + * @version 3.1.1 */ public class SpringBeanUtils { @@ -88,6 +89,30 @@ public class SpringBeanUtils { } } + /** + * 获取存在的Bean。名称和类型任意批量即可返回 + * @param applicationContext applicationContext + * @param beanName bean名称 + * @param beanClass bean class + * @return T + * @param bean 类型 + */ + public static T getExistBean(ApplicationContext applicationContext, String beanName, Class beanClass){ + Map beansOfTypeMap = applicationContext.getBeansOfType(beanClass); + if(ObjectUtils.isEmpty(beansOfTypeMap)){ + return null; + } + Set> entries = beansOfTypeMap.entrySet(); + for (Map.Entry entry : entries) { + String key = entry.getKey(); + T value = entry.getValue(); + if(beanName.equals(key) || Objects.equals(value.getClass().getName(), beanClass.getName())){ + return value; + } + } + return null; + } + /** * 通过注解获取bean * @param applicationContext applicationContext diff --git a/spring-brick/src/main/resources/META-INF/spring-configuration-metadata.json b/spring-brick/src/main/resources/META-INF/spring-configuration-metadata.json index 67610e7b0fe6bd0ae08c1d01226751432b1b08de..2b65e6d2687a8873d21a23cae37fd32076af3ca2 100644 --- a/spring-brick/src/main/resources/META-INF/spring-configuration-metadata.json +++ b/spring-brick/src/main/resources/META-INF/spring-configuration-metadata.json @@ -95,11 +95,32 @@ }, { "name": "plugin.exactVersion", - "type": "java.lang.String", + "type": "java.lang.Boolean", "sourceType": "com.gitee.starblues.integration.AutoIntegrationConfiguration", "description": "是否完全匹配版本。设置为true表示插件设置的requires的版本号完全匹配version版本号才可允许插件安装, 即: requires=x.y.z; 设置为false表示插件设置的requires的版本号小于等于version值, 插件就可安装, 即requires<=x.y.z", "defaultValue": false }, + { + "name": "plugin.pluginSwaggerScan", + "type": "java.lang.Boolean", + "sourceType": "com.gitee.starblues.integration.AutoIntegrationConfiguration", + "description": "是否扫描插件 swagger 接口", + "defaultValue": true + }, + { + "name": "plugin.pluginFollowProfile", + "type": "java.lang.Boolean", + "sourceType": "com.gitee.starblues.integration.AutoIntegrationConfiguration", + "description": "插件的配置文件 Profile 是否跟随主程序的 Profile 配置动态切换", + "defaultValue": false + }, + { + "name": "plugin.pluginFollowLog", + "type": "java.lang.Boolean", + "sourceType": "com.gitee.starblues.integration.AutoIntegrationConfiguration", + "description": "插件日志打印是否跟随主程序", + "defaultValue": false + }, { "name": "plugin.decrypt", "type": "com.gitee.starblues.integration.decrypt.DecryptConfiguration", diff --git a/spring-brick/src/test/java/com/gitee/starblues/core/checker/DefaultPluginIsolationLauncherCheckerTest.java b/spring-brick/src/test/java/com/gitee/starblues/core/checker/DefaultPluginIsolationLauncherCheckerTest.java index 559b996f3bd168b1a652b14f7d3827da6bcc6088..6bca70309aa593f4804e0e709a9c5cdcde7db6e1 100644 --- a/spring-brick/src/test/java/com/gitee/starblues/core/checker/DefaultPluginIsolationLauncherCheckerTest.java +++ b/spring-brick/src/test/java/com/gitee/starblues/core/checker/DefaultPluginIsolationLauncherCheckerTest.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-brick/src/test/java/com/gitee/starblues/core/version/SemverVersionInspectorTest.java b/spring-brick/src/test/java/com/gitee/starblues/core/version/SemverVersionInspectorTest.java index c8e87d72da807b603b99eb27f66c601116ca0534..2eaaf1200b1fc372a61350750c556bb308af6373 100644 --- a/spring-brick/src/test/java/com/gitee/starblues/core/version/SemverVersionInspectorTest.java +++ b/spring-brick/src/test/java/com/gitee/starblues/core/version/SemverVersionInspectorTest.java @@ -1,5 +1,5 @@ /** - * Copyright [2019-2022] [starBlues] + * Copyright [2019-Present] [starBlues] * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/update.md b/update.md index 3e8f5e913171e18ff32e9e20343ccf6e0a9dbb98..9ac1b24f33171b67fa917d68e53d2b05fcddc2fb 100644 --- a/update.md +++ b/update.md @@ -1,14 +1,8 @@ -1. 【新增】增加主包`MANIFEST.MF`中`title`和`version`定义, 标准jar包中包含`Implementation-Title`和`Implementation-Version`属性 -2. 【新增】新增根据个人需求选择开发模式,支持隔离式开发模式(目前已有的)、共享式开发模式 -3. 【新增】新增可自主实现扩展插件信息 -4. 【新增】新增插件停止类型 -3. 【修复】修复插件中`LiveBeansView`注册异常问题 -4. 【修复[#I5IFR4](https://gitee.com/starblues/springboot-plugin-framework-parent/issues/I5IFR3)】 `ExtractFactory#getExtractByCoordinate` 类型转换`Bug` -5. 【修复[#I5GJO9](https://gitee.com/starblues/springboot-plugin-framework-parent/issues/I5GJO9)】`DefaultPluginManager#install` 异常无法抛出 -6. 【修复】修复插件无法加载其他包依赖中的`mybatis-xml`问题 -7. 【修复】修复插件子启动问题 -8. 【修复】修复插件`load`解压异常 -9. 【修复】修复`jar`、`zip`加载依赖时未使用`libDir`配置前缀 -10.【优化】优化插件`parse`后为`parsed`状态 -11.【优化】优化依赖资源默认不缓存, 以减少内存 - +1. 【新增】主程序可通过`pluginInfo`对象获取插件的`ClassLoader`。 +2. 【新增】新增配置`plugin.pluginSwaggerScan`可禁用扫描插件的 `swagger` 接口。 +3. 【新增】插件配置文件`spring.profiles.active`的值可跟随主程序配置切换。 +4. 【新增】插件的日志可配置为跟随主程序日志配置打印。 +5. 【新增】补充常见打包的 `META-INF\MANIFEST.MF` 文件内容。 +6. 【优化】优化插件隔离模式下,内存占用过大的问题。 +7. 【修复[#I61INH](https://gitee.com/starblues/springboot-plugin-framework-parent/issues/I61INH)】修复`PluginUser#getBean(String name, boolean includeMainBeans)`返回的`Bean`错误 + \ No newline at end of file