@@ -0,0 +1,2824 @@
+/*%0A * Copyright 2016-2018 shardingsphere.io.%0A * %3Cp%3E%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * %3C/p%3E%0A */%0A%0Apackage io.shardingsphere.shardingui.util;%0A%0Aimport io.shardingsphere.orchestration.reg.api.RegistryCenter;%0Aimport io.shardingsphere.orchestration.reg.api.RegistryCenterConfiguration;%0Aimport io.shardingsphere.orchestration.reg.etcd.EtcdRegistryCenter;%0Aimport io.shardingsphere.orchestration.reg.zookeeper.curator.CuratorZookeeperRegistryCenter;%0Aimport io.shardingsphere.shardingui.common.constant.RegistryCenterType;%0Aimport io.shardingsphere.shardingui.common.domain.RegistryCenterConfig;%0Aimport lombok.AccessLevel;%0Aimport lombok.NoArgsConstructor;%0A%0Aimport java.util.concurrent.ConcurrentHashMap;%0A%0A/**%0A * Registry center factory.%0A *%0A * @author chenqingyang%0A */%0A@NoArgsConstructor(access = AccessLevel.PRIVATE)%0Apublic final class RegistryCenterFactory %7B%0A    %0A    private static final ConcurrentHashMap%3CString, RegistryCenter%3E REGISTRY_CENTER_MAP = new ConcurrentHashMap%3C%3E();%0A    %0A    /**%0A     * Create registry center instance.%0A     *%0A     * @param config registry center config%0A     * @return registry center%0A     */%0A    public static RegistryCenter createRegistryCenter(final RegistryCenterConfig config) %7B%0A        RegistryCenter result = REGISTRY_CENTER_MAP.get(config.getName());%0A        if (null != result) %7B%0A            return result;%0A        %7D%0A        RegistryCenterType registryCenterType = RegistryCenterType.nameOf(config.getRegistryCenterType());%0A        switch (registryCenterType) %7B%0A            case ZOOKEEPER:%0A                result = new CuratorZookeeperRegistryCenter();%0A                break;%0A            case ETCD:%0A                result = new EtcdRegistryCenter();%0A                break;%0A            default:%0A                throw new UnsupportedOperationException(config.getName());%0A        %7D%0A        result.init(convert(config));%0A        REGISTRY_CENTER_MAP.put(config.getName(), result);%0A        return result;%0A    %7D%0A    %0A    private static RegistryCenterConfiguration convert(final RegistryCenterConfig config) %7B%0A        RegistryCenterConfiguration result = new RegistryCenterConfiguration();%0A        result.setServerLists(config.getServerLists());%0A        result.setNamespace(config.getNamespace());%0A        result.setDigest(config.getDigest());%0A        return result;%0A    %7D%0A    %0A%7D%0A

add registry center factory