Browse Source

fix #1257 add jvmOptions

Shinsuke Sugaya 8 years ago
parent
commit
baadf5695e
1 changed files with 18 additions and 0 deletions
  1. 18 0
      src/main/java/org/codelibs/fess/job/SuggestJob.java

+ 18 - 0
src/main/java/org/codelibs/fess/job/SuggestJob.java

@@ -15,6 +15,7 @@
  */
 package org.codelibs.fess.job;
 
+import static org.codelibs.core.stream.StreamUtil.split;
 import static org.codelibs.core.stream.StreamUtil.stream;
 
 import java.io.File;
@@ -43,6 +44,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class SuggestJob {
+    private static final String REMOTE_DEBUG_OPTIONS = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=localhost:8000";
+
     private static final Logger logger = LoggerFactory.getLogger(SuggestJob.class);
 
     protected JobExecutor jobExecutor;
@@ -55,6 +58,8 @@ public class SuggestJob {
 
     protected String logLevel;
 
+    protected String jvmOptions;
+
     public SuggestJob jobExecutor(final JobExecutor jobExecutor) {
         this.jobExecutor = jobExecutor;
         return this;
@@ -80,6 +85,15 @@ public class SuggestJob {
         return this;
     }
 
+    public SuggestJob remoteDebug() {
+        return jvmOptions(REMOTE_DEBUG_OPTIONS);
+    }
+
+    public SuggestJob jvmOptions(final String option) {
+        this.jvmOptions = option;
+        return this;
+    }
+
     public String execute(final JobExecutor jobExecutor) {
         jobExecutor(jobExecutor);
         return execute();
@@ -204,6 +218,10 @@ public class SuggestJob {
             }
         }
 
+        if (StringUtil.isNotBlank(jvmOptions)) {
+            split(jvmOptions, " ").of(stream -> stream.filter(StringUtil::isNotBlank).forEach(s -> cmdList.add(s)));
+        }
+
         cmdList.add(SuggestCreator.class.getCanonicalName());
 
         cmdList.add("--sessionId");