コード例 #1
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        public static void StopInstance(AemInstance pInstance)
        {
            string shutdownUrl = pInstance.UrlWithContextPath + "/system/console/vmstat?shutdown_type=Stop";

            if (pInstance.AemInstanceType == AemInstanceType.AEM54)
            {
                shutdownUrl = pInstance.UrlWithoutContextPath + "/admin/shutdown";
            }

            try {
                mLog.Debug("Execute shutdown URL: " + shutdownUrl);

                pInstance.ConsoleOutputWindow.AppendConsoleLog("Shutting down instance...");

                HttpWebRequest request = pInstance.WebRequestCreate(shutdownUrl);
                request.Method = "POST";

                request.GetResponse();
            }
            catch (WebException ex) {
                mLog.Debug("Unable to connect to " + shutdownUrl + ": " + ex.Message);
            }
            catch (Exception ex) {
                mLog.Error("Error executing shutdown URL: " + shutdownUrl, ex);
            }
        }
コード例 #2
0
        public static void AddControlMenuItems(Menu.MenuItemCollection pParent, AemInstance pInstance)
        {
            List<MenuItem> menuItems = new List<MenuItem>();
              MenuItem item;

              item = new MenuItem();
              item.Text = "Start instance";
              item.Click += new EventHandler(ControlStartInstance);
              menuItems.Add(item);

              item = new MenuItem();
              item.Text = "Stop instance";
              item.Click += new EventHandler(ControlStopInstance);
              menuItems.Add(item);

              item = new MenuItem();
              item.Text = "Kill instance";
              item.Click += new EventHandler(ControlKillInstance);
              menuItems.Add(item);

              foreach (MenuItem i in menuItems) {
            i.Tag = pInstance;
              }

              pParent.AddRange(menuItems.ToArray());
        }
コード例 #3
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void KillProcessAndChildrens(int pid, AemInstance instance)
        {
            ManagementObjectSearcher processSearcher = new ManagementObjectSearcher
                                                           ("Select * From Win32_Process Where ParentProcessID=" + pid);
            ManagementObjectCollection processCollection = processSearcher.Get();

            try {
                Process proc = Process.GetProcessById(pid);
                if (proc != null && !proc.HasExited)
                {
                    mLog.Debug("Killing process #" + pid + " for instance " + instance.Name);
                    proc.Kill();
                }
            }
            catch (ArgumentException) {
                // Process already exited.
            }

            if (processCollection != null)
            {
                foreach (ManagementObject mo in processCollection)
                {
                    // kill child processes(also kills childrens of childrens etc.)
                    KillProcessAndChildrens(Convert.ToInt32(mo["ProcessID"]), instance);
                }
            }
        }
コード例 #4
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        public static void AddControlMenuItems(Menu.MenuItemCollection pParent, AemInstance pInstance)
        {
            List <MenuItem> menuItems = new List <MenuItem>();
            MenuItem        item;

            item        = new MenuItem();
            item.Text   = "Start instance";
            item.Click += new EventHandler(ControlStartInstance);
            menuItems.Add(item);

            item        = new MenuItem();
            item.Text   = "Stop instance";
            item.Click += new EventHandler(ControlStopInstance);
            menuItems.Add(item);

            item        = new MenuItem();
            item.Text   = "Kill instance";
            item.Click += new EventHandler(ControlKillInstance);
            menuItems.Add(item);

            foreach (MenuItem i in menuItems)
            {
                i.Tag = pInstance;
            }

            pParent.AddRange(menuItems.ToArray());
        }
コード例 #5
0
ファイル: AemManager.cs プロジェクト: kvemulap01/aem-manager
        private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AemInstance instance = this.SelectedInstanceInListview;

            if (instance == null)
            {
                return;
            }
            instance      = instance.Clone();
            instance.Name = "Copy of " + instance.Name;
            AemInstanceDialog dialog = new AemInstanceDialog(instance);

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                instance.Save();
                Program.InstanceList.Add(instance);
                Program.InstanceList.SortByName();
                Program.UpdateInstanceListInViews();
            }
            else
            {
                // remove instance icon because instance not saved
                instance.NotifyIcon.Visible = false;
                instance.NotifyIcon.Dispose();
                instance.NotifyIcon = null;
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: kvemulap01/aem-manager
        static void ShowInTaskbarMenuItem_Click(object sender, EventArgs e)
        {
            MenuItem    menuItem         = (MenuItem)sender;
            AemInstance selectedInstance = (AemInstance)menuItem.Tag;

            selectedInstance.ShowInTaskbar = !selectedInstance.ShowInTaskbar;
            selectedInstance.Save();
            Program.UpdateInstanceListInViews();
        }
コード例 #7
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void OpenFelixConsole(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }
            OpenUrl(instance.UrlWithContextPath + "/system/console", instance);
        }
コード例 #8
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void OpenServletEngineAdmin(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }
            OpenUrl(instance.UrlWithoutContextPath + "/admin", instance);
        }
コード例 #9
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void ShowConsoleWindow(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }
            instance.ConsoleOutputWindow.Show();
        }
コード例 #10
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        public static void OpenAuthorPublish(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }
            OpenUrl(instance.UrlWithContextPath, instance);
        }
コード例 #11
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void ControlStopInstance(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }
            StopInstance(instance);
        }
コード例 #12
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void OpenLogFile(object sender, EventArgs e)
        {
            MenuItem    item     = (MenuItem)sender;
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }
            OpenLogViewer(instance.PathWithoutFilename + @"\crx-quickstart\logs\" + item.Text, instance.Name + " - " + item.Text);
        }
コード例 #13
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void ControlStartInstance(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }

            if (instance.CurrentBundleStatus == BundleStatus.UNKNOWN ||
                instance.CurrentBundleStatus == BundleStatus.STARTING_STOPPING ||
                instance.CurrentBundleStatus == BundleStatus.RUNNING)
            {
                if (MessageBox.Show("The instance seems to be running already.\n"
                                    + "Press OK to continue starting the instance, it may fail.",
                                    "Start Instance", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.Cancel)
                {
                    return;
                }
            }

            string executable           = "cmd";
            string aemInstanceArguments = BuildCommandLineArguments(instance);
            string arguments            = "/c \"" + instance.JavaExecutable + "\" " + aemInstanceArguments;

            // add jprofiler path to current applications path to make sure spawned process gets it as well
            if (instance.JProfiler && (instance.JProfilerPort > 0))
            {
                string path = System.Environment.GetEnvironmentVariable("Path");
                if (!path.Contains(AEMManager.Properties.Settings.Default.JProfilerPath))
                {
                    path += ";" + AEMManager.Properties.Settings.Default.JProfilerPath;
                    System.Environment.SetEnvironmentVariable("Path", path);
                }
            }

            bool isConsoleOutputWindow = instance.ConsoleOutputWindow.Visible;

            if (!isConsoleOutputWindow)
            {
                // show and hide console window again when it is not shown already - to prevent deadlock that occured sometimes stopping instances (DINT-349)
                instance.ConsoleOutputWindow.Show();
            }
            instance.ConsoleOutputWindow.InitStartProcess(instance.PathWithoutFilename, instance.JavaExecutable, aemInstanceArguments);

            instance.JavaProcess        = ExecuteCommand(instance.PathWithoutFilename, executable, arguments, instance.Name, instance.ShowInstanceWindow, "aem.ico", false, instance);
            instance.JavaProcessVisible = instance.ShowInstanceWindow;

            if (!isConsoleOutputWindow)
            {
                instance.ConsoleOutputWindow.Hide();
            }
        }
コード例 #14
0
ファイル: AemManager.cs プロジェクト: kvemulap01/aem-manager
 private void timerStatusRefresh_Tick(object sender, EventArgs e)
 {
     if (!this.Visible)
     {
         return;
     }
     foreach (DataGridViewRow gridRow in dgInstances.Rows)
     {
         DataRow     row      = (DataRow)((DataRowView)gridRow.DataBoundItem).Row;
         AemInstance instance = (AemInstance)row["Instance"];
         row["Status"] = instance.GetStatusText();
     }
 }
コード例 #15
0
ファイル: AemManager.cs プロジェクト: kvemulap01/aem-manager
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialogJar.ShowDialog(this) == DialogResult.OK)
            {
                AemInstance instance = new AemInstance();

                // auto-detect some instance properties
                instance.Path = openFileDialogJar.FileName;
                string[] pathParts = instance.Path.Split('/', '\\');

                string jarFilename = pathParts[pathParts.Length - 1];
                if (jarFilename.Contains("-publish") || instance.Path.Contains("/publish/"))
                {
                    instance.Runmode = Runmode.PUBLISH;
                }
                else
                {
                    instance.Runmode = Runmode.AUTHOR;
                }

                string[] fileParts = jarFilename.Split('-', '.');
                foreach (string filePart in fileParts)
                {
                    int port = 0;
                    if (int.TryParse(filePart, out port))
                    {
                        instance.Port = port;
                    }
                }

                if (pathParts.Length > 4)
                {
                    string name = pathParts[pathParts.Length - 2];
                    if ("author".Equals(name) || "publish".Equals(name))
                    {
                        name = pathParts[pathParts.Length - 3];
                    }
                    instance.Name = name;
                }


                AemInstanceDialog dialog = new AemInstanceDialog(instance);
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    instance.Save();
                    Program.InstanceList.Add(instance);
                    Program.InstanceList.SortByName();
                    Program.UpdateInstanceListInViews();
                }
            }
        }
コード例 #16
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        public static void AddOpenMenuItems(Menu.MenuItemCollection pParent, AemInstance pInstance, bool pSetDefaultItem)
        {
            List <MenuItem> menuItems = new List <MenuItem>();
            MenuItem        item;

            item        = new MenuItem();
            item.Text   = "Open Author/Publish";
            item.Click += new EventHandler(OpenAuthorPublish);
            if (pSetDefaultItem)
            {
                item.DefaultItem = true;
            }
            menuItems.Add(item);

            item        = new MenuItem();
            item.Text   = "Open CRX";
            item.Click += new EventHandler(OpenCRX);
            menuItems.Add(item);

            item        = new MenuItem();
            item.Text   = "Open CRXDE Lite";
            item.Click += new EventHandler(OpenCRXDELite);
            menuItems.Add(item);

            item        = new MenuItem();
            item.Text   = "Open Felix Console";
            item.Click += new EventHandler(OpenFelixConsole);
            menuItems.Add(item);

            item        = new MenuItem();
            item.Text   = "Open Folder";
            item.Click += new EventHandler(OpenFolder);
            menuItems.Add(item);

            if (pInstance.AemInstanceType == AemInstanceType.AEM54)
            {
                item        = new MenuItem();
                item.Text   = "Open Servlet Engine Admin";
                item.Click += new EventHandler(OpenServletEngineAdmin);
                menuItems.Add(item);
            }

            foreach (MenuItem i in menuItems)
            {
                i.Tag = pInstance;
            }

            pParent.AddRange(menuItems.ToArray());
        }
コード例 #17
0
ファイル: AemManager.cs プロジェクト: kvemulap01/aem-manager
        private void setShowInTaskbarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AemInstance instance = this.SelectedInstanceInListview;

            if (instance == null)
            {
                return;
            }
            MenuItem menuItem = (MenuItem)sender;

            instance.ShowInTaskbar = !instance.ShowInTaskbar;
            menuItem.Checked       = instance.ShowInTaskbar;
            instance.Save();
            Program.UpdateInstanceListInViews();
        }
コード例 #18
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void OpenUrl(string pUrl, AemInstance pInstance)
        {
            mLog.Info("Open Url: " + pUrl);

            System.Diagnostics.Process p = new System.Diagnostics.Process();
            if (string.IsNullOrEmpty(pInstance.BrowserExecutable))
            {
                p.StartInfo.FileName = pUrl;
            }
            else
            {
                p.StartInfo.FileName  = pInstance.BrowserExecutable;
                p.StartInfo.Arguments = pUrl;
            }
            p.Start();
        }
コード例 #19
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void OpenCRX(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }
            string url = instance.UrlWithContextPath + "/crx/explorer/";

            if (instance.AemInstanceType == AemInstanceType.AEM54)
            {
                url = instance.UrlWithoutContextPath + "/crx/";
            }
            OpenUrl(url, instance);
        }
コード例 #20
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void ControlKillInstance(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }

            Process process = instance.GetInstanceJavaProcess();

            if (process != null)
            {
                KillProcessAndChildrens(process.Id, instance);
            }
        }
コード例 #21
0
ファイル: AemManager.cs プロジェクト: kvemulap01/aem-manager
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AemInstance instance = this.SelectedInstanceInListview;

            if (instance == null)
            {
                return;
            }
            AemInstanceDialog dialog = new AemInstanceDialog(instance);

            if (dialog.ShowDialog(this) == DialogResult.OK)
            {
                instance.Save();
                Program.InstanceList.SortByName();
                Program.UpdateInstanceListInViews();
            }
        }
コード例 #22
0
ファイル: Program.cs プロジェクト: kvemulap01/aem-manager
        /// <summary>
        /// Instance to execute actions upon
        /// </summary>
        public static AemInstance GetActionInstance(Object pSender)
        {
            AemInstance instance = null;

            if (pSender is AemInstance)
            {
                instance = (AemInstance)pSender;
            }
            else if (pSender is MenuItem)
            {
                instance = (AemInstance)((MenuItem)pSender).Tag;
            }
            if (instance == null && Program.AemManagerForm.Visible)
            {
                instance = Program.AemManagerForm.SelectedInstanceInListview;
            }
            return(instance);
        }
コード例 #23
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void OpenFolder(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }

            string folder = instance.PathWithoutFilename;

            if (!Directory.Exists(folder))
            {
                return;
            }
            mLog.Info("Open Folder: " + folder);
            System.Diagnostics.Process.Start(folder);
        }
コード例 #24
0
ファイル: AemManager.cs プロジェクト: kvemulap01/aem-manager
        private void removeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AemInstance instance = this.SelectedInstanceInListview;

            if (instance == null)
            {
                return;
            }
            if (MessageBox.Show(this, "Instance '" + instance.Name + "' will be removed.", "Remove intance", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.OK)
            {
                instance.NotifyIcon.Visible = false;
                instance.NotifyIcon.Dispose();
                instance.NotifyIcon = null;
                instance.Delete();
                Program.InstanceList.Remove(instance);
                Program.UpdateInstanceListInViews();
            }
        }
コード例 #25
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void LogFilesItem_Popup(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }

            MenuItem logFilesItem = (MenuItem)sender;

            logFilesItem.MenuItems.Clear();

            string logsPath = instance.PathWithoutFilename + @"\crx-quickstart\logs";

            if (Directory.Exists(logsPath))
            {
                string[] logFiles = Directory.GetFiles(logsPath);
                if (logFiles.Length > 0)
                {
                    foreach (string logFilePath in logFiles)
                    {
                        string logFile = logFilePath.Substring(logFilePath.LastIndexOf(@"\") + 1);
                        // skip logfiles with suffixes like ".2016-07-19", "", "-2016-07-12.log", "-4108.log"
                        if (Regex.Match(logFile, @"^.*\.\d+\-\d+\-\d+$").Success ||
                            Regex.Match(logFile, @"^.*\-\d+(\-\d+\-\d+)?\.log$").Success)
                        {
                            continue;
                        }

                        MenuItem item = new MenuItem();
                        item.Text   = logFile;
                        item.Click += new EventHandler(OpenLogFile);
                        item.Tag    = instance;
                        logFilesItem.MenuItems.Add(item);
                    }
                }
            }

            if (logFilesItem.MenuItems.Count == 0)
            {
                logFilesItem.MenuItems.Add(new MenuItem("-- No logfiles --"));
            }
        }
コード例 #26
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFileDialogJar.ShowDialog(this) == DialogResult.OK) {
            AemInstance instance = new AemInstance();

            // auto-detect some instance properties
            instance.Path = openFileDialogJar.FileName;
            string[] pathParts = instance.Path.Split('/', '\\');

            string jarFilename = pathParts[pathParts.Length-1];
            if (jarFilename.Contains("-publish") || instance.Path.Contains("/publish/")) {
              instance.Runmode = Runmode.PUBLISH;
            }
            else {
              instance.Runmode = Runmode.AUTHOR;
            }

            string[] fileParts = jarFilename.Split('-','.');
            foreach (string filePart in fileParts) {
              int port = 0;
              if (int.TryParse(filePart, out port)) {
            instance.Port = port;
              }
            }

            if (pathParts.Length > 4) {
              string name = pathParts[pathParts.Length - 2];
              if ("author".Equals(name) || "publish".Equals(name)) {
            name = pathParts[pathParts.Length - 3];
              }
              instance.Name = name;
            }

            AemInstanceDialog dialog = new AemInstanceDialog(instance);
            if (dialog.ShowDialog(this) == DialogResult.OK) {
              instance.Save();
              Program.InstanceList.Add(instance);
              Program.InstanceList.SortByName();
              Program.UpdateInstanceListInViews();
            }
              }
        }
コード例 #27
0
ファイル: AemInstance.cs プロジェクト: kvemulap01/aem-manager
        public AemInstance Clone()
        {
            AemInstance clone = new AemInstance();

            clone.mAemInstanceType       = mAemInstanceType;
            clone.mName                  = mName;
            clone.mHostname              = mHostname;
            clone.mPort                  = mPort;
            clone.mContextPath           = mContextPath;
            clone.mPath                  = mPath;
            clone.mJavaExecutable        = mJavaExecutable;
            clone.mUsername              = mUsername;
            clone.mPassword              = mPassword;
            clone.mRunmode               = mRunmode;
            clone.mAdditionalRunmodes    = mAdditionalRunmodes;
            clone.mRunmodeSampleContent  = mRunmodeSampleContent;
            clone.mIconSet               = mIconSet;
            clone.mCustomIconPath        = mCustomIconPath;
            clone.mShowInTaskbar         = mShowInTaskbar;
            clone.mHeapMinSizeMb         = mHeapMinSizeMb;
            clone.mHeapMaxSizeMb         = mHeapMaxSizeMb;
            clone.mMaxPermSizeMb         = mMaxPermSizeMb;
            clone.mJVMDebug              = mJVMDebug;
            clone.mDebugPort             = mDebugPort;
            clone.mJProfiler             = mJProfiler;
            clone.mJProfilerPort         = mJProfilerPort;
            clone.mJConsole              = mJConsole;
            clone.mJConsolePort          = mJConsolePort;
            clone.mHideConfigWizard      = mHideConfigWizard;
            clone.mShowInstanceWindow    = mShowInstanceWindow;
            clone.mOpenBrowser           = mOpenBrowser;
            clone.mRemoteProcess         = mRemoteProcess;
            clone.mCustomJVMParam1Active = mCustomJVMParam1Active;
            clone.mCustomJVMParam1       = mCustomJVMParam1;
            clone.mCustomJVMParam2Active = mCustomJVMParam2Active;
            clone.mCustomJVMParam2       = mCustomJVMParam2;
            clone.mCustomJVMParam3Active = mCustomJVMParam3Active;
            clone.mCustomJVMParam3       = mCustomJVMParam3;
            clone.mBrowserExecutable     = mBrowserExecutable;

            return(clone);
        }
コード例 #28
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        private static void OpenCRXDELite(object sender, EventArgs e)
        {
            AemInstance instance = Program.GetActionInstance(sender);

            if (instance == null)
            {
                return;
            }

            string url = instance.UrlWithContextPath + "/crx/de/";

            if (instance.AemInstanceType == AemInstanceType.AEM54)
            {
                url = instance.UrlWithoutContextPath + "/crx/de/";
            }
            else
            {
                // check if DavEx servlet is enabled before opening CRXDE lite
                SlingDavExServlet davEx = new SlingDavExServlet(instance);
                davEx.CheckDavExStatus();
            }
            OpenUrl(url, instance);
        }
コード例 #29
0
        public static void AddLogMenuItems(Menu.MenuItemCollection pParent, AemInstance pInstance)
        {
            List<MenuItem> menuItems = new List<MenuItem>();
              MenuItem item;

              // show dynamic list of current logfiles
              item = new MenuItem();
              item.Text = "Open logfile...";
              item.Popup += LogFilesItem_Popup;
              item.MenuItems.Add(new MenuItem("-- No logfiles --"));
              menuItems.Add(item);

              item = new MenuItem();
              item.Text = "Console window";
              item.Click += new EventHandler(ShowConsoleWindow);
              menuItems.Add(item);

              foreach (MenuItem i in menuItems) {
            i.Tag = pInstance;
              }

              pParent.AddRange(menuItems.ToArray());
        }
コード例 #30
0
ファイル: AemManager.cs プロジェクト: kvemulap01/aem-manager
        public void UpdateInstanceListView()
        {
            AemInstance selectedInstance = this.SelectedInstanceInListview;

            DataTable dt = new DataTable();

            dt.Columns.Add("Instance", typeof(AemInstance));
            dt.Columns.Add("Name", typeof(string));
            dt.Columns.Add("Type", typeof(string));
            dt.Columns.Add("URL", typeof(string));
            dt.Columns.Add("Path", typeof(string));
            dt.Columns.Add("Status", typeof(string));

            foreach (AemInstance instance in Program.InstanceList)
            {
                DataRow row = dt.NewRow();
                row["Instance"] = instance;
                row["Name"]     = instance.Name;
                row["Type"]     = AemInstanceTypeUtil.GetLabel(instance.AemInstanceType);
                row["URL"]      = instance.UrlWithContextPath;
                row["Path"]     = instance.Path;
                row["Status"]   = instance.GetStatusText();
                dt.Rows.Add(row);
            }

            dgInstances.DataSource = dt;

            foreach (DataGridViewRow gridRow in dgInstances.Rows)
            {
                DataRow row = (DataRow)((DataRowView)gridRow.DataBoundItem).Row;
                if (row["Instance"] == selectedInstance)
                {
                    dgInstances.CurrentCell = gridRow.Cells[0];
                    break;
                }
            }
        }
コード例 #31
0
ファイル: AemActions.cs プロジェクト: kvemulap01/aem-manager
        public static void AddLogMenuItems(Menu.MenuItemCollection pParent, AemInstance pInstance)
        {
            List <MenuItem> menuItems = new List <MenuItem>();
            MenuItem        item;

            // show dynamic list of current logfiles
            item        = new MenuItem();
            item.Text   = "Open logfile...";
            item.Popup += LogFilesItem_Popup;
            item.MenuItems.Add(new MenuItem("-- No logfiles --"));
            menuItems.Add(item);

            item        = new MenuItem();
            item.Text   = "Console window";
            item.Click += new EventHandler(ShowConsoleWindow);
            menuItems.Add(item);

            foreach (MenuItem i in menuItems)
            {
                i.Tag = pInstance;
            }

            pParent.AddRange(menuItems.ToArray());
        }
コード例 #32
0
 public ConsoleWindow(AemInstance pAemInstance)
 {
     InitializeComponent();
       mAemInstance = pAemInstance;
 }
コード例 #33
0
        public AemInstance Clone()
        {
            AemInstance clone = new AemInstance();

              clone.mAemInstanceType = mAemInstanceType;
              clone.mName = mName;
              clone.mHostname = mHostname;
              clone.mPort = mPort;
              clone.mContextPath = mContextPath;
              clone.mPath = mPath;
              clone.mJavaExecutable = mJavaExecutable;
              clone.mUsername = mUsername;
              clone.mPassword = mPassword;
              clone.mRunmode = mRunmode;
              clone.mAdditionalRunmodes = mAdditionalRunmodes;
              clone.mRunmodeSampleContent = mRunmodeSampleContent;
              clone.mIconSet = mIconSet;
              clone.mCustomIconPath = mCustomIconPath;
              clone.mShowInTaskbar = mShowInTaskbar;
              clone.mHeapMinSizeMb = mHeapMinSizeMb;
              clone.mHeapMaxSizeMb = mHeapMaxSizeMb;
              clone.mMaxPermSizeMb = mMaxPermSizeMb;
              clone.mJVMDebug = mJVMDebug;
              clone.mDebugPort = mDebugPort;
              clone.mJProfiler = mJProfiler;
              clone.mJProfilerPort = mJProfilerPort;
              clone.mJConsole = mJConsole;
              clone.mJConsolePort = mJConsolePort;
              clone.mHideConfigWizard = mHideConfigWizard;
              clone.mShowInstanceWindow = mShowInstanceWindow;
              clone.mOpenBrowser = mOpenBrowser;
              clone.mRemoteProcess = mRemoteProcess;
              clone.mCustomJVMParam1Active = mCustomJVMParam1Active;
              clone.mCustomJVMParam1 = mCustomJVMParam1;
              clone.mCustomJVMParam2Active = mCustomJVMParam2Active;
              clone.mCustomJVMParam2 = mCustomJVMParam2;
              clone.mCustomJVMParam3Active = mCustomJVMParam3Active;
              clone.mCustomJVMParam3 = mCustomJVMParam3;
              clone.mBrowserExecutable = mBrowserExecutable;

              return clone;
        }
コード例 #34
0
 public AemInstanceDialog(AemInstance pInstance)
 {
     InitializeComponent();
       mInstance = pInstance;
 }
コード例 #35
0
        public static void StopInstance(AemInstance pInstance)
        {
            string shutdownUrl = pInstance.UrlWithContextPath + "/system/console/vmstat?shutdown_type=Stop";
              if (pInstance.AemInstanceType == AemInstanceType.AEM54) {
            shutdownUrl = pInstance.UrlWithoutContextPath + "/admin/shutdown";
              }

              try {
            mLog.Debug("Execute shutdown URL: " + shutdownUrl);

            pInstance.ConsoleOutputWindow.AppendConsoleLog("Shutting down instance...");

            WebRequest request = pInstance.WebRequestCreate(shutdownUrl);
            request.Method = "POST";
            request.Timeout = 3000;

            request.GetResponse();
              }
              catch (WebException ex) {
            mLog.Debug("Unable to connect to " + shutdownUrl + ": " + ex.Message);
              }
              catch (Exception ex) {
            mLog.Error("Error executing shutdown URL: " + shutdownUrl, ex);
              }
        }
コード例 #36
0
        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());
        }
コード例 #37
0
        private static void KillProcessAndChildrens(int pid, AemInstance instance)
        {
            ManagementObjectSearcher processSearcher = new ManagementObjectSearcher
            ("Select * From Win32_Process Where ParentProcessID=" + pid);
              ManagementObjectCollection processCollection = processSearcher.Get();

              try {
            Process proc = Process.GetProcessById(pid);
            if (proc != null && !proc.HasExited) {
              mLog.Debug("Killing process #" + pid + " for instance " + instance.Name);
              proc.Kill();
            }
              }
              catch (ArgumentException) {
            // Process already exited.
              }

              if (processCollection != null) {
            foreach (ManagementObject mo in processCollection) {
              // kill child processes(also kills childrens of childrens etc.)
              KillProcessAndChildrens(Convert.ToInt32(mo["ProcessID"]), instance);
            }
              }
        }
コード例 #38
0
        private static void OpenUrl(string pUrl, AemInstance pInstance)
        {
            mLog.Info("Open Url: " + pUrl);

              System.Diagnostics.Process p = new System.Diagnostics.Process();
              if (string.IsNullOrEmpty(pInstance.BrowserExecutable)) {
            p.StartInfo.FileName = pUrl;
              }
              else {
            p.StartInfo.FileName = pInstance.BrowserExecutable;
            p.StartInfo.Arguments = pUrl;
              }
              p.Start();
        }
コード例 #39
0
        public static void AddOpenMenuItems(Menu.MenuItemCollection pParent, AemInstance pInstance, bool pSetDefaultItem)
        {
            List<MenuItem> menuItems = new List<MenuItem>();
              MenuItem item;

              item = new MenuItem();
              item.Text = "Open Author/Publish";
              item.Click += new EventHandler(OpenAuthorPublish);
              if (pSetDefaultItem) {
            item.DefaultItem = true;
              }
              menuItems.Add(item);

              item = new MenuItem();
              item.Text = "Open CRX";
              item.Click += new EventHandler(OpenCRX);
              menuItems.Add(item);

              item = new MenuItem();
              item.Text = "Open CRXDE Lite";
              item.Click += new EventHandler(OpenCRXDELite);
              menuItems.Add(item);

              item = new MenuItem();
              item.Text = "Open Felix Console";
              item.Click += new EventHandler(OpenFelixConsole);
              menuItems.Add(item);

              item = new MenuItem();
              item.Text = "Open Folder";
              item.Click += new EventHandler(OpenFolder);
              menuItems.Add(item);

              if (pInstance.AemInstanceType == AemInstanceType.AEM54) {
            item = new MenuItem();
            item.Text = "Open Servlet Engine Admin";
            item.Click += new EventHandler(OpenServletEngineAdmin);
            menuItems.Add(item);
              }

              foreach (MenuItem i in menuItems) {
            i.Tag = pInstance;
              }

              pParent.AddRange(menuItems.ToArray());
        }
コード例 #40
0
 public SlingDavExServlet(AemInstance instance)
 {
     this.instance = instance;
 }
コード例 #41
0
 public SlingDavExServlet(AemInstance instance)
 {
     this.instance = instance;
 }
コード例 #42
0
        private static Process ExecuteCommand(string pWorkDir, string pExecutable, string pArguments, string pProcessName,
            bool pShowInstanceWindow, string pIconFile, bool pProcessNameViaShortcut, AemInstance pAemInstance)
        {
            mLog.Info("Execute: WorkDir=" + pWorkDir + ", executable=" + pExecutable + ", arguments=" + pArguments);

              Process process;

              // execute via auto-generated shortcut
              if (pShowInstanceWindow && pProcessNameViaShortcut) {
            string shortcutFilename = Path.GetTempPath() + pProcessName + ".lnk";

            IWshRuntimeLibrary.WshShell wshShell = new IWshRuntimeLibrary.WshShellClass();
            IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)wshShell.CreateShortcut(shortcutFilename);

            if (!string.IsNullOrEmpty(pWorkDir)) {
              shortcut.WorkingDirectory = pWorkDir;
            }
            try {
              shortcut.TargetPath = pExecutable;
            }
            catch (ArgumentException) {
              MessageBox.Show("Executable not found: " + pExecutable, "Execute Command", MessageBoxButtons.OK, MessageBoxIcon.Warning);
              return null;
            }
            shortcut.Arguments = pArguments;
            shortcut.Description = pProcessName;
            if (!string.IsNullOrEmpty(pIconFile)) {
              shortcut.IconLocation = Path.GetDirectoryName(Application.ExecutablePath) + "\\icons\\" + pIconFile;
            }
            shortcut.Save();

            process = new Process();
            process.StartInfo.FileName = shortcutFilename;
              }

              // start directly
              else {
            process = new Process();
            if (!string.IsNullOrEmpty(pWorkDir)) {
              process.StartInfo.WorkingDirectory = pWorkDir;
            }
            process.StartInfo.FileName = pExecutable;
            process.StartInfo.Arguments = pArguments;
              }

              if (!pShowInstanceWindow) {
            process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
              }

              if (pProcessNameViaShortcut) {
            // use shellexecute if start via shortcut is used - this forbids using output stream redirection etc.
            process.StartInfo.UseShellExecute = true;
              }
              else {
            // directy start process if no shortcut is used.
            process.StartInfo.UseShellExecute = false;
            process.StartInfo.CreateNoWindow = !pShowInstanceWindow;
            if (pAemInstance != null && !pShowInstanceWindow) {
              // use output handling if AEM instance is available
              process.OutputDataReceived += new DataReceivedEventHandler(pAemInstance.ConsoleOutputWindow.Process_OutputDataReceived);
              process.StartInfo.RedirectStandardOutput = true;
              process.ErrorDataReceived += new DataReceivedEventHandler(pAemInstance.ConsoleOutputWindow.Process_ErrorDataReceived);
              process.StartInfo.RedirectStandardError = true;
            }
              }

              try {
            process.Start();

            if (!pProcessNameViaShortcut) {
              if (pAemInstance != null && !pShowInstanceWindow) {
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
              }
            }

            return process;
              }
              catch (Exception ex) {
            throw new Exception(ex.Message + "\n"
              + "WorkDir: " + pWorkDir + "\n"
              + "Executable: " + pExecutable + "\n"
              + "Arguments: " + pArguments, ex);
              }
        }
コード例 #43
0
 public AemInstanceDialog(AemInstance pInstance)
 {
     InitializeComponent();
     mInstance = pInstance;
 }
コード例 #44
0
        public static BundleStatus GetCombinedBundleStatus(AemInstance pInstance)
        {
            if (pInstance == null) {
            return BundleStatus.NO_ACTIVE_INSTANCE;
              }

              // check if process is running
              if (!pInstance.RemoteProcess) {
            Process process = pInstance.GetInstanceJavaProcess();
            if (process == null || process.HasExited) {
              return BundleStatus.DISABLED;
            }
              }

              // get bundle status
              BundleStatus bundleStatus = BundleStatus.UNKNOWN;
              string bundleListUrl = pInstance.UrlWithContextPath + "/system/console/bundles/.json";
              Stopwatch responseTimeStopwatch = new Stopwatch();
              try {
            mLog.Debug("Get bundle list from URL: " + bundleListUrl);

            WebRequest request = pInstance.WebRequestCreate(bundleListUrl);
            request.Method = "GET";
            request.Timeout = AEMManager.Properties.Settings.Default.BundleListTimeout;

            responseTimeStopwatch.Start();
            using (WebResponse response = request.GetResponse()) {
              responseTimeStopwatch.Stop();

              String responseText;
              using (StreamReader streamReader = new StreamReader(response.GetResponseStream())) {
            responseText = streamReader.ReadToEnd();
              }

              // parse JSON
              bool success = false;
              object value = JSON.JsonDecode(responseText, ref success);
              if (success) {
            bundleStatus = GetCombinedBundleStatus(value, responseTimeStopwatch.ElapsedMilliseconds);
              }
              else {
            mLog.Warn("Parsing JSON response failed: " + responseText);
              }
            }

              }
              catch (WebException ex) {
            if (ex.Status == WebExceptionStatus.Timeout) {
              mLog.Debug("Unable to connect to " + bundleListUrl + " due to timeout. "
            + "Configured timeout: " + AEMManager.Properties.Settings.Default.BundleListTimeout + "ms, "
            + "measured response time: " + responseTimeStopwatch.ElapsedMilliseconds + "ms");
            }
            else {
              mLog.Debug("Unable to connect to " + bundleListUrl + ": " + ex.Message);
              bundleStatus = BundleStatus.UNKNOWN;
            }
              }
              catch (Exception ex) {
            mLog.Error("Error getting bundle list from URL: " + bundleListUrl, ex);
            bundleStatus = BundleStatus.UNKNOWN;
              }

              return bundleStatus;
        }