Merge branch 'master' of ../infrautils
[odlguice.git] / inject / src / main / java / org / opendaylight / infrautils / inject / Lifecycle.java
diff --git a/inject/src/main/java/org/opendaylight/infrautils/inject/Lifecycle.java b/inject/src/main/java/org/opendaylight/infrautils/inject/Lifecycle.java
new file mode 100644 (file)
index 0000000..81a6a0a
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Red Hat, 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.infrautils.inject;
+
+/**
+ * Something which can be {@link #init()}-ialized and {@link #destroy()}-d.
+ *
+ * <p>Annotated so that Dependency Injection Frameworks (whichever) automatically call these methods during wiring.
+ *
+ * @see AbstractLifecycle
+ *
+ * @author Michael Vorburger
+ */
+public interface Lifecycle {
+
+    /**
+     * Initialize the object.
+     *
+     * @throws ModuleSetupRuntimeException if initialization failed
+     */
+    void init() throws ModuleSetupRuntimeException;
+
+    /**
+     * Destroy the object.
+     *
+     * @throws ModuleSetupRuntimeException if destruction failed
+     */
+    void destroy() throws ModuleSetupRuntimeException;
+
+    boolean isRunning();
+
+}