2def0ac215f8503ac4da842bc7e043ce1eccf98c.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. package com.system.configer.service;
  2. import java.sql.Connection;
  3. import java.sql.SQLException;
  4. import org.apache.log4j.Logger;
  5. import org.springframework.context.ApplicationContext;
  6. import org.springframework.context.support.ClassPathXmlApplicationContext;
  7. import com.system.configer.vo.GisConfigure;
  8. import com.system.configer.vo.WSClientConfigure;
  9. import com.toolkit.DES.DESPlus;
  10. import com.toolkit.copy.BeanUtil;
  11. //服务器运行参数配置类
  12. public class ServerConfigure{
  13. private Logger log = Logger.getLogger(this.getClass());
  14. // static ApplicationContext ctx=null;
  15. // public static ApplicationContext ctx = new
  16. // ClassPathXmlApplicationContext(
  17. // "applicationContextnew.xml");
  18. // servlet容器运行环境引用
  19. public static String serverConfiger;
  20. public static boolean flag = true;
  21. public static boolean flag2 = true;
  22. public static ApplicationContext ctx = new ClassPathXmlApplicationContext(
  23. "applicationContext.xml");
  24. public static ApplicationContext ctx2 = new ClassPathXmlApplicationContext(
  25. "applicationContext.xml");
  26. // public static ServerConfigure wsClient =
  27. // (ServerConfigure)ctx.getBean("WSClientConfigure");
  28. private javax.servlet.ServletContext myServletContext;
  29. // 单体类
  30. private static ServerConfigure sc = null;
  31. @SuppressWarnings("unused")
  32. private javax.sql.DataSource dataSource = null;
  33. private static String dbType = null;
  34. public static String getDbType() {
  35. if (sc == null || dbType == null) {
  36. try {
  37. dbType = "UNKNOWN";
  38. sc = ServerConfigure.getServerConfigerInstance();
  39. Connection con = sc.getDataSource().getConnection();
  40. dbType = con.getMetaData().getDriverName();
  41. if (dbType.contains("IBM")) {
  42. dbType = "IBM";
  43. } else if (dbType.contains("Microsoft")) {
  44. dbType = "MsSql";
  45. } else if (dbType.contains("Oracle")) {
  46. dbType = "Oracle";
  47. }
  48. con.close();
  49. } catch (SQLException e) {
  50. e.printStackTrace();
  51. }
  52. }
  53. return dbType;
  54. }
  55. public static ApplicationContext getCtx() {
  56. return ctx;
  57. }
  58. public com.mchange.v2.c3p0.ComboPooledDataSource getDataSource() {
  59. log.info("获取数据源c3p0.getDataSource");
  60. com.mchange.v2.c3p0.ComboPooledDataSource cds = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
  61. .getBean("dataSource");
  62. if (flag) {
  63. String eps = cds.getPassword();
  64. String euser = cds.getUser();
  65. DESPlus des;
  66. String despwd = "";
  67. String desuser = "";
  68. try {
  69. des = new DESPlus("leemenz");
  70. // 自定义密钥
  71. // log.debug("加密前的字符:"+eps);
  72. // log.debug("加密后的字符:" + eps);
  73. despwd = des.decrypt(eps);
  74. // log.debug("解密后的字符:" + despwd);
  75. desuser = des.decrypt(euser);
  76. cds.setPassword(despwd);
  77. cds.setUser(desuser);
  78. } catch (Exception e) {
  79. // TODO Auto-generated catch block
  80. e.printStackTrace();
  81. }
  82. flag = false;
  83. }
  84. // log.debug(cds.getPassword());
  85. return cds;
  86. }
  87. public com.mchange.v2.c3p0.ComboPooledDataSource getDataSource(int type) {
  88. log.info("获取数据源c3p0.getDataSource.type");
  89. com.mchange.v2.c3p0.ComboPooledDataSource cds = null;
  90. try {
  91. // log.debug("连接测试----"+type);
  92. DESPlus des = new DESPlus("leemenz");
  93. if (type == 1) {// MSSQL
  94. com.mchange.v2.c3p0.ComboPooledDataSource temp = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
  95. .getBean("DSMsSql");
  96. cds = BeanUtil.cloneTo(temp);;
  97. if (cds != null) {
  98. cds.setPassword(des.decrypt(temp.getPassword()));
  99. cds.setUser(des.decrypt(temp.getUser()));
  100. }
  101. } else if (type == 2) {// MYSQL
  102. com.mchange.v2.c3p0.ComboPooledDataSource temp = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
  103. .getBean("DSMySql");
  104. cds = BeanUtil.cloneTo(temp);;
  105. if (cds != null) {
  106. cds.setPassword(des.decrypt(temp.getPassword()));
  107. cds.setUser(des.decrypt(temp.getUser()));
  108. }
  109. } else if (type == 3) {// DB2
  110. com.mchange.v2.c3p0.ComboPooledDataSource temp = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
  111. .getBean("DSDB2");
  112. cds = BeanUtil.cloneTo(temp);;
  113. if (cds != null) {
  114. cds.setPassword(des.decrypt(temp.getPassword()));
  115. cds.setUser(des.decrypt(temp.getUser()));
  116. }
  117. } else if (type == 4) {// ORACLE
  118. com.mchange.v2.c3p0.ComboPooledDataSource temp = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
  119. .getBean("DSOracle");
  120. cds = BeanUtil.cloneTo(temp);;
  121. if (cds != null) {
  122. cds.setPassword(des.decrypt(temp.getPassword()));
  123. cds.setUser(des.decrypt(temp.getUser()));
  124. }
  125. }
  126. } catch (Exception e) {
  127. // TODO Auto-generated catch block
  128. e.printStackTrace();
  129. }
  130. return cds;
  131. }
  132. public void setDataSource(javax.sql.DataSource dataSource) {
  133. this.dataSource = dataSource;
  134. }
  135. public javax.sql.DataSource getDataSourceDB2() {
  136. log.info("获取数据源c3p0.getDataSource.getDataSourceDB2");
  137. com.mchange.v2.c3p0.ComboPooledDataSource cds2 = (com.mchange.v2.c3p0.ComboPooledDataSource) ctx
  138. .getBean("dataSourceDB2");
  139. if (flag2) {
  140. String eps = cds2.getPassword();
  141. String euser = cds2.getUser();
  142. DESPlus des;
  143. String despwd = "";
  144. String desuser = "";
  145. try {
  146. des = new DESPlus("leemenz");
  147. // 自定义密钥
  148. // log.debug("加密前的字符:"+eps);
  149. log.debug("加密后的字符:" + eps);
  150. despwd = des.decrypt(eps);
  151. desuser = des.decrypt(euser);
  152. log.debug("解密后的字符:" + despwd);
  153. cds2.setPassword(despwd);
  154. cds2.setUser(desuser);
  155. } catch (Exception e) {
  156. e.printStackTrace();
  157. }
  158. flag2 = false;
  159. }
  160. return cds2;
  161. }
  162. public void setDataSourceDB2(javax.sql.DataSource dataSourceDB2) {
  163. this.dataSource = dataSourceDB2;
  164. }
  165. public static ServerConfigure getServerConfigerInstance() {
  166. if (sc == null) {
  167. sc = new ServerConfigure();
  168. }
  169. return sc;
  170. }
  171. public static void setCtx(ApplicationContext ctx) {
  172. ServerConfigure.ctx = ctx;
  173. }
  174. public javax.servlet.ServletContext getMyServletContext() {
  175. return myServletContext;
  176. }
  177. public void setMyServletContext(javax.servlet.ServletContext myServletContext) {
  178. this.myServletContext = myServletContext;
  179. }
  180. // ScheduleConfiger scheduleCfg = null;
  181. //
  182. // public String getUpLoadCronExpression() {
  183. // if (scheduleCfg == null)
  184. // scheduleCfg = (ScheduleConfiger) ctx.getBean("ScheduleConfiger");
  185. //
  186. // return scheduleCfg.getUpLoadCronExpression();
  187. // }
  188. GisConfigure gscon = null;
  189. public String getArcGisMapName() {
  190. if (gscon == null)
  191. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  192. return gscon.getArcGisMapName();
  193. }
  194. public String arcGisRoadBufferDisstance() {
  195. if (gscon == null)
  196. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  197. return gscon.getArcGisRoadBufferDisstance();
  198. }
  199. public String getArcGisBypassrouteName() {
  200. if (gscon == null)
  201. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  202. return gscon.getArcGisBypassrouteName();
  203. }
  204. public String getThemeHost() {
  205. if (gscon == null)
  206. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  207. return gscon.getThemeServerHost();
  208. }
  209. public String getThemeHostUserName() {
  210. if (gscon == null)
  211. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  212. return gscon.getThemeHostUserName();
  213. }
  214. public String getThemeHostPassWord() {
  215. if (gscon == null)
  216. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  217. return gscon.getThemeHostUserPassWord();
  218. }
  219. public String getThemeServerName() {
  220. if (gscon == null)
  221. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  222. return gscon.getThemeServerName();
  223. }
  224. public String getLayerNames() {
  225. if (gscon == null)
  226. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  227. return gscon.getLayerNames();
  228. }
  229. public String getBufferRd() {
  230. if (gscon == null)
  231. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  232. return gscon.getBufferRd();
  233. }
  234. public long getTimeInterval() {
  235. if (gscon == null)
  236. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  237. return Long.parseLong(gscon.getTimeInterval());
  238. }
  239. public String getThemePicturePath() {
  240. if (gscon == null)
  241. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  242. return gscon.getThemePicturePath();
  243. }
  244. public String getThemeyingjibaogaoPath() {
  245. if (gscon == null)
  246. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  247. return gscon.getThemeyingjibaogaoPath();
  248. }
  249. public String getMarkPicturePath() {
  250. if (gscon == null)
  251. gscon = (GisConfigure) ctx.getBean("GisConfigure");
  252. return gscon.getMarkPicturePath();
  253. }
  254. WSClientConfigure wscon = null;
  255. public String getweatherEquipStatus() {
  256. if (wscon == null)
  257. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  258. return wscon.getWeatherEquipStatus();
  259. }
  260. public String gettrafficFlowEquipStatus() {
  261. if (wscon == null)
  262. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  263. return wscon.getTrafficFlowEquipStatus();
  264. }
  265. public String getgpsEquipStatus() {
  266. if (wscon == null)
  267. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  268. return wscon.getGpsEquipStatus();
  269. }
  270. public String getinfoBoardEquipStatus() {
  271. if (wscon == null)
  272. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  273. return wscon.getInfoBoardEquipStatus();
  274. }
  275. public String getMonitorDataWS() {
  276. if (wscon == null)
  277. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  278. return wscon.getMonitorData();
  279. }
  280. public String getImagePath() {
  281. if (wscon == null)
  282. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  283. return wscon.getImagePath();
  284. }
  285. public String getInfoboardPublishNote() {
  286. if (wscon == null)
  287. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  288. return wscon.getInfoboardPublishNote();
  289. }
  290. public String getDownloadNote() {
  291. if (wscon == null)
  292. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  293. return wscon.getDownloadNote();
  294. }
  295. public String getMaintainFrequency() {
  296. if (wscon == null)
  297. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  298. return wscon.getMaintainFrequency();
  299. }
  300. public String getInfoboardDataFrequency() {
  301. if (wscon == null)
  302. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  303. return wscon.getInfoboardDataFrequency();
  304. }
  305. public String getInfoboardDataToSub() {
  306. if (wscon == null)
  307. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  308. return wscon.getInfoboardDataToSub();
  309. }
  310. public String getInfoboardData() {
  311. if (wscon == null)
  312. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  313. return wscon.getSynInfoboardData();
  314. }
  315. public String getInfoboardOverDue() {
  316. if (wscon == null)
  317. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  318. return wscon.getInfoboardOverDue();
  319. }
  320. /**
  321. * 读取最新GPS数据频率
  322. *
  323. * @return
  324. */
  325. public String getGpsLatestData() {
  326. if (wscon == null)
  327. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  328. return wscon.getGpsLatestData();
  329. }
  330. public String getStatPatrolCheck() {
  331. if (wscon == null)
  332. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  333. return wscon.getStatpatrolcheck();
  334. }
  335. public String getAmalgamateFile() {
  336. if (wscon == null)
  337. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  338. return wscon.getAmalgamateFile();
  339. }
  340. public String getImageBridge() {
  341. if (wscon == null)
  342. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  343. return wscon.getImageBridgePath();
  344. }
  345. public String getImage_HM() {
  346. if (wscon == null)
  347. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  348. return wscon.getImage_HMPath();
  349. }
  350. public String getMsgService() {
  351. if (wscon == null)
  352. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  353. return wscon.getMsgService();
  354. }
  355. public String getMonitorToGzfwService() {
  356. if (wscon == null)
  357. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  358. return wscon.getMonitorToGzfwService();
  359. }
  360. public String getInfoboardToGzfwService() {
  361. if (wscon == null)
  362. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  363. return wscon.getInfoboardToGzfwService();
  364. }
  365. public String getVehServiceURL() {
  366. if (wscon == null)
  367. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  368. return wscon.getVehServiceURL();
  369. }
  370. public String getPtgllzbb() {
  371. if (wscon == null)
  372. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  373. return wscon.getPtgllzbb();
  374. }
  375. public String getSynvideouserServiceUrl() {
  376. if (wscon == null)
  377. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  378. return wscon.getSynvideouserServiceUrl();
  379. }
  380. public String getPublishForeCast() {
  381. if (wscon == null)
  382. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  383. return wscon.getPublishForeCast();
  384. }
  385. public String getPublishEvent() {
  386. if (wscon == null)
  387. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  388. return wscon.getPublishEvent();
  389. }
  390. public String getPublishEventToGw() {
  391. if (wscon == null)
  392. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  393. return wscon.getPublishEventToGw();
  394. }
  395. public String getPublishEventToGwAddress() {
  396. if (wscon == null)
  397. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  398. return wscon.getPublishEventToGwAddress();
  399. }
  400. public String getGlServiceUrl() {
  401. if (wscon == null)
  402. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  403. return wscon.getGlServiceUrl();
  404. }
  405. public String getGlwcServiceUrl() {
  406. if (wscon == null)
  407. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  408. return wscon.getGlwcServiceUrl();
  409. }
  410. public String getTrafficflowTime() {
  411. if (wscon == null) {
  412. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  413. }
  414. return wscon.getTrafficflowTime();
  415. }
  416. /**
  417. * 所属路线下拉框加载
  418. *
  419. * @return
  420. */
  421. public String getRoadWayLoadJobTrigger() {
  422. if (wscon == null)
  423. wscon = (WSClientConfigure) ctx.getBean("WSClientConfigure");
  424. return wscon.getRoadWayLoadJobTrigger();
  425. }
  426. }