- All Implemented Interfaces:
Serializable, Cloneable, Iterable<HTTPServer>, Collection<HTTPServer>, List<HTTPServer>, RandomAccess, SequencedCollection<HTTPServer>
A collection of HTTPServer instances that extends Vector. This class manages multiple HTTP servers, allowing them to be started, stopped, and configured as a group.
- See Also:
Field Summary
FieldsModifier and TypeFieldDescriptionprivate InetAddress[]Local addresses the servers are opened on, or null to bind all interfaces.private intPort each server is opened on.Fields inherited from class Vector
capacityIncrement, elementCount, elementDataFields inherited from class AbstractList
modCountConstructor Summary
ConstructorsConstructorDescriptionCreates a new empty HTTPServerList.HTTPServerList(InetAddress[] list, int port) Creates a new HTTPServerList with specified bind addresses and port.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidaddRequestListener(HTTPRequestListener listener) Adds a request listener to all HTTP servers in this list.voidclose()Closes all HTTP servers in this list.getHTTPServer(int n) Gets the HTTPServer at the specified index.intopen()Opens HTTP servers on all configured bind addresses.booleanopen(int port) Opens HTTP servers on the specified port.voidstart()Starts all HTTP servers in this list.voidstop()Stops all HTTP servers in this list.Methods inherited from class Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, forEach, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, iterator, lastElement, lastIndexOf, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeIf, removeRange, replaceAll, retainAll, set, setElementAt, setSize, size, sort, spliterator, subList, toArray, toArray, toString, trimToSizeMethods inherited from interface Collection
parallelStream, stream, toArrayMethods inherited from interface List
addFirst, addLast, getFirst, getLast, removeFirst, removeLast, reversed
Field Details
binds
Local addresses the servers are opened on, or null to bind all interfaces.port
private int portPort each server is opened on.
Constructor Details
HTTPServerList
public HTTPServerList()Creates a new empty HTTPServerList.HTTPServerList
Creates a new HTTPServerList with specified bind addresses and port.- Parameters:
list- array of InetAddress objects to bind toport- the port number for all servers
Method Details
addRequestListener
Adds a request listener to all HTTP servers in this list.- Parameters:
listener- the request listener to add
getHTTPServer
Gets the HTTPServer at the specified index.- Parameters:
n- the index of the server to retrieve- Returns:
- the HTTPServer at the specified index
close
public void close()Closes all HTTP servers in this list.open
public int open()Opens HTTP servers on all configured bind addresses. If no bind addresses are specified, uses I2P local addresses.- Returns:
- the number of successfully opened servers
open
public boolean open(int port) Opens HTTP servers on the specified port.- Parameters:
port- the port number to use- Returns:
- true if at least one server was opened successfully
start
public void start()Starts all HTTP servers in this list.stop
public void stop()Stops all HTTP servers in this list.