1 package org.opendaylight.yangtools.concepts;
\r
4 * Utility registration handle. It is a convenience for register-style method
\r
5 * which can return an AutoCloseable realized by a subclass of this class.
\r
6 * Invoking the close() method triggers unregistration of the state the method
\r
9 public abstract class AbstractRegistration<T> implements Registration<T> {
\r
11 private boolean closed = false;
\r
12 private final T instance;
\r
14 public AbstractRegistration(T instance) {
\r
15 this.instance = instance;
\r
19 public T getInstance() {
\r
24 * Remove the state referenced by this registration. This method is
\r
25 * guaranteed to be called at most once. The referenced state must be
\r
26 * retained until this method is invoked.
\r
28 protected abstract void removeRegistration();
\r
31 public void close() throws Exception {
\r
34 removeRegistration();
\r