1
0
mirror of https://gitee.com/mirrors/Spring-Cloud-Alibaba.git synced 2021-06-26 13:25:11 +08:00

update comments and docs

This commit is contained in:
fangjian0423
2018-10-16 16:51:31 +08:00
parent 65f380c064
commit 41db9c945b
4 changed files with 24 additions and 16 deletions

View File

@@ -16,19 +16,25 @@
package org.springframework.cloud.alibaba.sentinel.annotation;
import java.lang.annotation.*;
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 com.alibaba.csp.sentinel.datasource.ReadableDataSource;
import org.springframework.core.annotation.AliasFor;
/**
* An annotation to inject {@link com.alibaba.csp.sentinel.datasource.DataSource} instance
* An annotation to inject {@link ReadableDataSource} instance
* into a Spring Bean. The Properties of DataSource bean get from config files with
* specific prefix.
*
* @author fangjian
* @see com.alibaba.csp.sentinel.datasource.DataSource
* @see ReadableDataSource
*/
@Target({ ElementType.FIELD })
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface SentinelDataSource {

View File

@@ -18,6 +18,8 @@ package org.springframework.cloud.alibaba.sentinel.datasource;
import java.util.concurrent.ConcurrentHashMap;
import com.alibaba.csp.sentinel.datasource.ReadableDataSource;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
@@ -28,7 +30,7 @@ import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.Zookeep
* Registry to save DataSource FactoryBean
*
* @author fangjian
* @see com.alibaba.csp.sentinel.datasource.DataSource
* @see ReadableDataSource
* @see FileRefreshableDataSourceFactoryBean
* @see ZookeeperDataSourceFactoryBean
* @see NacosDataSourceFactoryBean
@@ -37,17 +39,17 @@ import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.Zookeep
public class SentinelDataSourceRegistry {
private static ConcurrentHashMap<String, Class<? extends FactoryBean>> cache = new ConcurrentHashMap<>(
32);
32);
static {
SentinelDataSourceRegistry.registerFactoryBean("file",
FileRefreshableDataSourceFactoryBean.class);
FileRefreshableDataSourceFactoryBean.class);
SentinelDataSourceRegistry.registerFactoryBean("zk",
ZookeeperDataSourceFactoryBean.class);
ZookeeperDataSourceFactoryBean.class);
SentinelDataSourceRegistry.registerFactoryBean("nacos",
NacosDataSourceFactoryBean.class);
NacosDataSourceFactoryBean.class);
SentinelDataSourceRegistry.registerFactoryBean("apollo",
ApolloDataSourceFactoryBean.class);
ApolloDataSourceFactoryBean.class);
}
public static synchronized void registerFactoryBean(String alias,