2 * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.netconf.config;
10 import static java.util.Objects.requireNonNull;
13 import javax.annotation.PreDestroy;
14 import javax.inject.Inject;
15 import javax.inject.Singleton;
16 import org.opendaylight.controller.config.threadpool.ScheduledThreadPool;
17 import org.opendaylight.controller.config.threadpool.util.ScheduledThreadPoolWrapper;
18 import org.osgi.service.component.annotations.Activate;
19 import org.osgi.service.component.annotations.Component;
20 import org.osgi.service.component.annotations.Deactivate;
23 @Component(factory = GlobalNetconfSshScheduledExecutor.FACTORY_NAME, service = ScheduledThreadPool.class)
24 public final class GlobalNetconfSshScheduledExecutor extends ScheduledThreadPoolWrapper {
25 public static final String OSGI_TYPE = "global-netconf-ssh-scheduled-executor";
26 public static final int DEFAULT_MAX_THREAD_COUNT = 8;
28 // OSGi DS Component Factory name
29 static final String FACTORY_NAME = "org.opendaylight.netconf.config.GlobalNetconfSshScheduledExecutor";
31 private static final String PROP_MAX_THREAD_COUNT = ".maxThreadCount";
32 private static final String PROP_THREAD_FACTORY = ".threadFactory";
34 public GlobalNetconfSshScheduledExecutor(final GlobalNetconfThreadFactory threadFactory, final int maxThreadCount) {
35 super(maxThreadCount, threadFactory);
39 public GlobalNetconfSshScheduledExecutor(final GlobalNetconfThreadFactory threadFactory) {
40 this(threadFactory, DEFAULT_MAX_THREAD_COUNT);
44 public GlobalNetconfSshScheduledExecutor(final Map<String, ?> properties) {
45 this(GlobalNetconfConfiguration.extractProp(properties, PROP_THREAD_FACTORY, GlobalNetconfThreadFactory.class),
46 GlobalNetconfConfiguration.extractProp(properties, PROP_MAX_THREAD_COUNT, Integer.class));
56 static Map<String, ?> props(final GlobalNetconfThreadFactory threadFactory, final Configuration configuration) {
59 PROP_MAX_THREAD_COUNT, configuration.max$_$thread$_$count$_$scheduled$_$thread$_$pool(),
60 PROP_THREAD_FACTORY, requireNonNull(threadFactory));