第 39 章 数据库连接
Business Central 为带有 Red Hat Process Automation Manager 的数据库服务器提供了一个专用的 UserGroup 回调
实施,以启用用户任务服务。用户任务服务有助于直接从数据库检索用户和组(角色)的信息。
您可以配置以下数据库 UserGroupCallback
实现属性:
属性 | 描述 |
---|---|
| 用于连接的数据源的 JNDI 名称 |
| 验证用户是否存在 |
| 为给定用户收集组 |
| 验证组是否存在 |
39.1. 数据库用户组回调实施
在数据库 UserGroup 回调
实现中,您必须创建所需的数据库。您可以通过使用以下方法之一配置对应的数据库属性来使用此实现:
以编程方式:使用对应的
DBUserGroupCallbackImpl
属性构建属性对象,并使用与其参数相同的属性对象创建DBUserGroupCallbackImpl
。例如:
import static org.jbpm.services.task.identity.DBUserGroupCallbackImpl.DS_JNDI_NAME; import static org.jbpm.services.task.identity.DBUserGroupCallbackImpl.PRINCIPAL_QUERY; import static org.jbpm.services.task.identity.DBUserGroupCallbackImpl.ROLES_QUERY; import static org.jbpm.services.task.identity.DBUserGroupCallbackImpl.USER_ROLES_QUERY; ... props = new Properties(); props.setProperty(DS_JNDI_NAME, "jdbc/jbpm-ds"); props.setProperty(PRINCIPAL_QUERY, "select userId from Users where userId = ?"); props.setProperty(ROLES_QUERY, "select groupId from UserGroups where groupId = ?"); props.setProperty(USER_ROLES_QUERY, "select groupId from UserGroups where userId = ?"); callback = new DBUserGroupCallbackImpl(props);
声明性:在应用程序根目录中创建
jbpm.usergroup.callback.properties
文件,或者将文件位置指定为系统属性。例如:
-Djbpm.usergroup.callback.properties=FILE_LOCATION_ON_CLASSPATH
确保您在启动用户任务服务器时注册数据库回调。
例如:
System.setProperty("jbpm.usergroup.callback.properties", "/jbpm.usergroup.callback.db.properties"); callback = new DBUserGroupCallbackImpl(true); ... db.ds.jndi.name = jdbc/jbpm-ds db.user.query = select userId from Users where userId = ? db.roles.query = select groupId from UserGroups where groupId = ? db.user.roles.query = select groupId from UserGroups where userId = ?