Initial framework migration to netty.
[bgpcep.git] / framework / src / test / java / org / opendaylight / protocol / framework / SimpleSession.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.framework;
9
10 import java.io.IOException;
11
12 public final class SimpleSession implements ProtocolSession {
13
14         private final SessionListener listener;
15
16         private final SessionParent d;
17
18         private final int maxMsgSize;
19
20         public SimpleSession(final ProtocolConnection connection, final SessionParent d, final int maxMsgSize) {
21                 this.listener = connection.getListener();
22                 this.d = d;
23                 this.maxMsgSize = maxMsgSize;
24         }
25
26         @Override
27         public void close() throws IOException {
28                 this.d.onSessionClosed(this);
29         }
30
31         @Override
32         public void startSession() {
33                 ((SimpleSessionListener) this.listener).onSessionUp(this, null, null);
34         }
35
36         @Override
37         public void handleMessage(final ProtocolMessage msg) {
38         }
39
40         @Override
41         public void handleMalformedMessage(final DeserializerException e) {
42         }
43
44         @Override
45         public void handleMalformedMessage(final DocumentedException e) {
46         }
47
48         @Override
49         public void endOfInput() {
50         }
51
52         @Override
53         public ProtocolMessageFactory getMessageFactory() {
54                 return null;
55         }
56
57         @Override
58         public void onConnectionFailed(final IOException e) {
59                 ((SimpleSessionListener) this.listener).onConnectionFailed(this, e);
60         }
61
62         @Override
63         public int maximumMessageSize() {
64                 return this.maxMsgSize;
65         }
66 }