BUG-7698: do not allow nulls in registrations
[yangtools.git] / common / concepts / src / main / java / org / opendaylight / yangtools / concepts / ObjectRegistration.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 import javax.annotation.Nonnull;
11
12 /**
13  * Class representing a registration of an object. Such a registration is
14  * a proper resource and should be cleaned up when no longer required, so
15  * references to the object can be removed. This mechanism lies above the
16  * usual Java reference mechanism, as the entity where the object is
17  * registered may reside outside of the Java Virtual Machine.
18  */
19 public interface ObjectRegistration<T> extends Registration {
20     /**
21      * Return the object instance.
22      *
23      * @return Registered object.
24      */
25     @Nonnull T getInstance();
26
27     /**
28      * Unregisters the object. This operation is required not to invoke
29      * blocking operations. Implementations which require interaction
30      * with outside world must provide guarantees that any work is done
31      * behind the scenes and the unregistration process looks as if it
32      * has already succeeded once this method returns.
33      */
34     @Override
35     void close() throws Exception;
36 }