提交 119de4d7 编写于 作者: W william.liangf

DUBBO-204 修改destroyAll

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@1559 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 106c2e37
......@@ -241,6 +241,18 @@ public class ExtensionLoader<T> {
return false;
}
@SuppressWarnings("unchecked")
public T getLoadedExtension(String name) {
if (name == null || name.length() == 0)
throw new IllegalArgumentException("Extension name == null");
Reference<Object> reference = cachedInstances.get(name);
if (reference == null) {
cachedInstances.putIfAbsent(name, new Reference<Object>());
reference = cachedInstances.get(name);
}
return (T) reference.get();
}
@SuppressWarnings("unchecked")
public T getExtension(String name) {
if (name == null || name.length() == 0)
......
......@@ -406,9 +406,13 @@ public class ProtocolConfig extends AbstractConfig {
public static void destroyAll() {
AbstractRegistryFactory.destroyAll();
for (String protocol : ExtensionLoader.getExtensionLoader(Protocol.class).getLoadedExtensions()) {
ExtensionLoader<Protocol> loader = ExtensionLoader.getExtensionLoader(Protocol.class);
for (String protocolName : loader.getLoadedExtensions()) {
try {
ExtensionLoader.getExtensionLoader(Protocol.class).getExtension(protocol).destroy();
Protocol protocol = loader.getLoadedExtension(protocolName);
if (protocol != null) {
protocol.destroy();
}
} catch (Throwable t) {
logger.warn(t.getMessage(), t);
}
......
......@@ -276,10 +276,6 @@ public class RegistryConfig extends AbstractConfig {
this.subscribe = subscribe;
}
public static void closeAll() {
AbstractRegistryFactory.destroyAll();
}
public String getGroup() {
return group;
}
......@@ -313,4 +309,13 @@ public class RegistryConfig extends AbstractConfig {
this.isDefault = isDefault;
}
public static void destroyAll() {
AbstractRegistryFactory.destroyAll();
}
@Deprecated
public static void closeAll() {
destroyAll();
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册