Jian Li | 6322a36 | 2016-10-31 00:57:19 +0900 | [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 | package org.onosproject.lisp.ctl; |
| 17 | |
| 18 | import org.apache.felix.scr.annotations.Component; |
| 19 | import org.apache.felix.scr.annotations.Reference; |
| 20 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 21 | import org.apache.felix.scr.annotations.Service; |
| 22 | import org.apache.felix.scr.annotations.Activate; |
| 23 | import org.apache.felix.scr.annotations.Deactivate; |
| 24 | |
| 25 | import org.onosproject.core.CoreService; |
| 26 | import org.onosproject.lisp.LispController; |
| 27 | import org.onosproject.net.device.DeviceService; |
| 28 | import org.slf4j.Logger; |
| 29 | import org.slf4j.LoggerFactory; |
| 30 | |
| 31 | /** |
| 32 | * LISP controller initiation class. |
| 33 | */ |
| 34 | @Component(immediate = true) |
| 35 | @Service |
| 36 | public class LispControllerImpl implements LispController { |
| 37 | |
| 38 | private static final String APP_ID = "org.onosproject.lisp-base"; |
| 39 | |
| 40 | private static final Logger log = |
| 41 | LoggerFactory.getLogger(LispControllerImpl.class); |
| 42 | |
| 43 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 44 | protected CoreService coreService; |
| 45 | |
| 46 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 47 | protected DeviceService deviceService; |
| 48 | |
| 49 | private final LispControllerBootstrap bootstrap = new LispControllerBootstrap(); |
| 50 | |
| 51 | @Activate |
| 52 | public void activate() { |
| 53 | coreService.registerApplication(APP_ID); |
| 54 | bootstrap.start(); |
| 55 | log.info("Started"); |
| 56 | } |
| 57 | |
| 58 | @Deactivate |
| 59 | public void deactivate() { |
| 60 | bootstrap.stop(); |
| 61 | log.info("Stopped"); |
| 62 | } |
| 63 | } |