Skip to content

Commit

Permalink
Merge pull request #10 from buession/development
Browse files Browse the repository at this point in the history
Release 2.3.0
  • Loading branch information
eduosi authored Aug 17, 2023
2 parents fe4cd2e + 9cb9eee commit dfd3219
Show file tree
Hide file tree
Showing 72 changed files with 1,277 additions and 520 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@
===========================


## [2.3.0](https://github.com/buession/buession-springboot/releases/tag/v2.3.0) (2023-08-17)

### 🔨依赖升级

- [依赖库版本升级和安全漏洞修复](https://github.com/buession/buession-parent/releases/tag/v2.3.0)


### ⭐ 新特性

- **buession-springboot-boot:** Application 支持可设置 Banner Mode、lazyInitialization
- **buession-springboot-cli:** CliApplication 支持可设置 addCommandLineProperties
- **buession-springboot-httpclient:** 新增 HTTP 异步请求客户端
- **buession-springboot-captcha:** 新增对 WebFlux 的支持
- **buession-springboot-web:** webflux 下创建 HttpMessageConverters bean


### 🔔 变化

- **buession-springboot-boot:** AbstractApplication 允许 Banner 传 null
- **buession-springboot-boot:** Banner 不再使用 jfiglet
- **buession-springboot-web:** AbstractWebApplication webApplicationType 属性默认值由 WebApplicationType.SERVLET 改为 null


### ⏪ 优化

- 其它优化


---


## [2.2.1](https://github.com/buession/buession-springboot/releases/tag/v2.2.1) (2023-03-31)

### 🔨依赖升级
Expand Down
13 changes: 6 additions & 7 deletions buession-springboot-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>com.buession.springboot</groupId>
<artifactId>buession-springboot-parent</artifactId>
<relativePath>../buession-springboot-parent</relativePath>
<version>2.2.1</version>
<version>2.3.0</version>
</parent>
<artifactId>buession-springboot-boot</artifactId>
<url>https://springboot.buession.com/</url>
Expand Down Expand Up @@ -172,12 +172,6 @@
<artifactId>bcpkix-jdk15on</artifactId>
</dependency>

<dependency>
<groupId>com.github.lalyos</groupId>
<artifactId>jfiglet</artifactId>
<version>0.0.9</version>
</dependency>

<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
Expand All @@ -187,6 +181,11 @@
<artifactId>aspectjweaver</artifactId>
</dependency>

<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>

<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@
*/
package com.buession.springboot.boot.application;

import com.buession.core.utils.Assert;
import com.buession.springboot.boot.config.RuntimeProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.Banner;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.properties.PropertyMapper;
import org.springframework.context.ConfigurableApplicationContext;
Expand All @@ -51,12 +49,26 @@ public abstract class AbstractApplication implements Application {
private Class<? extends ConfigurableApplicationContext> configurableApplicationContext;

/**
* Banner
* {@link Banner}
*
* @since 1.3.1
*/
private Banner banner;

/**
* {@link Banner} Mode
*
* @since 2.3.0
*/
private Banner.Mode bannerMode;

/**
* 是否延迟初始化
*
* @since 2.3.0
*/
private Boolean lazyInitialization;

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

/**
Expand All @@ -79,8 +91,9 @@ protected AbstractApplication(){
*/
protected AbstractApplication(final Class<? extends Banner> banner) throws InstantiationException,
IllegalAccessException{
Assert.isNull(banner, "Banner class cloud not be null.");
this.banner = banner.newInstance();
if(banner != null){
this.banner = banner.newInstance();
}
}

/**
Expand All @@ -92,10 +105,39 @@ protected AbstractApplication(final Class<? extends Banner> banner) throws Insta
* @since 1.3.1
*/
protected AbstractApplication(final Banner banner){
Assert.isNull(banner, "Banner cloud not be null.");
this.banner = banner;
}

@Override
public Banner getBanner(){
return banner;
}

@Override
public void setBanner(Banner banner){
this.banner = banner;
}

@Override
public Banner.Mode getBannerMode(){
return bannerMode;
}

@Override
public void setBannerMode(Banner.Mode bannerMode){
this.bannerMode = bannerMode;
}

@Override
public Boolean getLazyInitialization(){
return lazyInitialization;
}

@Override
public void setLazyInitialization(Boolean lazyInitialization){
this.lazyInitialization = lazyInitialization;
}

@Override
public Class<? extends ConfigurableApplicationContext> getConfigurableApplicationContext(){
return configurableApplicationContext;
Expand All @@ -116,26 +158,27 @@ public void startup(final String[] args){
}
}

public void doStartup(final Class<? extends Application> clazz, final WebApplicationType webApplicationType,
final String[] args){
final SpringApplicationBuilder springApplicationBuilder = new SpringApplicationBuilder(clazz);
@Override
public void startup(final Class<? extends Application> clazz, final String[] args){
doStartup(clazz, args);
}

protected SpringApplicationBuilder springApplicationBuilder(final Class<? extends Application> clazz){
final PropertyMapper propertyMapper = PropertyMapper.get().alwaysApplyingWhenNonNull();
final SpringApplicationBuilder springApplicationBuilder = new SpringApplicationBuilder(clazz);

propertyMapper.from(getBanner()).to(springApplicationBuilder::banner);
propertyMapper.from(getBannerMode()).to(springApplicationBuilder::bannerMode);
propertyMapper.from(getConfigurableApplicationContext()).to(springApplicationBuilder::contextClass);
propertyMapper.from(getLazyInitialization()).to(springApplicationBuilder::lazyInitialization);

springApplicationBuilder.properties(createRuntimeProperties()).logStartupInfo(true);

springApplicationBuilder.web(webApplicationType).properties(createRuntimeProperties()).logStartupInfo(true)
.run(args);
return springApplicationBuilder;
}

/**
* 获取 Banner
*
* @return Banner
*/
protected Banner getBanner(){
return banner;
protected void doStartup(final Class<? extends Application> clazz, final String[] args){
springApplicationBuilder(clazz).run(args);
}

protected RuntimeProperties createRuntimeProperties(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
package com.buession.springboot.boot.application;

import org.springframework.boot.Banner;
import org.springframework.context.ConfigurableApplicationContext;

/**
Expand All @@ -35,6 +36,61 @@
*/
public interface Application extends Launcher, Daemon {

/**
* 获取 {@link Banner}
*
* @return {@link Banner}
*/
Banner getBanner();

/**
* 设置 {@link Banner}
*
* @param banner
* {@link Banner}
*
* @since 2.3.0
*/
void setBanner(Banner banner);

/**
* 获取 {@link Banner} 模式
*
* @return {@link Banner} 模式
*
* @since 2.3.0
*/
Banner.Mode getBannerMode();

/**
* 设置 {@link Banner} 模式
*
* @param bannerMode
* {@link Banner} 模式
*
* @since 2.3.0
*/
void setBannerMode(Banner.Mode bannerMode);

/**
* 返回是否延迟初始化
*
* @return 是否延迟初始化
*
* @since 2.3.0
*/
Boolean getLazyInitialization();

/**
* 设置是否延迟初始化
*
* @param lazyInitialization
* 是否延迟初始化
*
* @since 2.3.0
*/
void setLazyInitialization(Boolean lazyInitialization);

/**
* 返回可配置的应用上下文类
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* +-------------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng <webmaster@buession.com> |
* | Copyright @ 2013-2022 Buession.com Inc. |
* | Copyright @ 2013-2023 Buession.com Inc. |
* +-------------------------------------------------------------------------------------------------------+
*/
package com.buession.springboot.boot.autoconfigure;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@
* +------------------------------------------------------------------------------------------------+
* | License: http://www.apache.org/licenses/LICENSE-2.0.txt |
* | Author: Yong.Teng <webmaster@buession.com> |
* | Copyright @ 2013-2022 Buession.com Inc. |
* | Copyright @ 2013-2023 Buession.com Inc. |
* +------------------------------------------------------------------------------------------------+
*/
package com.buession.springboot.boot.banner;

import com.buession.core.Framework;
import com.buession.core.utils.JceUtils;
import com.buession.core.utils.StringUtils;
import com.buession.core.utils.VersionUtils;
import com.buession.springboot.boot.utils.FileUtils;
import com.buession.springboot.boot.utils.JceUtils;
import com.github.lalyos.jfiglet.FigletFont;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringBootVersion;
import org.springframework.core.SpringVersion;
Expand All @@ -48,9 +47,14 @@
*/
public abstract class AbstractBanner implements Banner {

private final static String ANSI_CYAN = "\u001B[36m";

private final static String ANSI_RESET = "\u001B[0m";

private final static int SEPARATOR_REPEAT_COUNT = 60;

private final static String LINE_SEPARATOR = String.join(StringUtils.EMPTY, Collections.nCopies(SEPARATOR_REPEAT_COUNT, "-"));
private final static String LINE_SEPARATOR = String.join(StringUtils.EMPTY,
Collections.nCopies(SEPARATOR_REPEAT_COUNT, "-"));

private final static String BANNER_SKIP_PROPERTY_NAME = "BANNER_SKIP";

Expand All @@ -59,25 +63,28 @@ public void printBanner(Environment environment, Class<?> sourceClass, PrintStre
String additional = collectEnvironmentInfo(environment, sourceClass);

try{
out.println("\u001b[36m");
out.println(FigletFont.convertOneLine(getTitle()));
out.println(ANSI_CYAN);
out.println(getTitle());

if(StringUtils.isNotBlank(additional)){
out.println(additional);
}

out.println("\u001b[0m");
out.println(ANSI_RESET);
}catch(Exception e){
throw new RuntimeException(e);
}
}

protected String getTitle(){
StringBuilder sb = new StringBuilder(Framework.NAME.length());

sb.append('(').append(Framework.NAME.toUpperCase()).append(')');

return sb.toString();
return '\n'
+ "______ _ \n" +
"| ___ \\ (_) \n" +
"| |_/ / _ _ ___ ___ ___ _ ___ _ __ \n" +
"| ___ \\| | | | / _ \\/ __|/ __|| | / _ \\ | '_ \\ \n" +
"| |_/ /| |_| || __/\\__ \\\\__ \\| || (_) || | | |\n" +
"\\____/ \\__,_| \\___||___/|___/|_| \\___/ |_| |_|\n" +
" \n";
}

protected String getVersion(){
Expand Down Expand Up @@ -124,7 +131,7 @@ private String collectEnvironmentInfo(final Environment environment, final Class
formatter.format("JVM Total Memory: %s%n", FileUtils.byteCountToDisplaySize(runtime.totalMemory()));
formatter.format("JVM Maximum Memory: %s%n", FileUtils.byteCountToDisplaySize(runtime.maxMemory()));
formatter.format("JVM Free Memory: %s%n", FileUtils.byteCountToDisplaySize(runtime.freeMemory()));
formatter.format("JCE Installed: %s%n", JceUtils.isJceInstalled() ? "Yes" : "No");
formatter.format("JCE Installed: %s%n", JceUtils.isInstalled() ? "Yes" : "No");
formatter.format("%s%n", LINE_SEPARATOR);

injectEnvironmentInfoIntoBanner(formatter, environment, sourceClass);
Expand All @@ -139,7 +146,8 @@ private String collectEnvironmentInfo(final Environment environment, final Class
}
}

protected void injectEnvironmentInfoIntoBanner(final Formatter formatter, final Environment environment, final Class<?> sourceClass){
protected void injectEnvironmentInfoIntoBanner(final Formatter formatter, final Environment environment,
final Class<?> sourceClass){
}

private static void closeFormatter(Formatter formatter, Throwable throwable){
Expand Down
Loading

0 comments on commit dfd3219

Please sign in to comment.