8b2631f7531bd4ffae50d1b6c5734d7e6f0b1223
[yangtools.git] / concepts / src / main / java / org / opendaylight / yangtools / concepts / Registration.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.concepts;
9
10 /**
11  * Class representing a registration of an object. Such a registration is
12  * a proper resource and should be cleaned up when no longer required, so
13  * references to the object can be removed. This mechanism lies above the
14  * usual Java reference mechanism, as the entity where the object is
15  * registered may reside outside of the Java Virtual Machine.
16  */
17 public interface Registration<T> extends AutoCloseable {
18     /**
19      * Return the object instance.
20      *
21      * @return Registered object.
22      *
23      * @deprecated This class is currently deprecated pending its rework for
24      *             general-purpose registration. This rework will remove the
25      *             getInstance() method, such that the registration is no
26      *             longer tied to a particular object. Please use
27      *             {@link ObjectRegistration} to ensure your code does not
28      *             break when that happens.
29      */
30     @Deprecated
31     T getInstance();
32
33     /**
34      * Unregisters the object. This operation is required not to invoke
35      * blocking operations. Implementations which require interaction
36      * with outside world must provide guarantees that any work is done
37      * behind the scenes and the unregistration process looks as if it
38      * has already succeeded once this method returns.
39      */
40     @Override
41     void close() throws Exception;
42 }