Remove callhome-server
[netconf.git] / apps / callhome-provider / src / main / java / org / opendaylight / netconf / callhome / server / CallHomeSessionContextManager.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.callhome.server;
9
10 import io.netty.channel.Channel;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.eclipse.jdt.annotation.Nullable;
13
14 /**
15  * Manager service for active Call-Home connections. Serves session context per id mapping (registry).
16  *
17  * @param <T> class representing transport specific implementation of {@link CallHomeSessionContext}
18  */
19 public interface CallHomeSessionContextManager<T extends CallHomeSessionContext> extends AutoCloseable {
20
21     /**
22      * Checks if contexts with same id already defined.
23      *
24      * @param id unique session context identifier
25      * @return {@code true} if context with same id exists in registry, {@code false} otherwise
26      */
27     boolean exists(@NonNull String id);
28
29     /**
30      * Registers (maps) new context object.
31      *
32      * @param context context object associated with new incoming connection
33      */
34     void register(T context);
35
36     /**
37      * Searches for session context associated with requested {@link Channel}.
38      *
39      * @param channel {@link Channel} instance
40      * @return session context instance if found, {@code null} otherwise
41      */
42     @Nullable T findByChannel(@NonNull Channel channel);
43
44     /**
45      * Removes session context by id from registry. Connection associated with removed context will be closed if open.
46      *
47      * @param id unique session context identifier
48      */
49     void remove(@NonNull String id);
50 }