blob: fdd73c4e15f1826e81ac894bf587d01003a9b1b9 [file] [log] [blame]
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.dubbo.samples.simplified.registry.properties;
import org.apache.dubbo.common.URL;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
/**
* set -Dzookeeper.address=127.0.0.1 before run
*/
public class SimpleRegistryPropertiesProvider {
private static final String ZOOKEEPER_ADDRESS = "zookeeper.address";
private static final String ZOOKEEPER_PORT = "zookeeper.port";
public static void main(String[] args) throws Exception {
new EmbeddedZooKeeper(2181, false).start();
initProperties();
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/simplified-provider.xml");
context.start();
printServiceData();
System.out.println("dubbo service started");
new CountDownLatch(1).await();
}
private static void initProperties() {
if (System.getProperty(ZOOKEEPER_ADDRESS) == null) {
System.setProperty(ZOOKEEPER_ADDRESS, "127.0.0.1");
}
if (System.getProperty(ZOOKEEPER_PORT) == null) {
System.setProperty(ZOOKEEPER_PORT, "2181");
}
}
private static void printServiceData() {
List<String> urls = ZkUtil.getChildren(ZkUtil.toUrlPath("providers"));
System.out.println("*********************************************************");
urls.stream().map(URL::decode).forEach(System.out::println);
System.out.println("not contains 'executes':" + !urls.get(0).contains("executes"));
System.out.println("contains 'retries':" + urls.get(0).contains("retries"));
System.out.println("contains 'owner':" + urls.get(0).contains("owner"));
System.out.println("contains 'timeout(default)':" + urls.get(0).contains("timeout"));
System.out.println("contains 'version(default)':" + urls.get(0).contains("version"));
System.out.println("contains 'group(default)':" + urls.get(0).contains("group"));
System.out.println("contains 'specVersion(default)':" + urls.get(0).contains(RELEASE_KEY));
System.out.println("*********************************************************");
}
}