xml :JBPM配置文件,主配置文件jbpm.cfg.xml;
binding :解析JBPM配置文件中的标签,解析后生成Descritor对象;每个bind对象和xml中的标签一一对应;可以参看WireParser类中对bind的解析和初始化,bindings定义文件jbpm.wire.bindings.xml;
descritor:JBPM配置文件的描述对象,暂且没有实例化,但是有创建和初始化的方法;
wireDefinition:description对象的集合,用Map对象实现;
wireContext:解析上下文,包含wireDefine对象,封装了descrition的创建方法,相当于descritor的代理;
1、jbpm.tx.hibernate.cfg.xml中有如下定义:
2、Binding对象用于解析xml:
public class CommandServiceBinding extends WireDescriptorBinding {
public CommandServiceBinding() {
super("command-service");
}
protected CommandServiceBinding(String tagName) {
super(tagName);
}
public Object parse(Element element, Parse parse, Parser parser) {
CommandServiceDescriptor commandServiceDescriptor = new CommandServiceDescriptor();
CommandService commandService = getCommandService(element, parse, parser);
commandServiceDescriptor.setCommandService(commandService);
List
for (Element interceptorElement : interceptorElements) {
Descriptor interceptorDescriptor = (Descriptor) parser.parseElement(interceptorElement, parse, WireParser.CATEGORY_INTERCEPTOR);
commandServiceDescriptor.addInterceptorDescriptor(interceptorDescriptor);
}
return commandServiceDescriptor;
}
protected CommandService getCommandService(Element element, Parse parse, Parser parser) {
Boolean async = XmlUtil.attributeBoolean(element, "async", parse);
if (Boolean.TRUE.equals(async)) {
AsyncCommandService asyncCommandService = new AsyncCommandService();
Boolean propagateUserId = XmlUtil.attributeBoolean(element, "propagate-auth", parse);
if (propagateUserId!=null) {
asyncCommandService.setPropagateUserId(propagateUserId);
}
return asyncCommandService;
}
return new DefaultCommandService();
}
}
3、Descriptor的代码:
public class CommandServiceDescriptor extends AbstractDescriptor {
private static final long serialVersionUID = 1L;
CommandService commandService;
List
public Object construct(WireContext wireContext) {
CommandService interceptedCommandService = commandService;
if (interceptorDescriptors!=null) {
for (int i=interceptorDescriptors.size()-1 ; i>=0; i--) {
Descriptor descriptor = interceptorDescriptors.get(i);
Interceptor interceptor = (Interceptor) descriptor.construct(wireContext);
interceptor.setNext(interceptedCommandService);
interceptedCommandService = interceptor;
}
}
return interceptedCommandService;
}
public Class< ? > getType(WireDefinition wireDefinition) {
return (name==null ? CommandService.class : null);
}
public void addInterceptorDescriptor(Descriptor descriptor) {
if (interceptorDescriptors==null) {
interceptorDescriptors = new ArrayList
}
interceptorDescriptors.add(descriptor);
}
public void setCommandService(CommandService commandService) {
this.commandService = commandService;
}
}