Search in sources :

Example 16 with SystemProperty

use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.

the class PortManager method process.

public String process() throws TransactionFailure {
    try {
        // if there are no port system-property's -- no point in going on!
        if (newServerPorts.getMap().isEmpty())
            // all done!
            return null;
        // make sure user-supplied props are not flaky
        PortUtils.checkInternalConsistency(newServer);
        // create a list of ALL servers running on the same machine
        createServerList();
        // create a sorted list of every port on every other server on the same machine.
        populateAllPorts();
        // we have a list of all possible conflicting server ports.
        // let's find some unused ports and reassign the variables inside
        // the ServerPorts class
        Map<String, Integer> reassigned = reassignPorts();
        Set<Map.Entry<String, Integer>> entries = reassigned.entrySet();
        List<SystemProperty> sps = newServer.getSystemProperty();
        // We want to display EVERY port assignment -- no matter if it overrides or
        // not.  Tricky to get the display string just right.
        // if there are reassignments -- we overwrite the ones in finalPorts.
        // if not -- finalPorts contains all the stock ones
        // in any case ALL port assignments should be displayed.
        Map<String, Integer> finalPorts = newServerPorts.getMap();
        if (entries.size() > 0) {
            for (Map.Entry<String, Integer> entry : entries) {
                String name = entry.getKey();
                int port = entry.getValue();
                // do not want commas in the int!
                changeSystemProperty(sps, name, "" + port);
                finalPorts.put(name, port);
            }
        }
        return generateAssignedPortMessage(finalPorts);
    } catch (Exception e) {
        throw new TransactionFailure(e.toString(), e);
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty) PropertyVetoException(java.beans.PropertyVetoException)

Example 17 with SystemProperty

use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.

the class ServerHelper method translatePortOld.

private static String translatePortOld(String portString, Server server, Config config) {
    if (!isToken(portString))
        return portString;
    // isToken returned true so we are NOT assuming anything below!
    String key = portString.substring(2, portString.length() - 1);
    // check cluster and the cluster's config if applicable
    // bnevins Jul 18, 2010 -- don't botehr this should never be called anymore
    SystemProperty prop = server.getSystemProperty(key);
    if (prop != null) {
        return prop.getValue();
    }
    prop = config.getSystemProperty(key);
    if (prop != null) {
        return prop.getValue();
    }
    return null;
}
Also used : SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Example 18 with SystemProperty

use of com.sun.enterprise.config.serverbeans.SystemProperty in project Payara by payara.

the class ServerPorts method addAll.

private void addAll(List<SystemProperty> propList) {
    if (propList == null)
        return;
    for (SystemProperty sp : propList) {
        // we only care about
        // 1. the official Port Props that we support
        // 2. But only if they also have a value that is a legal port number
        String name = sp.getName();
        String value = sp.getValue();
        if (StringUtils.ok(name) && StringUtils.ok(value) && PORTSLIST.contains(name)) {
            try {
                int port = Integer.parseInt(value);
                if (NetUtils.isPortValid(port))
                    props.put(name, port);
            } catch (Exception e) {
            // we're all done here!
            }
        }
    }
}
Also used : SystemProperty(com.sun.enterprise.config.serverbeans.SystemProperty)

Aggregations

SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)18 PropertyVetoException (java.beans.PropertyVetoException)5 Domain (com.sun.enterprise.config.serverbeans.Domain)4 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)4 Cluster (com.sun.enterprise.config.serverbeans.Cluster)3 Server (com.sun.enterprise.config.serverbeans.Server)3 ActionReport (org.glassfish.api.ActionReport)3 Config (com.sun.enterprise.config.serverbeans.Config)2 JavaConfig (com.sun.enterprise.config.serverbeans.JavaConfig)2 Node (com.sun.enterprise.config.serverbeans.Node)2 VirtualServer (com.sun.enterprise.config.serverbeans.VirtualServer)2 ConfigApiTest (com.sun.enterprise.configapi.tests.ConfigApiTest)2 ArrayList (java.util.ArrayList)2 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)2 Test (org.junit.Test)2 Changed (org.jvnet.hk2.config.Changed)2 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)2 NotProcessed (org.jvnet.hk2.config.NotProcessed)2 Property (org.jvnet.hk2.config.types.Property)2 ConfigCustomizationToken (com.sun.enterprise.config.modularity.customization.ConfigCustomizationToken)1