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.framework;
10 import java.io.Closeable;
11 import java.io.IOException;
14 * Protocol Session represents the finite state machine in underlying protocol, including timers and its purpose is to
15 * create a connection between server and client. Session is automatically started, when TCP connection is created, but
16 * can be stopped manually. If the session is up, it has to redirect messages to/from user. Handles also malformed
17 * messages and unknown requests.
19 * This interface should be implemented by a final class representing a protocol specific session.
21 public interface ProtocolSession extends Closeable {
24 * Starts the session. This method should be used only internally by the Dispatcher.
26 public void startSession();
29 * Handles incoming message (parsing, reacting if necessary).
31 * @param msg incoming message
33 public void handleMessage(final ProtocolMessage msg);
36 * Handles malformed message when a deserializer exception occurred. The handling might be different from when a
37 * documented exception is thrown.
39 * @param e deserializer exception that occurred
41 public void handleMalformedMessage(final DeserializerException e);
44 * Handles malformed message when a documented exception occurred. The handling might be different from when a
45 * deserializer exception is thrown.
47 * @param e documented exception that occurred
49 public void handleMalformedMessage(final DocumentedException e);
52 * Called when reached the end of input stream while reading.
54 public void endOfInput();
57 * Getter for message factory
59 * @return protocol specific message factory
61 public ProtocolMessageFactory getMessageFactory();
64 * Session is notified about the connection not being established successfully.
66 * @param e IOException that was the cause of failed connection.
68 public void onConnectionFailed(final IOException e);
71 * Returns the maximum message size (in bytes) for purposes of dispatcher buffering -- the dispatcher allocates a
72 * buffer this big, and if it gets full without making decoding progress, the dispatcher terminates the session.
74 * @return maximum message size
76 public int maximumMessageSize();