6.3 外部资源
Process definitions live in the Flowable database. These process definitions can reference delegation classes when using Service Tasks or execution listeners or Spring beans from the Flowable configuration file. These classes and the Spring configuration file have to be available to all process engines that may execute the process definitions.
流程定义位于Flowable数据库中。当通过Flowable配置文件使用服务任务(Service Task)、或执行侦听器(execution listener)、或Spring bean时,这些流程定义可以引用委托类(delegation class)。这些类和Spring配置文件必须对可能执行这些流程定义的流程引擎可用。
6.3.1 Java类
All custom classes that are used in your process (for example, JavaDelegates used in Service Tasks or event-listeners, TaskListeners and so on) should be present on the engine’s classpath when an instance of the process is started.
During deployment of a business archive however, those classes don’t have to be present on the classpath. This means that your delegation classes don’t have to be on the classpath when deploying a new business archive with Ant, for example.
When you are using the demo setup and you want to add your custom classes, you should add a JAR containing your classes to the flowable-task or flowable-rest webapp lib. Don’t forget to include the dependencies of your custom classes (if any) as well. Alternatively, you can include your dependencies in the libraries directory of your Tomcat installation, ${tomcat.home}/lib.
当启动流程实例时,流程中使用的所有自定义类(例如,在服务任务或事件侦听器、任务侦听器等中使用的JavaDelegates)都应该出现在引擎的classpath上。
但是,在部署业务归档时,这些类不必出现在classpath上。这意味着,例如,使用Ant部署新的业务归档时,委托类(delegation classe)不必位于classpath上。
当您使用demo设置并希望添加自定义类时,您应该将包含该类的JAR添加到flowable-task或flowable-rest webapp lib中。同样,别忘了包括自定义类的依赖项(如果有的话)。或者,可以在Tomcat安装的libraries目录中包含依赖项${tomcat.home}/lib。
6.3.2 通过流程使用Spring bean
When expressions or scripts use Spring beans, those beans have to be available to the engine when executing the process definition. If you are building your own webapp and you configure your process engine in your context as described in the spring integration section, that is straightforward. But bear in mind that you also should update the Flowable task and rest webapps with that context if you use it.
当表达式或脚本使用Spring bean时,在执行流程定义时,这些bean必须对引擎可用。如果您正在构建自己的webapp,并且按照Spring集成章节中的描述在您的上下文中配置流程引擎,那么这很简单直观。但是请记住,如果您使用了Flowable任务和rest webapps,那么也应该使用该上下文更新它。
6.3.3 创建单个应用
Instead of making sure that all process engines have all the delegation classes on their classpath and use the right Spring configuration, you may consider including the Flowable REST webapp inside your own webapp so that there is only a single ProcessEngine.
除了确保所有流程引擎在其classpath上都有所有的委托类并使用正确的Spring配置,您也可以考虑在自己的webapp中包含Flowable REST webapp,这样只有一个ProcessEngine。