Adde Weblogic specific runtime MBeanServer
@param servers set to add own MBean servers
496652
@Override
    public void addMBeanServers(Set<MBeanServerConnection> servers) {
        // Weblogic stores the MBeanServer in a JNDI context

        // Workaround for broken JBoss 4.2.3 which doesn't like JNDI lookups. See #123 for details.
        if (!isJBoss()) {
            InitialContext ctx;
            try {
                ctx = new InitialContext();
                MBeanServer server = (MBeanServer) ctx.lookup("java:comp/env/jmx/runtime");
                if (server != null) {
                    servers.add(server);
                }
            } catch (NamingException e) {
                // expected and can happen on non-Weblogic platforms
            }
        }
    }
1126920
public final void addServer(String hostList) throws IOException {
    Map<InetSocketAddress, InetSocketAddress> addresses = AddrUtil.getAddressMap(hostList);
    if (addresses != null && addresses.size() > 0) {
      for (Map.Entry<InetSocketAddress, InetSocketAddress> entry : addresses.entrySet()) {
        final InetSocketAddress mainNodeAddr = entry.getKey();
        final InetSocketAddress standbyNodeAddr = entry.getValue();
        this.connect(new InetSocketAddressWrapper(mainNodeAddr,
            this.serverOrderCount.incrementAndGet(), 1, null));
        if (standbyNodeAddr != null) {
          this.connect(new InetSocketAddressWrapper(standbyNodeAddr,
              this.serverOrderCount.incrementAndGet(), 1, mainNodeAddr));
        }
      }
    }
  }
336259
public void addScannerServers(final int query_index, final int id, 
      final Set<String> servers) {
    Map<Integer, Set<String>> query_servers = scanner_servers.get(query_index);
    if (query_servers == null) {
      query_servers = new ConcurrentHashMap<Integer, Set<String>>(
          Const.SALT_WIDTH() > 0 ? Const.SALT_BUCKETS() : 1);
      scanner_servers.put(query_index, query_servers);
    }
    query_servers.put(id, servers);
  }
259344
public void setServers(java.util.Collection<ListedServer> servers) {
        if (servers == null) {
            this.servers = null;
            return;
        }

        this.servers = new java.util.ArrayList<ListedServer>(servers);
    }
725737
public static ServerConnector createServerConnectorAndAddToServer(Server server) {
		ServerConnector connector = new ServerConnector(server, JettySetting.createHttpConnectionFactory());

		connector.setHost(setting.getStr("host", "http", "0.0.0.0"));
		connector.setPort(setting.getInt("port", "http", 8090));
		connector.setIdleTimeout(setting.getLong("idle-timeout", "http", 30000L));
		server.addConnector(connector);

		return connector;
	}
849125
public ProviderConfig<T> setServer(ServerConfig server) {
        if (this.server == null) {
            this.server = new ArrayList<ServerConfig>();
        }
        this.server.add(server);
        return this;
    }
235419
@org.osgi.service.component.annotations.Reference(target = "(jmx.objectname=WebSphere:feature=kernel,name=ServerInfo)", policy = ReferencePolicy.DYNAMIC, cardinality = ReferenceCardinality.MULTIPLE, policyOption = ReferencePolicyOption.GREEDY)
    protected void setServerInfoMBean(ServerInfoMBean serverInfoMBean) {
        this.serverInfoMBean = serverInfoMBean;
    }
48924
public static String dump(Set<MBeanServerConnection> servers) {
            StringBuffer ret = new StringBuffer();
            ret.append("Found ").append(servers.size()).append(" MBeanServers\n");
            for (MBeanServerConnection c : servers) {
                MBeanServer s = (MBeanServer) c;
                ret.append("    ")
                   .append("++ ")
                   .append(s.toString())
           .append(": default domain = ")
           .append(s.getDefaultDomain())
           .append(", ")
           .append(s.getMBeanCount())
           .append(" MBeans\n");

            ret.append("        Domains:\n");
            for (String d : s.getDomains()) {
                appendDomainInfo(ret, s, d);
            }
        }
        ret.append("\n");
        ret.append("Platform MBeanServer: ")
           .append(ManagementFactory.getPlatformMBeanServer())
           .append("\n");
        return ret.toString();
    }
863898
public static void initMBeans() {
		// rq: en général, il y a 2 connecteurs (http et ajp 1.3) définis dans server.xml et donc
		// 2 threadPools et 2 globalRequestProcessors de même nom : http-8080 et jk-8009 (ajp13)
		THREAD_POOLS.clear();
		GLOBAL_REQUEST_PROCESSORS.clear();
		THREAD_POOLS.addAll(MBeansAccessor.getTomcatThreadPools());
		GLOBAL_REQUEST_PROCESSORS.addAll(MBeansAccessor.getTomcatGlobalRequestProcessors());
	}
99091
private ServerPod []buildServers(int serverCount)
  {
    ArrayList<ServerPod> serversPod = new ArrayList<>();

    for (int i = 0; i < serverCount; i++) {
      //ServerPod serverPod = new ServerPod(i);
      
      //serversPod.add(serverPod);
      
      if (i < _serverList.size()) {
        serversPod.add(_serverList.get(i));
      }
      else {
        serversPod.add(new ServerPod(i));
      }
      
      /*        ServerPod serverHint = _serverList.get(i);
        
        serverPod.setHint(serverHint.getHint());

        if (server == null) {
        }
        else if (server.startsWith("127")) {
          int p = server.indexOf(':');
          int port = Integer.parseInt(server.substring(p + 1));
          
          serverPod.setHintPort(port);
        }
        else {
          serverPod.setHintServerId(server);
        }
        
        ServerBartender server = _cluster.findServerByName(serverHint.getServerId());
        System.out.println("BS22: " + server + " " + serverHint + " " + serverHint.getServerId() + " " + serverHint.getHint());
        serverPod.setServer(server);
      }
        */
    }
    
    ServerPod []serverArray = new ServerPod[serverCount];
    for (int i = 0; i < serverCount; i++) {
      serverArray[i] = serversPod.get(i);
    }
    
    return serverArray;
  }
1023924
public void add(Collection<ApplicationHost> applicationHosts)
    {
        for(ApplicationHost applicationHost : applicationHosts)
            this.applicationHosts.put(applicationHost.getId(), applicationHost);
    }
805209
private static void addEarToServer(LibertyServer server, String dir, String earName, boolean addEarResources,
                                       String warName, boolean addWarResources, String jarName, boolean addJarResources, String... packageNames) throws Exception {

        if (warName == null)
            return;

        // If server is already started and app exists no need to add it.
        if (server.isStarted()) {
            String appName = warName.substring(0, warName.indexOf(".war"));
            Set<String> appInstalled = server.getInstalledAppNames(appName);
            LOG.info("addEarToServer : " + appName + " already installed : " + !appInstalled.isEmpty());

            if (!appInstalled.isEmpty())
                return;
        }

        JavaArchive jar = null;
        WebArchive war = null;

        if (jarName != null) {

            LOG.info("addEarToServer : create jar " + jarName + ", jar includes resources : " + addJarResources);

            jar = ShrinkWrap.create(JavaArchive.class, jarName);
            if (packageNames != null) {
                for (String packageName : packageNames) {
                    if (packageName.contains(".jar.")) {
                        jar.addPackage(packageName);
                    }
                }
            }
            if (addJarResources)
                ShrinkHelper.addDirectory(jar, "test-applications/" + jarName + "/resources");
        }

        war = ShrinkWrap.create(WebArchive.class, warName);
        LOG.info("addEarToServer : create war " + warName + ", war includes resources : " + addWarResources);
        if (packageNames != null) {
            for (String packageName : packageNames) {
                if (packageName.contains(".war.")) {
                    war.addPackage(packageName);
                }
            }
        }
        if (jar != null)
            war.addAsLibrary(jar);
        if (addWarResources)
            ShrinkHelper.addDirectory(war, "test-applications/" + warName + "/resources");

        if (earName != null) {
            LOG.info("addEarToServer : crteate ear " + earName + ", ear include application/.xml : " + addEarResources);
            EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, earName);
            ear.addAsModule(war);
            if (addEarResources)
                ear.addAsManifestResource(
                                          new File("test-applications/" + earName + "/resources/META-INF/application.xml"));

            //Liberty does not use was.policy but permissions.xml
            File permissionsXML = new File("test-applications/" + earName + "/resources/META-INF/permissions.xml");
            if (permissionsXML.exists()) {
                ear.addAsManifestResource(permissionsXML);
            }

            ShrinkHelper.exportToServer(server, dir, ear);
        } else {
            ShrinkHelper.exportToServer(server, dir, war);
        }

    }
837764
@SuppressWarnings("unused")
    private void printServerInfo() {
        Context ctx;
        try{
            ctx = new InitialContext();
            MBeanServer server = (MBeanServer)ctx.lookup("java:comp/env/jmx/runtime");
            ObjectName service = new ObjectName("com.bea:Name=RuntimeService," +
                  "Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");
            ObjectName domainMBean = (ObjectName) server.getAttribute(service,
                "DomainConfiguration");
            ObjectName[] servers = (ObjectName[]) server.getAttribute(domainMBean,
                    "Servers");
            for (ObjectName one : servers) {
                String name = (String)server.getAttribute(one, "Name");
                String address = (String)server.getAttribute(one, "ListenAddress");
                Integer port = (Integer)server.getAttribute(one, "ListenPort");
                System.out.println("SERVER: " + name + " on " + address + ":" + port);
                ObjectName machine = (ObjectName)server.getAttribute(one, "Machine");
                ObjectName nodeManager = (ObjectName)server.getAttribute(machine, "NodeManager");
                // above line need WLS admin!!!
                address = (String)server.getAttribute(machine, "ListenAddress");
                System.out.println(" - hostname: " + address);
            }
            if (ctx!=null) return;
        }catch(Exception ex){
            ex.printStackTrace();
        }
    }
287010
public ServerHandle detect(MBeanServerExecutor pMBeanServerExecutor) {
        String domainConfigMBean = getSingleStringAttribute(pMBeanServerExecutor,"*:Name=RuntimeService,*","DomainConfiguration");
        if (domainConfigMBean != null) {
            String version = getSingleStringAttribute(pMBeanServerExecutor,domainConfigMBean,"ConfigurationVersion");
            return new ServerHandle("Oracle","weblogic",version, null);
        }
        return null;
    }
220223
Collection<MBeanServer> getMBeanServers() {
        Collection<MBeanServer> mbeanServers = new HashSet<MBeanServer>();
        mbeanServers.add(ManagementFactory.getPlatformMBeanServer());
        mbeanServers.addAll(MBeanServerFactory.findMBeanServer(null));
        return mbeanServers;
    }
478038
public void setServerReplicationConfigurations(java.util.Collection<ServerReplicationConfiguration> serverReplicationConfigurations) {
        if (serverReplicationConfigurations == null) {
            this.serverReplicationConfigurations = null;
            return;
        }

        this.serverReplicationConfigurations = new java.util.ArrayList<ServerReplicationConfiguration>(serverReplicationConfigurations);
    }
753100
public Deployment setServerGroups(final Collection<String> serverGroups) {
        this.serverGroups.clear();
        this.serverGroups.addAll(serverGroups);
        return this;
    }