Inheritance: System.ServiceProcess.ServiceBase
Example #1
0
        public static int Main(String[] args)
        {
            ResinArgs resinArgs = new ResinArgs(Environment.GetCommandLineArgs());

              Resin resin = new Resin(resinArgs);

              return resin.Execute();
        }
Example #2
0
        public static int Main(String[] args)
        {
            ResinArgs resinArgs = new ResinArgs(Environment.GetCommandLineArgs());

            Resin resin = new Resin(resinArgs);

            return(resin.Execute());
        }
Example #3
0
        public IList <ResinService> GetResinServices(Resin resin)
        {
            IList <ResinService> result = new List <ResinService>();

            foreach (ResinService resinService in _resinServices)
            {
                if (resin.Home.Equals(resinService.Home))
                {
                    result.Add(resinService);
                }
            }

            return(result);
        }
Example #4
0
 public String GetResinConfFile(Resin resin)
 {
     if (File.Exists(resin.Home + @"\conf\resin.xml"))
     {
         return(@"conf\resin.xml");
     }
     else if (File.Exists(resin.Home + @"\conf\resin.conf"))
     {
         return(@"conf\resin.conf");
     }
     else
     {
         return(null);
     }
 }
Example #5
0
        public SetupForm(Setup setup)
        {
            _setup = setup;
              _resin = _setup.Resin;

              InitializeComponent();
              _none = _folderDlg.RootFolder;

              _resinCmbBox.BeginUpdate();
              _resinCmbBox.DataSource = _setup.GetResinList();
              _resinCmbBox.SelectedItem = _resin;
              _resinCmbBox.EndUpdate();

              UpdateServices(null);
        }
Example #6
0
        public Resin SelectResin(String home)
        {
            home = Util.Canonicalize(home);

            Resin result = null;

            foreach (Resin resin in _resinList)
            {
                if (home.Equals(resin.Home))
                {
                    result = resin;
                }
            }

            if (result == null)
            {
                result = new Resin(home);
                AddResin(result);
            }

            return(result);
        }
Example #7
0
 public void AddResin(Resin resin)
 {
     _resinList.Add(resin);
 }
Example #8
0
 public bool HasResin(Resin resin)
 {
     return(_resinList.Contains(resin));
 }
Example #9
0
        public void FindResin()
        {
            DriveInfo[] drives = DriveInfo.GetDrives();
            foreach (DriveInfo drive in drives)
            {
                if (DriveType.Fixed != drive.DriveType && DriveType.Ram != drive.DriveType)
                {
                    continue;
                }
                DirectoryInfo   root        = drive.RootDirectory;
                DirectoryInfo[] directories = root.GetDirectories();
                foreach (DirectoryInfo directory in directories)
                {
                    if (directory.Name.StartsWith("resin", StringComparison.CurrentCultureIgnoreCase) &&
                        Util.IsResinHome(directory.FullName))
                    {
                        Resin resin = new Resin(Util.Canonicalize(directory.FullName));
                        if (!HasResin(resin))
                        {
                            AddResin(resin);
                        }
                    }
                    else if (directory.Name.Contains("appservers"))
                    {
                        DirectoryInfo[] appserverDirectories = directory.GetDirectories();
                        foreach (DirectoryInfo appserverDir in appserverDirectories)
                        {
                            if (Util.IsResinHome(appserverDir.FullName))
                            {
                                String home  = Util.Canonicalize(appserverDir.FullName);
                                Resin  resin = new Resin(home);
                                if (!HasResin(resin))
                                {
                                    AddResin(resin);
                                }
                            }
                        }
                    }
                }
            }

            String currentResin    = Util.GetCurrentResinFromRegistry();
            Resin  resinInRegistry = null;

            if (currentResin != null)
            {
                currentResin    = Util.Canonicalize(currentResin);
                resinInRegistry = new Resin(currentResin);

                if (!HasResin(resinInRegistry))
                {
                    AddResin(resinInRegistry);
                }
            }

            RegistryKey services = Registry.LocalMachine.OpenSubKey(Setup.REG_SERVICES);

            foreach (String name in services.GetSubKeyNames())
            {
                RegistryKey key = services.OpenSubKey(name);
                try
                {
                    Object imagePathObj = key.GetValue("ImagePath");
                    if (imagePathObj == null && !"".Equals(imagePathObj))
                    {
                        continue;
                    }

                    String imagePath          = (String)imagePathObj;
                    String lowerCaseImagePath = imagePath.ToLower();

                    if (imagePath.IndexOf("resin.exe") != -1)
                    {
                        ResinArgs resinArgs = new ResinArgs(imagePath);
                        Resin     resin     = null;
                        if (resinArgs.ResinHome != null)
                        {
                            resin = new Resin(resinArgs.ResinHome);
                        }
                        else if (resinArgs.Exe != null)
                        {
                            String exe  = resinArgs.Exe;
                            String home = exe.Substring(0, exe.Length - 10);
                            if (Util.IsResinHome(home))
                            {
                                resin = new Resin(home);
                            }
                        }

                        if (resin != null && !HasResin(resin))
                        {
                            AddResin(resin);
                        }
                    }
                }
                catch (Exception e)
                {
                    LogStartupError(e.Message, e);
                }
                finally
                {
                    key.Close();
                }
            }

            services.Close();

            String resinHome = Util.GetResinHome(null, System.Reflection.Assembly.GetExecutingAssembly().Location);

            foreach (Resin resin in _resinList)
            {
                if (resin.Home.Equals(resinHome))
                {
                    Resin = resin;

                    return;
                }
            }

            if (Resin == null && resinInRegistry != null)
            {
                Resin = resinInRegistry;
            }

            if (Resin == null && resinHome != null)
            {
                Resin = new Resin(resinHome);

                AddResin(Resin);
            }

            if (Resin == null && _resinList.Count > 0)
            {
                Resin = _resinList[_resinList.Count - 1];
            }
        }
Example #10
0
        private void SelectResin(String resinHome)
        {
            _resinCmbBox.BeginUpdate();
              _resin = _setup.SelectResin(resinHome);
              _resinCmbBox.DataSource = _setup.GetResinList();
              _resinCmbBox.SelectedItem = _resin;
              _resinCmbBox.EndUpdate();

              UpdateServices(null);
        }
Example #11
0
        private void UpdateServices(ResinService newResinService)
        {
            _resin = (Resin)_resinCmbBox.SelectedItem;
              if (_resin != null) {
            IList<ResinService> services = _setup.GetResinServices(_resin);
            ArrayList items = new ArrayList();

            items.Add(_createService);
            items.AddRange((ICollection)services);

            _servicesCmbBox.BeginUpdate();
            _servicesCmbBox.DataSource = items;

            if (services.Count == 0) {
              _servicesCmbBox.SelectedIndex = 0;
            } else if (services.Count > 0) {
              _servicesCmbBox.SelectedIndex = -1;
              StringBuilder builder = new StringBuilder("Select Service: [");
              for (int i = 0; i < services.Count; i++) {
            ResinService service = services[i];
            builder.Append(service.Name);
            if (i + 1 < services.Count)
              builder.Append(", ");
              }
              builder.Append(']');

              _servicesCmbBox.Text = builder.ToString();
            }
            _servicesCmbBox.EndUpdate();
              }
        }
 public static int Main(String[] args)
 {
   Resin resin = new Resin(Environment.GetCommandLineArgs());
   if (resin.ResinArgs.IsServiceCommand()) {
     resin.Info("Please use setup.exe to install or remove the service.");
     return -1;
   } else if (!resin.ResinArgs.IsValid()) {
     resin.Usage(resin.ServiceName);
     return -1;
   } else {
     return resin.Execute();
   }
 }
 public ResinWindow(Resin resin, String title)
 {
   _resin = resin;
   _title = title;
   InitializeComponent();
 }