Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2016-present Open Networking Laboratory |
| 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 | */ |
| 16 | |
| 17 | package org.onosproject.bmv2.api.service; |
| 18 | |
| 19 | import org.onosproject.bmv2.api.context.Bmv2DeviceContext; |
| 20 | import org.onosproject.bmv2.api.context.Bmv2Interpreter; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | |
| 23 | /** |
| 24 | * A service for managing BMv2 device contexts. |
| 25 | */ |
| 26 | public interface Bmv2DeviceContextService { |
| 27 | |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 28 | /** |
Carmelo Cascone | c18e82c | 2016-06-16 14:22:36 -0700 | [diff] [blame^] | 29 | * Returns the context of the given device, null if no context has been previously set. |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 30 | * |
| 31 | * @param deviceId a device ID |
| 32 | * @return a BMv2 device context |
| 33 | */ |
| 34 | Bmv2DeviceContext getContext(DeviceId deviceId); |
| 35 | |
| 36 | /** |
Carmelo Cascone | c18e82c | 2016-06-16 14:22:36 -0700 | [diff] [blame^] | 37 | * Sets the context for the given device. |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 38 | * |
| 39 | * @param deviceId a device ID |
| 40 | * @param context a BMv2 device context |
| 41 | */ |
Carmelo Cascone | c18e82c | 2016-06-16 14:22:36 -0700 | [diff] [blame^] | 42 | void setContext(DeviceId deviceId, Bmv2DeviceContext context); |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 43 | |
| 44 | /** |
| 45 | * Binds the given interpreter with the given class loader so that other ONOS instances in the cluster can properly |
| 46 | * load the interpreter. |
| 47 | * |
| 48 | * @param interpreterClass an interpreter class |
| 49 | * @param loader a class loader |
| 50 | */ |
| 51 | void registerInterpreterClassLoader(Class<? extends Bmv2Interpreter> interpreterClass, ClassLoader loader); |
| 52 | |
| 53 | /** |
Carmelo Cascone | c18e82c | 2016-06-16 14:22:36 -0700 | [diff] [blame^] | 54 | * Returns a default context. |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 55 | * |
Carmelo Cascone | c18e82c | 2016-06-16 14:22:36 -0700 | [diff] [blame^] | 56 | * @return a BMv2 device context |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 57 | */ |
Carmelo Cascone | c18e82c | 2016-06-16 14:22:36 -0700 | [diff] [blame^] | 58 | Bmv2DeviceContext defaultContext(); |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 59 | } |