/** * @return the port number on which this connector is configured to listen * for requests. The special value of 0 means select a random free port * when the socket is bound. */ public int getPort() { // Try shortcut that should work for nearly all uses first as it does // not use reflection and is therefore faster. if (protocolHandler instanceof AbstractProtocol<?>) { return ((AbstractProtocol<?>) protocolHandler).getPort(); } // Fall back for custom protocol handlers not based on AbstractProtocol Object port = getProperty("port"); if (port instanceof Integer) { return ((Integer) port).intValue(); } // Usually means an invalid protocol has been configured return -1; }
private ObjectName createObjectName() throws MalformedObjectNameException { // Use the same domain as the connector domain = adapter.getDomain(); if (domain == null) { return null; } StringBuilder name = new StringBuilder(getDomain()); name.append(":type=ProtocolHandler,port="); int port = getPort(); if (port > 0) { name.append(getPort()); } else { name.append("auto-"); name.append(getNameIndex()); } InetAddress address = getAddress(); if (address != null) { name.append(",address="); name.append(ObjectName.quote(address.getHostAddress())); } return new ObjectName(name.toString()); }
private ObjectName createObjectName() throws MalformedObjectNameException { // Use the same domain as the connector domain = getAdapter().getDomain(); if (domain == null) { return null; } StringBuilder name = new StringBuilder(getDomain()); name.append(":type=ProtocolHandler,port="); int port = getPort(); if (port > 0) { name.append(getPort()); } else { name.append("auto-"); name.append(getNameIndex()); } InetAddress address = getAddress(); if (address != null) { name.append(",address="); name.append(ObjectName.quote(address.getHostAddress())); } return new ObjectName(name.toString()); }
private ObjectName createObjectName() throws MalformedObjectNameException { // Use the same domain as the connector domain = adapter.getDomain(); if (domain == null) { return null; } StringBuilder name = new StringBuilder(getDomain()); name.append(":type=ProtocolHandler,port="); int port = getPort(); if (port > 0) { name.append(getPort()); } else { name.append("auto-"); name.append(getNameIndex()); } InetAddress address = getAddress(); if (address != null) { name.append(",address="); name.append(ObjectName.quote(address.getHostAddress())); } return new ObjectName(name.toString()); }
private ObjectName createObjectName() throws MalformedObjectNameException { // Use the same domain as the connector domain = getAdapter().getDomain(); if (domain == null) { return null; } StringBuilder name = new StringBuilder(getDomain()); name.append(":type=ProtocolHandler,port="); int port = getPort(); if (port > 0) { name.append(getPort()); } else { name.append("auto-"); name.append(getNameIndex()); } InetAddress address = getAddress(); if (address != null) { name.append(",address="); name.append(ObjectName.quote(address.getHostAddress())); } return new ObjectName(name.toString()); }
private String getNameInternal() { StringBuilder name = new StringBuilder(getNamePrefix()); name.append('-'); if (getAddress() != null) { name.append(getAddress().getHostAddress()); name.append('-'); } int port = getPort(); if (port == 0) { // Auto binding is in use. Check if port is known name.append("auto-"); name.append(getNameIndex()); port = getLocalPort(); if (port != -1) { name.append('-'); name.append(port); } } else { name.append(port); } return name.toString(); }
/** * The name will be prefix-address-port if address is non-null and * prefix-port if the address is null. The name will be appropriately quoted * so it can be used directly in an ObjectName. */ public String getName() { StringBuilder name = new StringBuilder(getNamePrefix()); name.append('-'); if (getAddress() != null) { name.append(getAddress().getHostAddress()); name.append('-'); } int port = getPort(); if (port == 0) { // auto binding is in use so port is unknown at this point name.append("auto-"); name.append(getNameIndex()); } else { name.append(port); } return ObjectName.quote(name.toString()); }
/** * The name will be prefix-address-port if address is non-null and * prefix-port if the address is null. The name will be appropriately quoted * so it can be used directly in an ObjectName. */ public String getName() { StringBuilder name = new StringBuilder(getNamePrefix()); name.append('-'); if (getAddress() != null) { name.append(getAddress().getHostAddress()); name.append('-'); } int port = getPort(); if (port == 0) { // Auto binding is in use. Check if port is known name.append("auto-"); name.append(getNameIndex()); port = getLocalPort(); if (port != -1) { name.append('-'); name.append(port); } } else { name.append(port); } return ObjectName.quote(name.toString()); }
/** * The name will be prefix-address-port if address is non-null and * prefix-port if the address is null. The name will be appropriately quoted * so it can be used directly in an ObjectName. */ public String getName() { StringBuilder name = new StringBuilder(getNamePrefix()); name.append('-'); if (getAddress() != null) { name.append(getAddress().getHostAddress()); name.append('-'); } int port = getPort(); if (port == 0) { // Auto binding is in use. Check if port is known name.append("auto-"); name.append(getNameIndex()); port = getLocalPort(); if (port != -1) { name.append('-'); name.append(port); } } else { name.append(port); } return ObjectName.quote(name.toString()); }
.forEach(protocol -> { final Executor executor = protocol.getExecutor(); final int port = protocol.getPort(); if (!ports.add(port)) { return;