调整registry api,保证其开放性
This commit is contained in:
parent
30980991a4
commit
dbc221e2ed
|
|
@ -1,4 +1,7 @@
|
|||
package com.a.eye.skywalking.registry.api;
|
||||
package com.a.eye.skywalking.registry;
|
||||
|
||||
import com.a.eye.skywalking.registry.api.Center;
|
||||
import com.a.eye.skywalking.registry.api.RegistryCenter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -10,7 +13,7 @@ import java.util.ServiceLoader;
|
|||
*/
|
||||
public class RegistryCenterFactory {
|
||||
|
||||
private Map<CenterType, RegistryCenter> registryCenter = new HashMap<CenterType, RegistryCenter>();
|
||||
private Map<String, RegistryCenter> registryCenter = new HashMap<String, RegistryCenter>();
|
||||
|
||||
private RegistryCenterFactory() {
|
||||
ServiceLoader<RegistryCenter> loaders = ServiceLoader.load(RegistryCenter.class);
|
||||
|
|
@ -27,7 +30,7 @@ public class RegistryCenterFactory {
|
|||
}
|
||||
}
|
||||
|
||||
public RegistryCenter getRegistryCenter(CenterType type) {
|
||||
public RegistryCenter getRegistryCenter(String type) {
|
||||
return registryCenter.get(type);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,5 +5,5 @@ import java.lang.annotation.*;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
public @interface Center {
|
||||
CenterType type() default CenterType.zookeeper;
|
||||
String type() default CenterType.DEFAULT_CENTER_TYPE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +1,8 @@
|
|||
package com.a.eye.skywalking.registry.api;
|
||||
|
||||
/**
|
||||
* Created by xin on 2016/11/10.
|
||||
* Created by wusheng on 2016/11/10.
|
||||
*/
|
||||
public enum CenterType {
|
||||
zookeeper("zookeeper");
|
||||
|
||||
private String type;
|
||||
|
||||
CenterType(String typeStr) {
|
||||
this.type = typeStr;
|
||||
}
|
||||
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static CenterType convert(String type) {
|
||||
if (zookeeper.type.equals(type)) {
|
||||
return zookeeper;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("Failed to find center type[" + type + "]");
|
||||
}
|
||||
public interface CenterType {
|
||||
String DEFAULT_CENTER_TYPE = "zookeeper";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue