/* * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ package org.opendaylight.protocol.pcep.impl; import java.util.ArrayList; import java.util.List; import org.opendaylight.protocol.framework.TerminationReason; import org.opendaylight.protocol.pcep.PCEPMessage; import org.opendaylight.protocol.pcep.PCEPSession; import org.opendaylight.protocol.pcep.PCEPSessionListener; import org.opendaylight.protocol.pcep.object.PCEPOpenObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Simple Session Listener that is notified about messages and changes in the session. */ public class SimpleSessionListener extends PCEPSessionListener { public List messages = new ArrayList(); public boolean up = false; private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class); public SimpleSessionListener() { } @Override public void onMessage(final PCEPSession session, final PCEPMessage message) { logger.debug("Received message: {} {}", message.getClass(), message); this.messages.add(message); } @Override public synchronized void onSessionUp(final PCEPSession session, final PCEPOpenObject local, final PCEPOpenObject remote) { logger.debug("Session up."); this.up = true; this.notifyAll(); } @Override public void onSessionDown(final PCEPSession session, final TerminationReason reason, final Exception e) { logger.debug("Session down. Cause: {} or {}", reason, e); this.up = false; // this.notifyAll(); } @Override public void onSessionTerminated(final PCEPSession session, final TerminationReason cause) { logger.debug("Session terminated. Cause : ", cause.toString()); } }