-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
- <parent>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools</artifactId>
- <version>0.1.1-SNAPSHOT</version>
- </parent>
- <packaging>bundle</packaging>
- <modelVersion>4.0.0</modelVersion>
- <artifactId>concepts</artifactId>
- <name>Concepts</name>
- <description>Java binding for YANG</description>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
-</project>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
+\r
+ <parent>\r
+ <groupId>org.opendaylight.yangtools</groupId>\r
+ <artifactId>yangtools</artifactId>\r
+ <version>0.1.1-SNAPSHOT</version>\r
+ </parent>\r
+ <packaging>bundle</packaging>\r
+ <modelVersion>4.0.0</modelVersion>\r
+ <artifactId>concepts</artifactId>\r
+ <name>Concepts</name>\r
+ <description>Java binding for YANG</description>\r
+\r
+ <build>\r
+ <plugins>\r
+ <plugin>\r
+ <groupId>org.apache.felix</groupId>\r
+ <artifactId>maven-bundle-plugin</artifactId>\r
+ </plugin>\r
+ </plugins>\r
+ </build>\r
+</project>\r
--- /dev/null
+package org.opendaylight.yangtools.concepts;\r
+\r
+/**\r
+ * Utility registration handle. It is a convenience for register-style method\r
+ * which can return an AutoCloseable realized by a subclass of this class.\r
+ * Invoking the close() method triggers unregistration of the state the method\r
+ * installed.\r
+ */\r
+public abstract class AbstractRegistration<T> implements Registration<T> {\r
+\r
+ private boolean closed = false;\r
+ private final T instance;\r
+\r
+ public AbstractRegistration(T instance) {\r
+ this.instance = instance;\r
+ }\r
+\r
+ @Override\r
+ public T getInstance() {\r
+ return instance;\r
+ }\r
+\r
+ /**\r
+ * Remove the state referenced by this registration. This method is\r
+ * guaranteed to be called at most once. The referenced state must be\r
+ * retained until this method is invoked.\r
+ */\r
+ protected abstract void removeRegistration();\r
+\r
+ @Override\r
+ public void close() throws Exception {\r
+ if (!closed) {\r
+ closed = true;\r
+ removeRegistration();\r
+ }\r
+ }\r
+\r
+}\r
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.concepts;
-
-/**
- * Builder object which produces a product.
- *
- * @param <P> Product of builder
- *
- * @author Tony Tkacik <ttkacik@cisco.com>
- */
-public interface Builder<P> extends Mutable {
- P toInstance();
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.concepts;\r
+\r
+/**\r
+ * Builder object which produces a product.\r
+ * \r
+ * @param <P> Product of builder\r
+ * \r
+ * @author Tony Tkacik <ttkacik@cisco.com>\r
+ */\r
+public interface Builder<P> extends Mutable {\r
+ P toInstance();\r
+}\r
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.concepts;
-
-public interface Identifiable<T> {
- T getIdentifier();
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.concepts;\r
+\r
+public interface Identifiable<T> {\r
+ T getIdentifier();\r
+}\r
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.concepts;
-
-import java.io.Serializable;
-
-/**
- * General identifier interface. It is primarily a marker for all things that
- * identify concepts -- such as names, addresses, classes, etc. We do not
- * require too much, just that the identifiers are serializable (and this
- * transferable).
- */
-public interface Identifier extends Serializable, Immutable {
-
-}
-
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.concepts;\r
+\r
+import java.io.Serializable;\r
+\r
+/**\r
+ * General identifier interface. It is primarily a marker for all things that\r
+ * identify concepts -- such as names, addresses, classes, etc. We do not\r
+ * require too much, just that the identifiers are serializable (and this\r
+ * transferable).\r
+ */\r
+public interface Identifier extends Serializable, Immutable {\r
+\r
+}\r
+\r
--- /dev/null
+package org.opendaylight.yangtools.concepts;\r
+\r
+import java.util.EventListener;\r
+\r
+public interface ListenerRegistration<T extends EventListener> extends Registration<T> {\r
+\r
+}\r
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.concepts;
-
-/**
- * Mutable object - object may change it's state during lifecycle.
- *
- * This interface is mutually exclusive with {@link Immutable} and other
- * {@link MutationBehaviour}s.
- *
- * @author Tony Tkacik <ttkacik@cisco.com>
- *
- */
-public interface Mutable extends MutationBehaviour<Mutable>{
-
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.concepts;\r
+\r
+/**\r
+ * Mutable object - object may change it's state during lifecycle.\r
+ * \r
+ * This interface is mutually exclusive with {@link Immutable} and other\r
+ * {@link MutationBehaviour}s.\r
+ * \r
+ * @author Tony Tkacik <ttkacik@cisco.com>\r
+ *\r
+ */\r
+public interface Mutable extends MutationBehaviour<Mutable>{\r
+ \r
+}\r
-package org.opendaylight.yangtools.concepts;
-
-import java.util.Set;
-
-public interface Namespace<K,V> {
-
- V get(K key);
-
- Namespace<K,V> getParent();
- Set<Namespace<K,V>> getSubnamespaces();
- Namespace<K,V> getSubnamespace(V key);
-}
+package org.opendaylight.yangtools.concepts;\r
+\r
+import java.util.Set;\r
+\r
+public interface Namespace<K,V> {\r
+ \r
+ V get(K key);\r
+ \r
+ Namespace<K,V> getParent();\r
+ Set<Namespace<K,V>> getSubnamespaces();\r
+ Namespace<K,V> getSubnamespace(V key);\r
+}\r
-package org.opendaylight.yangtools.concepts;
-import java.util.List;
-import java.util.Set;
-
-
-public interface OrderedSet<E> extends Set<E>,List<E> {
-
-
-}
+package org.opendaylight.yangtools.concepts;\r
+import java.util.List;\r
+import java.util.Set;\r
+\r
+\r
+public interface OrderedSet<E> extends Set<E>,List<E> {\r
+\r
+ \r
+}\r
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.concepts;
-
-public interface Path<P extends Path<P>> {
-
- boolean contains(P other);
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.concepts;\r
+\r
+public interface Path<P extends Path<P>> {\r
+\r
+ boolean contains(P other);\r
+}\r
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.concepts;
-
-public interface Registration<T> {
-
- T getInstance();
- void unregister();
-}
+/*\r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.\r
+ *\r
+ * This program and the accompanying materials are made available under the\r
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
+ * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ */\r
+package org.opendaylight.yangtools.concepts;\r
+\r
+public interface Registration<T> extends AutoCloseable {\r
+\r
+ T getInstance();\r
+\r
+ /**\r
+ * Unregisters object\r
+ * \r
+ */\r
+ @Override\r
+ public void close() throws Exception;\r
+}\r