Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
touzizhuo03
Dubbo
提交
c3618b50
D
Dubbo
项目概览
touzizhuo03
/
Dubbo
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dubbo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c3618b50
编写于
7月 18, 2012
作者:
L
liangfei0201
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
清理demo
上级
5495e300
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
0 addition
and
510 deletion
+0
-510
dubbo-demo/dubbo-demo-consumer/src/test/java/com/alibaba/dubbo/demo/consumer/AdminConsumer.java
...t/java/com/alibaba/dubbo/demo/consumer/AdminConsumer.java
+0
-90
dubbo-demo/dubbo-demo-consumer/src/test/java/com/alibaba/dubbo/demo/consumer/ExitConsumer.java
...st/java/com/alibaba/dubbo/demo/consumer/ExitConsumer.java
+0
-33
dubbo-demo/dubbo-demo-consumer/src/test/java/com/alibaba/dubbo/demo/consumer/PerformanceConsumer.java
.../com/alibaba/dubbo/demo/consumer/PerformanceConsumer.java
+0
-35
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/ExitProvider.java
...st/java/com/alibaba/dubbo/demo/provider/ExitProvider.java
+0
-29
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/MockAdd.java
...rc/test/java/com/alibaba/dubbo/demo/provider/MockAdd.java
+0
-74
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/MockRemove.java
...test/java/com/alibaba/dubbo/demo/provider/MockRemove.java
+0
-74
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/PerformanceProvider.java
.../com/alibaba/dubbo/demo/provider/PerformanceProvider.java
+0
-27
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/RouteAdd.java
...c/test/java/com/alibaba/dubbo/demo/provider/RouteAdd.java
+0
-74
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/RouteRemove.java
...est/java/com/alibaba/dubbo/demo/provider/RouteRemove.java
+0
-74
未找到文件。
dubbo-demo/dubbo-demo-consumer/src/test/java/com/alibaba/dubbo/demo/consumer/AdminConsumer.java
已删除
100644 → 0
浏览文件 @
5495e300
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.dubbo.demo.consumer
;
import
java.util.List
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.ExtensionLoader
;
import
com.alibaba.dubbo.common.logger.Logger
;
import
com.alibaba.dubbo.common.logger.LoggerFactory
;
import
com.alibaba.dubbo.common.utils.ConfigUtils
;
import
com.alibaba.dubbo.common.utils.NetUtils
;
import
com.alibaba.dubbo.registry.NotifyListener
;
import
com.alibaba.dubbo.registry.Registry
;
import
com.alibaba.dubbo.registry.RegistryFactory
;
/**
* RegistryContainer
*
* @author william.liangf
*/
public
class
AdminConsumer
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
AdminConsumer
.
class
);
public
static
final
String
REGISTRY_ADDRESS
=
"dubbo.registry.address"
;
private
final
RegistryFactory
registryFactory
=
ExtensionLoader
.
getExtensionLoader
(
RegistryFactory
.
class
).
getAdaptiveExtension
();
private
Registry
registry
;
public
Registry
getRegistry
()
{
return
registry
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
AdminConsumer
c
=
new
AdminConsumer
();
c
.
start
();
System
.
in
.
read
();
c
.
stop
();
}
public
void
start
()
{
String
url
=
ConfigUtils
.
getProperty
(
REGISTRY_ADDRESS
);
if
(
url
==
null
||
url
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"Please set java start argument: -D"
+
REGISTRY_ADDRESS
+
"=zookeeper://127.0.0.1:2181"
);
}
URL
registryUrl
=
URL
.
valueOf
(
url
).
addParameter
(
Constants
.
CHECK_KEY
,
String
.
valueOf
(
false
));
registry
=
registryFactory
.
getRegistry
(
registryUrl
);
URL
subscribeUrl
=
new
URL
(
Constants
.
ADMIN_PROTOCOL
,
NetUtils
.
getLocalHost
(),
0
,
""
,
Constants
.
INTERFACE_KEY
,
Constants
.
ANY_VALUE
,
Constants
.
GROUP_KEY
,
Constants
.
ANY_VALUE
,
Constants
.
VERSION_KEY
,
Constants
.
ANY_VALUE
,
Constants
.
CLASSIFIER_KEY
,
Constants
.
ANY_VALUE
,
Constants
.
CATEGORY_KEY
,
Constants
.
ANY_VALUE
,
Constants
.
ENABLED_KEY
,
Constants
.
ANY_VALUE
,
Constants
.
CHECK_KEY
,
String
.
valueOf
(
false
));
registry
.
subscribe
(
subscribeUrl
,
new
NotifyListener
()
{
public
void
notify
(
List
<
URL
>
urls
)
{
if
(
urls
==
null
||
urls
.
size
()
==
0
)
{
return
;
}
System
.
out
.
println
(
"-----------(size:"
+
urls
.
size
()
+
") "
+
urls
);
}
});
}
public
void
stop
()
{
try
{
registry
.
destroy
();
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
\ No newline at end of file
dubbo-demo/dubbo-demo-consumer/src/test/java/com/alibaba/dubbo/demo/consumer/ExitConsumer.java
已删除
100644 → 0
浏览文件 @
5495e300
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.dubbo.demo.consumer
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
com.alibaba.dubbo.demo.DemoService
;
public
class
ExitConsumer
{
public
static
void
main
(
String
[]
args
)
{
ClassPathXmlApplicationContext
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]
{
"META-INF/spring/dubbo-demo-consumer.xml"
});
context
.
start
();
DemoService
demoService
=
(
DemoService
)
context
.
getBean
(
"demoService"
);
String
hello
=
demoService
.
sayHello
(
"world"
);
System
.
out
.
println
(
"demoService.sayHello result: "
+
hello
);
System
.
out
.
println
(
"Exit after once invoke!"
);
}
}
\ No newline at end of file
dubbo-demo/dubbo-demo-consumer/src/test/java/com/alibaba/dubbo/demo/consumer/PerformanceConsumer.java
已删除
100644 → 0
浏览文件 @
5495e300
package
com.alibaba.dubbo.demo.consumer
;
import
java.util.List
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.ExtensionLoader
;
import
com.alibaba.dubbo.common.utils.NetUtils
;
import
com.alibaba.dubbo.registry.NotifyListener
;
import
com.alibaba.dubbo.registry.Registry
;
import
com.alibaba.dubbo.registry.RegistryFactory
;
public
class
PerformanceConsumer
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
RegistryFactory
registryFactory
=
ExtensionLoader
.
getExtensionLoader
(
RegistryFactory
.
class
).
getAdaptiveExtension
();
final
Registry
registry
=
registryFactory
.
getRegistry
(
URL
.
valueOf
(
"zookeeper://10.20.153.10:2181"
));
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
final
int
fi
=
i
;
new
Thread
(
new
Runnable
()
{
public
void
run
()
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
registry
.
subscribe
(
URL
.
valueOf
(
"consumer://"
+
NetUtils
.
getLocalHost
()
+
":208"
+
fi
+
"/com.alibaba.dubbo.demo.DemoService"
+
j
+
"?version=1.0.0&timeout=200&category=providers,routers,overrides"
),
new
NotifyListener
()
{
public
void
notify
(
List
<
URL
>
urls
)
{
System
.
out
.
println
(
urls
);
}
});
}
}
}).
start
();
}
System
.
in
.
read
();
}
}
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/ExitProvider.java
已删除
100644 → 0
浏览文件 @
5495e300
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.dubbo.demo.provider
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
public
class
ExitProvider
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
ClassPathXmlApplicationContext
context
=
new
ClassPathXmlApplicationContext
(
new
String
[]
{
"META-INF/spring/dubbo-demo-provider.xml"
});
context
.
start
();
System
.
out
.
print
(
"Press any key to exit: "
);
System
.
in
.
read
();
}
}
\ No newline at end of file
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/MockAdd.java
已删除
100644 → 0
浏览文件 @
5495e300
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.dubbo.demo.provider
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.ExtensionLoader
;
import
com.alibaba.dubbo.common.logger.Logger
;
import
com.alibaba.dubbo.common.logger.LoggerFactory
;
import
com.alibaba.dubbo.common.utils.ConfigUtils
;
import
com.alibaba.dubbo.common.utils.NetUtils
;
import
com.alibaba.dubbo.demo.DemoService
;
import
com.alibaba.dubbo.registry.Registry
;
import
com.alibaba.dubbo.registry.RegistryFactory
;
/**
* RegistryContainer
*
* @author william.liangf
*/
public
class
MockAdd
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MockAdd
.
class
);
public
static
final
String
REGISTRY_ADDRESS
=
"dubbo.registry.address"
;
private
final
RegistryFactory
registryFactory
=
ExtensionLoader
.
getExtensionLoader
(
RegistryFactory
.
class
).
getAdaptiveExtension
();
private
Registry
registry
;
public
Registry
getRegistry
()
{
return
registry
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
MockAdd
c
=
new
MockAdd
();
c
.
start
();
Thread
.
sleep
(
500
);
c
.
stop
();
}
public
void
start
()
{
String
url
=
ConfigUtils
.
getProperty
(
REGISTRY_ADDRESS
);
if
(
url
==
null
||
url
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"Please set java start argument: -D"
+
REGISTRY_ADDRESS
+
"=zookeeper://127.0.0.1:2181"
);
}
URL
registryUrl
=
URL
.
valueOf
(
url
).
addParameter
(
Constants
.
CHECK_KEY
,
String
.
valueOf
(
false
));
registry
=
registryFactory
.
getRegistry
(
registryUrl
);
URL
mockUrl
=
URL
.
valueOf
(
"override://"
+
NetUtils
.
getLocalHost
()
+
"/"
+
DemoService
.
class
.
getName
()
+
"?category=configurators&dynamic=false&mock=force:return+null"
);
registry
.
register
(
mockUrl
);
}
public
void
stop
()
{
try
{
registry
.
destroy
();
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
\ No newline at end of file
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/MockRemove.java
已删除
100644 → 0
浏览文件 @
5495e300
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.dubbo.demo.provider
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.ExtensionLoader
;
import
com.alibaba.dubbo.common.logger.Logger
;
import
com.alibaba.dubbo.common.logger.LoggerFactory
;
import
com.alibaba.dubbo.common.utils.ConfigUtils
;
import
com.alibaba.dubbo.common.utils.NetUtils
;
import
com.alibaba.dubbo.demo.DemoService
;
import
com.alibaba.dubbo.registry.Registry
;
import
com.alibaba.dubbo.registry.RegistryFactory
;
/**
* RegistryContainer
*
* @author william.liangf
*/
public
class
MockRemove
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MockRemove
.
class
);
public
static
final
String
REGISTRY_ADDRESS
=
"dubbo.registry.address"
;
private
final
RegistryFactory
registryFactory
=
ExtensionLoader
.
getExtensionLoader
(
RegistryFactory
.
class
).
getAdaptiveExtension
();
private
Registry
registry
;
public
Registry
getRegistry
()
{
return
registry
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
MockRemove
c
=
new
MockRemove
();
c
.
start
();
Thread
.
sleep
(
500
);
c
.
stop
();
}
public
void
start
()
{
String
url
=
ConfigUtils
.
getProperty
(
REGISTRY_ADDRESS
);
if
(
url
==
null
||
url
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"Please set java start argument: -D"
+
REGISTRY_ADDRESS
+
"=zookeeper://127.0.0.1:2181"
);
}
URL
registryUrl
=
URL
.
valueOf
(
url
).
addParameter
(
Constants
.
CHECK_KEY
,
String
.
valueOf
(
false
));
registry
=
registryFactory
.
getRegistry
(
registryUrl
);
URL
mockUrl
=
URL
.
valueOf
(
"override://"
+
NetUtils
.
getLocalHost
()
+
"/"
+
DemoService
.
class
.
getName
()
+
"?category=configurators&dynamic=false&mock=force:return+null"
);
registry
.
unregister
(
mockUrl
);
}
public
void
stop
()
{
try
{
registry
.
destroy
();
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
\ No newline at end of file
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/PerformanceProvider.java
已删除
100644 → 0
浏览文件 @
5495e300
package
com.alibaba.dubbo.demo.provider
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.ExtensionLoader
;
import
com.alibaba.dubbo.common.utils.NetUtils
;
import
com.alibaba.dubbo.registry.Registry
;
import
com.alibaba.dubbo.registry.RegistryFactory
;
public
class
PerformanceProvider
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
RegistryFactory
registryFactory
=
ExtensionLoader
.
getExtensionLoader
(
RegistryFactory
.
class
).
getAdaptiveExtension
();
final
Registry
registry
=
registryFactory
.
getRegistry
(
URL
.
valueOf
(
"zookeeper://10.20.153.10:2181"
));
for
(
int
i
=
0
;
i
<
10
;
i
++)
{
final
int
fi
=
i
;
new
Thread
(
new
Runnable
()
{
public
void
run
()
{
for
(
int
j
=
0
;
j
<
10
;
j
++)
{
registry
.
register
(
URL
.
valueOf
(
"dubbo://"
+
NetUtils
.
getLocalHost
()
+
":208"
+
fi
+
"/com.alibaba.dubbo.demo.DemoService"
+
j
+
"?version=1.0.0&timeout=2000"
));
}
}
}).
start
();
}
System
.
in
.
read
();
}
}
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/RouteAdd.java
已删除
100644 → 0
浏览文件 @
5495e300
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.dubbo.demo.provider
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.ExtensionLoader
;
import
com.alibaba.dubbo.common.logger.Logger
;
import
com.alibaba.dubbo.common.logger.LoggerFactory
;
import
com.alibaba.dubbo.common.utils.ConfigUtils
;
import
com.alibaba.dubbo.common.utils.NetUtils
;
import
com.alibaba.dubbo.demo.DemoService
;
import
com.alibaba.dubbo.registry.Registry
;
import
com.alibaba.dubbo.registry.RegistryFactory
;
/**
* RegistryContainer
*
* @author william.liangf
*/
public
class
RouteAdd
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RouteAdd
.
class
);
public
static
final
String
REGISTRY_ADDRESS
=
"dubbo.registry.address"
;
private
final
RegistryFactory
registryFactory
=
ExtensionLoader
.
getExtensionLoader
(
RegistryFactory
.
class
).
getAdaptiveExtension
();
private
Registry
registry
;
public
Registry
getRegistry
()
{
return
registry
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
RouteAdd
c
=
new
RouteAdd
();
c
.
start
();
Thread
.
sleep
(
500
);
c
.
stop
();
}
public
void
start
()
{
String
url
=
ConfigUtils
.
getProperty
(
REGISTRY_ADDRESS
);
if
(
url
==
null
||
url
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"Please set java start argument: -D"
+
REGISTRY_ADDRESS
+
"=zookeeper://127.0.0.1:2181"
);
}
URL
registryUrl
=
URL
.
valueOf
(
url
).
addParameter
(
Constants
.
CHECK_KEY
,
String
.
valueOf
(
false
));
registry
=
registryFactory
.
getRegistry
(
registryUrl
);
URL
routeUrl
=
URL
.
valueOf
(
"condition://"
+
NetUtils
.
getLocalHost
()
+
"/"
+
DemoService
.
class
.
getName
()
+
"?category=routers&dynamic=false&rule="
+
URL
.
encode
(
"host="
+
NetUtils
.
getLocalHost
()
+
" => host="
+
NetUtils
.
getLocalHost
()));
registry
.
register
(
routeUrl
);
}
public
void
stop
()
{
try
{
registry
.
destroy
();
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
\ No newline at end of file
dubbo-demo/dubbo-demo-provider/src/test/java/com/alibaba/dubbo/demo/provider/RouteRemove.java
已删除
100644 → 0
浏览文件 @
5495e300
/*
* Copyright 1999-2011 Alibaba Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com.alibaba.dubbo.demo.provider
;
import
com.alibaba.dubbo.common.Constants
;
import
com.alibaba.dubbo.common.URL
;
import
com.alibaba.dubbo.common.extension.ExtensionLoader
;
import
com.alibaba.dubbo.common.logger.Logger
;
import
com.alibaba.dubbo.common.logger.LoggerFactory
;
import
com.alibaba.dubbo.common.utils.ConfigUtils
;
import
com.alibaba.dubbo.common.utils.NetUtils
;
import
com.alibaba.dubbo.demo.DemoService
;
import
com.alibaba.dubbo.registry.Registry
;
import
com.alibaba.dubbo.registry.RegistryFactory
;
/**
* RegistryContainer
*
* @author william.liangf
*/
public
class
RouteRemove
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
RouteRemove
.
class
);
public
static
final
String
REGISTRY_ADDRESS
=
"dubbo.registry.address"
;
private
final
RegistryFactory
registryFactory
=
ExtensionLoader
.
getExtensionLoader
(
RegistryFactory
.
class
).
getAdaptiveExtension
();
private
Registry
registry
;
public
Registry
getRegistry
()
{
return
registry
;
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
RouteRemove
c
=
new
RouteRemove
();
c
.
start
();
Thread
.
sleep
(
500
);
c
.
stop
();
}
public
void
start
()
{
String
url
=
ConfigUtils
.
getProperty
(
REGISTRY_ADDRESS
);
if
(
url
==
null
||
url
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"Please set java start argument: -D"
+
REGISTRY_ADDRESS
+
"=zookeeper://127.0.0.1:2181"
);
}
URL
registryUrl
=
URL
.
valueOf
(
url
).
addParameter
(
Constants
.
CHECK_KEY
,
String
.
valueOf
(
false
));
registry
=
registryFactory
.
getRegistry
(
registryUrl
);
URL
routeUrl
=
URL
.
valueOf
(
"condition://"
+
NetUtils
.
getLocalHost
()
+
"/"
+
DemoService
.
class
.
getName
()
+
"?category=routers&dynamic=false&rule="
+
URL
.
encode
(
"host="
+
NetUtils
.
getLocalHost
()
+
" => host="
+
NetUtils
.
getLocalHost
()));
registry
.
unregister
(
routeUrl
);
}
public
void
stop
()
{
try
{
registry
.
destroy
();
}
catch
(
Throwable
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录