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.server.impl;
10 import java.util.concurrent.atomic.AtomicLong;
11 import javax.inject.Inject;
12 import javax.inject.Singleton;
13 import org.opendaylight.netconf.server.api.SessionIdProvider;
14 import org.osgi.service.component.annotations.Component;
17 * Default {@link SessionIdProvider}. Counts sessions from the start of the component.
20 @Component(immediate = true, property = "type=default")
21 public final class DefaultSessionIdProvider implements SessionIdProvider {
22 private final AtomicLong sessionCounter = new AtomicLong();
25 public DefaultSessionIdProvider() {
30 public long getNextSessionId() {
31 return sessionCounter.incrementAndGet();
35 public long getCurrentSessionId() {
36 return sessionCounter.get();