Package com.google.apphosting.utils.config

Examples of com.google.apphosting.utils.config.AppEngineWebXml


      ApplicationConfigurationManager applicationConfigurationManager,
      String serverInfo, File externalResourceDir, String address, DevAppServer devAppServer) {
    ImmutableList.Builder<Module> builder = ImmutableList.builder();
    for (ApplicationConfigurationManager.ModuleConfigurationHandle moduleConfigurationHandle :
      applicationConfigurationManager.getModuleConfigurationHandles()) {
      AppEngineWebXml appEngineWebXml =
          moduleConfigurationHandle.getModule().getAppEngineWebXml();
      Module module = null;
      if (!appEngineWebXml.getBasicScaling().isEmpty()) {
        module = new BasicModule(moduleConfigurationHandle, serverInfo, address, devAppServer,
            appEngineWebXml);
      } else if (!appEngineWebXml.getManualScaling().isEmpty()) {
        module = new ManualModule(moduleConfigurationHandle, serverInfo, address, devAppServer,
            appEngineWebXml);
      } else {
        module = new AutomaticModule(moduleConfigurationHandle, serverInfo, externalResourceDir,
            address, devAppServer);
View Full Code Here


          Class.forName("com.google.appengine.api.LifecycleManager", true, serverClassLoader);
      Method lifeCycleManagerGetter = lifeCycleManagerClass.getMethod("getInstance");
      Object userThreadLifeCycleManager = lifeCycleManagerGetter.invoke(null, new Object[0]);

      Method beginShutdown = lifeCycleManagerClass.getMethod("beginShutdown", long.class);
      AppEngineWebXml appEngineWebXml = containerService.getAppEngineWebXmlConfig();
      String moduleName = WebModule.getModuleName(appEngineWebXml);
      ApiProxy.setEnvironmentForCurrentThread(new LocalInitializationEnvironment(
          appEngineWebXml.getAppId(), moduleName, appEngineWebXml.getMajorVersionId(), instance,
          containerService.getPort()));

      try {
        beginShutdown.invoke(userThreadLifeCycleManager, AH_REQUEST_DEFAULT_TIMEOUT);
      } catch (Exception e) {
View Full Code Here

   */
  private synchronized void validateAndRegisterGlobalValues(WebModule module,
      LoggingConfigurationManager loggingConfigurationManager,
      File externalResourceDirectory) {
    module.getWebXml().validate();
    AppEngineWebXml appEngineWebXml = module.getAppEngineWebXml();
    loggingConfigurationManager.read(systemPropertiesManager.getOriginalSystemProperties(),
        appEngineWebXml.getSystemProperties(), module.getApplicationDirectory(),
        externalResourceDirectory);
    systemPropertiesManager.setSystemProperties(appEngineWebXml, module.getAppEngineWebXmlFile());
  }
View Full Code Here

    String majorVersionId = null;
    String urlStreamHandlerType = null;
    LoggingConfigurationManager loggingConfigurationManager = new LoggingConfigurationManager();
    for (WebModule module : earInfo.getWebModules()) {
      module.getWebXml().validate();
      AppEngineWebXml appEngineWebXml = module.getAppEngineWebXml();
      if (majorVersionId == null) {
        majorVersionId = appEngineWebXml.getMajorVersionId();
        urlStreamHandlerType = appEngineWebXml.getUrlStreamHandlerType();
      }
      validateAndRegisterGlobalValues(module, loggingConfigurationManager, null);
    }
    systemPropertiesManager.setAppengineSystemProperties(sdkRelease,
        earInfo.getAppengineApplicationXml().getApplicationId(), majorVersionId);
View Full Code Here

            new BackendsXmlReader(baseDir).readBackendsXml();
        if (backendsXml == null) {
          BackendsYamlReader backendsYaml = new BackendsYamlReader(webinf.getPath());
          backendsXml = backendsYaml.parse();
        }
        AppEngineWebXml appEngineWebXml = webModule.getAppEngineWebXml();
        String appId = System.getenv("APPLICATION_ID");
        if (appId == null
            && (appEngineWebXml.getAppId() == null || appEngineWebXml.getAppId().isEmpty())) {
          appId = "no_app_id";
        }
        if (appId != null) {
          appEngineWebXml.setAppId(appId);
        }
        LoggingConfigurationManager loggingConfigurationManager = new LoggingConfigurationManager();
        validateAndRegisterGlobalValues(webModule, loggingConfigurationManager,
            externalResourceDirectory);
        systemPropertiesManager.setAppengineSystemProperties(sdkRelease,
            appEngineWebXml.getAppId(), appEngineWebXml.getMajorVersionId());
        loggingConfigurationManager.updateLoggingConfiguration();
        updateUrlStreamHandlerMode(appEngineWebXml.getUrlStreamHandlerType());
      }
    }
View Full Code Here

    ContextHandler.SContext context = (ContextHandler.SContext) getServletContext();
    staticFileUtils = new StaticFileUtils(context);

    welcomeFiles = context.getContextHandler().getWelcomeFiles();

    AppEngineWebXml appEngineWebXml = (AppEngineWebXml) getServletContext().getAttribute(
        "com.google.appengine.tools.development.appEngineWebXml");

    resourceRoot = appEngineWebXml.getPublicRoot();
    try {
      resourceBase = context.getContextHandler().getResource(URIUtil.SLASH + resourceRoot);
    } catch (MalformedURLException ex) {
      logger.log(Level.WARNING, "Could not initialize:", ex);
      throw new ServletException(ex);
View Full Code Here

  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String servletPath;
    String pathInfo;

    AppEngineWebXml appEngineWebXml = (AppEngineWebXml) getServletContext().getAttribute(
        "com.google.appengine.tools.development.appEngineWebXml");

    WebXml webXml = (WebXml) getServletContext().getAttribute(
        "com.google.appengine.tools.development.webXml");

    Boolean forwarded = (Boolean) request.getAttribute(Dispatcher.__FORWARD_JETTY);
    if (forwarded == null) {
      forwarded = Boolean.FALSE;
    }

    Boolean included = (Boolean) request.getAttribute(Dispatcher.__INCLUDE_JETTY);
    if (included != null && included) {
      servletPath = (String) request.getAttribute(Dispatcher.__INCLUDE_SERVLET_PATH);
      pathInfo = (String) request.getAttribute(Dispatcher.__INCLUDE_PATH_INFO);
      if (servletPath == null) {
        servletPath = request.getServletPath();
        pathInfo = request.getPathInfo();
      }
    } else {
      included = Boolean.FALSE;
      servletPath = request.getServletPath();
      pathInfo = request.getPathInfo();
    }

    String pathInContext = URIUtil.addPaths(servletPath, pathInfo);

    if (maybeServeWelcomeFile(pathInContext, included, request, response)) {
      return;
    }

    Resource resource = null;
    try {
      resource = getResource(pathInContext);

      if (resource != null && resource.isDirectory()) {
        if (included ||
            staticFileUtils.passConditionalHeaders(request, response, resource)) {
          response.sendError(HttpServletResponse.SC_FORBIDDEN);
        }
      } else {
        if (resource == null || !resource.exists()) {
          logger.warning("No file found for: " + pathInContext);
          response.sendError(HttpServletResponse.SC_NOT_FOUND);
        } else {
          boolean isStatic = appEngineWebXml.includesStatic(resourceRoot + pathInContext);
          boolean isResource = appEngineWebXml.includesResource(
              resourceRoot + pathInContext);
          boolean usesRuntime = webXml.matches(pathInContext);
          Boolean isWelcomeFile = (Boolean)
              request.getAttribute("com.google.appengine.tools.development.isWelcomeFile");
          if (isWelcomeFile == null) {
View Full Code Here

    if (!path.endsWith(URIUtil.SLASH)) {
      path += URIUtil.SLASH;
    }

    AppEngineWebXml appEngineWebXml = (AppEngineWebXml) getServletContext().getAttribute(
        "com.google.appengine.tools.development.appEngineWebXml");

    ContextHandler.SContext context = (ContextHandler.SContext) getServletContext();
    ServletHandler handler = ((Context) context.getContextHandler()).getServletHandler();
    PathMap.Entry defaultEntry = handler.getHolderEntry("/");
    PathMap.Entry jspEntry = handler.getHolderEntry("/foo.jsp");

    for (String welcomeName : welcomeFiles) {
      String welcomePath = path + welcomeName;
      String relativePath = welcomePath.substring(1);

      PathMap.Entry entry = handler.getHolderEntry(welcomePath);
      if (entry != defaultEntry && entry != jspEntry) {
        RequestDispatcher dispatcher = request.getRequestDispatcher(path + welcomeName);
        return staticFileUtils.serveWelcomeFileAsForward(dispatcher, included, request, response);
      }

      Resource welcomeFile = getResource(path + welcomeName);
      if (welcomeFile != null && welcomeFile.exists()) {
        if (entry != defaultEntry) {
          RequestDispatcher dispatcher = request.getRequestDispatcher(path + welcomeName);
          return staticFileUtils.serveWelcomeFileAsForward(dispatcher, included, request, response);
        }
        if (appEngineWebXml.includesResource(relativePath)) {
          RequestDispatcher dispatcher = request.getRequestDispatcher(path + welcomeName);
          return staticFileUtils.serveWelcomeFileAsForward(dispatcher, included, request, response);
        }
      }
      RequestDispatcher namedDispatcher = context.getNamedDispatcher(welcomeName);
View Full Code Here

      return false;
    }

    try {
      AppEngineWebXmlReader reader = new AppEngineWebXmlReader(appDir);
      AppEngineWebXml appEngineWebXml = reader.readAppEngineWebXml();
      return appEngineWebXml.getUseVm();
    } catch (AppEngineConfigException e) {
      System.err.println("Error reading: " + f.getAbsolutePath());
      return false;
    }
  }
View Full Code Here

   * @return The Set of the names of all headers that were added, canonicalized to lower case.
   */
  @VisibleForTesting
  Set<String> addUserStaticHeaders(String localFilePath,
                                     HttpServletResponse response) {
    AppEngineWebXml appEngineWebXml = (AppEngineWebXml) servletContext.getAttribute(
        "com.google.appengine.tools.development.appEngineWebXml");

    Set<String> headersApplied = new HashSet<String>();
    for (AppEngineWebXml.StaticFileInclude include : appEngineWebXml.getStaticFileIncludes()) {
      Pattern pattern = include.getRegularExpression();
      if (pattern.matcher(localFilePath).matches()) {
        for (Map.Entry<String, String> entry : include.getHttpHeaders().entrySet()) {
          response.addHeader(entry.getKey(), entry.getValue());
          headersApplied.add(entry.getKey().toLowerCase());
View Full Code Here

TOP

Related Classes of com.google.apphosting.utils.config.AppEngineWebXml

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.