Revert "Checkstyle enforcer"
[controller.git] / opendaylight / protocol_plugins / openflow / src / main / java / org / opendaylight / controller / protocol_plugin / openflow / internal / FlowProgrammerNotifier.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.protocol_plugin.openflow.internal;
10
11 import org.apache.felix.dm.Component;
12 import org.opendaylight.controller.protocol_plugin.openflow.IFlowProgrammerNotifier;
13 import org.opendaylight.controller.sal.core.Node;
14 import org.opendaylight.controller.sal.flowprogrammer.Flow;
15 import org.opendaylight.controller.sal.flowprogrammer.IPluginOutFlowProgrammerService;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 /**
20  * Flow Programmer Notifier class for relaying asynchronous messages received
21  * from the network node to the listeners on the proper container
22  */
23 public class FlowProgrammerNotifier implements IFlowProgrammerNotifier {
24     protected static final Logger logger = LoggerFactory
25             .getLogger(FlowProgrammerNotifier.class);
26     private IPluginOutFlowProgrammerService salNotifier;
27
28     public FlowProgrammerNotifier() {
29         salNotifier = null;
30     }
31
32     void init(Component c) {
33         logger.debug("INIT called!");
34     }
35
36     /**
37      * Function called by the dependency manager when at least one dependency
38      * become unsatisfied or when the component is shutting down because for
39      * example bundle is being stopped.
40      * 
41      */
42     void destroy() {
43         logger.debug("DESTROY called!");
44     }
45
46     /**
47      * Function called by dependency manager after "init ()" is called and after
48      * the services provided by the class are registered in the service registry
49      * 
50      */
51     void start() {
52         logger.debug("START called!");
53     }
54
55     /**
56      * Function called by the dependency manager before the services exported by
57      * the component are unregistered, this will be followed by a "destroy ()"
58      * calls
59      * 
60      */
61     void stop() {
62         logger.debug("STOP called!");
63     }
64
65     public void setPluginOutFlowProgrammerService(
66             IPluginOutFlowProgrammerService s) {
67         this.salNotifier = s;
68     }
69
70     public void unsetPluginOutFlowProgrammerService(
71             IPluginOutFlowProgrammerService s) {
72         if (this.salNotifier == s) {
73             this.salNotifier = null;
74         }
75     }
76
77     @Override
78     public void flowRemoved(Node node, Flow flow) {
79         if (salNotifier != null) {
80             salNotifier.flowRemoved(node, flow);
81         } else {
82             logger.warn("Unable to relay switch message to upper layer");
83         }
84     }
85
86     @Override
87     public void flowErrorReported(Node node, long rid, Object err) {
88         if (salNotifier != null) {
89             salNotifier.flowErrorReported(node, rid, err);
90         } else {
91             logger.warn("Unable to relay switch error message to upper layer");
92         }
93     }
94
95 }