| 8 | import java.util.ResourceBundle; |
| 9 | |
| 10 | public class SqlParseConfig { |
| 11 | private static final Logger logger = LogManager.getLogger(SqlParseConfig.class); |
| 12 | |
| 13 | static final String DEFAULT_SQL_PARSE_CONFIG = "com/sql/parse/config/sql-parse"; |
| 14 | static final String DEFINE_SQL_PARSE_CONFIG = "sql-parse"; |
| 15 | private static String HANDLE; |
| 16 | private static String DB_TYPE; |
| 17 | |
| 18 | |
| 19 | static{ |
| 20 | try { |
| 21 | /*指定使用zh_CN*/ |
| 22 | ResourceBundle resourceBundle = ResourceBundle.getBundle(DEFAULT_SQL_PARSE_CONFIG.replaceAll("/", "."), new Locale("zh", "CN")); |
| 23 | SqlParseConfig.HANDLE = resourceBundle.getString("handle"); |
| 24 | SqlParseConfig.DB_TYPE = resourceBundle.getString("db.type"); |
| 25 | } catch (Exception e) { |
| 26 | logger.error("加载默认的配置文件出错:" + e.getMessage()); |
| 27 | } |
| 28 | try { |
| 29 | /*指定使用zh_CN*/ |
| 30 | ResourceBundle resourceBundle = ResourceBundle.getBundle(DEFINE_SQL_PARSE_CONFIG.replaceAll("/", "."), new Locale("zh", "CN")); |
| 31 | SqlParseConfig.HANDLE = resourceBundle.getString("handle"); |
| 32 | SqlParseConfig.DB_TYPE = resourceBundle.getString("db.type"); |
| 33 | } catch (Exception e) { |
| 34 | logger.debug("没有指定sql-parse的自定义配置文件"); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | public static String getHandle() { |
| 39 | return HANDLE; |
| 40 | } |
| 41 | |
| 42 | public static DbType getDbType() { |
| 43 | return DbType.of(DB_TYPE); |
| 44 | } |
| 45 | } |