/**
   * Add and initialize a new Deployer to deployment engine.
   *
   * @param deployer the deployer instance to register
   * @throws org.wso2.carbon.deployment.exception.DeployerRegistrationException Throwing deployment
   *     registration exception
   */
  public void registerDeployer(Deployer deployer) throws DeployerRegistrationException {

    if (deployer == null) {
      throw new DeployerRegistrationException(
          "Failed to add Deployer : " + "Deployer Class Name is null");
    }
    // Try and initialize the deployer
    deployer.init();

    if (deployer.getLocation() == null) {
      throw new DeployerRegistrationException(
          "Failed to add Deployer "
              + deployer.getClass().getName()
              + ": missing 'directory' attribute "
              + "in deployer instance");
    }
    ArtifactType type = deployer.getArtifactType();

    if (type == null) {
      throw new DeployerRegistrationException(
          "Artifact Type for Deployer : " + deployer + " is null");
    }

    Deployer existingDeployer = deployerMap.get(type);
    if (existingDeployer == null) {
      deployerMap.put(type, deployer);
    }
  }
  /**
   * Removes a deployer from the deployment engine configuration
   *
   * @param deployer the deployer instance to un-register
   * @throws DeploymentEngineException Throwing deployment registration exception
   */
  public void unregisterDeployer(Deployer deployer) throws DeploymentEngineException {
    ArtifactType type = deployer.getArtifactType();
    if (type == null) {
      throw new DeploymentEngineException("Artifact Type for Deployer : " + deployer + " is null");
    }

    Deployer existingDeployer = deployerMap.get(type);
    if (existingDeployer != null) {
      deployerMap.remove(type);
    }
  }