Class PortManager.PortRef
- java.lang.Object
-
- org.terracotta.utilities.test.net.PortManager.PortRef
-
- All Implemented Interfaces:
java.lang.AutoCloseable
- Enclosing class:
- PortManager
public static class PortManager.PortRef extends java.lang.Object implements java.lang.AutoCloseableRepresents a reserved TCP port. When use of the port is no longer needed, this reference should be closed to release the reservation.
-
-
Constructor Summary
Constructors Modifier Constructor Description privatePortRef(int port)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes thisPortRef.private java.util.concurrent.atomic.AtomicReference<java.util.function.IntConsumer>closers()Gets the "closers"AtomicReferencefor use during weak-reference release.booleanisClosed()Returns whether or not thisPortRefis closed.(package private) voidonClose(java.util.function.IntConsumer action)Prepends a close action to thisPortRef.intport()Gets the reserved port number.
-
-
-
Method Detail
-
onClose
void onClose(java.util.function.IntConsumer action)
Prepends a close action to thisPortRef. Actions are executed in reverse order of their addition. Each action is passed the port number being closed.- Parameters:
action- the action to take to close thisPortRefinstance
-
closers
private java.util.concurrent.atomic.AtomicReference<java.util.function.IntConsumer> closers()
Gets the "closers"AtomicReferencefor use during weak-reference release.- Returns:
- the
AtomicReferenceinstance to call for closing thisPortRef
-
port
public int port()
Gets the reserved port number.- Returns:
- the port number
-
isClosed
public boolean isClosed()
Returns whether or not thisPortRefis closed.- Returns:
trueif thisPortRefhas been closed;falseotherwise
-
close
public void close()
Closes thisPortRef.- Specified by:
closein interfacejava.lang.AutoCloseable
-
-