Skip to content

Commit 380beac

Browse files
chore: merge main into release [skip ci]
2 parents c625727 + b801aad commit 380beac

3 files changed

Lines changed: 117 additions & 6 deletions

File tree

microsphere-spring-boot-webmvc/src/main/java/io/microsphere/spring/boot/webmvc/autoconfigure/WebMvcAutoConfiguration.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@
3030
import org.springframework.context.annotation.Bean;
3131
import org.springframework.context.annotation.Import;
3232

33-
import static io.microsphere.constants.PropertyConstants.ENABLED_PROPERTY_NAME;
34-
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.FILTER_PROPERTY_NAME_PREFIX;
35-
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.LOGGING_PROPERTY_NAME_PREFIX;
33+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENALBED_PROPERTY_NAME;
34+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENALBED_PROPERTY_NAME;
35+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED_PROPERTY_NAME;
3636
import static io.microsphere.spring.webmvc.context.ExclusiveViewResolverApplicationListener.EXCLUSIVE_VIEW_RESOLVER_BEAN_NAME_PROPERTY_NAME;
3737

3838
/**
@@ -57,13 +57,13 @@
5757
})
5858
public class WebMvcAutoConfiguration {
5959

60-
@ConditionalOnProperty(prefix = FILTER_PROPERTY_NAME_PREFIX, name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
60+
@ConditionalOnProperty(name = MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENALBED_PROPERTY_NAME, matchIfMissing = true)
6161
@Bean
6262
public ContentCachingFilter contentCachingFilter() {
6363
return new ContentCachingFilter();
6464
}
6565

66-
@ConditionalOnProperty(prefix = "microsphere.spring.webmvc.content-negotiation.", name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
66+
@ConditionalOnProperty(name = MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED_PROPERTY_NAME, matchIfMissing = true)
6767
@Bean
6868
public ConfigurableContentNegotiationManagerWebMvcConfigurer contentNegotiationManagerWebMvcConfigurer() {
6969
return new ConfigurableContentNegotiationManagerWebMvcConfigurer();
@@ -75,7 +75,7 @@ public ExclusiveViewResolverApplicationListener exclusiveViewResolverApplication
7575
return new ExclusiveViewResolverApplicationListener();
7676
}
7777

78-
@ConditionalOnProperty(prefix = LOGGING_PROPERTY_NAME_PREFIX, name = ENABLED_PROPERTY_NAME, matchIfMissing = true)
78+
@ConditionalOnProperty(name = MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENALBED_PROPERTY_NAME, matchIfMissing = true)
7979
@Import(value = {
8080
LoggingMethodHandlerInterceptor.class,
8181
LoggingPageRenderContextHandlerInterceptor.class,

microsphere-spring-boot-webmvc/src/main/java/io/microsphere/spring/boot/webmvc/constants/PropertyConstants.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
package io.microsphere.spring.boot.webmvc.constants;
1818

1919
import io.microsphere.annotation.ConfigurationProperty;
20+
import io.microsphere.spring.webmvc.config.ConfigurableContentNegotiationManagerWebMvcConfigurer;
2021

2122
import static io.microsphere.annotation.ConfigurationProperty.APPLICATION_SOURCE;
2223
import static io.microsphere.constants.PropertyConstants.ENABLED_PROPERTY_NAME;
2324
import static io.microsphere.spring.boot.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_PROPERTY_NAME_PREFIX;
25+
import static io.microsphere.spring.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_WEBMVC_PROPERTY_NAME_PREFIX;
2426

2527
/**
2628
* The Property constants for Microsphere Spring Boot Web MVC
@@ -40,6 +42,21 @@ public interface PropertyConstants {
4042
*/
4143
String DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_ENABLED = "true";
4244

45+
/**
46+
* The default value of 'enabled' property of Microsphere Spring Boot MVC Filter : "true"
47+
*/
48+
String DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENABLED = "true";
49+
50+
/**
51+
* The default value of 'enabled' property of Microsphere Spring Boot MVC Logging : "true"
52+
*/
53+
String DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENABLED = "true";
54+
55+
/**
56+
* The default value of 'enabled' property of Microsphere Spring Web MVC Content Negotiation : "true"
57+
*/
58+
String DEFAULT_MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED = "true";
59+
4360
/**
4461
* The 'enabled' property name of Microsphere Spring Boot Web MVC : "microsphere.spring.boot.webmvc.enabled"
4562
*/
@@ -55,8 +72,45 @@ public interface PropertyConstants {
5572
*/
5673
String FILTER_PROPERTY_NAME_PREFIX = MICROSPHERE_SPRING_BOOT_WEBMVC_PROPERTY_NAME_PREFIX + "filter.";
5774

75+
/**
76+
* The 'enabled' property name of Microsphere Spring Boot Web MVC Filter : "microsphere.spring.boot.webmvc.filter.enabled"
77+
*/
78+
@ConfigurationProperty(
79+
type = boolean.class,
80+
defaultValue = DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENABLED,
81+
source = APPLICATION_SOURCE
82+
)
83+
String MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENALBED_PROPERTY_NAME = FILTER_PROPERTY_NAME_PREFIX + ENABLED_PROPERTY_NAME;
84+
85+
/**
86+
* The property name prefix of Microsphere Spring Web MVC Content Negotiation : "microsphere.spring.webmvc.content-negotiation."
87+
*
88+
* @see ConfigurableContentNegotiationManagerWebMvcConfigurer#PROPERTY_NAME_PREFIX
89+
*/
90+
String CONTENT_NEGOTIATION_PROPERTY_NAME_PREFIX = MICROSPHERE_SPRING_WEBMVC_PROPERTY_NAME_PREFIX + "content-negotiation.";
91+
92+
/**
93+
* The 'enabled' property name of Microsphere Spring Web MVC Content Negotiation : "microsphere.spring.webmvc.content-negotiation.enabled"
94+
*/
95+
@ConfigurationProperty(
96+
type = boolean.class,
97+
defaultValue = DEFAULT_MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED,
98+
source = APPLICATION_SOURCE
99+
)
100+
String MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED_PROPERTY_NAME = CONTENT_NEGOTIATION_PROPERTY_NAME_PREFIX + ENABLED_PROPERTY_NAME;
101+
58102
/**
59103
* The property name prefix of Microsphere Spring Boot Web MVC Logging : "microsphere.spring.boot.webmvc.logging."
60104
*/
61105
String LOGGING_PROPERTY_NAME_PREFIX = MICROSPHERE_SPRING_BOOT_WEBMVC_PROPERTY_NAME_PREFIX + "logging.";
106+
107+
/**
108+
* The 'enabled' property name of Microsphere Spring Boot Web MVC Logging : "microsphere.spring.boot.webmvc.logging.enabled"
109+
*/
110+
@ConfigurationProperty(
111+
type = boolean.class,
112+
defaultValue = DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENABLED,
113+
source = APPLICATION_SOURCE
114+
)
115+
String MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENALBED_PROPERTY_NAME = LOGGING_PROPERTY_NAME_PREFIX + ENABLED_PROPERTY_NAME;
62116
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package io.microsphere.spring.boot.webmvc.constants;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_ENABLED;
22+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENABLED;
23+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENABLED;
24+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.DEFAULT_MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED;
25+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.FILTER_PROPERTY_NAME_PREFIX;
26+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.LOGGING_PROPERTY_NAME_PREFIX;
27+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_WEBMVC_ENALBED_PROPERTY_NAME;
28+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENALBED_PROPERTY_NAME;
29+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENALBED_PROPERTY_NAME;
30+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_BOOT_WEBMVC_PROPERTY_NAME_PREFIX;
31+
import static io.microsphere.spring.boot.webmvc.constants.PropertyConstants.MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED_PROPERTY_NAME;
32+
import static org.junit.jupiter.api.Assertions.assertEquals;
33+
34+
/**
35+
* {@link PropertyConstants} Test
36+
*
37+
* @author <a href="mailto:mercyblitz@gmail.com">Mercy</a>
38+
* @see PropertyConstants
39+
* @since 1.0.0
40+
*/
41+
class PropertyConstantsTest {
42+
43+
@Test
44+
void testConstants() {
45+
assertEquals("microsphere.spring.boot.webmvc.", MICROSPHERE_SPRING_BOOT_WEBMVC_PROPERTY_NAME_PREFIX);
46+
assertEquals("true", DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_ENABLED);
47+
assertEquals("true", DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENABLED);
48+
assertEquals("true", DEFAULT_MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENABLED);
49+
assertEquals("true", DEFAULT_MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED);
50+
assertEquals("microsphere.spring.boot.webmvc.enabled", MICROSPHERE_SPRING_BOOT_WEBMVC_ENALBED_PROPERTY_NAME);
51+
assertEquals("microsphere.spring.boot.webmvc.filter.", FILTER_PROPERTY_NAME_PREFIX);
52+
assertEquals("microsphere.spring.boot.webmvc.filter.enabled", MICROSPHERE_SPRING_BOOT_WEBMVC_FILTER_ENALBED_PROPERTY_NAME);
53+
assertEquals("microsphere.spring.webmvc.content-negotiation.enabled", MICROSPHERE_SPRING_WEBMVC_CONTENT_NEGOTIATION_ENABLED_PROPERTY_NAME);
54+
assertEquals("microsphere.spring.boot.webmvc.logging.", LOGGING_PROPERTY_NAME_PREFIX);
55+
assertEquals("microsphere.spring.boot.webmvc.logging.enabled", MICROSPHERE_SPRING_BOOT_WEBMVC_LOGGING_ENALBED_PROPERTY_NAME);
56+
}
57+
}

0 commit comments

Comments
 (0)