AEMManager.AemActions.BuildCommandLineArguments C# (CSharp) Method

BuildCommandLineArguments() private static method

private static BuildCommandLineArguments ( AemInstance pInstance ) : string
pInstance AemInstance
return string
        private static string BuildCommandLineArguments(AemInstance pInstance)
        {
            List<string> javaArgs = new List<string>();
              List<string> jarArgs = new List<string>();

              // memory settings
              javaArgs.Add("-Xms" + pInstance.HeapMinSizeMb + "m");
              javaArgs.Add("-Xmx" + pInstance.HeapMaxSizeMb + "m");
              javaArgs.Add("-XX:MaxPermSize=" + pInstance.MaxPermSizeMb + "m");

              // instance port
              if (pInstance.AemInstanceType == AemInstanceType.AEM54) {
            javaArgs.Add("-D-crx.quickstart.server.port=" + pInstance.Port);
              }
              else {
            jarArgs.Add("-p " + pInstance.Port);
              }

              // run modes
              string runModes = pInstance.Runmode.ToString().ToLower()
            + "," + (pInstance.RunmodeSampleContent ? "samplecontent" : "nosamplecontent")
            + (!string.IsNullOrEmpty(pInstance.AdditionalRunmodes) ? "," + pInstance.AdditionalRunmodes : "");
              if (pInstance.AemInstanceType == AemInstanceType.AEM54) {
            javaArgs.Add("-Dsling.run.modes=" + runModes);
              }
              else {
            jarArgs.Add("-r " + runModes);
              }

              // context path
              if (!string.IsNullOrEmpty(pInstance.ContextPath) && pInstance.ContextPath!="/") {
            jarArgs.Add("-contextpath " + pInstance.ContextPath);
              }

              // debug mode
              if (pInstance.JVMDebug && (pInstance.DebugPort > 0)) {
            javaArgs.Add("-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + pInstance.DebugPort);
              }

              // JProfile mode
              if (pInstance.JProfiler && (pInstance.JProfilerPort > 0)) {
            javaArgs.Add("-agentlib:jprofilerti=port=" + pInstance.JProfilerPort + " -Xbootclasspath/a:" + AEMManager.Properties.Settings.Default.JProfilerAgent.Replace("\\", "/"));
              }

              // JConsole mode
              if (pInstance.JConsole && (pInstance.JConsolePort > 0)) {
            javaArgs.Add("-Dcom.sun.management.jmxremote.port=" + pInstance.JConsolePort + " -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false");
              }

              // Hide AEM configuration wizards
              if (pInstance.HideConfigWizard) {
            javaArgs.Add("-DhideConfigWizard=true");
              }

              // custom JVM args
              if (pInstance.CustomJVMParam1Active) {
            javaArgs.Add(pInstance.CustomJVMParam1);
              }
              if (pInstance.CustomJVMParam2Active) {
            javaArgs.Add(pInstance.CustomJVMParam2);
              }
              if (pInstance.CustomJVMParam3Active) {
            javaArgs.Add(pInstance.CustomJVMParam3);
              }

              // configure AEM start mode
              if (pInstance.ShowInstanceWindow) {
            jarArgs.Add("-v");
              }
              if (!pInstance.OpenBrowser) {
            jarArgs.Add("-nobrowser");
              }

              // suppress forking for AEM55 and above, because otherwise debugging will not work
              if (pInstance.AemInstanceType != AemInstanceType.AEM54) {
            jarArgs.Add("-nofork");
              }

              // add jar command line args
              javaArgs.Add("-jar " + pInstance.PathFilename + " " + String.Join(" ", jarArgs.ToArray()));

              // build complete string
              return String.Join(" ", javaArgs.ToArray());
        }