All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.google.gxp.base.dynamic..svn.text-base.RuntimeConfiguration.svn-base Maven / Gradle / Ivy

Go to download

Google XML Pages (GXP) is a templating system used to generate XML/SGML markup (most often HTML).

The newest version!
/*
 * Copyright (C) 2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.gxp.base.dynamic;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.gxp.compiler.Configuration;
import com.google.gxp.compiler.Phase;
import com.google.gxp.compiler.alerts.AlertPolicy;
import com.google.gxp.compiler.base.OutputLanguage;
import com.google.gxp.compiler.codegen.CodeGeneratorFactory;
import com.google.gxp.compiler.codegen.DefaultCodeGeneratorFactory;
import com.google.gxp.compiler.fs.FileRef;
import com.google.gxp.compiler.fs.FileSystem;
import com.google.gxp.compiler.fs.SourcePathFileSystem;
import com.google.gxp.compiler.parser.SourceEntityResolver;
import com.google.gxp.compiler.parser.FileSystemEntityResolver;

import java.util.Set;
import java.util.SortedSet;

/**
 * An implementation of {@code Configuration} to be used to compile
 * GXPs at runtime.
 */
public class RuntimeConfiguration implements Configuration {
  private static final ImmutableSet OUTPUT_LANGUAGES =
      ImmutableSet.of(OutputLanguage.DYNAMIC_IMPL_JAVA);
  private static final CodeGeneratorFactory CODE_GENERATOR_FACTORY =
      new DefaultCodeGeneratorFactory();
  private static final ImmutableSortedSet DOT_PHASES = ImmutableSortedSet.of();

  private final ImmutableSet sourceFiles;
  private final ImmutableSet schemaFiles;
  private final ImmutableSet allowedOutputFiles;
  private final long compilationVersion;
  private final SourceEntityResolver sourceEntityResolver;
  private final AlertPolicy alertPolicy;

  public RuntimeConfiguration(FileSystem inputFileSystem,
                              FileSystem outputFileSystem,
                              Set sourceFiles,
                              Set sourceSchemas,
                              Set sourcePaths,
                              String outputFile,
                              long compilationVersion,
                              AlertPolicy alertPolicy) {

    SourcePathFileSystem sourcePathFs = new SourcePathFileSystem(inputFileSystem,
                                                                 sourcePaths,
                                                                 sourceFiles,
                                                                 outputFileSystem.getRoot());

    this.sourceFiles = ImmutableSet.copyOf(sourcePathFs.getSourceFileRefs());
    this.schemaFiles = ImmutableSet.copyOf(sourceSchemas);
    this.sourceEntityResolver = new FileSystemEntityResolver(sourcePathFs);
    this.allowedOutputFiles = ImmutableSet.of(sourcePathFs.parseFilename(outputFile));
    this.compilationVersion = compilationVersion;
    this.alertPolicy = Preconditions.checkNotNull(alertPolicy);
  }

  @Override
  public Set getSourceFiles() {
    return sourceFiles;
  }

  @Override
  public Set getSchemaFiles() {
    return schemaFiles;
  }

  @Override
  public Set getOutputLanguages() {
    return OUTPUT_LANGUAGES;
  }

  @Override
  public long getCompilationVersion() {
    return compilationVersion;
  }

  @Override
  public CodeGeneratorFactory getCodeGeneratorFactory() {
    return CODE_GENERATOR_FACTORY;
  }

  @Override
  public Set getAllowedOutputFiles() {
    return allowedOutputFiles;
  }

  @Override
  public FileRef getDependencyFile() {
    return null;
  }

  @Override
  public FileRef getPropertiesFile() {
    return null;
  }

  @Override
  public boolean isDebugEnabled() {
    return false;
  }

  @Override
  public AlertPolicy getAlertPolicy() {
    return alertPolicy;
  }

  @Override
  public SortedSet getDotPhases() {
    return DOT_PHASES;
  }

  @Override
  public SourceEntityResolver getEntityResolver() {
    return sourceEntityResolver;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy