在Activiti中,所有複雜對象都使用Java序列化進行序列化並存儲在數據庫中。我希望爲我的自定義類型覆蓋此行爲並將對象存儲爲JSON。這應該有助於我更好地控制持久對象。Activiti自定義變量類型問題
我已經創建了我的自定義VariableType來執行此操作。下面是摘錄
public class CustomVariableType extends ByteArrayType{
// overrided all the needed method.
}
這些類型的Activiti的配置IMPL如下配置:
public class WorklistConfigurationService {
private ProcessEngineConfigurationImpl processEngineConfigurationImpl;
private List<CustomVariableType> customVarsTypes;
public void init(){
logger.debug("inside init");
for(VOVariableType varType : voVars){
logger.debug("adding type {}", varType.getTypeName());
processEngineConfigurationImpl.getVariableTypes().addType(varType, 0);
}
}
// getter and setters...
}
下面是怎麼了注射值高於春季
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration">
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="worklistConfigurationService"
class="...WorklistConfigurationService" init-method="init">
<property name="customVarTypes">
<list>
<bean id="var1" class="...CustomVariableType">
<constructor-arg type="java.lang.String" value="custom" />
<constructor-arg type="java.lang.Class"
value="..CustomType" />
</bean>
</list>
</property>
<property name="processEngineConfigurationImpl" ref="processEngineConfiguration" />
</bean>
但新序列化機制從未被activiti引擎使用過。相反,它總是使用默認的序列化。有人可以幫助解決這個問題。
你是否也覆蓋'CustomVariableType'中的'isAbleToStore'方法?什麼是voVar? – matts
@matts我只是想隱藏我的商業類名稱。將voVars重命名爲自定義類型。是的,我重寫了isAbleToStore方法。 – ajjain
我不知道如何,但同一段代碼工作。我的不好,有人可以關閉這個問題。順便說一句,我打算分享這個GIST,這樣可以參考。這是記錄最少但非常有用的功能之一。一旦完成GIST,就會在這裏更新。主持人請lemme知道如果共享代碼鏈接是不允許的。 – ajjain