---
title: "Shark和jbpm的配置文件处理方式比较"
author: "hongsoft"
date: "2005-01-07T18:37:00Z"
tags: []
slug: "shark-jbpm"
draft: false
lastmod: "2005-01-07T18:37:00Z"
id: 287505
url: "https://hongsoft.iteye.com/blog/287505"
---

1.都使用了单例模式  
我想这个是最基本的,一般的程序员写解析程序都会这样使用;要说明的是,AgileFlow  
除了使用单例模式,还实现了配置文件的动态装载,如果用户修改了配置文件,它能够在  
运行中动态的获取这些变化.  
使用jbpm时,第一句话就要使用该模式:JbpmServiceFactory.getInstance()....

2.都实现了缺省配置和定制配置  
Shark中,缺省配置放在一个深层次的目录中,定制配置放在config目录,两个配置  
文件的内容差不多;  
jbpm中,缺省配置放在代码中实现,如下:  
propertyClassNames = new HashMap();  
propertyClassNames.put( "default", "org.jbpm.impl.DefaultServiceFactory" );  
abbreviatedClassNames.put( "jbpm.service.factory", propertyClassNames );  
定制配置放在config目录中,为jbpm.properties  
比较而言,jbpm的实现方式要好,理由如下:  
1)缺省配置容易找到  
2)定制配置很简单,默认是没有配置的,比shark的要清爽很多

3.都实现了用一个单例实现多个单例  
我在Shark学习系列的文章中讨论过这个功能,jbpm是在JbpmConfiguration.java中实现的:  
private void instantiateConfiguredObjects() {  
    // instantiate configured objects  
    this.fileMgr = (FileMgr) instantiate( "jbpm.file.mgr", FileMgr.class );  
    this.idGenerator = (IdGenerator) instantiate( "jbpm.id.generator", IdGenerator.class );  
    this.serviceFactory = (ServiceFactory) instantiate( "jbpm.service.factory", ServiceFactory.class );  
}