Ray Milkey | 2d572dd | 2017-04-14 10:01:24 -0700 | [diff] [blame^] | 1 | /* |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Ray Milkey | 2d572dd | 2017-04-14 10:01:24 -0700 | [diff] [blame^] | 3 | * |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 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 |
Ray Milkey | 2d572dd | 2017-04-14 10:01:24 -0700 | [diff] [blame^] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.kafkaintegration.api; |
| 17 | |
Shravan Ambati | 5a11e17 | 2016-07-21 15:55:28 -0700 | [diff] [blame] | 18 | import java.util.List; |
| 19 | |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 20 | import org.onosproject.kafkaintegration.api.dto.EventSubscriber; |
Sanjana Agarwal | cb4a3db | 2016-07-14 11:42:48 -0700 | [diff] [blame] | 21 | import org.onosproject.kafkaintegration.api.dto.OnosEvent.Type; |
Shravan Ambati | 5a11e17 | 2016-07-21 15:55:28 -0700 | [diff] [blame] | 22 | import org.onosproject.kafkaintegration.api.dto.RegistrationResponse; |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 23 | import org.onosproject.kafkaintegration.errors.InvalidApplicationException; |
| 24 | import org.onosproject.kafkaintegration.errors.InvalidGroupIdException; |
Shravan Ambati | bb6b445 | 2016-05-04 13:25:28 -0700 | [diff] [blame] | 25 | |
| 26 | import com.google.common.annotations.Beta; |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 27 | |
| 28 | /** |
| 29 | * APIs for subscribing to Onos Event Messages. |
| 30 | */ |
Shravan Ambati | bb6b445 | 2016-05-04 13:25:28 -0700 | [diff] [blame] | 31 | @Beta |
Sanjana Agarwal | cb4a3db | 2016-07-14 11:42:48 -0700 | [diff] [blame] | 32 | public interface EventSubscriptionService { |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Registers the external application to receive events generated in ONOS. |
| 36 | * |
| 37 | * @param appName Application Name |
Shravan Ambati | 5a11e17 | 2016-07-21 15:55:28 -0700 | [diff] [blame] | 38 | * @return Registration Response DTO. |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 39 | */ |
Shravan Ambati | 5a11e17 | 2016-07-21 15:55:28 -0700 | [diff] [blame] | 40 | RegistrationResponse registerListener(String appName); |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 41 | |
| 42 | /** |
| 43 | * Removes the Registered Listener. |
| 44 | * |
| 45 | * @param appName Application Name |
| 46 | */ |
| 47 | void unregisterListener(String appName); |
| 48 | |
| 49 | /** |
| 50 | * Allows registered listener to subscribe for a specific event type. |
| 51 | * |
| 52 | * @param subscriber Subscription data containing the event type |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 53 | * @throws InvalidGroupIdException |
| 54 | * @throws InvalidApplicationException |
| 55 | */ |
| 56 | void subscribe(EventSubscriber subscriber) |
Shravan Ambati | bb6b445 | 2016-05-04 13:25:28 -0700 | [diff] [blame] | 57 | throws InvalidGroupIdException, InvalidApplicationException; |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 58 | |
| 59 | /** |
| 60 | * Allows the registered listener to unsubscribe for a specific event. |
| 61 | * |
| 62 | * @param subscriber Subscription data containing the event type |
| 63 | * @throws InvalidGroupIdException |
| 64 | * @throws InvalidApplicationException |
| 65 | */ |
| 66 | void unsubscribe(EventSubscriber subscriber) |
| 67 | throws InvalidGroupIdException, InvalidApplicationException; |
Sanjana Agarwal | cb4a3db | 2016-07-14 11:42:48 -0700 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * Returns the event subscriber for various event types. |
| 71 | * |
| 72 | * @param type ONOS event type. |
| 73 | * @return List of event subscribers |
| 74 | */ |
| 75 | List<EventSubscriber> getEventSubscribers(Type type); |
Shravan Ambati | 7d19954 | 2016-04-22 16:09:05 -0700 | [diff] [blame] | 76 | } |