NetconfOperationRouter should not expose close()
[netconf.git] / protocol / netconf-server / src / main / java / org / opendaylight / netconf / server / impl / DefaultSessionIdProvider.java
1 /*
2  * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netconf.server.impl;
9
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;
15
16 /**
17  * Default {@link SessionIdProvider}. Counts sessions from the start of the component.
18  */
19 @Singleton
20 @Component(immediate = true, property = "type=default")
21 public final class DefaultSessionIdProvider implements SessionIdProvider {
22     private final AtomicLong sessionCounter = new AtomicLong();
23
24     @Inject
25     public DefaultSessionIdProvider() {
26         // Nothing here
27     }
28
29     @Override
30     public long getNextSessionId() {
31         return sessionCounter.incrementAndGet();
32     }
33
34     @Override
35     public long getCurrentSessionId() {
36         return sessionCounter.get();
37     }
38 }