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.impl;
10 import com.google.common.collect.Lists;
12 import java.util.List;
14 import org.opendaylight.protocol.pcep.PCEPSession;
15 import org.opendaylight.protocol.pcep.PCEPSessionListener;
16 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * Simple Session Listener that is notified about messages and changes in the session.
24 public class SimpleSessionListener implements PCEPSessionListener {
26 public List<Message> messages = Lists.newArrayList();
28 public boolean up = false;
30 private static final Logger LOG = LoggerFactory.getLogger(SimpleSessionListener.class);
32 public SimpleSessionListener() {
36 public void onMessage(final PCEPSession session, final Message message) {
37 LOG.debug("Received message: {} {}", message.getClass(), message);
38 this.messages.add(message);
42 public synchronized void onSessionUp(final PCEPSession session) {
43 LOG.debug("Session up.");
49 public void onSessionDown(final PCEPSession session, final Exception exception) {
50 LOG.debug("Session down.", exception);
56 public void onSessionTerminated(final PCEPSession session, final PCEPTerminationReason cause) {
57 LOG.debug("Session terminated. Cause : {}", cause.toString());