Package com.google.gwt.dev.cfg

Examples of com.google.gwt.dev.cfg.ModuleDef


      // See if the request references a module we know.
      // Note that we do *not* actually try to load the module here, because
      // we're only looking for servlet invocations, which can only happen
      // when we have *already* loaded the destination module to serve up the
      // client code in the first place.
      ModuleDef moduleDef = (ModuleDef) loadedModulesByName.get(parts.moduleName);
      if (moduleDef != null) {
        // Okay, we know this module. Do we know this servlet path?
        // It is right to prepend the slash because (1) ModuleDefSchema requires
        // every servlet path to begin with a slash and (2) RequestParts always
        // rips off the leading slash.
        String servletPath = "/" + parts.partialPath;
        servletClassName = moduleDef.findServletForPath(servletPath);

        // Fall-through below, where we check servletClassName.
      } else {
        // Fall-through below, where we check servletClassName.
      }
    } catch (UnableToCompleteException e) {
      // Do nothing, since it was speculative anyway.
    }

    // BEGIN BACKWARD COMPATIBILITY
    if (servletClassName == null) {
      // Try to map a bare path that isn't preceded by the module name.
      // This is no longer the recommended practice, so we warn.
      String path = request.getPathInfo();
      ModuleDef moduleDef = (ModuleDef) modulesByServletPath.get(path);
      if (moduleDef != null) {
        // See if there is a servlet we can delegate to for the given url.
        servletClassName = moduleDef.findServletForPath(path);

        if (servletClassName != null) {
          TreeLogger branch = logger.branch(TreeLogger.WARN,
              "Use of deprecated hosted mode servlet path mapping", null);
          branch.log(
              TreeLogger.WARN,
              "The client code is invoking the servlet with a URL that is not module-relative: "
                  + path, null);
          branch.log(
              TreeLogger.WARN,
              "Prepend GWT.getModuleBaseURL() to the URL in client code to create a module-relative URL: /"
                  + moduleDef.getName() + path, null);
          branch.log(
              TreeLogger.WARN,
              "Using module-relative URLs ensures correct URL-independent behavior in external servlet containers",
              null);
        }
View Full Code Here


    URL foundResource;
    try {
      // Look for the requested file on the public path.
      //
      ModuleDef moduleDef = getModuleDef(logger, moduleName);
      foundResource = moduleDef.findPublicFile(partialPath);

      if (foundResource == null) {
        // Look in the place where we write compiled output.
        File moduleDir = new File(getOutputDir(), moduleName);
        File requestedFile = new File(moduleDir, partialPath);
View Full Code Here

    String msg = asScript ? "Generating a script selection script for module "
        : "Generating an html selection script for module ";
    msg += moduleName;
    logger.log(TreeLogger.TRACE, msg, null);

    ModuleDef moduleDef = getModuleDef(logger, moduleName);
    SelectionScriptGenerator gen = new SelectionScriptGenerator(moduleDef);
    return gen.generateSelectionScript(false, asScript);
  }
View Full Code Here

   * We don't actually log this on purpose since the client does anyway.
   */
  private ModuleDef getModuleDef(TreeLogger logger, String moduleName)
      throws UnableToCompleteException {
    synchronized (loadedModulesByName) {
      ModuleDef moduleDef = (ModuleDef) loadedModulesByName.get(moduleName);
      if (moduleDef == null) {
        moduleDef = ModuleDefLoader.loadFromClassPath(logger, moduleName);
        loadedModulesByName.put(moduleName, moduleDef);

        // BEGIN BACKWARD COMPATIBILITY
        // The following map of servlet path to module is included only
        // for backward-compatibility. We are going to remove this functionality
        // when we go out of beta. The new behavior is that the client should
        // specify the module name as part of the URL and construct it using
        // getModuleBaseURL().
        String[] servletPaths = moduleDef.getServletPaths();
        for (int i = 0; i < servletPaths.length; i++) {
          ModuleDef oldDef = (ModuleDef) modulesByServletPath.put(
              servletPaths[i], moduleDef);
          if (oldDef != null) {
            logger.log(TreeLogger.WARN, "Undefined behavior: Servlet path "
                + servletPaths[i] + " conflicts in modules "
                + moduleDef.getName() + " and " + oldDef.getName(), null);
          }
        }
        // END BACKWARD COMPATIBILITY
      }
      return moduleDef;
View Full Code Here

  private boolean run(AbstractTreeLogger logger) {
    try {
      logger.setMaxDetail(logLevel);

      ModuleDef moduleDef = ModuleDefLoader.loadFromClassPath(logger,
          moduleName);
      distill(logger, moduleDef);
      return true;
    } catch (UnableToCompleteException e) {
      // We intentionally don't pass in the exception here since the real
View Full Code Here

      if (context instanceof StandardGeneratorContext) {
        StandardGeneratorContext stdContext = (StandardGeneratorContext) context;
        Field field = StandardGeneratorContext.class.getDeclaredField("module");
        field.setAccessible(true);

        ModuleDef moduleDef = (ModuleDef) field.get(stdContext);

        String moduleName = moduleDef.getName();

        for (int i = 0; i < moduleName.length(); i++) {
          if (moduleName.charAt(i) == '.' && i < moduleName.length()
                  && Character.isUpperCase(moduleName.charAt(i + 1))) {
            this.modulePackage = moduleName.substring(0, i);
View Full Code Here

    String partialPath = parts.partialPath;
    String moduleName = parts.moduleName;

    // If the module is renamed, substitute the renamed module name
    ModuleDef moduleDef = loadedModulesByName.get(moduleName);
    if (moduleDef != null) {
      moduleName = moduleDef.getName();
    }

    if (partialPath == null) {
      // Redir back to the same URL but ending with a slash.
      //
View Full Code Here

      logger = logger.branch(TreeLogger.TRACE, "Request " + id + ": " + url,
          null);
    }

    String servletClassName = null;
    ModuleDef moduleDef = null;

    try {
      // Attempt to split the URL into module/path, which we'll use to see
      // if we can map the request to a module's servlet.
      RequestParts parts = new RequestParts(request);

      if ("favicon.ico".equalsIgnoreCase(parts.moduleName)) {
        sendErrorResponse(response, HttpServletResponse.SC_NOT_FOUND,
            "Icon not available");
        return;
      }

      // See if the request references a module we know.
      moduleDef = getModuleDef(logger, parts.moduleName);
      if (moduleDef != null) {
        // Okay, we know this module. Do we know this servlet path?
        // It is right to prepend the slash because (1) ModuleDefSchema requires
        // every servlet path to begin with a slash and (2) RequestParts always
        // rips off the leading slash.
        String servletPath = "/" + parts.partialPath;
        servletClassName = moduleDef.findServletForPath(servletPath);

        // Fall-through below, where we check servletClassName.
      } else {
        // Fall-through below, where we check servletClassName.
      }
    } catch (UnableToCompleteException e) {
      // Do nothing, since it was speculative anyway.
    }

    // BEGIN BACKWARD COMPATIBILITY
    if (servletClassName == null) {
      // Try to map a bare path that isn't preceded by the module name.
      // This is no longer the recommended practice, so we warn.
      String path = request.getPathInfo();
      moduleDef = modulesByServletPath.get(path);
      if (moduleDef != null) {
        // See if there is a servlet we can delegate to for the given url.
        servletClassName = moduleDef.findServletForPath(path);

        if (servletClassName != null) {
          TreeLogger branch = logger.branch(TreeLogger.WARN,
              "Use of deprecated hosted mode servlet path mapping", null);
          branch.log(
              TreeLogger.WARN,
              "The client code is invoking the servlet with a URL that is not module-relative: "
                  + path, null);
          branch.log(
              TreeLogger.WARN,
              "Prepend GWT.getModuleBaseURL() to the URL in client code to create a module-relative URL: /"
                  + moduleDef.getName() + path, null);
          branch.log(
              TreeLogger.WARN,
              "Using module-relative URLs ensures correct URL-independent behavior in external servlet containers",
              null);
        }
View Full Code Here

    URL foundResource = null;
    try {
      // Look for the requested file on the public path.
      //
      ModuleDef moduleDef = getModuleDef(logger, moduleName);
      if (shouldAutoGenerateResources()) {
        Resource publicResource = moduleDef.findPublicFile(partialPath);
        if (publicResource != null) {
          foundResource = publicResource.getURL();
        }

        if (foundResource == null) {
View Full Code Here

      throws UnableToCompleteException {
    if (logger.isLoggable(TreeLogger.TRACE)) {
      logger.log(TreeLogger.TRACE,
          "Generating a script selection script for module " + moduleName);
    }
    ModuleDef module = getModuleDef(logger, moduleName);
    StandardLinkerContext context = new StandardLinkerContext(logger, module,
        new JJSOptionsImpl());
    ArtifactSet artifacts = context.getArtifactsForPublicResources(logger,
        module);
    HostedModeLinker linker = new HostedModeLinker();
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.cfg.ModuleDef

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.