2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.pcep.testtool;
10 import com.google.common.collect.Lists;
11 import java.util.List;
12 import org.opendaylight.protocol.pcep.PCEPSession;
13 import org.opendaylight.protocol.pcep.PCEPSessionListener;
14 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
20 * Simple Session Listener that is notified about messages and changes in the session.
22 public class SimpleSessionListener implements PCEPSessionListener {
24 private List<Message> messages = Lists.newArrayList();
26 private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class);
28 public SimpleSessionListener() {
32 public void onMessage(final PCEPSession session, final Message message) {
33 LOG.debug("Received message: {}", message);
34 this.messages.add(message);
38 public void onSessionUp(final PCEPSession session) {
39 LOG.debug("Session up.");
43 public void onSessionDown(final PCEPSession session, final Exception exception) {
44 LOG.debug("Session down with cause : {} or exception: {}", exception.getCause(), exception, exception);
47 } catch (Exception ie) {
48 LOG.warn("Error closing session", ie);
53 public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
54 LOG.debug("Session terminated. Cause : {}", cause.toString());