Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | a09fe5b | 2017-08-03 21:12:30 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Foundation |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.provider; |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 17 | |
tom | 132b58a | 2014-08-28 16:11:28 -0700 | [diff] [blame] | 18 | import java.util.Set; |
| 19 | |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 20 | /** |
tom | 96dfcab | 2014-08-28 09:26:03 -0700 | [diff] [blame] | 21 | * Registry for tracking information providers with the core. |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 22 | * |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 23 | * @param <P> type of the information provider |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 24 | * @param <S> type of the provider service |
| 25 | */ |
tom | 96dfcab | 2014-08-28 09:26:03 -0700 | [diff] [blame] | 26 | public interface ProviderRegistry<P extends Provider, S extends ProviderService<P>> { |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * Registers the supplied provider with the core. |
| 30 | * |
| 31 | * @param provider provider to be registered |
| 32 | * @return provider service for injecting information into core |
tom | b1260e4 | 2014-08-26 18:39:57 -0700 | [diff] [blame] | 33 | * @throws java.lang.IllegalArgumentException if the provider is registered already |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 34 | */ |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 35 | S register(P provider); |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * Unregisters the supplied provider. As a result the previously issued |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 39 | * provider service will be invalidated and any subsequent invocations |
| 40 | * of its methods may throw {@link java.lang.IllegalStateException}. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 41 | * <p> |
tom | b1260e4 | 2014-08-26 18:39:57 -0700 | [diff] [blame] | 42 | * Unregistering a provider that has not been previously registered results |
| 43 | * in a no-op. |
Thomas Vachuska | 4b42077 | 2014-10-30 16:46:17 -0700 | [diff] [blame] | 44 | * </p> |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 45 | * |
| 46 | * @param provider provider to be unregistered |
| 47 | */ |
tom | 64b7aac | 2014-08-26 00:18:21 -0700 | [diff] [blame] | 48 | void unregister(P provider); |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 49 | |
tom | 132b58a | 2014-08-28 16:11:28 -0700 | [diff] [blame] | 50 | /** |
| 51 | * Returns a set of currently registered provider identities. |
| 52 | * |
| 53 | * @return set of provider identifiers |
| 54 | */ |
| 55 | Set<ProviderId> getProviders(); |
| 56 | |
tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 57 | } |