/**
   * Gets the value of the parameter indicated by the urn.
   *
   * <p>The parameter is to be found in one of the registered parameterizable. Otherwise, a
   * ParameterizationException will be thrown.
   *
   * @see eu.artemis.demanes.parameterization.Parameterizable#setParameter(eu.artemis
   *     .demanes.datatypes.ANES_URN, java.lang.Object)
   */
  @Override
  public Object getParameter(ANES_URN urn) throws ParameterizationException {
    UUID uid = UUID.randomUUID();
    logger.trace(
        new LogEntry(
            this.getClass().getName(),
            LogConstants.LOG_LEVEL_TRACE,
            "Param",
            "Getting Parameter " + urn + " from broker (" + uid + ")"));

    Parameterizable parameterizable = findURNOwner(urn);
    if (parameterizable != null) {
      Object response = parameterizable.getParameter(urn);
      logger.trace(
          new LogEntry(
              this.getClass().getName(),
              LogConstants.LOG_LEVEL_TRACE,
              "Param",
              "Parameter " + urn + " obtained (" + uid + ")"));

      return response;
    } else {
      logger.error(
          new LogEntry(
              this.getClass().getName(),
              LogConstants.LOG_LEVEL_ERROR,
              "Param",
              "Unable to find parameter " + urn));

      throw new ParameterizationURNException();
    }
  }
  /**
   * Sets the parameter indicated by the urn, with the given value.
   *
   * <p>The parameter is to be found in one of the registered parameterizable. Otherwise, a
   * ParameterizationException will be thrown.
   *
   * @see eu.artemis.demanes.parameterization.Parameterizable#setParameter(eu.artemis
   *     .demanes.datatypes.ANES_URN, java.lang.Object)
   */
  @Override
  public void setParameter(ANES_URN urn, Object value) throws ParameterizationException {
    UUID uid = UUID.randomUUID();
    logger.trace(
        new LogEntry(
            this.getClass().getName(),
            LogConstants.LOG_LEVEL_TRACE,
            "Param",
            "Setting parameter " + urn + " from broker (" + uid + ")"));

    Parameterizable parameterizable = findURNOwner(urn);
    if (parameterizable != null) {
      parameterizable.setParameter(urn, value);
    } else {
      logger.error(
          new LogEntry(
              this.getClass().getName(),
              LogConstants.LOG_LEVEL_ERROR,
              "Param",
              "Setting unknown parameter " + urn));
      throw new ParameterizationURNException();
    }

    logger.trace(
        new LogEntry(
            this.getClass().getName(),
            LogConstants.LOG_LEVEL_TRACE,
            "Param",
            "Parameter set (" + uid + ")"));
  }
  /**
   * Lists all urns accessible through this broker.
   *
   * @return an array with all the urns accessible through this parameterizable.
   * @see eu.artemis.demanes.parameterization.Parameterizable#setParameter(eu.artemis
   *     .demanes.datatypes.ANES_URN, java.lang.Object)
   */
  @Override
  public Set<ANES_URN> listParameters() {
    UUID uid = UUID.randomUUID();
    logger.trace(
        new LogEntry(
            this.getClass().getName(),
            LogConstants.LOG_LEVEL_TRACE,
            "Param",
            "Listing parameters (" + uid + ")"));

    final Set<ANES_URN> urnList = new HashSet<ANES_URN>();
    for (Parameterizable it : this.parSet)
      try {
        urnList.addAll(it.listParameters());
      } catch (ParameterizationException e) {
        logger.error(
            new LogEntry(
                this.getClass().getName(),
                LogConstants.LOG_LEVEL_ERROR,
                "Param",
                "Error Listing parameters",
                e));
        // Do nothing
      }

    logger.trace(
        new LogEntry(
            this.getClass().getName(),
            LogConstants.LOG_LEVEL_TRACE,
            "Param",
            "Finished listing (" + uid + ")"));
    return urnList;
  }
 /**
  * Finds a parameterizable that owns a parameter with the indicated URN.
  *
  * @return the parameterizable or null if no owner is found.
  */
 private Parameterizable findURNOwner(ANES_URN urn) {
   for (Parameterizable parameterizable : parSet)
     try {
       if (parameterizable.listParameters().contains(urn)) return parameterizable;
     } catch (ParameterizationException e) {
       // Do nothing, search next one
     }
   return null;
 }