<groupId>${project.groupId}</groupId>
<artifactId>netconf-impl</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ </dependency>
</dependencies>
<build>
<reference id="scheduledThreadPool"
interface="org.opendaylight.controller.config.threadpool.ScheduledThreadPool"
odl:type="global-netconf-ssh-scheduled-executor"/>
+ <reference id="sessionIdProvider"
+ interface="org.opendaylight.netconf.impl.SessionIdProvider"/>
<cm:property-placeholder persistent-id="org.opendaylight.netconf.impl" update-strategy="none">
<cm:default-properties>
<!--NetconfServerDispatcher -->
- <bean id="sessionIdProvider"
- class="org.opendaylight.netconf.impl.SessionIdProvider"/>
-
<bean id="aggregatedNetconfOperationServiceFactoryMappers"
class="org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory"
destroy-method="close">
import org.opendaylight.netconf.api.capability.Capability;
import org.opendaylight.netconf.api.capability.YangModuleCapability;
import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService;
+import org.opendaylight.netconf.impl.DefaultSessionIdProvider;
import org.opendaylight.netconf.impl.NetconfServerDispatcherImpl;
import org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory;
import org.opendaylight.netconf.impl.ServerChannelInitializer;
}));
transformedCapabilities.add(new BasicCapability("urn:ietf:params:netconf:capability:candidate:1.0"));
final NetconfMonitoringService monitoringService1 = new DummyMonitoringService(transformedCapabilities);
- final SessionIdProvider idProvider = new SessionIdProvider();
+ final SessionIdProvider idProvider = new DefaultSessionIdProvider();
final NetconfOperationServiceFactory aggregatedNetconfOperationServiceFactory = createOperationServiceFactory(
sourceProvider, transformedCapabilities, monitoringService1, idProvider);
<packaging>bundle</packaging>
<dependencies>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>threadpool-config-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.netconf.model</groupId>
<artifactId>rfc6022</artifactId>
</dependency>
- <!-- compile dependencies -->
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-api</artifactId>
<artifactId>netconf-util</artifactId>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
+ <groupId>com.guicedee.services</groupId>
+ <artifactId>javax.inject</artifactId>
+ <optional>true</optional>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>threadpool-config-api</artifactId>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
- <!-- test dependencies -->
+
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>mockito-configuration</artifactId>
</dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>netconf-client</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-legacy</artifactId>
--- /dev/null
+/*
+ * Copyright (c) 2023 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.netconf.impl;
+
+import java.util.concurrent.atomic.AtomicLong;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * Default {@link SessionIdProvider}. Counts sessions from the start of the component.
+ */
+@Singleton
+@Component(immediate = true, property = "type=default")
+public final class DefaultSessionIdProvider implements SessionIdProvider {
+ private final AtomicLong sessionCounter = new AtomicLong();
+
+ @Inject
+ public DefaultSessionIdProvider() {
+ // Nothing here
+ }
+
+ @Override
+ public long getNextSessionId() {
+ return sessionCounter.incrementAndGet();
+ }
+
+ @Override
+ public long getCurrentSessionId() {
+ return sessionCounter.get();
+ }
+}
* 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.netconf.impl;
-import java.util.concurrent.atomic.AtomicLong;
-
-public final class SessionIdProvider {
-
- private final AtomicLong sessionCounter = new AtomicLong(0);
+public interface SessionIdProvider {
- public long getNextSessionId() {
- return sessionCounter.incrementAndGet();
- }
+ long getNextSessionId();
- public long getCurrentSessionId() {
- return sessionCounter.get();
- }
+ long getCurrentSessionId();
}
factoriesListener.onAddNetconfOperationServiceFactory(
new TestingOperationServiceFactory(testingNetconfOperation));
- SessionIdProvider idProvider = new SessionIdProvider();
+ SessionIdProvider idProvider = new DefaultSessionIdProvider();
NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = new
NetconfServerSessionNegotiatorFactoryBuilder()
* 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.netconf.impl;
import io.netty.channel.ChannelFuture;
import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory;
public class NetconfDispatcherImplTest {
-
private EventLoopGroup nettyGroup;
private NetconfServerDispatcherImpl dispatch;
private HashedWheelTimer hashedWheelTimer;
-
@Before
public void setUp() throws Exception {
nettyGroup = new NioEventLoopGroup();
AggregatedNetconfOperationServiceFactory factoriesListener = new AggregatedNetconfOperationServiceFactory();
- SessionIdProvider idProvider = new SessionIdProvider();
+ SessionIdProvider idProvider = new DefaultSessionIdProvider();
hashedWheelTimer = new HashedWheelTimer();
NetconfServerSessionNegotiatorFactory serverNegotiatorFactory =