// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/jdbc/init/UninitializedConnectionProcessor.java
// public class UninitializedConnectionProcessor {
// 
//     private static Map<ConnectionProperty, InnerBean> map = new HashMap<ConnectionProperty, InnerBean>();
// 
//     public static void setDefaultValue(ConnectionProperty prop, Object val, boolean isSyncDefaultValue) {
//         if (prop == ConnectionProperty.metaData && isSyncDefaultValue) {
//             throw new DDRDataSourceException("Can't execute update for metaData");
//         }
//         map.put(prop, new InnerBean(val, isSyncDefaultValue));
//     }
// 
//     public static Object getDefaultValue(ConnectionProperty prop) {
//         InnerBean obj = map.get(prop);
//         if (obj != null) {
//             return obj.getVal();
//         } else {
//             return null;
//         }
//     }
// 
//     public static boolean isSetDefaultValue(ConnectionProperty prop) {
//         return map.containsKey(prop);
//     }
// 
//     public static boolean isSyncDefaultValue(ConnectionProperty prop) {
//         InnerBean obj = map.get(prop);
//         if (obj != null) {
//             return obj.isSyncDefaultValue();
//         } else {
//             return false;
//         }
//     }
// 
//     public static Object removeDefaultValue(ConnectionProperty prop) {
//         return map.remove(prop);
//     }
// 
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/jdbc/property/ConnectionProperty.java
// public enum ConnectionProperty {
// 
//     readOnly,
// 
//     autoCommit,
// 
//     catalog,
// 
//     transactionIsolation,
// 
//     typeMap,
// 
//     holdability,
// 
//     schema,
// 
//     metaData;
// 
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/jdbc/property/DataSourceProperty.java
// public enum DataSourceProperty {
// 
//     loginTimeout,
// 
//     logWriter;
// 
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/manager/DataSourceParam.java
// public class DataSourceParam {
// 
//     private Set<String> scNames;
//     private boolean     readOnly;
// 
//     public Set<String> getScNames() {
//         return scNames;
//     }
// 
//     public void setScNames(Set<String> scNames) {
//         this.scNames = scNames;
//     }
// 
//     public boolean isReadOnly() {
//         return readOnly;
//     }
// 
//     public void setReadOnly(boolean readOnly) {
//         this.readOnly = readOnly;
//     }
// 
//     @Override
//     public String toString() {
//         return new DDRToStringBuilder().append("readOnly", readOnly).append("scNames", scNames).toString();
//     }
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/shard/ShardParser.java
// public interface ShardParser {
// 
//     SQLParsedResult parse(String sql, Map<Object, Object> jdbcParams);
// 
// }


import org.hellojavaer.ddal.ddr.datasource.jdbc.init.UninitializedConnectionProcessor;
import org.hellojavaer.ddal.ddr.datasource.jdbc.init.UninitializedDataSourceProcessor;
import org.hellojavaer.ddal.ddr.datasource.jdbc.property.ConnectionProperty;
import org.hellojavaer.ddal.ddr.datasource.jdbc.property.DataSourceProperty;
import org.hellojavaer.ddal.ddr.datasource.manager.DataSourceManager;
import org.hellojavaer.ddal.ddr.datasource.manager.DataSourceParam;
import org.hellojavaer.ddal.ddr.shard.ShardParser;
import org.hellojavaer.ddal.ddr.sqlparse.SQLParsedResult;
import java.util.Collections;
import java.util.Map;
/*
 * Copyright 2016-2017 the original author or authors.
 *
 * 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 org.hellojavaer.ddal.ddr.datasource.jdbc;



/**
 *
 * @author <a href="mailto:hellojavaer@gmail.com">Kaiming Zou</a>,created on 10/12/2016.
 */
public class DefaultDDRDataSource extends AbstractDDRDataSource {

    private DataSourceManager dataSourceManager;
    private ShardParser       shardParser;

    static {
        UninitializedDataSourceProcessor.setDefaultValue(DataSourceProperty.loginTimeout, 0, false);
        UninitializedConnectionProcessor.setDefaultValue(ConnectionProperty.autoCommit, true, true);
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/jdbc/init/UninitializedConnectionProcessor.java
// public class UninitializedConnectionProcessor {
// 
//     private static Map<ConnectionProperty, InnerBean> map = new HashMap<ConnectionProperty, InnerBean>();
// 
//     public static void setDefaultValue(ConnectionProperty prop, Object val, boolean isSyncDefaultValue) {
//         if (prop == ConnectionProperty.metaData && isSyncDefaultValue) {
//             throw new DDRDataSourceException("Can't execute update for metaData");
//         }
//         map.put(prop, new InnerBean(val, isSyncDefaultValue));
//     }
// 
//     public static Object getDefaultValue(ConnectionProperty prop) {
//         InnerBean obj = map.get(prop);
//         if (obj != null) {
//             return obj.getVal();
//         } else {
//             return null;
//         }
//     }
// 
//     public static boolean isSetDefaultValue(ConnectionProperty prop) {
//         return map.containsKey(prop);
//     }
// 
//     public static boolean isSyncDefaultValue(ConnectionProperty prop) {
//         InnerBean obj = map.get(prop);
//         if (obj != null) {
//             return obj.isSyncDefaultValue();
//         } else {
//             return false;
//         }
//     }
// 
//     public static Object removeDefaultValue(ConnectionProperty prop) {
//         return map.remove(prop);
//     }
// 
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/jdbc/property/ConnectionProperty.java
// public enum ConnectionProperty {
// 
//     readOnly,
// 
//     autoCommit,
// 
//     catalog,
// 
//     transactionIsolation,
// 
//     typeMap,
// 
//     holdability,
// 
//     schema,
// 
//     metaData;
// 
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/jdbc/property/DataSourceProperty.java
// public enum DataSourceProperty {
// 
//     loginTimeout,
// 
//     logWriter;
// 
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/manager/DataSourceParam.java
// public class DataSourceParam {
// 
//     private Set<String> scNames;
//     private boolean     readOnly;
// 
//     public Set<String> getScNames() {
//         return scNames;
//     }
// 
//     public void setScNames(Set<String> scNames) {
//         this.scNames = scNames;
//     }
// 
//     public boolean isReadOnly() {
//         return readOnly;
//     }
// 
//     public void setReadOnly(boolean readOnly) {
//         this.readOnly = readOnly;
//     }
// 
//     @Override
//     public String toString() {
//         return new DDRToStringBuilder().append("readOnly", readOnly).append("scNames", scNames).toString();
//     }
// }
// 
// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/shard/ShardParser.java
// public interface ShardParser {
// 
//     SQLParsedResult parse(String sql, Map<Object, Object> jdbcParams);
// 
// }


// Path: ddal-ddr/src/main/java/org/hellojavaer/ddal/ddr/datasource/jdbc/DefaultDDRDataSource.java
import org.hellojavaer.ddal.ddr.datasource.jdbc.init.UninitializedConnectionProcessor;
import org.hellojavaer.ddal.ddr.datasource.jdbc.init.UninitializedDataSourceProcessor;
import org.hellojavaer.ddal.ddr.datasource.jdbc.property.ConnectionProperty;
import org.hellojavaer.ddal.ddr.datasource.jdbc.property.DataSourceProperty;
import org.hellojavaer.ddal.ddr.datasource.manager.DataSourceManager;
import org.hellojavaer.ddal.ddr.datasource.manager.DataSourceParam;
import org.hellojavaer.ddal.ddr.shard.ShardParser;
import org.hellojavaer.ddal.ddr.sqlparse.SQLParsedResult;
import java.util.Collections;
import java.util.Map;

/*
 * Copyright 2016-2017 the original author or authors.
 *
 * 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 org.hellojavaer.ddal.ddr.datasource.jdbc;



/**
 *
 * @author <a href="mailto:hellojavaer@gmail.com">Kaiming Zou</a>,created on 10/12/2016.
 */
public class DefaultDDRDataSource extends AbstractDDRDataSource {

    private DataSourceManager dataSourceManager;
    private ShardParser       shardParser;

    static {
        UninitializedDataSourceProcessor.setDefaultValue(DataSourceProperty.loginTimeout, 0, false);
        UninitializedConnectionProcessor.setDefaultValue(ConnectionProperty.autoCommit, true, true);
        UninitializedConnectionProcessor.setDefaultValue(ConnectionProperty.metaData, null, false);