Jian Li | e0e01c2 | 2016-02-09 14:02:49 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 2016 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.provider.of.message.impl; |
| 17 | |
| 18 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; |
| 21 | import org.apache.felix.scr.annotations.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 23 | import org.onosproject.cpman.message.ControlMessageProvider; |
| 24 | import org.onosproject.cpman.message.ControlMessageProviderRegistry; |
| 25 | import org.onosproject.cpman.message.ControlMessageProviderService; |
| 26 | import org.onosproject.net.provider.AbstractProvider; |
| 27 | import org.onosproject.net.provider.ProviderId; |
| 28 | import org.slf4j.Logger; |
| 29 | |
| 30 | import static org.slf4j.LoggerFactory.getLogger; |
| 31 | |
| 32 | /** |
| 33 | * Provider which uses an OpenFlow controller to collect control message. |
| 34 | */ |
| 35 | @Component(immediate = true) |
| 36 | public class OpenFlowControlMessageProvider extends AbstractProvider |
| 37 | implements ControlMessageProvider { |
| 38 | |
| 39 | private static final Logger LOG = getLogger(OpenFlowControlMessageProvider.class); |
| 40 | |
| 41 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 42 | protected ControlMessageProviderRegistry providerRegistry; |
| 43 | |
| 44 | private ControlMessageProviderService providerService; |
| 45 | |
| 46 | /** |
| 47 | * Creates a provider with the supplier identifier. |
| 48 | */ |
| 49 | public OpenFlowControlMessageProvider() { |
| 50 | super(new ProviderId("of", "org.onosproject.provider.openflow")); |
| 51 | } |
| 52 | |
| 53 | @Activate |
| 54 | protected void activate() { |
| 55 | providerService = providerRegistry.register(this); |
| 56 | LOG.info("Started"); |
| 57 | } |
| 58 | |
| 59 | @Deactivate |
| 60 | protected void deactivate() { |
| 61 | providerRegistry.unregister(this); |
| 62 | providerService = null; |
| 63 | LOG.info("Stopped"); |
| 64 | } |
| 65 | } |