private EPR createEpr(final Token token)
{
ProcessInstance instance = token.getProcessInstance();
final EPR epr = new EPR();
final PortReference portRef = epr.getAddr();
final long nodeId = token.getNode().getId();
final long tokenId = token.getId();
final long processVersion = instance.getProcessDefinition().getVersion();
portRef.addExtension(Constants.NODE_ID, String.valueOf(nodeId));
portRef.addExtension(Constants.TOKEN_ID, String.valueOf(tokenId));
portRef.addExtension(Constants.PROCESS_INSTANCE_ID, String.valueOf(instance.getId()));
// Set the counter
String counterName = Constants.PROCESS_NODE_VERSION_COUNTER + nodeId + '_' + tokenId;
portRef.addExtension(counterName, String.valueOf(processVersion));
// The counterName variable is expected to be found in the process context.
instance.getContextInstance().setVariableLocally(counterName, processVersion);
return epr;
}