@@ -0,0 +1,4530 @@
+/*%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.orchestration.internal.config;%0A%0Aimport io.shardingsphere.core.config.DataSourceConfiguration;%0Aimport io.shardingsphere.core.event.ShardingEventBusInstance;%0Aimport io.shardingsphere.core.rule.Authentication;%0Aimport io.shardingsphere.core.rule.ShardingRule;%0Aimport io.shardingsphere.orchestration.internal.event.config.ConfigurationChangedEvent;%0Aimport io.shardingsphere.orchestration.internal.event.config.MasterSlaveConfigurationChangedEvent;%0Aimport io.shardingsphere.orchestration.internal.event.config.ShardingConfigurationChangedEvent;%0Aimport io.shardingsphere.orchestration.internal.listener.ListenerManager;%0Aimport io.shardingsphere.orchestration.internal.state.datasource.DataSourceService;%0Aimport io.shardingsphere.orchestration.reg.api.RegistryCenter;%0Aimport io.shardingsphere.orchestration.reg.listener.DataChangedEvent;%0Aimport io.shardingsphere.orchestration.reg.listener.EventListener;%0A%0Aimport java.util.Map;%0Aimport java.util.Properties;%0A%0A/**%0A * Properties listener manager.%0A *%0A * @author panjuan%0A */%0Apublic final class PropertiesListenerManager implements ListenerManager %7B%0A    %0A    private final ConfigurationNode configNode;%0A    %0A    private final RegistryCenter regCenter;%0A    %0A    private final String shardingSchemaName;%0A    %0A    private final ConfigurationService configService;%0A    %0A    private final DataSourceService dataSourceService;%0A    %0A    public PropertiesListenerManager(final String name, final RegistryCenter regCenter, final String shardingSchemaName) %7B%0A        configNode = new ConfigurationNode(name);%0A        this.regCenter = regCenter;%0A        this.shardingSchemaName = shardingSchemaName;%0A        configService = new ConfigurationService(name, regCenter);%0A        dataSourceService = new DataSourceService(name, regCenter);%0A    %7D%0A    %0A    @Override%0A    public void watch() %7B%0A        watch(configNode.getDataSourcePath(shardingSchemaName));%0A        watch(configNode.getRulePath(shardingSchemaName));%0A        watch(configNode.getPropsPath());%0A    %7D%0A    %0A    private void watch(final String path) %7B%0A        regCenter.watch(path, new EventListener() %7B%0A            %0A            @Override%0A            public void onChange(final DataChangedEvent event) %7B%0A                if (DataChangedEvent.Type.UPDATED == event.getEventType()) %7B%0A                    Map%3CString, DataSourceConfiguration%3E dataSourceConfigurations = dataSourceService.getAvailableDataSourceConfigurations(shardingSchemaName);%0A                    Authentication authentication = configService.loadAuthentication();%0A                    Properties props = configService.loadProperties();%0A                    ShardingEventBusInstance.getInstance().post(configService.isShardingRule(shardingSchemaName)%0A                            ? getShardingEvent(dataSourceConfigurations, authentication, props) : getMasterSlaveEvent(dataSourceConfigurations, authentication, props));%0A                %7D%0A            %7D%0A            %0A            private ConfigurationChangedEvent getShardingEvent(final Map%3CString, DataSourceConfiguration%3E dataSourceConfigurations, final Authentication authentication, final Properties props) %7B%0A                return new ShardingConfigurationChangedEvent(shardingSchemaName, dataSourceConfigurations,%0A                        new ShardingRule(dataSourceService.getAvailableShardingRuleConfiguration(shardingSchemaName), dataSourceConfigurations.keySet()), authentication, props);%0A            %7D%0A            %0A            private ConfigurationChangedEvent getMasterSlaveEvent(final Map%3CString, DataSourceConfiguration%3E dataSourceConfigurations, final Authentication authentication, final Properties props) %7B%0A                return new MasterSlaveConfigurationChangedEvent(shardingSchemaName, dataSourceConfigurations,%0A                        dataSourceService.getAvailableMasterSlaveRuleConfiguration(shardingSchemaName), authentication, props);%0A            %7D%0A        %7D);%0A    %7D%0A%7D%0A

add Properties listener manager