//should be invoked after applyChanges() of this ProcessInstance
getProcessTransactionContext().addTransactionListener(new TransactionListener(){
public void beforeCommit(TransactionContext tx) throws Exception{
ProcessInstanceDAOType pidt = ProcessInstanceDAOType.getInstance(getProcessTransactionContext());
pidt.archiveInstance(new Long(getInstanceId()), archivePath);
}
public void beforeRollback(TransactionContext tx) throws Exception{
// TODO Auto-generated method stub