ActiveBpel有很多的目錄和文件配置,它對配置的處理也非常巧妙,我們分析如下:
1)CATALINA_HOME配置
有些朋友對TOMCAT的CATALINA_HOME配置感覺奇怪,其實看看TOMCAT的代碼我們就能夠
明白;在ActiveBpel中也有同樣的配置,它是怎么實現(xiàn)的呢?我們看看
org.activebpel.rt.tomcat.AeProcessEngineServlet的代碼就知道了.
org.activebpel.rt.tomcat.AeProcessEngineServlet用來啟動bpel服務(wù)器和axis服務(wù)
器,它是隨著tomcat的發(fā)布自動裝載的,它啟動后能夠啟動線程,該線程能夠監(jiān)聽業(yè)務(wù)流
程的發(fā)布.
org.activebpel.rt.tomcat.AeProcessEngineServlet有代碼如下:
??????? public static final String CATALINA_HOME = System.getProperties????
?? ().getProperty("catalina.home");
我想您已經(jīng)知道怎么回事了.
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比較熟悉,應(yīng)該不難看懂上面的代碼.如果/bpr/下面有配置文件,
則從該目錄下讀;否則,該文件可以被打包放到包里面了,那么從包中讀取配置文件.
posted on 2006-09-14 16:32
matthew 閱讀(406)
評論(0) 編輯 收藏 所屬分類:
Web Services and SOA