private ServiceConfiguration handleDsl() throws DSLException {
    File dslFile = null;

    if (serviceFileName != null) {
      dslFile = new File(this.puExtDir, this.serviceFileName);
    }

    DSLReader dslReader = new DSLReader();
    dslReader.setAdmin(USMUtils.getAdmin());
    dslReader.setClusterInfo(clusterInfo);
    dslReader.setPropertiesFileName(propertiesFileName);
    dslReader.setRunningInGSC(isRunningInGSC);
    dslReader.setDslFile(dslFile);
    dslReader.setWorkDir(this.puExtDir);
    dslReader.setDslFileNameSuffix(DSLReader.SERVICE_DSL_FILE_NAME_SUFFIX);

    // When loading a service in the USM, expect the jar files to
    // be available in the pu lib dir, and ignore the contents of usmlib
    dslReader.setLoadUsmLib(false);

    logger.info("Loading Service configuration from DSL File");
    Service service = dslReader.readDslEntity(Service.class);
    return new ServiceConfiguration(
        service, dslReader.getContext(), this.puExtDir, dslReader.getDslFile());
  }
Ejemplo n.º 2
0
 private DSLReader createDslReader(final File recipeFile) {
   final DSLReader dslReader = new DSLReader();
   dslReader.setDslFile(recipeFile);
   dslReader.setWorkDir(recipeFile.getParentFile());
   dslReader.setRunningInGSC(true);
   dslReader.setOverridesFile(overrides);
   dslReader.setDslFileNameSuffix(DSLUtils.SERVICE_DSL_FILE_NAME_SUFFIX);
   return dslReader;
 }
Ejemplo n.º 3
0
  private static Object testDSLOverrides(
      final String servicePath,
      final String overridesFilePath,
      final Class<?> clazz,
      final Map<String, Object> expectedFields)
      throws IllegalAccessException, InvocationTargetException, NoSuchMethodException,
          DSLException {
    final File workDir = new File(servicePath);

    final boolean isApplication = clazz.equals(Application.class);
    final boolean isService = clazz.equals(Service.class);
    final boolean isCloud = clazz.equals(Cloud.class);

    File overridesFile = null;
    if (overridesFilePath != null) {
      overridesFile = new File(overridesFilePath);
    }
    final DSLReader reader = new DSLReader();
    reader.setWorkDir(workDir);
    reader.setRunningInGSC(true);
    if (isApplication) {
      reader.setDslFileNameSuffix(DSLUtils.APPLICATION_DSL_FILE_NAME_SUFFIX);
      reader.addProperty(DSLUtils.APPLICATION_DIR, workDir.getAbsolutePath());
      reader.setCreateServiceContext(false);
    } else if (isService) {
      reader.setDslFileNameSuffix(DSLUtils.SERVICE_DSL_FILE_NAME_SUFFIX);
    } else if (isCloud) {
      reader.setDslFileNameSuffix(DSLUtils.CLOUD_DSL_FILE_NAME_SUFFIX);
      reader.setCreateServiceContext(false);
    } else {
      throw new DSLException("Class " + clazz.getName() + " does not exist in the DSL Domain");
    }
    reader.setOverridesFile(overridesFile);
    final Object object = reader.readDslEntity(clazz);
    assertOverrides(object, reader, expectedFields, workDir);
    return object;
  }