??xml version="1.0" encoding="utf-8" standalone="yes"?>久久精品国产亚洲网站,亚洲影院天堂中文av色,亚洲一区二区成人http://m.tkk7.com/libin2722/category/40764.html虚其心,可解天下之问Q专其心Q可d下之学;静其心,可悟天下之理Q恒其心Q可成天下之业?/description>zh-cnTue, 14 Jul 2009 17:03:01 GMTTue, 14 Jul 2009 17:03:01 GMT60jBPM 4.0 解读分析http://m.tkk7.com/libin2722/articles/286675.htmlC物C物Tue, 14 Jul 2009 05:15:00 GMThttp://m.tkk7.com/libin2722/articles/286675.htmlhttp://m.tkk7.com/libin2722/comments/286675.htmlhttp://m.tkk7.com/libin2722/articles/286675.html#Feedback0http://m.tkk7.com/libin2722/comments/commentRss/286675.htmlhttp://m.tkk7.com/libin2722/services/trackbacks/286675.html
Revision History
Revision 0.1 2009/06/29
增加了前3章的内容

Abstract

q篇文章主要是介l了jBPM 4.0的基架构,以及通过一个简单的例子来让大家知道怎么应用jBPM. Z么选择4.0版本?以后的主版本应该是4.0版本?所以直接写4.0版本的了.

在默认情况下,jBPM包里有个jbpm.cfg.xml,q个是他的配置文g,我们先看下它的内?

												
														
<jbpm-configuration>
<import resource="jbpm.default.cfg.xml" />
<import resource="jbpm.tx.jta.cfg.xml" />
<import resource="jbpm.jpdl.cfg.xml" />
<import resource="jbpm.identity.cfg.xml" />
<import resource="jbpm.jobexecutor.cfg.xml" />
</jbpm-configuration>

q里,我们再l看?span class="emphasis">jbpm.default.cfg.xml,看下配置文g到底是长啥样.

												
														
<process-engine-context>
<repository-service />
<repository-cache />
<execution-service />
<history-service />
<management-service />
<identity-service />
<task-service />
<hibernate-configuration>
<cfg resource="jbpm.hibernate.cfg.xml" />
</hibernate-configuration>
...........
</process-engine-context>

<transaction-context>
<repository-session />
<db-session />
<message-session />
<timer-session />
<history-session />
<mail-session>
<mail-server>
<session-properties resource="jbpm.mail.properties" />
</mail-server>
</mail-session>
</transaction-context>

q个配置文g主要包含?process-engine-context'?'transaction-context'的配|?

我们知道,现在都是讲究Dependency Inject (Inversion of Control),那么,我们q里到底是哪个类来实现repository-service?那配|mail-session又是怎么实例化的? 我们先来看下jBPM的IOC实现机制.

首先?span class="emphasis">Context接口,你可以从q里存储,获得对象.它的接口很简?

												  Object get(String key);
<T> T get(Class<T> type);

Object set(String key, Object value);

你看可以从Context中获取到lg,对于IOC容器来说Q一般情况下都会提供一U加载的方式Q比如从xml文gq行加蝲、从资源文gq行加蝲?

Jbpm4是通过WireParser来解析xml,然后创徏q把对象存放?span class="emphasis">WireContext. WireContextq个c负责存?提取对象,内部用一个Map来存储已l创建的对象实例,可以单得把他看成是IOC的一个实现类. ?span class="emphasis">WireContext的javadoc,我们可以看出,他主要是?span class="emphasis">WireDefinition, Descriptor? 交道. WireContext里面 包含了一个WireDefinition,而WireDefinition里面包含了一pd的Descriptor.每个Descriptor负责创徏? 初始化该对象. 比如我们可以看到IntegerDescriptor, FloatDescriptor, ObjectDescriptor{等. 我们来看下Descriptor的接?

												
														
/**
* constructs the object.
* @param wireContext {@link WireContext} in which the object is created. This is also the {@link WireContext}
* where the object will search for other object that may be needed during the initialization phase.
* @return the constructed object.
*/
Object construct(WireContext wireContext);

/**
*called by the WireContext to initialize the specified object.
*/
void initialize(Object object, WireContext wireContext);

Descriptor对象的创建可以直接通过Java对象的实例化,比如(new IntegerDescriptor(..)),也可以通过xml的配|文件来实现.可以说我们更l常用xml来配|?所以就有了Binding的概? BindingcL主要的Q务就是把XML DOM 到Java对象的{? Bindings是把Binding归类了一下而已. 以下是Binding的接?

												
														
public interface Binding {
String getCategory();

/** does this binding apply to the given element? */
boolean matches(Element element);

/** translates the given element into a domain model java object.
* Use the parse to report problems.
*/
Object parse(Element element, Parse parse, Parser parser);
}

如果想看实现,我们可以看下IdentityServiceBinding, RepositoryServiceBinding{等.q里注意?在jBPM的实现当?WireDescriptorBinding是根据tagName来解析的. 所?从jBPM的xml配置文g,到ProcessEngine对象的构?是这L一个流E?

												 jbpm.cfg.xml ?gt;  jBPMConfigurationParser ->  Binding ?gt;  Descriptor --> WireContext
										

或者更清楚?我们可以看下下面q张?sup>[ 1].

我们不妨也看下ConfigurationTest试.

												
public void testConfigurationServices() {
ProcessEngine processEngine = new Configuration()
.setXmlString(
"<jbpm-configuration>" +
" <process-engine-context>" +
" <repository-service />" +
" <execution-service />" +
" <management-service />" +
" </process-engine-context>" +
"</jbpm-configuration>"
)
.buildProcessEngine();
assertNotNull(processEngine);
assertNotNull(processEngine.getExecutionService());
assertNotNull(processEngine.getManagementService());
}

Configuration cLjBPM的入?你可以从 ConfigurationcM创徏ProcessEngine,而从ProcessEngine中获取到RepositoryService, ExecutionService, TaskService{等. Configurationc里有两个实现类,一个是JbpmConfiguration,q是默认的jBPM自带的Configuration解析? 另外一个是SpringConfiguration,q个是jBPM和Spring的集? 在这?我们只看下JbpmConfiguration的实?在JbpmConfigurationc里,我们可以看到他是q么去调用Parser? 解析xml?

												
protected void parse(StreamInput streamSource) {
isConfigured = true;
JbpmConfigurationParser.getInstance()
.createParse()
.pushObject(this)
.setStreamSource(streamSource)
.execute()
.checkErrors("jbpm configuration " + streamSource);
}

在这?我们可以看到,jbpm的配|文件是有两个元素组成的,一个是process-engine-context,另外一个是transaction-context. 其中process-engine-context里面的元素是包括了对外发布的服务, 比如repository-service, execution-service{等. 而transaction-context则包括了他的内部真正实现,比如repository-service对应repository-session. 也可以简单的把repository-servie看做是API, repository-session看做是SPI. q样做的好处?SPI的实?对API一点媄响都没有,很大E度上提供了一个容易集成的Ҏ?

说到q里,应该对jBPM的IOC介绍的差不多?我自己在用JBoss IDM project[2]来实现jBPM的Identity module?需要增加如下的配置.

												
<jbpm-configuration>
<process-engine-context>
<jboss-idm-identity-session-factory jndi="java:/IdentitySessionFactory" />
</process-engine-context>
<transaction-context>
<jboss-idm-identity-session realm="realm://JBossIdentity" />
</transaction-context>
</jbpm-configuration>

于是,我需要增加以下的cL完成对象的创建和实例? JbossIdmIdentitySessionFactoryBinding,JbossIdmIdentitySessionFactoryDescriptor,JbossIdmIdentitySessionBinding, JbossIdmIdentitySessionDescriptor 然后,?span class="emphasis">jbpm.wire.bindings.xml里面注册我们新加的Binding. 从上面我们所说的,不难看出本nq个IOC的实现机制也是很单的,而且也很Ҏ扩展,如果说到时候和Spring, JBoss MC{IOC容器的集成也是很方便?

q里,我们看下jBPM-PVM概念和架?q也是jBPM整个目的核心所?

PVM (Process Virtual Machine), 主要是想作ؓ一个开发^?在这个^C,可以很方便的开发工作流,服务~制(orchestration),BPM{等.比? 说jPDLq套语法的内部实现就是基于PVM?来ZPVM可以开发一个符合WS-BPEL 2.0的模? PVM可以单的看成是一个状态机. 我们接下ȝ下jBPM里面的几个重要概?

Command 概念的引?主要是想Ҏ有的操作做一个封? 可以说上面每个Service的方法的实现都是通过实现一个Command来操?然后通过CommandService调用到后面具体的实现. 我们先来看下Command的接?

														public interface Command<T> extends Serializable {
T execute(Environment environment) throws Exception;
}

很简?很典型的Command模式.

我们接下来看CommandService接口,֐思义,他主要是负责来执行Command(s)的操?所以其他Service的实现都是通过CommandService来调用到后面的实?可以把CommandService 看做一个桥梁的作用.看一下CommandService的接?

														public interface CommandService {
/**
* @throws JbpmException if command throws an exception.
*/
<T> T execute(Command<T> command);
}

CommandService q有一个特?是可以配置Interceptor,比如事务是在这一Service中来配置.看下CommandService的配|?

														    <command-service>
<retry-interceptor />
<environment-interceptor />
<standard-transaction-interceptor />
</command-service>

q里,在执行真正的CommandServiceImpl之前,会先之前retry-Interceptor,environment-interceptor{等.q里的Interceptor的顺序是跟配|的序一致的. 比如q样的配|?那就是retry-interceptor在environment-interceptor之前执行. 我们看下面这个图.

ProcessDefinition是一个定义好的工作流E? OpenProcessDefinition里面包含了启始的Activity. 程的走向是通过Activity的流向来l成? Transition是用来q接Activity而后来构成一个流E的. 一个工作流的工作引?最基本的两个功?一个是设计好当前的工作程.W二个是有个东西需要来体现当前走到程的哪一?那么PVM中的Execution API是q个作用. 至于最后一个Event,是你可以定义一些事?比如当流E进入到某一个Activity的时?促发email. Event和Activity最大的区别在于Event本n不会构成ҎE走向的改变.

我们先看下ActivityBehaviour的接?

														public interface ActivityBehaviour extends Serializable {
void execute(ActivityExecution execution) throws Exception;
}

是到这个Activity,需要执行的操作都在executeҎ? q有一UActivityBehaviour,是属于wait state,也就是会停留在这个节点上, 需要外部的一些触?才会l箋执行下去,q种情况,需要实现的接口是ExternalActivityBehaviour, 接口如下.

														public interface ExternalActivityBehaviour extends ActivityBehaviour { 
//handles an external trigger.
void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception;
}

Wait State (也就是实现ExternalActivityBehaviour)的促?是通过Transition来完成的,来看下Transitionq个接口.

														public interface Transition extends ObservableElement {
/** the activity from which this transition leaves. */
Activity getSource();

/** the activity in which this transition arrives. */
Activity getDestination();
}

在pvm?也包括了对event的支?event的接口如?

														public interface EventListener extends Serializable { 
void notify(EventListenerExecution execution) throws Exception;
}

如我们之前所说的, ProcessDefinition是由Activity,Transition以及Eventl成?ProcessDefinition是由ProcessDefinitionBuilder 的API来创?我们E微看下q个API的?

																ClientProcessDefinition definition = ProcessDefinitionBuilder.startProcess("jeffProcess")
.startActivity("initial", new AutomaticActivity())
.initial()
.transition("first")
.endActivity()
.startActivity("first", new WaitStateActivity())
.transition("end", "endSignal")
.endActivity()
.startActivity("end", new AutomaticActivity())
.endActivity()
.endProcess();

q里,我们利用PVM所提供的Model,来实C个基本的工作引?

正如我们之前所说的,ActivityBehaviour是整个流E的定义核心所?我们再看下它的API.

														public interface ActivityBehaviour extends Serializable {    
void execute(ActivityExecution execution) throws Exception;
}

当之行到ActivityBehaviour的时?整个程的走向完全是׃的execute()Ҏ来决? 比如你可以调用execution.end()来结束这个流E?或者调用execution.waitForSignal()q入一个等待状? 我们接下L实现一个很单的ActivityBehaviour.

														public class Display implements ActivityBehaviour {
String message;

public Display(String message) {
this.message = message;
}

public void execute(ActivityExecution execution) {
System.out.println(message);
}
}

我们先用q个Display,来创Z面的process.


														ClientProcessDefinition processDefinition = ProcessDefinitionBuilder.startProcess("helloworld")
.startActivity("a", new Display("Hello"))
.initial()
.transition("b")
.endActivity()
.startActivity("b", new Display("World"))
.endActivity()
.endProcess();

然后,你调?

														processDefinition.startProcessInstance();

׃得到如下的结?

														Hello
World

我们q个Display的节点就是采用的隐式execution执行Ҏ.

外部节点是代表着,q个zdq需要系l外部的配合,比如说h工的配合才能使得q个程l箋下去.我们一般称q种的节点ؓ Wait State. 因ؓ他需要一直等?直至外部zd的促?然后程才l? q种的节炚w要实现ExternalActivityBehaviour的API.

														public interface ExternalActivityBehaviour extends ActivityBehaviour { 
//handles an external trigger.
void signal(ActivityExecution execution, String signalName, Map<String, ?> parameters) throws Exception;
}

跟内部节点类?执行到ExternalActivityBehaviour的时?也是执行它的execute()Ҏ,但是一般来?在外部活动的execute()Ҏ? 会调用execution.waitForSignal()Ҏ,使得activityq入一个等待状? 直到外部调用signal()Ҏ来得流E再ơ从{待状态变成激z?一般来说在signal()Ҏ?会调用execution.take(signalName)ҎsignalName(也就是transition name)L? 下一个节?然后把整个流E走C一个节?

很简单的一个例子是,比如说一个申请审批的程,员工递交一份申请上?然后l箋p入一个wait state的状?因ؓ他需要经理的审批(也就是一个h工的zd),那么l理可以选择一个ok的signalName,使得整个 程q入C一个节?q里好比如是结束的节点,又或者得整个流E直接结?

我们接下来实C个简单的WaitState,实现ExternalActivityBehaviour的接?

														public class WaitState implements ExternalActivityBehaviour {

public void execute(ActivityExecution execution) {
execution.waitForSignal();
}

public void signal(ActivityExecution execution,
String signalName,
Map<String, Object> parameters) {
execution.take(signalName);
}
}

一L,我们来看一个简单的从a->b的流E?q次不同的是,a和b都是wait state.


ProcessDefinition的定?

														ClientProcessDefinition pd = ProcessDefinitionBuilder.startProcess("helloworld")
.startActivity("a", new WaitState())
.initial()
.transition("b", "b-transition")
.endActivity()
.startActivity("b", new WaitState())
.endActivity()
.endProcess();

启动q个ProcessDefinition

														ClientProcessInstance instance = pd.startProcessInstance();
instance.isActive("a")

在启动之?因ؓ执行到a的时?是一个wait state,所?当前的流E活动应该是指向a. 如果要到bq个activity,那么需要调?

														instance.signal("b-transition");
instance.isActive("b")

那么,你就会发?l过我们调用signalҎ,instanceҎ所提供的transitionName (b-transition),扑ֈ下一个节?也就是b. 但因为b也是一个wait state,所以此?整个程停留在了b节点w上.

接下?我们Z前面两种节点的实?来实C个稍微比较正式的程(loan process).


ProcessDefinition的定?

															ClientProcessDefinition pd = ProcessDefinitionBuilder.startProcess("loanprocess")
.startActivity("submit loan request", new Display("submit a loan request"))
.initial()
.transition("evaluate", "evaluate-transition")
.endActivity()
.startActivity("evaluate", new WaitState())
.transition("wiremoney", "approve")
.transition("end", "reject")
.endActivity()
.startActivity("wiremoney", new Display("wire the money"))
.transition("archive")
.endActivity()
.startActivity("archive", new WaitState())
.transition("end", "done")
.endActivity()
.startActivity("end", new WaitState())
.endActivity()
.endProcess();

启动q个processInstance

														instance = pd.startProcessInstance();

启动q个processInstance?它开始点在submit loan requestq个节点,后面l过Displayq个节点,默认走到了evaluateq个节点. 因ؓevaluate是个wait state,所以流E停在了evaluate.


现在? evaluateq个节点有两条支?一个是approve,指向wiremoney节点;另外一个是reject,直接走向end. 假设我们选择approveq条支\.

														instance.signal("approve");

那么,我们p向了wiremoneyq个节点,因ؓwiremoney是个Display节点,所以它昄完后,默认的走向下一个节?archive.


同样?因ؓarchive节点是个wait state,所以需要再一ơ的signal,才能走到endq个节点.

														instance.signal("done");

q样的话,整个程׃走向了end节点.


事g的订阅可以通过实现EventListener来实?

														public interface EventListener extends Serializable {
void notify(EventListenerExecution execution) throws Exception;
}

Event概念的引?主要是ؓ了I补分析员(Business Analyst)和开发h?Developer)之间的不同需? developer可以使用Event在一些节点上来做一些操?比如说操作数据库),q样?也不会媄响整个流E?所以分析员不用d心这些具体的Event, 他们只需要看程是否跟他们所期望的是一致的.

具体的Event是由ObservableElement?span class="emphasis">EventName来构成的.

														public interface EventListenerExecution extends OpenExecution {
void fire(String eventName, ObservableElement eventSource);
}

我们来实C个简单的EventListener, 叫PrintLn

														public class PrintLn implements EventListener {

String message;

public PrintLn(String message) {
this.message = message;
}

public void notify(EventListenerExecution execution) throws Exception {
System.out.println(message);
}
}


我们看下是怎么来定义一个具备有Events的ProcessDefinition:

														ClientProcessDefinition pd = ProcessDefinitionBuilder.startProcess("ab")
.startActivity("a", new Display("Testing Event"))
.initial()
.transition("b")
.startEvent(Event.END)
.listener(new PrintLn("leaving a"))
.listener(new PrintLn("second message while leaving a"))
.endEvent()
.startEvent(Event.TAKE)
.listener(new PrintLn("taking transition"))
.endEvent()
.endActivity()
.startActivity("b", new WaitState())
.startEvent(Event.START)
.listener(new PrintLn("entering b"))
.endEvent()
.endActivity()
.endProcess();

我们可以看到,一个事件可以有无穷多个的Listener(s).

x,我们主要看了PVM里面内部Model的一些设?一些核心的概念和API.



C物 2009-07-14 13:15 发表评论
]]>
jBPM4的运行期环境http://m.tkk7.com/libin2722/articles/286673.htmlC物C物Tue, 14 Jul 2009 05:13:00 GMThttp://m.tkk7.com/libin2722/articles/286673.htmlhttp://m.tkk7.com/libin2722/comments/286673.htmlhttp://m.tkk7.com/libin2722/articles/286673.html#Feedback0http://m.tkk7.com/libin2722/comments/commentRss/286673.htmlhttp://m.tkk7.com/libin2722/services/trackbacks/286673.html jBPM4的运行期环境         万物生长靠太阻I儿童的生长离不开土壤、空气和_当然Q也M开l坝娘的调教。应用程序也是如此,M开数据库连接、事务、日志、消息等Q这些,共同构成了应用程序的q行期环境?br />         理想中的环境是什么样子的哩。好吧,一句话Q召之即来,挥之卛_Q当需要某个服务时QokQ打个响指,该服务就准备好被调用了,调用完毕后也不用费心费力 地擦屁股Q不必老是提心吊胆有好事者追问:你擦了吗Q确定擦了?真的定擦了Q直接丢弃给环境降解处理Q自然又环保Q还有个好名声叫专注领域逻辑?br />
一、  ?q行期环境就是一个餐?/strong>
1、  ?提供必要的服?br /> 作ؓ一个餐馆,必须有厨师做饭我吃,必须有桌子和椅子。作行期环境同样如此Q我要发消息Q你得提供我发消息的ServiceQ我要获取节点Q务,你得扔给我TaskService?br />
2、  ?提供获取q些服务的统一方式
好吧Q我不会亲自到厨房告诉厨师我惛_什么(因ؓ我担心这样一来我会吃不下去)Q我也不会亲自到攉台给钱。这些服务有一个统一的获取方式:服务员。我? 吃什么和l̎Q告诉服务员卛_。关键是q一方式要统一Q要_单。Spring最懒,把服务给你全部注入了Q当然你也可以握住BeanFactory? U纤l手Q一个一个的get?br />
3、  ?提供特定于我U程不安全的服务
我点了一盘鱼香肉丝,隔壁也点了一盘鱼香肉丝,l果服务员让我们吃同一盘鱼香肉丝。我立刻跌v来:靠,你们的服务不是线E安全的吗?QHibernate 的Session正是属于q么一U情况,需要环境进行隔,我的唯一职责是吃饭Q我的领域逻辑是如何优的q餐Qؓ此还要不断重构我吃饭的姿势哩?br /> 好不Ҏ吃完饭,付完ƾ,正准备离场。服务员风度翩地走到我的n旁,我以有打折券供应Q结果是Q服务员姐d朱唇Q先生,ȝ您把吃剩的盘子清z完毕?br /> 崩溃Q?br /> 像数据库q接的打开Q关闭、事务的打开、提交等都属于运行期环境应该做的事情?br />
4、  ?其他的七七八?br /> 杂事不少Q例如统一的事件机制、权限拦截等{?br />
二、  ?jBPM4的运行期环境
好吧Q先来看看如何徏立jBPM4的运行期环境Q?br />
EnvironmentFactory environmentFactory = new DefaultEnvironmentFactory();
 
  
 
  Environment environment 
= environmentFactory.openEnvironment();
  
try {
 
     everything available in 
this block 
 
  } 
finally {
    environment.close();
  }


两个关键的类QEnvironmentFactory和Environment?br />
EnvironmentFactory是全局的,在整个应用程序中保持一个实例即可?br />
Environment则是每次Ҏ调用则要new一个?br />
看看Environment的主要方法:
public abstract Object get(String name);
public abstract <T> T get(Class<T> type);


是的Qenvironment为我们的代码提供所需要的服务cd例?br />
那么Q如何获得environmentQ?br /> l箋看:
public static Environment getCurrent()Q?/span>

staticQ我喜欢也。方ѝ快P不管是在C、R上还是房上Q随处都可调用?br />
那么Qؓ什么Environment每次调用要new呢?
好吧Q当你需要获取数据库Session的时候,是不是每ơ都要new呢。Environment提供的服务里包括了非U程安全的数据库操作服务?br />
三、  ?jBPM4q行期环境的实现

1、JbpmConfiguration
JbpmConfiguration是jBPM4里最重要的类Q它是整个应用程序的入口。它实现了EnvironmentFactory接口?br />
      JbpmConfiguration加蝲jBPMȝ配置文gQ还是大概扫一下这个配|文Ӟ
      <jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">

  
<process-engine-context>
 
    
<repository-service />
    
<repository-cache />
    
<execution-service />
    
<history-service />
    
<management-service />
    
<identity-service />
    
<task-service />

    
<hibernate-configuration>
      
<cfg resource="jbpm.hibernate.cfg.xml" />    
    
</hibernate-configuration>

    
<hibernate-session-factory />
 
  
</process-engine-context>

  
<transaction-context>
    
<repository-session />
    
<pvm-db-session />
    
<job-db-session />
    
<task-db-session />
    
<message-session />
    
<timer-session />
    
<history-session />
  
</transaction-context>

</jbpm-configuration>


配置文g被分Z两部分,分别是:process-engine-context和transaction-context?br /> 对应于两个IOC容器QWireContextQ的配置文g?br />
作ؓEnvironmentFactoryQJbpmConfiguration持有成品process-engine-context对应的IOC容器 Q全局的)实例Q持有半成品transaction-context的WireDefinition。当调用openEnvironmentҎ ӞJbpmConfiguration会new EnvironmentQ然后将process-engine-context IOC填充入environmentQ同时初始化transaction-context IOCQƈ其也填充入environment。这样通过environment可以获得所有所需要的服务Q包括全局的和非线E安全的服务实例。也是 environment透过IOC容器提供了查扑֐U服务的能力?br />

 

2、与U程l定的environment
environment初始化之?避免参数传递得一塌糊涂的方式是environment与线E绑定。看Environment的代码:
  static ThreadLocal<Environment> currentEnvironment = new ThreadLocal<Environment>();

  
static ThreadLocal<Stack<Environment>> currentEnvironmentStack = new ThreadLocal<Stack<Environment>>();


是的Q在openEnvironmentӞ有这么一行代码:
Environment.pushEnvironment(environment);


q样environment׃U程l定了,可以通过Environment.getCurrent()L调用了?br />
哪里有压q,哪里有放抗?br /> 在environment.close()Ҏ里:

Environment.popEnvironment();


OKQ结束?br />


C物 2009-07-14 13:13 发表评论
]]>
Jbpm4的IOC容器http://m.tkk7.com/libin2722/articles/286520.htmlC物C物Mon, 13 Jul 2009 02:34:00 GMThttp://m.tkk7.com/libin2722/articles/286520.htmlhttp://m.tkk7.com/libin2722/comments/286520.htmlhttp://m.tkk7.com/libin2722/articles/286520.html#Feedback0http://m.tkk7.com/libin2722/comments/commentRss/286520.htmlhttp://m.tkk7.com/libin2722/services/trackbacks/286520.html
一、  ?Jbpm4 IOC容器介绍
IOC容器的目的是理lg和实现组件之间的解耦。和Spring里的BeanFactory对应QJbpm4里的接口是ContextQ具体实现则? WireContext。Context实际在Jbpm4里有更多的含义,它与Environment一P共同构成了代码运行的q行期环境。在q个环境 里可以获取系l的lgQ更为重要的是提供了数据库连接(sessionQ和事务Q这个稍后会Ԍ?br />
先来看看Context接口的核心方法:
      Object get(String key);
  
<T> T get(Class<T> type);


很明显,提供两种从容器里获取lg的方法,一U是通过nameQ一U是通过type?br />
对于IOC容器来说Q一般情况下都会提供一U加载的方式Q比如从xml文gq行加蝲、从资源文gq行加蝲。Jbpm4透过WireParser具备从xml加蝲的能力?br />
此外QWireContext通过一个Map~存初始化后的组件?br />
二、  ?Jbpm4 IOC容器实现
容器的实现有五个关键cd接口Q分别是QWireParser、Binding、Descriptor、WireDefinition和WireContext?br />  

WireParserdxml文gQ同时WireParser会加载一pd的Binding(默认从jbpm.wire.bindins.xml文gd加蝲)?br />
Binding负责Ҏxml里元素的tagxml元素转换为对应的Descriptor?br />
Descriptor负责初始化对象。它们被d到WireDefinition?br />
WireDefinition被WireParserq回lWireContext。WireContext创徏对象时会讉KWireDefinition里的DescriptorQ同时将初始化对象的d委托lDescriptor自n?br />
需要注意的是:Jbpm4在初始化对象时有着四种{略Q分别是Qgq创建和初始化、gq创建和立刻初始化、立d建和延迟初始化、立d建和立刻初始化?br />
立刻创徏Q在WireContext创徏完毕后对象就已经创徏?br /> 延迟创徏Q调用WireContext的getҎ获取该对象时才创对象?br /> 初始化:一般完成对象属性的注入{操作?br />
三、  ?Jbpm4 IOC容器在Jbpm4里的应用
IOC容器在Jbpm4里最重要的作用就是加载Jbpm的ȝ配置文gQ默认是jbpm.cfg.xmlQ,q也是整个Jbpm应用的v炏V大概扫一下这个配|文Ӟ

<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration xmlns="http://jbpm.org/xsd/cfg">

  
<process-engine-context>
 
    
<repository-service />
    
<repository-cache />
    
<execution-service />
    
<history-service />
    
<management-service />
    
<identity-service />
    
<task-service />

    
<hibernate-configuration>
      
<cfg resource="jbpm.hibernate.cfg.xml" />    
    
</hibernate-configuration>

    
<hibernate-session-factory />
 
  
</process-engine-context>

  
<transaction-context>
    
<repository-session />
    
<pvm-db-session />
    
<job-db-session />
    
<task-db-session />
    
<message-session />
    
<timer-session />
    
<history-session />
  
</transaction-context>

</jbpm-configuration>


可以看到配置文g被分Z两部分,分别是:process-engine-context和transaction-context。在实际应用中,它们 分别对应着两个不同的WireContext:ProcessEngineContext和TransactionConext? ProcessEngineContext覆盖了jbpm4里最重要的服务类Q这些类是全局唯一的,当然QProcessEngineContext也是 独此一份。本是同根生Q命q各不同。TransactionConext则是在每ơopenEnvironment旉新创建,因ؓ其包含了数据库连接和 事务?br />
贯穿于整个Jbpm4中,q两个Context被压到Environment里(Environment和线E绑定)Q在M需要的地方都能提供一条龙的服务。于是,在很多领域类里,利用q些服务实现充血模型是很顺理成章的一件事了?br />
ȝ: ProcessEngineContextl引擎领域模型提供全局的组件查找;TransactionConext提供数据库相x务?br />


C物 2009-07-13 10:34 发表评论
]]>
jBPM4d理Q参与模式一?/title><link>http://m.tkk7.com/libin2722/articles/286518.html</link><dc:creator>C物</dc:creator><author>C物</author><pubDate>Mon, 13 Jul 2009 02:32:00 GMT</pubDate><guid>http://m.tkk7.com/libin2722/articles/286518.html</guid><wfw:comment>http://m.tkk7.com/libin2722/comments/286518.html</wfw:comment><comments>http://m.tkk7.com/libin2722/articles/286518.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/libin2722/comments/commentRss/286518.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/libin2722/services/trackbacks/286518.html</trackback:ping><description><![CDATA[ <p>原文地址Q?a >http://www.jboss.org/feeds/post/jbpm_task_management_a_look_at_the_participation_model</a></p> <p>jBPM d理Q参与模式一?br /> Posted on 2009-03-30 09:41:00.0 by Heiko Braun<br /> Since 4.0.0 Beta1<br /> 重新回顾jBPM中的d理模型Q引q了一个新的概念:d参与。参与模型描qCidentiesQ用hl)和Q务在实际完成中的参与cdQ?br /><img alt="" src="http://www.opug.org.cn/sites/default/files/participation.jpg" /> <br /> CZ1Q用户和业务理员参?br /> 在此与这个模型非帔R合的一个通常的案例是在一个实际执行Q务的用户和一个业务管理员监控q展情况之间的区别。依赖于参与cdQ某些规则将实际起作用,而其它的确保Q务在l定的约束内被执行(例如Q优先Q预定日期等Q?/p> <p>CZ2Q具有不同的参与cd的Q务利益相兌?br /> 另一个例子可能是利益相关者监控Q务的实际输出Q或者是在一个Q务上互相协作的不同参与者之间的委托。在q个案例中,一个Q务的发v人,一个候选h执行q个工作q且最l的与受者可能是不同的参与类型?/p> <p>The TaskService API已经反映了那些变化:</p> <p> </p> <pre class="java5"> <ol> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">org.<span style="color: rgb(0, 102, 0);">jbpm</span>.<span style="color: rgb(0, 102, 0);">TaskService</span><span style="color: rgb(102, 204, 102);">{</span></div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(102, 204, 102);">[</span>...<span style="color: rgb(102, 204, 102);">]</span></div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div> </li> <li style="font-weight: bold;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">/**</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  * retrieves a list of tasks for a user</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  * and a particular {@link org.jbpm.task.Participation} type</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  *</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  * @see org.jbpm.TaskQuery</span> </div> </li> <li style="font-weight: bold;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  */</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <a > <span style="color: rgb(170, 170, 221); font-weight: bold;">List</span> </a> findTasksByParticipation<span style="color: rgb(102, 204, 102);">(</span><a ><span style="color: rgb(170, 170, 221); font-weight: bold;">String</span></a> participation, UserRef user<span style="color: rgb(102, 204, 102);">)</span>;</div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">/**</span> </div> </li> <li style="font-weight: bold;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  * retrieves a list of tasks for a group</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  * and a particular {@link org.jbpm.task.Participation} type</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  *</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  * @see org.jbpm.TaskQuery </span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">  */</span> </div> </li> <li style="font-weight: bold;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <a > <span style="color: rgb(170, 170, 221); font-weight: bold;">List</span> </a> findTasksByParticipation<span style="color: rgb(102, 204, 102);">(</span><a ><span style="color: rgb(170, 170, 221); font-weight: bold;">String</span></a> participation, GroupRef... <span style="color: rgb(0, 102, 0);">groups</span><span style="color: rgb(102, 204, 102);">)</span>;</div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(102, 204, 102);">}</span> </div> </li> </ol> </pre> <p>目前Q我们封装了一些默认的参与cdQ其中仅仅支持“候选h”模型,但是你可以期待这些将在不久的来被扩展实现?/p> <p> </p> <p> </p> <pre class="java5"> <ol> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">org.<span style="color: rgb(0, 102, 0);">jbpm</span>.<span style="color: rgb(0, 102, 0);">task</span>.<span style="color: rgb(0, 102, 0);">Participation</span><span style="color: rgb(102, 204, 102);">{</span></div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(102, 204, 102);">[</span>...<span style="color: rgb(102, 204, 102);">]</span></div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <a > <span style="color: rgb(170, 170, 221); font-weight: bold;">String</span> </a> CANDIDATE = <span style="color: rgb(255, 0, 0);">"candidate"</span>;</div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;">IdentityRef getIdentityRef<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>;</div> </li> <li style="font-weight: bold;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(128, 128, 128); font-style: italic;">/** see constants for default participations */</span> </div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <a > <span style="color: rgb(170, 170, 221); font-weight: bold;">String</span> </a> getType<span style="color: rgb(102, 204, 102);">(</span><span style="color: rgb(102, 204, 102);">)</span>;</div> </li> <li style="font-family: 'Courier New',Courier,monospace; color: black; font-weight: normal; font-style: normal;"> <div style="font-family: 'Courier New',Courier,monospace; font-weight: normal;"> <span style="color: rgb(102, 204, 102);">}</span> </div> </li> </ol> </pre> <p>敬请期待?/p> <img src ="http://m.tkk7.com/libin2722/aggbug/286518.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/libin2722/" target="_blank">C物</a> 2009-07-13 10:32 <a href="http://m.tkk7.com/libin2722/articles/286518.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title> jBPM4理控制C?/title><link>http://m.tkk7.com/libin2722/articles/286517.html</link><dc:creator>C物</dc:creator><author>C物</author><pubDate>Mon, 13 Jul 2009 02:29:00 GMT</pubDate><guid>http://m.tkk7.com/libin2722/articles/286517.html</guid><wfw:comment>http://m.tkk7.com/libin2722/comments/286517.html</wfw:comment><comments>http://m.tkk7.com/libin2722/articles/286517.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/libin2722/comments/commentRss/286517.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/libin2722/services/trackbacks/286517.html</trackback:ping><description><![CDATA[ <span style="font-size: 10.5pt; font-family: 宋体;">JBoss已经发布了jBPM4 Alpha1版本Q?008q?2月,Red Hat发布公告Q已l与google{v了团体共享协议,正式采用GWT作ؓJBoss中间件核心组成部分,而jBPM4也作为整个JBoss SOAȝ体系的核心项目。Heiko Braun在JBoss SOA ȝ目的博客(<a >http://jboss-overlord.blogspot.com/</a>Q上l出了基于GWT的jBPM4的管理控制台一瞥。下面是我的译Q?/span> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;">新的</span> <span lang="EN-US"> <span style="font-family: Calibri;">BPM</span> </span> <span style="font-family: 宋体;">控制台已l发布了W一个里E碑Q我很高兴利用这个机会介l它最重要的改变及新特性?/span> </span> <span lang="EN-US"> <img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/1-definition-list.png" alt="" width="914" height="855" /> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> <span style="font-size: small;">程定义理</span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;">q移?/span> <span lang="EN-US"> <span style="font-family: Calibri;">GWT</span> </span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;">来多?/span> <span lang="EN-US"> <span style="font-family: Calibri;">JBoss </span> </span> <span style="font-family: 宋体;">目正在q移?/span> <span lang="EN-US"> <span style="font-family: Calibri;">GWT</span> </span> <span style="font-family: 宋体;">。他们这么做的原因是Q?/span> </span> </p> <p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; text-align: left;" align="left"> <span style="font-family: Wingdings;" lang="EN-US"> <span style=""> <span style="font-size: small;">Ø</span> <span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span> </span> </span> <span style="font-size: small;"> <span style="font-family: 宋体;">如果你熟?/span> <span lang="EN-US"> <span style="font-family: Calibri;">Java</span> </span> <span style="font-family: 宋体;">的开发ƈ且不xZ一?/span> <span lang="EN-US"> <span style="font-family: Calibri;">web</span> </span> <span style="font-family: 宋体;">开发的专家Q那?/span> <span lang="EN-US"> <span style="font-family: Calibri;">GWT</span> </span> <span style="font-family: 宋体;">是一个比较好的选择。?/span> <span lang="EN-US"> <span style="font-family: Calibri;">GWT</span> </span> <span style="font-family: 宋体;">你可以粘?/span> <span lang="EN-US"> <span style="font-family: Calibri;">eclipse</span> </span> <span style="font-family: 宋体;">Q发动一个调试ƈ且编写单元测试;</span> </span> </p> <p class="MsoListParagraph" style="margin: 0cm 0cm 0pt 21pt; text-indent: -21pt; text-align: left;" align="left"> <span style="font-family: Wingdings;" lang="EN-US"> <span style=""> <span style="font-size: small;">Ø</span> <span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;">  </span> </span> </span> <span style="font-size: small;"> <span style="font-family: 宋体;">它有一套丰富的</span> <span lang="EN-US"> <span style="font-family: Calibri;">UI</span> </span> <span style="font-family: 宋体;">H口部gQ你可以立马使用。这U窗口部仉过自己的实C证了一个统一的外观和感觉Q?/span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;">其它的比较好的成功的</span> <span lang="EN-US"> <span style="font-family: Calibri;">GWT</span> </span> <span style="font-family: 宋体;">实施的例子就?/span> <span lang="EN-US"> <span style="font-family: Calibri;">Drools </span> </span> <span style="font-family: 宋体;">控制C。(</span> <span lang="EN-US"> <span style="font-family: Calibri;">JBoss</span> </span> <span style="font-family: 宋体;">开源的规则引擎Q?/span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> <span style="font-size: small;"> <img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/2-instance-list.png" alt="" width="914" height="855" /> </span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> <span style="font-size: small;">程实例理</span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span lang="EN-US"> <span style="font-family: Calibri;">GWT</span> </span> <span style="font-family: 宋体;">已经非常的流行了Q它允许通过目来集成控制台。另一斚w的媄响就是,你可以轻村֜开发一个完整的</span> <span lang="EN-US"> <span style="font-family: Calibri;">GWT</span> </span> <span style="font-family: 宋体;">应用Q或者是一部分Qƈ且同已经存在?/span> <span lang="EN-US"> <span style="font-family: Calibri;">web</span> </span> <span style="font-family: 宋体;">应用整合在一赗D例来_q样可以允许用户?/span> <span lang="EN-US"> <span style="font-family: Calibri;">BPM</span> </span> <span style="font-family: 宋体;">控制台的d理功能嵌入C们自q内网应用中?/span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;"> <img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/3-instance-detail.png" alt="" /> </span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;"> <span style="font-size: small;"> <span lang="EN-US"> <span style="font-family: Calibri;">程实例l节</span> </span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;"> <span style="font-size: small;"> <span lang="EN-US"> </span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span lang="EN-US"> <span style="font-family: Calibri;">BAM</span> </span> <span style="font-family: 宋体;">Q业务活动监控)?/span> <span lang="EN-US"> <span style="font-family: Calibri;">BI</span> </span> <span style="font-family: 宋体;">Q商业智能)功能的改q?/span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;">或许当前控制台的最大缺点就是缺?/span> <span lang="EN-US"> <span style="font-family: Calibri;">BAM</span> </span> <span style="font-family: 宋体;">?/span> <span lang="EN-US"> <span style="font-family: Calibri;">BI</span> </span> <span style="font-family: 宋体;">Ҏ?/span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;"> <img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/5-metric-overview.png" alt="" width="914" height="855" /> </span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> <span style="font-size: small;">工作负蝲概览</span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;">改进</span> <span lang="EN-US"> <span style="font-family: Calibri;">BAM</span> </span> <span style="font-family: 宋体;">?/span> <span lang="EN-US"> <span style="font-family: Calibri;">BI</span> </span> <span style="font-family: 宋体;">不可能在一天内马上实现Q但是你可以期待在早期的发布版本中看到第一个度量及状态监控,在我们实C个功能齐全的</span> <span lang="EN-US"> <span style="font-family: Calibri;">BAM</span> </span> <span style="font-family: 宋体;">控制台的q程中,我们正尽力增加更多的零星的功能。因与服务zd监控目中的功能和技术发生重叠,感兴的读者可以关注一?/span> <span lang="EN-US"> <span style="font-family: Calibri;">SAM</span> </span> <span style="font-family: 宋体;">?/span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> <span style="font-size: small;"> <img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/6-metric-detail.png" alt="" width="914" height="855" /> </span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> <span style="font-size: small;">性能度量</span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-family: 宋体;"> <span style="font-size: small;">如何q移</span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> <span style="font-size: small;"> <span style="font-family: 宋体;">首先Q我们将Z</span> <span lang="EN-US"> <span style="font-family: Calibri;">GWT</span> </span> <span style="font-family: 宋体;">提供一个现?/span> <span lang="EN-US"> <span style="font-family: Calibri;">jBPM</span> </span> <span style="font-family: 宋体;">控制台的替代。它仍然保持当前的功能Ҏ,但是会增?/span> <span lang="EN-US"> <span style="font-family: Calibri;">BI</span> </span> <span style="font-family: 宋体;">功能。最初我们会q</span> <span lang="EN-US"> <span style="font-family: Calibri;">jBPM3</span> </span> <span style="font-family: 宋体;">的后端功能,然后逐渐地利?/span> <span lang="EN-US"> <span style="font-family: Calibri;">SAM</span> </span> <span style="font-family: 宋体;">的空间来丰富它,甚至最l完全代替它?/span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left;" align="left"> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> <span style="font-size: small;"> <img src="http://p.blog.csdn.net/images/p_blog_csdn_net/snow_fox_yaya/EntryImages/20090214/4-Enlarge-process.png" alt="" width="914" height="855" /> </span> </span> </p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: center;" align="center"> <span style="font-family: 宋体;"> <span style="font-size: small;">程囑Ş视图</span> </span> </p> <p> <span style="font-size: 10.5pt; font-family: 宋体;">l箋x。下ơ我们将要详l说明实现细节,包括Q?/span> <span style="font-size: 10.5pt; font-family: "Calibri","sans-serif";" lang="EN-US">gchart</span> <span style="font-size: 10.5pt; font-family: 宋体;">Q?/span> <span style="font-size: 10.5pt; font-family: "Calibri","sans-serif";" lang="EN-US">gwt</span> <span style="font-size: 10.5pt; font-family: 宋体;">?/span> <span style="font-size: 10.5pt; font-family: "Calibri","sans-serif";" lang="EN-US">gwt-ext</span> <span style="font-size: 10.5pt; font-family: 宋体;">?/span> </p> <p> <span style="font-size: 10.5pt; font-family: 宋体;">说明Q此文英文链接:<a >http://jboss-overlord.blogspot.com/2008/08/first-glimpse-at-new-bpm-console.html</a></span> </p> <img src ="http://m.tkk7.com/libin2722/aggbug/286517.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/libin2722/" target="_blank">C物</a> 2009-07-13 10:29 <a href="http://m.tkk7.com/libin2722/articles/286517.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>jbpm3与jbpm4实现Ҏhttp://m.tkk7.com/libin2722/articles/286513.htmlC物C物Mon, 13 Jul 2009 02:18:00 GMThttp://m.tkk7.com/libin2722/articles/286513.htmlhttp://m.tkk7.com/libin2722/comments/286513.htmlhttp://m.tkk7.com/libin2722/articles/286513.html#Feedback0http://m.tkk7.com/libin2722/comments/commentRss/286513.htmlhttp://m.tkk7.com/libin2722/services/trackbacks/286513.html

jBPM3 vs jBPM4

JBoss Goup 目前已经发布?/span> jBPM4 Alpha1 版本Q在版本 4 中最大的变化是引入 PVM Q流E虚拟机Q的概念Q而引擎内部的调度法中重要的 Token 机制Q在新版中也L了,U观整个代码Q变化可以说非常的大Q笔者接下来p着来比较一下这U变化,让大家能有个直观的认识。当?/span> Jbpm4 ?/span> JBoss 的官方网站上?/span> Road map 中,在今q的 7 ?/span> 1 h会发布第一个正式版本,因此后箋可能q会有变化?/span>

1?/span>   程定义对象的变化:

Jbpm3 程定义对象关系图:

图一 jbpm3程定义对象关系?/span>

 

从上图我们可以看 jbpm3 中, GraphElement 是流E图中所有流E元素的父对象,而整个流E是?/span> ProcessDefinition ?/span> Node ?/span> Transition 三个主要对象构成Q?/span>

 

 图二 PVM实体对象关系?/span>      

 

 

从上囑֏以看出,׃ PVM 概念的引入,所以在 jbpm3 中的 Graph 包在 jbpm4 中被U除了。在 pvm 中,在设计期Q所有节点元素的父类?/span> ProcessElementImpl Q流E的主要l成元素 Nodelmpl ?/span> TransitionImpl ?/span> ProcessDefinitionImpl ?/span> EventImpl 则都直接或间接承自 ProcessElementImpl 。在q行期: jbpm4 把流E的q行期行为定义ؓ执行行ؓQ?/span> ExecutionImpl Q及原子操作行ؓQ?/span> AtomicOperation Q其具体实现?/span> ExecuteNode ?/span> ProceedToDestination ?/span> TakeTranstion ?/span> MoveToParentNode ?/span> MoveToChildNode ?/span> signal Q,其中 ExecutionImpl 是流E实例、活动实例、事件监听器的所有执行期行ؓ的实现类?/span>

 

图三 jpdl q行期活动实体对象关pd

  上图?/span> jbpm4 在运行期的活动实例对象关pdQ从图中我们可以看出Q在q行期, jbpm4 中定义了两个zd接口 Activity ?/span> ExternalActivity Q其?/span> ExternalActivity l承?/span> Activity ?/span> Activity 是所有自动活动节点的父接口,其实现类?/span> JpdlActivity Q?/span> JpdlActivity 又衍生出了?/span> StartActivity ?/span> JoinActivity ?/span> ForkActivity ?/span> EndActivity ?/span> CreateTimerActivity ?/span> JavaActivity ?/span> EsbActivity {实例活动对象。?/span> ExternalActivity 是具有等待状态的zdQ?/span> StateActivity Q父接口Q像人工zd TaskActivity 是实现了此接口?/span>

  2?/span>   核心引擎的调度算?/span>

Jbpm3 的核心调度算法是Z Token 机制的,在运行期q个 Token ?/span> Node Instance 之间{Q依?/span> Token 的触发来推进程。具体的调度机制Q可参加胡长城的文章Q?/span> http://blog.csdn.net/james999/archive/2007/09/02/1769592.aspx Q;其实q个 Token 来自?/span> Pertri-net Q感兴趣的读者可以去?/span> Pertri-net 中的 Token ?/span> Place ?/span>

 

囑֛ jbpm3引擎调度?/span>  

Jbpm4 则去掉了 Token Q那么它的核心调度机制是怎样实现的呢Q?/span>

 图五 jbpm4程启动序列?/span>

囑օ jbpm4 程推进序列?/span>

图五是在 jbpm4 中启动一个流E实例的执行序列图,囑օ是节Ҏq的执行序列图,从上面两个图中我们可以看到核心的调度是依?/span> Execution 的{UL实现的( ExecutionImpl 可以?/span> ActivityExecution ?/span> ClientProcessInstance ?/span> EventListenerExecution 的实例)Q?/span> Execution 实际上就是取代了 Jbpm3 中的 Token Q?/span> Execution 的{Ud际上是Ҏ状态机的变q( ActivityExecution ?/span> ClientProcessInstance ?/span> EventListenerExecution 实例之间的切换)加上调用相应的原子操作: ExecuteNode ?/span> MoveToChildNode ?/span> MoveToParentNode ?/span> ProceedToDesitination ?/span> Signal ?/span> TakeTransition Q详?/span> pvm/internal/model/op 包下的相关类Q来实现的。所?/span> Execution 实例的集合及有向囑֮际上是q行期的路径?/span>

 

3?/span>   Event-Action 机制的变?/span>

?/span> jbpm3 中是Z Event-Action 机制来实C件与动作的触发的Q但是在 jbpm4 中则采用观察者模式来触发事g的。所有用戯己定义的动作Q全部要实现 EventListener 接口Q这些动作作为监听者(是事g Event 的观察?/span> Observer Q注册到相应的流E定义对象上Q?/span> ProcessElement 或?/span> Node Q,而事?/span> Event 则作观察的对象(实际上就?/span> Observerable Q,实际上在 jbpm4 中专门定义出了一个对?/span> ObservableElementImpl Q流E定义中?/span> NodeImpl ?/span> TransitionImpl ?/span> ProcessDefinitionImpl 均承自此对象,因此q些元素本n可以作?/span> Observerable 而被观察者来监控?/span>

4?/span>   客户端接口的变化

?/span> jbpm4 中对客户端的接口l一?/span> 7 个服务接口: ProcessService ?/span> ExecutionService ?/span> CommandService ?/span> TaskService ?/span> ManagementService ?/span> HistoryService ?/span> IdentityService Q这 7 个接口可以从 ProcessEngine 接口中获得, jbpm4 在启动的q程中由 JbpmConfiguration 负责构徏引擎?/span>

Ø  ProcessService- 程定义的服务接口,包括ҎE定义的部v、查询、删除操作;

Ø  ExecutionService- 执行服务接口Q包括启动流E、实例推q、设|变量等操作Q?/span>

Ø  CommandService-Command 模式的服务接口,实际上就是将客户端的h全部装在一个调用接口中Q然后由q个接口去调?/span> Command 接口的众多实玎ͼ StartExecutionCmd ?/span> SignalCmd ?/span> SetVariablesCmd ?/span> GetTimersCmd ?/span> DeployCmd ?/span> NewTaskCmd ?/span> SubmitTask ?/span> ExecuteJobCmd {等Q具体可参加 pvm/internal/cmd Q?/span> task/internal/cmd 包及其它包下实现 Command 接口的类Q,q是典型?/span> Command 模式的应用,感兴的读者可以去了解设计模式中的 Command 模式Q?/span>

Ø  TaskService- 人工zd的服务接口,包括对Q务的创徏、提交、查询、保存、删除等操作Q?/span>

Ø  ManagementService-web 理控制台的服务接口Q目前只有获得消息及计时器的接口实现Q?/span>

Ø  HistoryService- 目前有对历史库中的流E实例、活动实例进行查询、某个流E定义中的所有活动的q_持箋旉、某个流E定义中的某个活动实例的转移的执行次?/span>

Ø  IdentityService- 用户、组、成员关pȝ相关操作Ҏ

 

5?span style="font-family: "Times New Roman"; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal;"> 历史库的加入

jBPM3 中数据库设计一直是我比较诟病的地方Q尤其是其实例数据库没有设计历史库的概念q按照办l状态将q行l束的实例数据归入历史库Q在q种情况下它的实例数据库׃随着旉而无限膨胀Q这阻了它的真实应用Q而在 jBPM4 的最C码中Q注?/span> Alpha1 q没有出玎ͼQ历史库的相兛_能代码竟然出CQ详?/span> ExecutionImpl 最C码中?/span> fireHistoryEvent Ҏ及一pd?/span> historyXXX Ҏ。在 ActivityBehaviour ?/span> execute Ҏ中加入了 historyTaskStart Ҏ的调用?/span> signal Ҏ中加入了 historyTaskEnd Ҏ的调用,而以?/span> 2 个方法在 ExecutionImpl 中都是以历史事gQ?/span> HistoryEvent ?/span> 4 个实现子c?/span> ProcessInstanceStart ?/span> ProcessInstanceEnd ?/span> ActivityStart ?/span> ActivityEnd 分别用作程实例的创建结束期、活动实例的创徏l束期的历史数据处理Q的触发机制来实现的Q也是在整个流E实例执行的q程中,都加入了对将q行数据存入历史库的历史事gQ?/span> HistoryEvent Q的触发。这样实例列表的查询可以只查询历史库。不q这里很遗憾的是Q这个事件没有同时清除运行库的数据,q样q是会造成q行库的无限膨胀问题?/span>



C物 2009-07-13 10:18 发表评论
]]>
վ֩ģ壺 þþƷһ| ϺɫϺҳa| ҹɫƵվ| պѹۿһëƬ| LƷþ| avպav߳| ޹Ƶվ| ҹػaëƬѲ| þþþþþ99Ʒ| պһƵ| ޾ƷŮþ7777777| | ޾Ʒ߹ۿ| žѹۿȫƵ| 2021þþƷѹۿ| ƷV޾ƷVպƷ| οŮվѴȫ | Ʒҹѹۿվ| ĻƵ߹ۿ| һ| ޾ƷþþþAPP| ҹӰԺѹۿ| avһ߲| һ| ˾þô߽ӰԺ| ȷӰԴƬҹ߹ۿƵѲ| Ƶ߹ۿ| ˻18Ƶ| ޸Ůˮavվ| õ998Ƶѹۿ| Ļ| վѹۿ| պƷһ| պƵһ| ߹ۿѹۿַ | žžƷƵ| ޾Ʒ߲| ˳Ƶ߹ۿվ| ޹AV| 鴤һһgifƵ| ޳߹ۿ|