Skip to content

Instantly share code, notes, and snippets.

@confile
Last active February 5, 2016 10:01
Show Gist options
  • Select an option

  • Save confile/44d17779b890e2ca7e89 to your computer and use it in GitHub Desktop.

Select an option

Save confile/44d17779b890e2ca7e89 to your computer and use it in GitHub Desktop.

Revisions

  1. confile revised this gist Feb 5, 2016. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,6 @@ import com.google.gwt.user.client.rpc.SerializationException;
    /**
    * See: https://code.google.com/archive/p/google-web-toolkit/issues/7693 See:
    * https://github.com/gwtproject/gwt/issues/7690
    *
    * @author Dr. Michael Gorski
    *
    */
    public class GwtSuperDevModeLoggingServlet extends RemoteLoggingServiceImpl {
  2. confile created this gist Feb 5, 2016.
    141 changes: 141 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,141 @@
    package remoteLogging;

    import java.io.File;
    import java.util.logging.Logger;

    import javax.servlet.ServletException;

    import com.google.gwt.logging.server.RemoteLoggingServiceImpl;
    import com.google.gwt.user.client.rpc.SerializationException;

    /**
    * See: https://code.google.com/archive/p/google-web-toolkit/issues/7693 See:
    * https://github.com/gwtproject/gwt/issues/7690
    *
    * @author Dr. Michael Gorski
    *
    */
    public class GwtSuperDevModeLoggingServlet extends RemoteLoggingServiceImpl {
    // Change constants below, based on your GWT SuperDevMode build messages, like below:
    // Compiling module com.ajaxdatabase.ajaxwind.Main
    // Compiling 1 permutation
    // Compiling permutation 0...
    // Source Maps Enabled
    // Compile of permutations succeeded
    // Linking into
    // C:\Users\Administrator\AppData\Local\Temp\gwt-codeserver-9190081658547331755.tmp\com.ajaxdatabase.ajaxwind.Main\compile-2\war\com.ajaxdatabase.ajaxwind.Main;
    // Writing extras to
    // C:\Users\ADMINI~1\AppData\Local\Temp\gwt-codeserver-9190081658547331755.tmp\com.ajaxdatabase.ajaxwind.Main\compile-2\extras\com.ajaxdatabase.ajaxwind.Main
    // Link succeeded
    // Compilation succeeded -- 12.644s
    // Compile completed in 12845 ms
    // private final String TEMP_DIR = "C:\\Users\\Administrator\\AppData\\Local\\Temp\\";
    // private final String MODULE_NAME = "com.ajaxdatabase.ajaxwind.Main";

    private final String TEMP_DIR = "/Users/mg/Documents/Grails/GWT/test-gwt/build/putnami/work/";
    private final String MODULE_NAME = "test.dashboard.Dashboard";

    private String path = null;
    private final String symbolMapsPath = "/extras/test_dashboard/symbolMaps/";
    private final String productionFolder = "/WEB-INF/dashboard/symbolMaps";

    private static Logger logger = Logger.getLogger(GwtSuperDevModeLoggingServlet.class.getName());

    @Override
    public void init() throws ServletException {
    super.init();
    logger.info("GwtSuperDevModeLoggingServlet - init()");
    }

    @Override
    public String processCall(String payload) throws SerializationException {
    reconfigureMapsDir();
    logger.info("GwtSuperDevModeLoggingServlet - processCall(): path: " + path);
    logger.info("GwtSuperDevModeLoggingServlet - processCall(): payload: " + payload);
    return super.processCall(payload);
    }

    private void reconfigureMapsDir() {
    File last = null;
    File lastcompile = null;

    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir(): " + new File(TEMP_DIR));

    // find the MODULE_NAME directory
    for (File f : new File(TEMP_DIR).listFiles()) {
    if (f.getName().startsWith(MODULE_NAME) && (last == null || f.lastModified() > last.lastModified())) {
    last = f;
    break;
    }
    }

    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir() last: " + last);

    // if (last != null) {
    // for (File f : new File(last.getPath(), MODULE_NAME).listFiles()) {
    // logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir() f2: " + f);
    // if (f.getName().startsWith("compile-")
    // && (lastcompile == null || f.lastModified() > lastcompile.lastModified())) {
    // lastcompile = f;
    // }
    // }
    // }

    if (last != null) {
    // for SuperDevMode

    // find the last compile version
    for (File f : new File(last.getPath()).listFiles()) {
    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir() f2: " + f);
    if (f.getName().startsWith("compile-") && (lastcompile == null || f.lastModified() > lastcompile.lastModified())) {
    lastcompile = f;
    }
    }

    // find the last SuperDevMode compile folder which has SymbolMaps
    String lastCompileVersionString = lastcompile.getName().replaceFirst("compile-", "");
    int lastCompileVersion = 0;
    lastCompileVersion = Integer.parseInt(lastCompileVersionString);

    logger.info("GwtSuperDevModeLoggingServlet - lastCompileVersion: "+lastCompileVersion);
    String lastPath = lastcompile.getPath().replaceFirst("compile-.*", "compile-");
    for(int i=lastCompileVersion; i >= 0; i--) {
    File f = new File(lastPath + i + symbolMapsPath);
    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir() find last:: "+f);

    if (f.exists()) {
    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir() find last SymbolMaps: "+f);
    lastcompile = f;
    break;
    }
    }
    }
    else {
    // use a default directory on the server for production
    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir(): use SymbolMaps in "+productionFolder);
    setSymbolMapsDirectory(getServletContext().getRealPath(productionFolder));
    }

    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir() lastcompile: " + lastcompile);

    logger.info("done! \n\n");


    if (lastcompile != null) {
    String dirpath = lastcompile.getPath();

    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir() dirpath: " + dirpath);
    if (!dirpath.equals(path)) {
    path = dirpath;

    logger.info("GwtSuperDevModeLoggingServlet - reconfigureMapsDir() setSymbolMapsDirectory: " + path);
    setSymbolMapsDirectory(path);
    }
    else {
    logger.info("GwtSuperDevModeLoggingServlet - did not change SymbolMaps path nothing changed!");
    }
    }

    }

    }