隨筆 - 251  文章 - 504  trackbacks - 0
          <2006年9月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          1234567

          本博客系個人收集材料及學習記錄之用,各類“大俠”勿擾!

          留言簿(14)

          隨筆分類

          收藏夾

          My Favorite Web Sites

          名Bloger

          非著名Bloger

          搜索

          •  

          積分與排名

          • 積分 - 202840
          • 排名 - 284

          最新評論

          ActiveBpel有很多的目錄和文件配置,它對配置的處理也非常巧妙,我們分析如下:

          1)CATALINA_HOME配置
          有些朋友對TOMCAT的CATALINA_HOME配置感覺奇怪,其實看看TOMCAT的代碼我們就能夠

          明白;在ActiveBpel中也有同樣的配置,它是怎么實現的呢?我們看看

          org.activebpel.rt.tomcat.AeProcessEngineServlet的代碼就知道了.
          org.activebpel.rt.tomcat.AeProcessEngineServlet用來啟動bpel服務器和axis服務

          器,它是隨著tomcat的發布自動裝載的,它啟動后能夠啟動線程,該線程能夠監聽業務流

          程的發布.
          org.activebpel.rt.tomcat.AeProcessEngineServlet有代碼如下:

          ??????? public static final String CATALINA_HOME = System.getProperties????

          ?? ().getProperty("catalina.home");
          我想您已經知道怎么回事了.

          2)ServletConfig配置
          我們看看web.xml文件:
          <init-param>
          ???????? <param-name>bprDirectory</param-name>
          ???????? <param-value>bpr</param-value>
          </init-param>
          ?? <!-- Specify the engine configuration location, relative to bpr

          directory -->
          <init-param>
          ???????? <param-name>aeEngineConfigFile</param-name>
          ???????? <param-value>aeEngineConfig.xml</param-value>
          </init-param>
          我們再看看代碼:
          ???????? mBprDirectory = CATALINA_HOME + "/" + aConfig.getInitParameter

          ("bprDirectory");
          ???????? String engineConfigFilename = aConfig.getInitParameter

          ("aeEngineConfigFile");
          上面的aConfig就是在init(ServletConfig aConfig)中聲明的,也就是,ActiveBpel啟

          動時直接從web.xml中讀取目錄和文件的配置

          3)getResourceAsStream的使用
          我們看看loadConfiguration方法的代碼:
          ???????? File file = new File(aConfigFilename);
          ???????? ClassLoader cl = Thread.currentThread().getContextClassLoader();
          ???????? if(file.exists())
          ???????? {
          ??????????? // load the configuration xml
          ??????????? in = new FileInputStream(file);
          ???????? }
          ???????? else
          ???????? {
          ??????????? log.info("File " + aConfigFilename + " doesn't exist loading

          from default classpath " + DEFAULT_BPEL_ENGINE_CONFIG);
          ??????????? // load the default configuration file if not in bpr directory
          ??????????? in = cl.getResourceAsStream(DEFAULT_BPEL_ENGINE_CONFIG);
          ???????? }
          如果您對ClassLoader比較熟悉,應該不難看懂上面的代碼.如果/bpr/下面有配置文件,

          則從該目錄下讀;否則,該文件可以被打包放到包里面了,那么從包中讀取配置文件.

          posted on 2006-09-14 16:32 matthew 閱讀(408) 評論(0)  編輯  收藏 所屬分類: Web Services and SOA
          主站蜘蛛池模板: 惠来县| 麻江县| 黄龙县| 济源市| 化德县| 宝清县| 常宁市| 普定县| 浏阳市| 万宁市| 平昌县| 贵定县| 锡林郭勒盟| 长沙县| 茌平县| 睢宁县| 凉城县| 江川县| 江阴市| 锦屏县| 临安市| 乐业县| 忻州市| 镇平县| 历史| 凌源市| 南安市| 吉林市| 浙江省| 玉环县| 沾化县| 会同县| 读书| 迭部县| 鹤庆县| 上思县| 郎溪县| 左权县| 临夏县| 伊川县| 枣强县|