/* (non-Javadoc)
   * @see org.cagrid.workflow.helper.instance.service.globus.resource.WorkflowInstanceHelperResourceBase#remove()
   */
  public void remove() throws ResourceException {

    logger.info("Destroying InstanceHelper resource");

    super.remove();

    // Destroy each InvocationHelper associated with this resource
    Iterator<EndpointReferenceType> stages_iter = this.stagesEPRs.iterator();
    while (stages_iter.hasNext()) {

      EndpointReferenceType curr_epr = stages_iter.next();
      WorkflowInvocationHelperClient curr_client;
      try {
        curr_client = new WorkflowInvocationHelperClient(curr_epr);

        String stageID = curr_client.getEPRString();
        this.stageStatus.remove(stageID); // Stop monitoring current stage's status changes

        curr_client.destroy(); // Destroy the resource associated with current stage
      } catch (MalformedURIException e) {
        e.printStackTrace();
      } catch (RemoteException e) {
        e.printStackTrace();
      }

      logger.info("Done");
      return;
    }
  }