20e2ed71a158e596b0102950681cf1f95616277c
[bgpcep.git] / bgp / testtool / src / main / java / org / opendaylight / protocol / bgp / testtool / TestingListener.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.testtool;
9
10 import java.util.Set;
11
12 import org.opendaylight.protocol.bgp.concepts.BGPTableType;
13 import org.opendaylight.protocol.bgp.parser.BGPError;
14 import org.opendaylight.protocol.bgp.parser.BGPMessage;
15 import org.opendaylight.protocol.bgp.parser.BGPSession;
16 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
17 import org.opendaylight.protocol.framework.DispatcherImpl;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22  * Testing BGP Listener.
23  */
24 public class TestingListener extends BGPSessionListener {
25         private static final Logger logger = LoggerFactory.getLogger(TestingListener.class);
26
27         DispatcherImpl d;
28
29         TestingListener(final DispatcherImpl d) {
30                 this.d = d;
31         }
32
33         @Override
34         public void onMessage(final BGPMessage message) {
35                 logger.info("Client Listener: message received: {}", message.toString());
36         }
37
38         @Override
39         public void onSessionUp(final Set<BGPTableType> remoteParams) {
40                 logger.info("Client Listener: Session Up.");
41         }
42
43         @Override
44         public void onSessionDown(final BGPSession session, final Exception e) {
45                 logger.info("Client Listener: Connection lost.");
46                 session.close();
47                 // this.d.stop();
48         }
49
50         @Override
51         public void onSessionTerminated(final BGPError cause) {
52                 logger.info("Client Listener: Connection lost: {}.", cause);
53                 // this.d.stop();
54         }
55 }