-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f3dc3d
commit 17e93d9
Showing
10 changed files
with
125 additions
and
320 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,21 +16,20 @@ | |
*/ | ||
package io.microsphere.i18n.spring.boot.autoconfigure; | ||
|
||
import io.microsphere.i18n.spring.context.I18nConfiguration; | ||
import io.microsphere.i18n.spring.annotation.EnableI18n; | ||
import io.microsphere.i18n.spring.boot.condition.ConditionalOnI18nEnabled; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
|
||
import static io.microsphere.i18n.spring.constants.I18nConstants.ENABLED_PROPERTY_NAME; | ||
|
||
/** | ||
* I18n Auto-Configuration | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy</a> | ||
* @see I18nConfiguration | ||
* @since 1.0.0 | ||
*/ | ||
@ConditionalOnClass(name = { | ||
"io.microsphere.i18n.ServiceMessageSource", // microsphere-i18n-core | ||
"io.microsphere.i18n.spring.context.I18nConfiguration", // microsphere-i18n-spring | ||
}) | ||
@Import(I18nConfiguration.class) | ||
@ConditionalOnI18nEnabled | ||
@EnableI18n | ||
public class I18nAutoConfiguration { | ||
} |
31 changes: 31 additions & 0 deletions
31
...oot/src/main/java/io/microsphere/i18n/spring/boot/condition/ConditionalOnI18nEnabled.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package io.microsphere.i18n.spring.boot.condition; | ||
|
||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.context.annotation.Conditional; | ||
|
||
import java.lang.annotation.Documented; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import static io.microsphere.i18n.spring.constants.I18nConstants.ENABLED_PROPERTY_NAME; | ||
|
||
/** | ||
* {@link Conditional @Conditional} that checks whether the I18n enabled | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy</a> | ||
* @since 1.0.0 | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.TYPE, ElementType.METHOD}) | ||
@Documented | ||
@ConditionalOnClass(name = { | ||
"io.microsphere.i18n.ServiceMessageSource", // microsphere-i18n-core | ||
"io.microsphere.i18n.spring.annotation.EnableI18n", // microsphere-i18n-spring | ||
}) | ||
@ConditionalOnProperty(name = ENABLED_PROPERTY_NAME, matchIfMissing = true) | ||
public @interface ConditionalOnI18nEnabled { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,7 +33,10 @@ | |
import static io.microsphere.i18n.ServiceMessageSource.COMMON_SOURCE; | ||
|
||
/** | ||
* Enables the extension for Spring Internationalisation | ||
* Enables the extension for Spring Internationalisation. | ||
* <p> | ||
* The feature could be disabled by the Spring property if | ||
* {@link I18nConstants#ENABLED_PROPERTY_NAME "microsphere.i18n.enabled"} is <code>false</code> | ||
* | ||
* @author <a href="mailto:[email protected]">Mercy<a/> | ||
* @see I18nImportBeanDefinitionRegistrar | ||
|
@@ -48,13 +51,20 @@ | |
public @interface EnableI18n { | ||
|
||
/** | ||
* Declares the sources of the {@link ServiceMessageSource} as the {@link ServiceMessageSourceFactoryBean} Spring Beans | ||
* to be registered. | ||
* Declares the sources of the {@link ServiceMessageSource} to register the {@link ServiceMessageSourceFactoryBean} | ||
* Spring Beans whose names are composed by their source content appending "ServiceMessageSource", the default value | ||
* is {@value ServiceMessageSource#COMMON_SOURCE "common"} indicates that the named "commonServiceMessageSource" | ||
* Spring Bean will be registered. | ||
* <p> | ||
* The attribute value will be merged from the Spring property whose name is {@link I18nConstants#SOURCES_PROPERTY_NAME} | ||
* Besides the attribute value, the sources will be extended from the Spring property whose name is | ||
* {@link I18nConstants#SOURCES_PROPERTY_NAME "microsphere.i18n.sources"}. | ||
* <p> | ||
* Finally, all sourced {@link ServiceMessageSource} Spring Beans as the members will be composited into | ||
* a Primary Spring Bean named {@link I18nConstants#SERVICE_MESSAGE_SOURCE_BEAN_NAME "serviceMessageSource"}. | ||
* | ||
* @return {@link ServiceMessageSource#COMMON_SOURCE} as the default | ||
* @return {@link ServiceMessageSource#COMMON_SOURCE "common"} as the default | ||
* @see I18nConstants#SOURCES_PROPERTY_NAME | ||
* @see I18nConstants#SERVICE_MESSAGE_SOURCE_BEAN_NAME | ||
*/ | ||
String[] sources() default {COMMON_SOURCE}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 0 additions & 112 deletions
112
...phere-i18n-spring/src/main/java/io/microsphere/i18n/spring/context/I18nConfiguration.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.