提交 e8bb72c4 编写于 作者: T terrymanu

remove LogicSchemaFactory

上级 447e8bb2
/*
* 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.shardingsphere.shardingproxy.backend.schema;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.shardingproxy.backend.schema.impl.ShardingSphereSchema;
import org.apache.shardingsphere.shardingproxy.config.yaml.YamlDataSourceParameter;
import org.apache.shardingsphere.underlying.common.config.RuleConfiguration;
import java.sql.SQLException;
import java.util.Collection;
import java.util.Map;
/**
* Logic schema factory.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class LogicSchemaFactory {
/**
* Create new instance of logic schema.
*
* @param schemaName schema name
* @param schemaDataSources schema data sources
* @param ruleConfigurations rule configurations
* @return new instance of logic schema
* @throws SQLException SQL exception
*/
public static ShardingSphereSchema newInstance(final String schemaName, final Map<String, Map<String, YamlDataSourceParameter>> schemaDataSources,
final Collection<RuleConfiguration> ruleConfigurations) throws SQLException {
return new ShardingSphereSchema(schemaName, schemaDataSources.get(schemaName), ruleConfigurations);
}
}
......@@ -83,11 +83,11 @@ public final class ShardingSphereSchemas {
final Map<String, Collection<RuleConfiguration>> schemaRules) throws SQLException {
if (schemaRules.isEmpty()) {
String schema = schemaDataSources.keySet().iterator().next();
schemas.put(schema, LogicSchemaFactory.newInstance(schema, schemaDataSources, null));
schemas.put(schema, new ShardingSphereSchema(schema, schemaDataSources.get(schema), Collections.emptyList()));
}
for (Entry<String, Collection<RuleConfiguration>> entry : schemaRules.entrySet()) {
if (localSchemaNames.isEmpty() || localSchemaNames.contains(entry.getKey())) {
schemas.put(entry.getKey(), LogicSchemaFactory.newInstance(entry.getKey(), schemaDataSources, entry.getValue()));
schemas.put(entry.getKey(), new ShardingSphereSchema(entry.getKey(), schemaDataSources.get(entry.getKey()), entry.getValue()));
}
}
}
......@@ -129,9 +129,8 @@ public final class ShardingSphereSchemas {
*/
@Subscribe
public synchronized void renew(final SchemaAddedEvent schemaAddedEvent) throws SQLException {
schemas.put(schemaAddedEvent.getShardingSchemaName(), LogicSchemaFactory.newInstance(schemaAddedEvent.getShardingSchemaName(),
Collections.singletonMap(schemaAddedEvent.getShardingSchemaName(), DataSourceConverter.getDataSourceParameterMap(schemaAddedEvent.getDataSourceConfigurations())),
schemaAddedEvent.getRuleConfigurations()));
schemas.put(schemaAddedEvent.getShardingSchemaName(), new ShardingSphereSchema(schemaAddedEvent.getShardingSchemaName(),
DataSourceConverter.getDataSourceParameterMap(schemaAddedEvent.getDataSourceConfigurations()), schemaAddedEvent.getRuleConfigurations()));
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册