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 阅读(423) 
评论(0)  编辑  收藏  所属分类: 
Web Services and SOA