从 alfresco activiti 进程中调用 spring bean

发布于 2024-12-11 19:58:30 字数 1489 浏览 0 评论 0原文

在 alfresco activiti 中,我可以使用 servicetask 调用 spring bean,例如:

<serviceTask id="assignApplicationId" name="Assign Application Id" 
  activiti:expression="${sequenceUtil.getOutboundId(task.id)}" 
  activiti:resultVariable="OutboundWF_ApplicationNumber"/>

但是,在我的自定义上下文中,我将 sequenceUtil 声明如下:

<bean id="sequenceUtil" name="sequenceUtil" class="com.tts.mersal.presentation.bean.dialog.util.SequenceUtil">
    <property name="searchService">
        <ref bean="searchService" />
    </property>
    <property name="nodeService">
        <ref bean="nodeService" />
    </property>
    <property name="workflowService">
        <ref bean="WorkflowService" />
    </property>     
</bean>

实际上,我得到了以下异常

org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'sequenceUtil'
at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)
at org.activiti.engine.impl.juel.AstMethod.eval(AstMethod.java:75)
at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)
at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)
at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:46)

Within alfresco activiti, could I call a spring bean using the servicetask like :

<serviceTask id="assignApplicationId" name="Assign Application Id" 
  activiti:expression="${sequenceUtil.getOutboundId(task.id)}" 
  activiti:resultVariable="OutboundWF_ApplicationNumber"/>

however, in my custom context I declared the sequenceUtil as the following:

<bean id="sequenceUtil" name="sequenceUtil" class="com.tts.mersal.presentation.bean.dialog.util.SequenceUtil">
    <property name="searchService">
        <ref bean="searchService" />
    </property>
    <property name="nodeService">
        <ref bean="nodeService" />
    </property>
    <property name="workflowService">
        <ref bean="WorkflowService" />
    </property>     
</bean>

Actually I got the following exception

org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'sequenceUtil'
at org.activiti.engine.impl.juel.AstIdentifier.eval(AstIdentifier.java:83)
at org.activiti.engine.impl.juel.AstMethod.invoke(AstMethod.java:79)
at org.activiti.engine.impl.juel.AstMethod.eval(AstMethod.java:75)
at org.activiti.engine.impl.juel.AstEval.eval(AstEval.java:50)
at org.activiti.engine.impl.juel.AstNode.getValue(AstNode.java:26)
at org.activiti.engine.impl.juel.TreeValueExpression.getValue(TreeValueExpression.java:114)
at org.activiti.engine.impl.el.JuelExpression.getValue(JuelExpression.java:46)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦罢 2024-12-18 19:58:30

我明白了 :)

我必须重写 activitiProcessEngineConfiguration bean 以将我的自定义 bean 包含在 beans 属性中

<!-- -->
<!-- Activiti Process Engine -->
<!-- -->
<bean id="activitiProcessEngineConfiguration"
    class="org.alfresco.repo.workflow.activiti.AlfrescoProcessEngineConfiguration">
    <property name="dataSource" ref="wrappedDataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="${db.schema.update}" />
    <property name="history" value="full" />
    <property name="jobExecutorActivate" value="true" />

<!-- Limit the visible beans in expressions -->


<property name="beans">
    <map>
        <entry key="services" value-ref="ServiceRegistry" />
        <entry key="sequenceUtil" value-ref="sequenceUtil" />
    </map>    
</property>

    <property name="customTypes">
        <list>
            <ref bean="activitiScriptNodeType" />
            <ref bean="activitiScriptNodeListType" />
        </list>
    </property>
    <property name="customPreBPMNParseListeners">
        <list>
            <ref bean="activitiParseListener" />
        </list>
    </property>
</bean>

I got it :)

I have to override the activitiProcessEngineConfiguration bean to include my custom bean within beans property

<!-- -->
<!-- Activiti Process Engine -->
<!-- -->
<bean id="activitiProcessEngineConfiguration"
    class="org.alfresco.repo.workflow.activiti.AlfrescoProcessEngineConfiguration">
    <property name="dataSource" ref="wrappedDataSource" />
    <property name="transactionManager" ref="transactionManager" />
    <property name="databaseSchemaUpdate" value="${db.schema.update}" />
    <property name="history" value="full" />
    <property name="jobExecutorActivate" value="true" />

<!-- Limit the visible beans in expressions -->


<property name="beans">
    <map>
        <entry key="services" value-ref="ServiceRegistry" />
        <entry key="sequenceUtil" value-ref="sequenceUtil" />
    </map>    
</property>

    <property name="customTypes">
        <list>
            <ref bean="activitiScriptNodeType" />
            <ref bean="activitiScriptNodeListType" />
        </list>
    </property>
    <property name="customPreBPMNParseListeners">
        <list>
            <ref bean="activitiParseListener" />
        </list>
    </property>
</bean>
莫多说 2024-12-18 19:58:30

有一种更好的方法将 bean 名称映射到 el 表达式。至少对于 alfresco 5.2 来说是这样。

最初的 activitiProcessEngineConfiguration 定义如下:

<bean id="activitiProcessEngineConfiguration" class="org.alfresco.repo.workflow.activiti.AlfrescoProcessEngineConfiguration">

        <!-- Limit the visible beans in expressions -->
        <property name="beans" ref="activitiBeanRegistry" />
</bean>

其中 activitiBeanRegistry 定义如下:

<util:map id="activitiBeanRegistry" map-class="java.util.HashMap">
    <entry key="services" value-ref="ServiceRegistry" />
</util:map>

因此,您可以轻松添加带有名称的 bean,而无需触及原始 activitiProcessEngineConfiguration< /代码>。像这样:

<bean id="my.activitiBeanRegistry"  class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="activitiBeanRegistry">
<property name="targetObject">
  <ref bean="activitiBeanRegistry" />
</property>
<property name="targetMethod" value="put" />
<property name="arguments">
  <list>
    <value>sequenceUtil</value>
    <ref bean="sequenceUtil" />
   </list>
</property>

开放扩展以关闭修改:)

可以找到完整源代码 此处

另请参阅activiti-context.xml

There is a much better way to map bean names to el epressions. At least for alfresco 5.2.

Originally activitiProcessEngineConfiguration defined like that:

<bean id="activitiProcessEngineConfiguration" class="org.alfresco.repo.workflow.activiti.AlfrescoProcessEngineConfiguration">

        <!-- Limit the visible beans in expressions -->
        <property name="beans" ref="activitiBeanRegistry" />
</bean>

Where activitiBeanRegistry defined like that:

<util:map id="activitiBeanRegistry" map-class="java.util.HashMap">
    <entry key="services" value-ref="ServiceRegistry" />
</util:map>

So you can easy add your beans with names without touching original activitiProcessEngineConfiguration. Like that:

<bean id="my.activitiBeanRegistry"  class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" depends-on="activitiBeanRegistry">
<property name="targetObject">
  <ref bean="activitiBeanRegistry" />
</property>
<property name="targetMethod" value="put" />
<property name="arguments">
  <list>
    <value>sequenceUtil</value>
    <ref bean="sequenceUtil" />
   </list>
</property>

Open for extension closed for modification :)

Full source can be found here

See also activiti-context.xml

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文