code: public List<ActivityInstance> getActivityInstances(String masterRequestId, String processName, String activityLogicalId)
      throws ProcessException, DataAccessException {
          TransactionWrapper transaction = null;
          EngineDataAccessDB edao = new EngineDataAccessDB();
          try {
              Process procdef = ProcessCache.getProcess(processName, 0);
              if (procdef==null) return null;
              Activity actdef = procdef.getActivityByLogicalId(activityLogicalId);
              if (actdef==null) return null;
              transaction = edao.startTransaction();
              List<ActivityInstance> actInstList = new ArrayList<ActivityInstance>();
              List<ProcessInstance> procInstList =
                  edao.getProcessInstancesByMasterRequestId(masterRequestId, procdef.getId());
              if (procInstList.size()==0) return actInstList;
              for (ProcessInstance pi : procInstList) {
                  List<ActivityInstance> actInsts = edao.getActivityInstances(actdef.getId(), pi.getId(), false, false);
                  for (ActivityInstance ai : actInsts) {
                      actInstList.add(ai);
                  }
              }
              return actInstList;
          } catch (SQLException e) {
              throw new ProcessException(0, "Failed to remove event waits", e);
          } finally {
              edao.stopTransaction(transaction);
          }
      }
docs: Returns the activity instances by process name, activity logical ID, and  master request ID.
  
  @param processName
  @param activityLogicalId
  @param masterRequestId
  @return the list of activity instances. If the process definition or the activity
  with the given logical ID is not found, null
  is returned; if process definition is found but no process instances are found,
  or no such activity instances are found, an empty list is returned.
  @throws ProcessException
  @throws DataAccessException