addCloseable

open fun addCloseable(key: String, closeable: AutoCloseable)(source)

Adds an AutoCloseable resource with an associated key to this ComponentModel. The resource will be closed right before the onCleared method is called.

If the key already has a resource associated with it, the old resource will be replaced and closed immediately.

If onCleared has already been called, the provided resource will not be added and will be closed immediately.

Parameters

key

the key to associate with the resource, for retrieval with getCloseable.

closeable

the resource to be closed when the ComponentModel is cleared, right before the onCleared method is called.


open fun addCloseable(closeable: AutoCloseable)(source)

Adds an AutoCloseable resource to this ComponentModel. The resource will be closed right before the onCleared method is called.

If onCleared has already been called, the provided resource will not be added and will be closed immediately.

Parameters

closeable

the resource to be closed when the ComponentModel is cleared, right before the onCleared method is called.