Switched BGPMessage concept to yangtools.binding.Notification.
[bgpcep.git] / bgp / rib-impl / src / test / java / org / opendaylight / protocol / bgp / rib / impl / SimpleSessionListener.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.protocol.bgp.rib.impl;
9
10 import java.util.List;
11
12 import org.opendaylight.protocol.bgp.parser.BGPSession;
13 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
14 import org.opendaylight.protocol.bgp.parser.BGPTerminationReason;
15 import org.opendaylight.yangtools.yang.binding.Notification;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 import com.google.common.collect.Lists;
20
21 /**
22  * Listener for the client.
23  */
24 public class SimpleSessionListener implements BGPSessionListener {
25
26         private final List<Notification> listMsg = Lists.newArrayList();
27
28         public boolean up = false;
29
30         private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class);
31
32         public boolean down = false;
33
34         public List<Notification> getListMsg() {
35                 return this.listMsg;
36         }
37
38         @Override
39         public void onMessage(final BGPSession session, final Notification message) {
40                 this.listMsg.add(message);
41                 logger.debug("Message received:" + message);
42         }
43
44         @Override
45         public void onSessionUp(final BGPSession session) {
46                 logger.debug("Session Up");
47                 this.up = true;
48         }
49
50         @Override
51         public void onSessionDown(final BGPSession session, final Exception e) {
52                 logger.debug("Session Down", e);
53                 this.down = true;
54         }
55
56         @Override
57         public void onSessionTerminated(final BGPSession session, final BGPTerminationReason cause) {
58                 logger.debug("Session terminated. Cause : " + cause.toString());
59         }
60 }