private static void WriteDomain(TextWriter writer, MBeanDomain domain)
 {
     writer.WriteLine("<span class=\"folder\">{0}</span>", domain.Name);
     writer.WriteLine("<ul>");
     WriteDomainItems(writer, domain);
     writer.WriteLine("</ul>");
 }
Example #2
0
        public MBeanServerResource Get()
        {
            var beans             = _serverConnection.QueryNames(null, null);
            var delegateBeanProxy = _serverConnection.CreateDynamicProxy(MBeanServerDelegate.ObjectName);

            var rootDomain = new MBeanDomain();

            foreach (var bean in beans)
            {
                var nameParts     = bean.Domain.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
                var domainParts   = nameParts.Take(nameParts.Length - 1).ToArray();
                var currentDomain = EnsureSubdomain(rootDomain, domainParts);
                currentDomain.Beans.Add(new Resources.MBeanInfo
                {
                    ObjectName = bean.CanonicalName,
                    ShortName  = nameParts.Last() + ":" + bean.KeyPropertyListString,
                    HRef       = GetResourceUrl("bean", new { objectName = bean.CanonicalName })
                });
            }

            var resource = new MBeanServerResource
            {
                RootDomain      = rootDomain,
                InstanceName    = delegateBeanProxy.MBeanServerId,
                Version         = delegateBeanProxy.ImplementationVersion,
                StaticViewHref  = GetResourceUrl("server", new {}),
                DynamicViewHref = GetResourceUrl("ui", new { contentFile = "mbeanserver.htm" })
            };

            return(resource);
        }
 private static void WriteDomainItems(TextWriter writer, MBeanDomain domain)
 {
     foreach (var bean in domain.Beans)
     {
         writer.WriteLine("<li><span class=\"file\"><a href=\"{0}\">{1}</a></span></li>", bean.HRef, bean.ShortName);
     }
     foreach (var subdomain in domain.Subdomains)
     {
         writer.WriteLine("<li>");
         WriteDomain(writer, subdomain);
         writer.WriteLine("</li>");
     }
 }
Example #4
0
 private static MBeanDomain EnsureSubdomain(MBeanDomain currentDomain, string[] domainParts)
 {
     foreach (var domainPartName in domainParts)
     {
         var subdomain = currentDomain.Subdomains.FirstOrDefault(x => x.Name == domainPartName);
         if (subdomain == null)
         {
             subdomain = new MBeanDomain()
             {
                 Name = domainPartName
             };
             currentDomain.Subdomains.Add(subdomain);
         }
         currentDomain = subdomain;
     }
     return(currentDomain);
 }