123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538 |
- package com.system.configer.service;
- import java.sql.Connection;
- import java.sql.SQLException;
- import org.apache.log4j.Logger;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.support.ClassPathXmlApplicationContext;
- import com.system.configer.vo.GisConfigure;
- import com.system.configer.vo.WSClientConfigure;
- import com.toolkit.DES.DESPlus;
- import com.toolkit.copy.BeanUtil;
- //服务器运行参数配置类
- public class ServerConfigure{
- private Logger log = Logger.getLogger(this.getClass());
- // static ApplicationContext ctx=null;
- // public static ApplicationContext ctx = new
- // ClassPathXmlApplicationContext(
- // "applicationContextnew.xml");
- // servlet容器运行环境引用
- public static String serverConfiger;
- public static boolean flag = true;
- public static boolean flag2 = true;
- public static ApplicationContext ctx = new ClassPathXmlApplicationContext(
- "applicationContext.xml");
- public static ApplicationContext ctx2 = new ClassPathXmlApplicationContext(
- "applicationContext.xml");
- // public static ServerConfigure wsClient =
- // (ServerConfigure)ctx.getBean("WSClientConfigure");
- private javax.servlet.ServletContext myServletContext;
- // 单体类
- private static ServerConfigure sc = null;
- @SuppressWarnings("unused")
- private javax.sql.DataSource dataSource = null;
- private static String dbType = null;
- public static String getDbType() {
- if (sc == null || dbType == null) {
- try {
- dbType = "UNKNOWN";
- sc = ServerConfigure.getServerConfigerInstance();
- Connection con = sc.getDataSource().getConnection();
- dbType = con.getMetaData().getDriverName();
- if (dbType.contains("IBM")) {
- dbType = "IBM";
- } else if (dbType.contains("Microsoft")) {
- dbType = "MsSql";
- } else if (dbType.contains("Oracle")) {
- dbType = "Oracle";
- }
- con.close();
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return dbType;
- }
- public static ApplicationContext getCtx() {
- return ctx;
- }
- public com.mchange.v2.c3p0.ComboPooledDataSource getDataSource() {
- log.info("获取数据源c3p0.getDataSource");
- com.mchange.v2.c3p0.ComboPooledDataSource cds = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
- .getBean("dataSource");
- if (flag) {
- String eps = cds.getPassword();
- String euser = cds.getUser();
- DESPlus des;
- String despwd = "";
- String desuser = "";
- try {
- des = new DESPlus("leemenz");
- // 自定义密钥
- // log.debug("加密前的字符:"+eps);
- // log.debug("加密后的字符:" + eps);
- despwd = des.decrypt(eps);
- // log.debug("解密后的字符:" + despwd);
- desuser = des.decrypt(euser);
- cds.setPassword(despwd);
- cds.setUser(desuser);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- flag = false;
- }
- // log.debug(cds.getPassword());
- return cds;
- }
- public com.mchange.v2.c3p0.ComboPooledDataSource getDataSource(int type) {
- log.info("获取数据源c3p0.getDataSource.type");
- com.mchange.v2.c3p0.ComboPooledDataSource cds = null;
- try {
- // log.debug("连接测试----"+type);
- DESPlus des = new DESPlus("leemenz");
- if (type == 1) {// MSSQL
- com.mchange.v2.c3p0.ComboPooledDataSource temp = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
- .getBean("DSMsSql");
- cds = BeanUtil.cloneTo(temp);;
- if (cds != null) {
- cds.setPassword(des.decrypt(temp.getPassword()));
- cds.setUser(des.decrypt(temp.getUser()));
- }
- } else if (type == 2) {// MYSQL
- com.mchange.v2.c3p0.ComboPooledDataSource temp = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
- .getBean("DSMySql");
- cds = BeanUtil.cloneTo(temp);;
- if (cds != null) {
- cds.setPassword(des.decrypt(temp.getPassword()));
- cds.setUser(des.decrypt(temp.getUser()));
- }
- } else if (type == 3) {// DB2
- com.mchange.v2.c3p0.ComboPooledDataSource temp = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
- .getBean("DSDB2");
- cds = BeanUtil.cloneTo(temp);;
- if (cds != null) {
- cds.setPassword(des.decrypt(temp.getPassword()));
- cds.setUser(des.decrypt(temp.getUser()));
- }
- } else if (type == 4) {// ORACLE
- com.mchange.v2.c3p0.ComboPooledDataSource temp = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
- .getBean("DSOracle");
- cds = BeanUtil.cloneTo(temp);;
- if (cds != null) {
- cds.setPassword(des.decrypt(temp.getPassword()));
- cds.setUser(des.decrypt(temp.getUser()));
- }
- }
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return cds;
- }
- public void setDataSource(javax.sql.DataSource dataSource) {
- this.dataSource = dataSource;
- }
- public javax.sql.DataSource getDataSourceDB2() {
- log.info("获取数据源c3p0.getDataSource.getDataSourceDB2");
- com.mchange.v2.c3p0.ComboPooledDataSource cds2 = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
- .getBean("dataSourceDB2");
- if (flag2) {
- String eps = cds2.getPassword();
- String euser = cds2.getUser();
- DESPlus des;
- String despwd = "";
- String desuser = "";
- try {
- des = new DESPlus("leemenz");
- // 自定义密钥
- // log.debug("加密前的字符:"+eps);
- log.debug("加密后的字符:" + eps);
- despwd = des.decrypt(eps);
- desuser = des.decrypt(euser);
- log.debug("解密后的字符:" + despwd);
- cds2.setPassword(despwd);
- cds2.setUser(desuser);
- } catch (Exception e) {
- e.printStackTrace();
- }
- flag2 = false;
- }
- return cds2;
- }
- public void setDataSourceDB2(javax.sql.DataSource dataSourceDB2) {
- this.dataSource = dataSourceDB2;
- }
- public static ServerConfigure getServerConfigerInstance() {
- if (sc == null) {
- sc = new ServerConfigure();
- }
- return sc;
- }
- public static void setCtx(ApplicationContext ctx) {
- ServerConfigure.ctx = ctx;
- }
- public javax.servlet.ServletContext getMyServletContext() {
- return myServletContext;
- }
- public void setMyServletContext(javax.servlet.ServletContext myServletContext) {
- this.myServletContext = myServletContext;
- }
- // ScheduleConfiger scheduleCfg = null;
- //
- // public String getUpLoadCronExpression() {
- // if (scheduleCfg == null)
- // scheduleCfg = (ScheduleConfiger) ctx.getBean("ScheduleConfiger");
- //
- // return scheduleCfg.getUpLoadCronExpression();
- // }
- GisConfigure gscon = null;
- public String getArcGisMapName() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getArcGisMapName();
- }
- public String arcGisRoadBufferDisstance() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getArcGisRoadBufferDisstance();
- }
- public String getArcGisBypassrouteName() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getArcGisBypassrouteName();
- }
- public String getThemeHost() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getThemeServerHost();
- }
- public String getThemeHostUserName() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getThemeHostUserName();
- }
- public String getThemeHostPassWord() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getThemeHostUserPassWord();
- }
- public String getThemeServerName() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getThemeServerName();
- }
- public String getLayerNames() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getLayerNames();
- }
- public String getBufferRd() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getBufferRd();
- }
- public long getTimeInterval() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return Long.parseLong(gscon.getTimeInterval());
- }
- public String getThemePicturePath() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getThemePicturePath();
- }
- public String getThemeyingjibaogaoPath() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getThemeyingjibaogaoPath();
- }
- public String getMarkPicturePath() {
- if (gscon == null)
- gscon = (GisConfigure) ctx.getBean("GisConfigure");
- return gscon.getMarkPicturePath();
- }
- WSClientConfigure wscon = null;
- public String getweatherEquipStatus() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getWeatherEquipStatus();
- }
- public String gettrafficFlowEquipStatus() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getTrafficFlowEquipStatus();
- }
- public String getgpsEquipStatus() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getGpsEquipStatus();
- }
- public String getinfoBoardEquipStatus() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getInfoBoardEquipStatus();
- }
- public String getMonitorDataWS() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getMonitorData();
- }
- public String getImagePath() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getImagePath();
- }
- public String getInfoboardPublishNote() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getInfoboardPublishNote();
- }
- public String getDownloadNote() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getDownloadNote();
- }
- public String getMaintainFrequency() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getMaintainFrequency();
- }
- public String getInfoboardDataFrequency() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getInfoboardDataFrequency();
- }
- public String getInfoboardDataToSub() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getInfoboardDataToSub();
- }
- public String getInfoboardData() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getSynInfoboardData();
- }
- public String getInfoboardOverDue() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getInfoboardOverDue();
- }
- /**
- * 读取最新GPS数据频率
- *
- * @return
- */
- public String getGpsLatestData() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getGpsLatestData();
- }
- public String getStatPatrolCheck() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getStatpatrolcheck();
- }
- public String getAmalgamateFile() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getAmalgamateFile();
- }
- public String getImageBridge() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getImageBridgePath();
- }
- public String getImage_HM() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getImage_HMPath();
- }
- public String getMsgService() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getMsgService();
- }
- public String getMonitorToGzfwService() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getMonitorToGzfwService();
- }
- public String getInfoboardToGzfwService() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getInfoboardToGzfwService();
- }
- public String getVehServiceURL() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getVehServiceURL();
- }
- public String getPtgllzbb() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getPtgllzbb();
- }
- public String getSynvideouserServiceUrl() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getSynvideouserServiceUrl();
- }
- public String getPublishForeCast() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getPublishForeCast();
- }
- public String getPublishEvent() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getPublishEvent();
- }
- public String getPublishEventToGw() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getPublishEventToGw();
- }
- public String getPublishEventToGwAddress() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getPublishEventToGwAddress();
- }
- public String getGlServiceUrl() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getGlServiceUrl();
- }
- public String getGlwcServiceUrl() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getGlwcServiceUrl();
- }
- public String getTrafficflowTime() {
- if (wscon == null) {
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- }
- return wscon.getTrafficflowTime();
- }
- /**
- * 所属路线下拉框加载
- *
- * @return
- */
- public String getRoadWayLoadJobTrigger() {
- if (wscon == null)
- wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
- return wscon.getRoadWayLoadJobTrigger();
- }
- }
|