com.google.apphosting.utils.config.AppEngineWebXmlReader Java Examples

The following examples show how to use com.google.apphosting.utils.config.AppEngineWebXmlReader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractAppCfgMojo.java    From appengine-maven-plugin with Apache License 2.0 6 votes vote down vote up
String getProjectId() throws MojoExecutionException {
  if (project != null) {
    return project;
  }
  if (appId != null) {
    return appId;
  }
  File f = new File(getAppDir(), "WEB-INF/appengine-web.xml");
  if (f.exists()) {
    AppEngineWebXmlReader aewebReader = new AppEngineWebXmlReader(getAppDir());
    AppEngineWebXml appEngineWebXml = aewebReader.readAppEngineWebXml();
    return appEngineWebXml.getAppId();
  } else if (EarHelper.isEar(getAppDir(), false)) {
    EarInfo earInfo = EarHelper.readEarInfo(getAppDir(),
            new File(Application.getSdkDocsDir(), "appengine-application.xsd"));
    return earInfo.getAppengineApplicationXml().getApplicationId();
  }
  throw new MojoExecutionException(
          "No <application> defined in appengine-web.xml, nor <project>"
          + " <configuration> defined in the pom.xml.");
}
 
Example #2
Source File: VmRuntimeWebAppContext.java    From appengine-java-vm-runtime with Apache License 2.0 4 votes vote down vote up
/**
 * Initialize the WebAppContext for use by the VmRuntime.
 *
 * This method initializes the WebAppContext by setting the context path and application folder.
 * It will also parse the appengine-web.xml file provided to set System Properties and session
 * manager accordingly.
 *
 * @param appengineWebXmlFile The appengine-web.xml file path (relative to appDir).
 * @throws AppEngineConfigException If there was a problem finding or parsing the
 *         appengine-web.xml configuration.
 * @throws IOException If the runtime was unable to find/read appDir.
 */
public void init(String appengineWebXmlFile)
    throws AppEngineConfigException, IOException {

  String appDir=getBaseResource().getFile().getCanonicalPath();  
  defaultEnvironment = VmApiProxyEnvironment.createDefaultContext(
      System.getenv(), metadataCache, VmRuntimeUtils.getApiServerAddress(), wallclockTimer,
      VmRuntimeUtils.ONE_DAY_IN_MILLIS, appDir);
  ApiProxy.setEnvironmentForCurrentThread(defaultEnvironment);
  if (ApiProxy.getEnvironmentFactory() == null) {
    // Need the check above since certain unit tests initialize the context multiple times.
    ApiProxy.setEnvironmentFactory(new VmEnvironmentFactory(defaultEnvironment));
  }

  isDevMode = defaultEnvironment.getPartition().equals("dev");
  AppEngineWebXml appEngineWebXml = null;
  File appWebXml = new File(appDir, appengineWebXmlFile);
  if (appWebXml.exists()) {
    AppEngineWebXmlReader appEngineWebXmlReader
            = new AppEngineWebXmlReader(appDir, appengineWebXmlFile);
    appEngineWebXml = appEngineWebXmlReader.readAppEngineWebXml();
  }
  VmRuntimeUtils.installSystemProperties(defaultEnvironment, appEngineWebXml);
  VmRuntimeLogHandler.init();
  VmRuntimeFileLogHandler.init();

  for (String systemClass : SYSTEM_CLASSES) {
    addSystemClass(systemClass);
  }
  if (appEngineWebXml == null) {
    // No need to configure the session manager.
    return;
  }
  AbstractSessionManager sessionManager;
  if (appEngineWebXml.getSessionsEnabled()) {
    sessionManager = new SessionManager(createSessionStores(appEngineWebXml));
    getSessionHandler().setSessionManager(sessionManager);
  }

  setProtectedTargets(ArrayUtil.addToArray(getProtectedTargets(), "/app.yaml", String.class));
}
 
Example #3
Source File: AppengineWebAppContext.java    From yawp with MIT License 4 votes vote down vote up
private AppEngineWebXml readAppengineWebXml() {
    AppEngineWebXmlReader reader = new AppEngineWebXmlReader(mojo.getAppDir());
    AppEngineWebXml appEngineWebXml = reader.readAppEngineWebXml();
    applySystemProperties(appEngineWebXml);
    return appEngineWebXml;
}
 
Example #4
Source File: AbstractGcloudMojo.java    From gcloud-maven-plugin with Apache License 2.0 4 votes vote down vote up
protected AppEngineWebXml getAppEngineWebXml(String webAppDir) throws MojoExecutionException {
  AppEngineWebXmlReader reader = new AppEngineWebXmlReader(webAppDir);
  AppEngineWebXml appengineWebXml = reader.readAppEngineWebXml();
  return appengineWebXml;
}