blob: d1325ee618df1cdb0f864a7b43f0a26a9dc7e0cd [file] [log] [blame]
Jian Lie0e01c22016-02-09 14:02:49 -08001/*
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 */
16package org.onosproject.provider.of.message.impl;
17
18import org.apache.felix.scr.annotations.Activate;
19import org.apache.felix.scr.annotations.Component;
20import org.apache.felix.scr.annotations.Deactivate;
21import org.apache.felix.scr.annotations.Reference;
22import org.apache.felix.scr.annotations.ReferenceCardinality;
23import org.onosproject.cpman.message.ControlMessageProvider;
24import org.onosproject.cpman.message.ControlMessageProviderRegistry;
25import org.onosproject.cpman.message.ControlMessageProviderService;
26import org.onosproject.net.provider.AbstractProvider;
27import org.onosproject.net.provider.ProviderId;
28import org.slf4j.Logger;
29
30import static org.slf4j.LoggerFactory.getLogger;
31
32/**
33 * Provider which uses an OpenFlow controller to collect control message.
34 */
35@Component(immediate = true)
36public 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}