Convert netty-threadgroup-config to OSGi DS
[controller.git] / opendaylight / config / netty-threadgroup-config / src / main / java / org / opendaylight / controller / config / yang / netty / threadgroup / GlobalBossGroup.java
diff --git a/opendaylight/config/netty-threadgroup-config/src/main/java/org/opendaylight/controller/config/yang/netty/threadgroup/GlobalBossGroup.java b/opendaylight/config/netty-threadgroup-config/src/main/java/org/opendaylight/controller/config/yang/netty/threadgroup/GlobalBossGroup.java
new file mode 100644 (file)
index 0000000..5b46184
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2021 PANTHEON.tech, s.r.o. 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.controller.config.yang.netty.threadgroup;
+
+import io.netty.channel.EventLoopGroup;
+import org.osgi.service.component.annotations.Activate;
+import org.osgi.service.component.annotations.Component;
+import org.osgi.service.component.annotations.Deactivate;
+import org.osgi.service.metatype.annotations.Designate;
+
+@Component(immediate = true, service = EventLoopGroup.class, property = "type=global-boss-group")
+@Designate(ocd = Configuration.class)
+public final class GlobalBossGroup extends AbstractGlobalGroup {
+    @Activate
+    public GlobalBossGroup(final Configuration configuration) {
+        super(configuration.bossThreadCount());
+    }
+
+    @Deactivate
+    void deactivate() {
+        close();
+    }
+}