Add shutdown hook.
[controller.git] / opendaylight / config / shutdown-impl / src / main / java / org / opendaylight / controller / config / yang / shutdown / impl / ShutdownModule.java
diff --git a/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModule.java b/opendaylight/config/shutdown-impl/src/main/java/org/opendaylight/controller/config/yang/shutdown/impl/ShutdownModule.java
new file mode 100644 (file)
index 0000000..f6937f9
--- /dev/null
@@ -0,0 +1,91 @@
+/**
+ * Generated file
+
+ * Generated from: yang module name: shutdown-impl  yang module local name: shutdown
+ * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ * Generated at: Wed Dec 18 14:02:06 CET 2013
+ *
+ * Do not modify this file unless it is present under src/main directory
+ */
+package org.opendaylight.controller.config.yang.shutdown.impl;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttributeValidationException;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.osgi.framework.Bundle;
+
+public final class ShutdownModule extends AbstractShutdownModule {
+    private final Bundle systemBundle;
+    private final ShutdownModule nullableOldModule;
+
+    public ShutdownModule(ModuleIdentifier identifier, Bundle systemBundle) {
+        super(identifier, null);
+        singletonCheck(identifier);
+        this.systemBundle = systemBundle;
+        this.nullableOldModule = null;
+    }
+
+    public ShutdownModule(ModuleIdentifier identifier, ShutdownModule oldModule, java.lang.AutoCloseable oldInstance,
+                          Bundle systemBundle) {
+        super(identifier, null, oldModule, oldInstance);
+        singletonCheck(identifier);
+        this.systemBundle = systemBundle;
+        this.nullableOldModule = oldModule;
+    }
+
+    private static void singletonCheck(ModuleIdentifier identifier) {
+        if (AbstractShutdownModuleFactory.NAME.equals(identifier.getInstanceName()) == false) {
+            throw new IllegalArgumentException("Singleton enforcement failed. Expected instance name " + AbstractShutdownModuleFactory.NAME);
+        }
+    }
+
+    @Deprecated // needed for generated code
+    public ShutdownModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver, ShutdownModule oldModule,
+                          AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+        throw new UnsupportedOperationException();
+    }
+
+    @Deprecated // needed for generated code
+    public ShutdownModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String getSecret() {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public String getOldSecret() {
+        throw new UnsupportedOperationException();
+    }
+
+    String getActualSecret() {
+        return super.getSecret();
+    }
+
+    String getActualOldSecret() {
+        return super.getOldSecret();
+    }
+
+    @Override
+    protected void customValidation() {
+        JmxAttributeValidationException.checkNotNull(super.getOldSecret(), oldSecretJmxAttribute);
+        JmxAttributeValidationException.checkNotNull(super.getSecret(), secretJmxAttribute);
+        if (nullableOldModule != null) {
+            // if nothing changed, remain valid
+            boolean sameAsOldModule = isSame(nullableOldModule);
+            if (sameAsOldModule == false) {
+                boolean valid = getActualOldSecret().equals(nullableOldModule.getActualSecret());
+                JmxAttributeValidationException.checkCondition(valid, "Invalid old secret", oldSecretJmxAttribute);
+            }
+        }
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        return new ShutdownServiceImpl(getActualSecret(), systemBundle, getRootRuntimeBeanRegistratorWrapper());
+    }
+}