找到了一个直接修改流程定义字段的方法。
package org.jbpm.pvm.internal.cmd;
import java.io.IOException;
import java.io.InputStream;
import org.jbpm.api.JbpmException;
import org.jbpm.api.cmd.Command;
import org.jbpm.api.cmd.Environment;
import org.jbpm.pvm.internal.session.RepositorySession;
import org.jbpm.pvm.internal.util.IoUtil;
/**
* @author Tom Baeyens
*/
public class UpdateDeploymentResourceCmd implements Command<Void> {
private static final long serialVersionUID = 1L;
protected String deploymentId;
protected String resourceName;
protected byte[] bytes;
public UpdateDeploymentResourceCmd(String deploymentId, String resourceName,
InputStream inputStream) {
this.deploymentId = deploymentId;
this.resourceName = resourceName;
try {
bytes = IoUtil.readBytes(inputStream);
}
catch (IOException e) {
throw new JbpmException("could not read resource: " + resourceName, e);
}
finally {
IoUtil.close(inputStream);
}
}
public Void execute(Environment environment) throws Exception {
RepositorySession repositorySession = environment.get(RepositorySession.class);
repositorySession.updateDeploymentResource(deploymentId, resourceName, bytes);
return null;
}
}