Search in sources :

Example 1 with AdminAdapter

use of com.sun.enterprise.v3.admin.AdminAdapter in project Payara by payara.

the class WsUtil method getWebServerInfoForDAS.

public WebServerInfo getWebServerInfoForDAS() {
    WebServerInfo wsi = new WebServerInfo();
    if (this.networkListeners == null) {
        List<Integer> adminPorts = new ArrayList<Integer>();
        for (org.glassfish.api.container.Adapter subAdapter : WebServiceContractImpl.getInstance().getAdapters()) {
            if (subAdapter instanceof AdminAdapter) {
                AdminAdapter aa = (AdminAdapter) subAdapter;
                adminPorts.add(aa.getListenPort());
            } else if (subAdapter instanceof AdminConsoleAdapter) {
                AdminConsoleAdapter aca = (AdminConsoleAdapter) subAdapter;
                adminPorts.add(aca.getListenPort());
            }
        }
        for (NetworkListener nl : config.getNetworkConfig().getNetworkListeners().getNetworkListener()) {
            if (!adminPorts.contains(Integer.valueOf(nl.getPort()))) {
                // get rid of admin ports
                if (networkListeners == null)
                    networkListeners = new ArrayList<NetworkListener>();
                networkListeners.add(nl);
            }
        }
    }
    // Fix for issue 13107490
    if ((networkListeners != null) && (!networkListeners.isEmpty())) {
        for (NetworkListener listener : networkListeners) {
            String host = listener.getAddress();
            if (listener.getAddress().equals("0.0.0.0"))
                try {
                    host = InetAddress.getLocalHost().getHostName();
                } catch (UnknownHostException e) {
                    // fallback
                    host = "localhost";
                }
            if (listener.findHttpProtocol().getSecurityEnabled().equals("false"))
                wsi.setHttpVS(new VirtualServerInfo("http", host, Integer.parseInt(listener.getPort())));
            else if (listener.findHttpProtocol().getSecurityEnabled().equals("true"))
                wsi.setHttpsVS(new VirtualServerInfo("https", host, Integer.parseInt(listener.getPort())));
        }
    } else {
        wsi.setHttpVS(new VirtualServerInfo("http", "localhost", 0));
        wsi.setHttpsVS(new VirtualServerInfo("https", "localhost", 0));
    }
    return wsi;
}
Also used : VirtualServerInfo(org.glassfish.web.deployment.util.VirtualServerInfo) WebServerInfo(org.glassfish.web.deployment.util.WebServerInfo) AdminConsoleAdapter(com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter) AdminAdapter(com.sun.enterprise.v3.admin.AdminAdapter) NetworkListener(org.glassfish.grizzly.config.dom.NetworkListener)

Aggregations

AdminAdapter (com.sun.enterprise.v3.admin.AdminAdapter)1 AdminConsoleAdapter (com.sun.enterprise.v3.admin.adapter.AdminConsoleAdapter)1 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)1 VirtualServerInfo (org.glassfish.web.deployment.util.VirtualServerInfo)1 WebServerInfo (org.glassfish.web.deployment.util.WebServerInfo)1