/** {@inheritDoc} */
 @Override
 public void releaseResource(final String resourceId) throws InvalidResourceId {
   LocalSca localSca;
   try {
     localSca = ScaDebugPlugin.getInstance().getLocalSca(null);
   } catch (CoreException e) {
     throw new InvalidResourceId("Failed to find local sandbox to launch resource in.");
   }
   for (ScaComponent component : localSca.getSandboxWaveform().getComponents()) {
     if (component.getIdentifier().equals(resourceId)) {
       try {
         component.releaseObject();
       } catch (ReleaseError e) {
         // PASS
       }
     }
   }
 }
  /** {@inheritDoc} */
  @Override
  public Resource createResource(String resourceId, final DataType[] inputQualifiers)
      throws CreateResourceFailure {
    if (!resourceId.endsWith(identifier())) {
      resourceId = resourceId + ":" + identifier();
    }
    LocalSca localSca;
    try {
      localSca = ScaDebugPlugin.getInstance().getLocalSca(null);
    } catch (CoreException e) {
      throw new CreateResourceFailure(
          ErrorNumberType.CF_ENODEV, "Failed to find local sandbox to launch resource in.");
    }
    for (ScaComponent component : localSca.getSandboxWaveform().getComponents()) {
      if (component.getIdentifier().equals(resourceId)) {
        return component.getObj();
      }
    }
    String mode = null;

    // Strip off and Launch Type qualifiers
    List<DataType> qualifiers = new ArrayList<DataType>();
    for (final DataType t : inputQualifiers) {
      if (Sandbox.LAUNCH_TYPE.equals(t.id)) {
        final String value = t.value.extract_string();
        mode = value;
      } else {
        qualifiers.add(t);
      }
    }

    if (mode == null) {
      mode = "run";
    }

    // TODO Add support for other run modes
    if (!"run".equals(mode)) {
      throw new CreateResourceFailure(
          ErrorNumberType.CF_EINVAL, "Only 'run' mode is currently supported from sandbox.");
    }

    return createInstance(resourceId, qualifiers.toArray(new DataType[qualifiers.size()]), mode);
  }