public void addDefaults() { final Set<String> existingProtocols = new HashSet<String>(); if (portBindings != null) { for (ConfigPortBinding binding : portBindings) { existingProtocols.add(binding.protocolName); } } if (portBindings == null) { portBindings = new ArrayList<ConfigPortBinding>(); } for (Protocol proto : Protocol.getProtocols()) { if (!existingProtocols.contains(proto.getName())) { ConfigPortBinding binding = new ConfigPortBinding(getConfiguration()); binding.protocolName = proto.getName(); binding.protocol = proto; binding.port = proto.getDefaultPort(); portBindings.add(binding); } } }
public void bindAll() { addDefaults(); for (ConfigPortBinding binding : portBindings) { if (binding.protocol == null) { Protocol protocol = Protocol.getProtocol(binding.protocolName); if (protocol == null) { server .getLogger() .warning("Could not bind to port, unknown protocol '" + binding.protocolName + "'"); continue; } binding.protocol = protocol; } if (binding.port != -1) { server.bind(binding); } } }