Class DefaultCloseableService
- java.lang.Object
-
- org.glassfish.jersey.server.internal.process.DefaultCloseableService
-
- All Implemented Interfaces:
CloseableService
class DefaultCloseableService extends java.lang.Object implements CloseableService
Default implementation ofCloseableService. This implementation stores instances ofCloseablein an internal identity hash set and makes sure that the close method is invoked at most once.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.io.Closeable>closeablesprivate java.util.concurrent.atomic.AtomicBooleanclosedprivate static java.util.logging.LoggerLOGGER
-
Constructor Summary
Constructors Constructor Description DefaultCloseableService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(java.io.Closeable closeable)Register a new instance ofCloseablethat is to be closed when the request goes out of scope.voidclose()InvokesCloseable#close()method on all instances ofCloseableadded by the#add(Closeable)method.
-
-
-
Method Detail
-
add
public boolean add(java.io.Closeable closeable)
Description copied from interface:CloseableServiceRegister a new instance ofCloseablethat is to be closed when the request goes out of scope.After
CloseableService.close()has been called, this method will not accept any new instance registrations and will returnfalseinstead.- Specified by:
addin interfaceCloseableService- Parameters:
closeable- the instance ofCloseable.- Returns:
trueif the closeable service has not been closed yet and the closeable instance was successfully registered with the service,falseotherwise.
-
close
public void close()
Description copied from interface:CloseableServiceInvokesCloseable#close()method on all instances ofCloseableadded by the#add(Closeable)method. Subsequent calls of this method should not do anything.- Specified by:
closein interfaceCloseableService
-
-