Commits

Jan Lahoda committed 8c95a65

Ability to specify VM arguments for the web frontend.

Comments (0)

Files changed (3)

remoting/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/IndexingBuilder.java

     public static final class DescriptorImpl extends Descriptor<Builder> {
 
         private File cacheDir;
+        private String webVMOptions;
 
         public DescriptorImpl() {
             cacheDir = new File(Hudson.getInstance().getRootDir(), "index").getAbsoluteFile();
+            webVMOptions = "";
             load();
         }
 
             return cacheDir;
         }
 
+        public String getWebVMOptions() {
+            return webVMOptions;
+        }
+
         @Override
         public Builder newInstance(StaplerRequest req, JSONObject formData) throws FormException {
             return new IndexingBuilder(req, formData);
         public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
             cacheDir = new File(json.getString("cacheDir"));
 
+            String newWebVMOptions = json.getString("webVMOptions");
+
+            if (newWebVMOptions == null) newWebVMOptions = "";
+
+            boolean restartWebFrontEnd = !webVMOptions.equals(newWebVMOptions);
+
+            webVMOptions = newWebVMOptions;
+            
             save();
             
-            return super.configure(req, json);
+            boolean result = super.configure(req, json);
+
+            if (restartWebFrontEnd)
+                WebFrontEnd.restart();
+            
+            return result;
         }
 
         @Override

remoting/server/hudson/src/main/java/org/netbeans/modules/jackpot30/hudson/WebFrontEnd.java

 import java.util.Collections;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import org.netbeans.modules.jackpot30.hudson.IndexingBuilder.DescriptorImpl;
 
 /**
  *
         }
     }
 
+    public static void restart() {
+        stop();
+        ensureStarted();
+    }
+
     @Extension
     public static final class RestartIndexingFrontend extends CLICommand {
 
             args.add(cacheDir);
 
             doStart(launcher.launch().cmds(args)
+                                     .envs(Collections.singletonMap("JACKPOT_WEB_OPTS", ((DescriptorImpl) DescriptorImpl.find(DescriptorImpl.class.getName())).getWebVMOptions()))
                                      .stdout(listener),
                     requestId);
         } catch (IOException ex) {

remoting/server/hudson/src/main/resources/org/netbeans/modules/jackpot30/hudson/IndexingBuilder/global.jelly

         <f:entry title="Cache directory:" field="cacheDir">
             <f:textbox />
         </f:entry>
+        <f:advanced>
+            <f:entry title="Web frontend VM Options" field="webVMOptions">
+                <f:textbox />
+            </f:entry>
+        </f:advanced>
     </f:section>
     
 </j:jelly>