Migrate test-provider to CompositeListener
[openflowplugin.git] / test-provider / src / main / java / org / opendaylight / openflowplugin / test / FlowEventListenerLoggingImpl.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 package org.opendaylight.openflowplugin.test;
9
10 import java.util.Set;
11 import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener;
12 import org.opendaylight.mdsal.binding.api.NotificationService.CompositeListener.Component;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * Dummy implementation flushing events into log.
23  */
24 @Deprecated
25 public final class FlowEventListenerLoggingImpl {
26     private static final Logger LOG = LoggerFactory.getLogger(FlowEventListenerLoggingImpl.class);
27
28     private FlowEventListenerLoggingImpl() {
29         // Hidden on purpose
30     }
31
32     static CompositeListener newListener() {
33         return new CompositeListener(Set.of(
34             new Component<>(FlowAdded.class, notification -> {
35                 LOG.info("flow to be added {}", notification);
36                 LOG.info("added flow Xid {}", notification.getTransactionId().getValue());
37             }),
38             new Component<>(FlowRemoved.class, notification -> {
39                 LOG.debug("removed flow {}", notification);
40                 LOG.debug("remove flow Xid {}", notification.getTransactionId().getValue());
41             }),
42             new Component<>(FlowUpdated.class, notification -> {
43                 LOG.debug("updated flow {}", notification);
44                 LOG.debug("updated flow Xid {}", notification.getTransactionId().getValue());
45             }),
46             new Component<>(NodeErrorNotification.class, notification -> {
47                 //commenting as we have a NodeErrorListener
48                 /*    LOG.error("Error notification  flow Xid........................."
49                             + notification.getTransactionId().getValue());
50                     LOG.debug("notification Begin-Transaction:"
51                             + notification.getTransactionUri()
52                             + "-----------------------------------------------------------------------------------");
53                 */
54             }),
55             new Component<>(SwitchFlowRemoved.class, notification -> {
56                 LOG.debug("Switch flow removed : Cookies {}", notification.getCookie().toString());
57             })));
58     }
59 }