/**
   * 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);
    }
  }