示例#1
0
  private static Iaas loadIaas(IaasProvider iaasProvider) throws InvalidIaasProviderException {
    try {

      if (iaasProvider.getClassName() == null) {
        String msg =
            "You have not specified a class which represents the iaas of type: ["
                + iaasProvider.getType()
                + "].";
        log.error(msg);
        throw new InvalidIaasProviderException(msg);
      }

      Constructor<?> c =
          Class.forName(iaasProvider.getClassName()).getConstructor(IaasProvider.class);
      Iaas iaas = (Iaas) c.newInstance(iaasProvider);
      return iaas;
    } catch (Exception e) {
      String msg =
          "Class ["
              + iaasProvider.getClassName()
              + "] which represents the iaas of type: ["
              + iaasProvider.getType()
              + "] has failed to instantiate.";
      log.error(msg, e);
      throw new InvalidIaasProviderException(msg, e);
    }
  }