예제 #1
0
  /**
   * Through the method <code>getAddonDeveloper</code> you can get a addonDeveloper instance passing
   * like parameter a developer reference instance.
   *
   * @param addonDeveloperReference addon developer reference data.
   * @return a addon developer instance.
   * @throws DeveloperNotFoundException if we can't find a addon developer with the given developer
   *     reference parameters.
   */
  public final AbstractAddonDeveloper getAddonDeveloper(
      final AddonDeveloperReference addonDeveloperReference) throws DeveloperNotFoundException {

    try {

      return getAddonSubsystem(addonDeveloperReference.getAddonReference())
          .getDeveloperByReference(addonDeveloperReference);

    } catch (AddonNotFoundException e) {

      throw new DeveloperNotFoundException(
          e,
          addonDeveloperReference.toString(),
          "addon developer not found in the platform of the system context.");
    }
  }
  public final AbstractAddonDeveloper getDeveloperByReference(
      final AddonDeveloperReference addonDeveloperReference) throws DeveloperNotFoundException {

    if (developers.containsKey(addonDeveloperReference)) {
      return developers.get(addonDeveloperReference);
    } else {

      throw new DeveloperNotFoundException(
          addonDeveloperReference.toString(),
          "developer not found in the specified addon subsystem.");
    }
  }
  /**
   * Throw the method <code>registerDeveloper</code> you can add new developers to the addon
   * subsystem. Here we'll corroborate too that the developer is not added twice.
   *
   * @param addonDeveloper addonDeveloper in-self.
   * @throws CantRegisterDeveloperException if something goes wrong.
   */
  protected final void registerDeveloper(final AbstractAddonDeveloper addonDeveloper)
      throws CantRegisterDeveloperException {

    AddonDeveloperReference addonDeveloperReference = addonDeveloper.getAddonDeveloperReference();

    addonDeveloperReference.setAddonReference(this.addonReference);

    try {

      if (developers.containsKey(addonDeveloperReference))
        throw new CantRegisterDeveloperException(
            addonDeveloperReference.toString(), "developer already exists for this addon.");

      addonDeveloper.start();

      developers.put(addonDeveloperReference, addonDeveloper);

    } catch (final CantStartAddonDeveloperException e) {

      throw new CantRegisterDeveloperException(
          e, addonDeveloperReference.toString(), "Error trying to start the developer.");
    }
  }