Package com.google.gwt.dev.cfg

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


   * 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 = loadedModulesByName.get(moduleName);
      if (moduleDef == null) {
        moduleDef = ModuleDefLoader.loadFromClassPath(logger, moduleName, false);
        loadedModulesByName.put(moduleName, moduleDef);
        loadedModulesByName.put(moduleDef.getName(), 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++) {
          modulesByServletPath.put(servletPaths[i], moduleDef);
        }
        // END BACKWARD COMPATIBILITY
      }
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

    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);
      Resource publicResource = moduleDef.findPublicFile(partialPath);
      if (publicResource != null) {
        foundResource = publicResource.getURL();
      }

      if (foundResource == null) {
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 = loadedModulesByName.get(moduleName);
      if (moduleDef == null) {
        moduleDef = ModuleDefLoader.loadFromClassPath(logger, moduleName, false);
        loadedModulesByName.put(moduleName, moduleDef);
        loadedModulesByName.put(moduleDef.getName(), 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++) {
          modulesByServletPath.put(servletPaths[i], moduleDef);
        }
        // END BACKWARD COMPATIBILITY
      }
View Full Code Here

   * @return
   * @throws MalformedURLException
   * @see javax.servlet.ServletContext#getResource(java.lang.String)
   */
  public URL getResource(String path) throws MalformedURLException {
    ModuleDef moduleDef = moduleDefRef.get();
    assert (moduleDef != null) : "GWTShellServlet should have guaranteed that a"
        + " live servlet will never process a request for a dead module; if you"
        + " are using this servlet outside the context of processing a call,"
        + " then don't do that";

    String moduleContext = "/" + moduleDef.getName() + "/";
    if (!path.startsWith(moduleContext)) {
      // Check for a renamed module
      moduleContext = "/" + moduleDef.getCanonicalName() + "/";
      if (!path.startsWith(moduleContext)) {
        // This path is in a different context; just return null
        return null;
      }
    }

    String partialPath = path.substring(moduleContext.length());

    // Try to get the resource from the application's public path
    Resource publicResource = moduleDef.findPublicFile(partialPath);
    if (publicResource != null) {
      return publicResource.getURL();
    }

    // Otherwise try the path but rooted in the shell's output directory
    File shellDir = new File(outDir, GWTShell.GWT_SHELL_PATH + File.separator
        + moduleDef.getName());
    File requestedFile = new File(shellDir, partialPath);
    if (requestedFile.exists()) {
      return requestedFile.toURI().toURL();
    }

    /*
     * If the user is coming from compiled web-mode, check the linker output
     * directory for the file. We'll default to using the output directory of
     * the first linker defined in the <set-linker> tab.
     */
    requestedFile = new File(new File(outDir, moduleDef.getName()), partialPath);
    if (requestedFile.exists()) {
      try {
        return requestedFile.toURI().toURL();
      } catch (MalformedURLException e) {
        // ignore since it was speculative anyway
View Full Code Here

    }

    public void compile(String[] moduleNames) throws UnableToCompleteException {
      for (int i = 0; i < moduleNames.length; i++) {
        String moduleName = moduleNames[i];
        ModuleDef moduleDef = loadModule(moduleName, getLogger());
        compile(moduleDef);
      }
    }
View Full Code Here

        Cursor waitCursor = display.getSystemCursor(SWT.CURSOR_WAIT);
        widgetShell.setCursor(waitCursor);

        // Try to find an existing loaded version of the module def.
        //
        ModuleDef moduleDef = loadModule(moduleName, logger);
        assert (moduleDef != null);

        // Create a sandbox for the module.
        //
        File shellDir = new File(outDir, GWT_SHELL_PATH + File.separator
            + moduleName);

        TypeOracle typeOracle = moduleDef.getTypeOracle(logger);
        ShellModuleSpaceHost host = doCreateShellModuleSpaceHost(logger,
            typeOracle, moduleDef, genDir, shellDir);
        return host;
      } finally {
        Cursor normalCursor = display.getSystemCursor(SWT.CURSOR_ARROW);
View Full Code Here

     * @throws UnableToCompleteException
     */
    private ModuleDef loadModule(String moduleName, TreeLogger logger)
        throws UnableToCompleteException {
      boolean assumeFresh = !alreadySeenModules.contains(moduleName);
      ModuleDef moduleDef = ModuleDefLoader.loadFromClassPath(logger,
          moduleName, !assumeFresh);
      alreadySeenModules.add(moduleName);
      assert (moduleDef != null) : "Required module state is absent";
      return moduleDef;
    }
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.