Skip to content

Package: ConnectionProbe

ConnectionProbe

Coverage

1: /*
2: * Copyright (c) 2010, 2020 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.glassfish.grizzly;
18:
19: /**
20: * Monitoring probe providing callbacks that may be invoked by Grizzly {@link Connection} implementations.
21: *
22: * @author Alexey Stashok
23: *
24: * @since 2.0
25: */
26: public interface ConnectionProbe {
27:
28: /**
29: * Method will be called, when server side connection gets bound.
30: *
31: * @param connection {@link Connection}, the event belongs to.
32: */
33: void onBindEvent(Connection connection);
34:
35: /**
36: * Method will be called, when server side connection gets accepted.
37: *
38: * @param serverConnection server {@link Connection}, the event belongs to.
39: * @param clientConnection new client {@link Connection}.
40: */
41: void onAcceptEvent(Connection serverConnection, Connection clientConnection);
42:
43: /**
44: * Method will be called, when client side connection gets connected (opened).
45: *
46: * @param connection {@link Connection}, the event belongs to.
47: */
48: void onConnectEvent(Connection connection);
49:
50: /**
51: * Method will be called, when the {@link Connection} has read data.
52: *
53: * @param connection {@link Connection}, the event belongs to.
54: * @param data {@link Buffer}, where the data gets read.
55: * @param size the data size.
56: */
57: void onReadEvent(Connection connection, Buffer data, int size);
58:
59: /**
60: * Method will be called, when the {@link Connection} has written data.
61: *
62: * @param connection {@link Connection}, the event belongs to.
63: * @param data {@link Buffer}, where the data gets writen.
64: * @param size the data size.
65: */
66: void onWriteEvent(Connection connection, Buffer data, long size);
67:
68: /**
69: * Method will be called, when error occurs on the {@link Connection}.
70: *
71: * @param connection {@link Connection}, the event belongs to.
72: * @param error error
73: */
74: void onErrorEvent(Connection connection, Throwable error);
75:
76: /**
77: * Method will be called, when {@link Connection} gets closed.
78: *
79: * @param connection {@link Connection}, the event belongs to.
80: */
81: void onCloseEvent(Connection connection);
82:
83: /**
84: * Method will be called, when {@link IOEvent} for the specific {@link Connection} gets ready.
85: *
86: * @param connection {@link Connection}, the event belongs to.
87: * @param ioEvent {@link IOEvent}.
88: */
89: void onIOEventReadyEvent(Connection connection, IOEvent ioEvent);
90:
91: /**
92: * Method will be called, when {@link IOEvent} for the specific {@link Connection} gets enabled.
93: *
94: * @param connection {@link Connection}, the event belongs to.
95: * @param ioEvent {@link IOEvent}.
96: */
97: void onIOEventEnableEvent(Connection connection, IOEvent ioEvent);
98:
99: /**
100: * Method will be called, when {@link IOEvent} for the specific {@link Connection} gets disabled.
101: *
102: * @param connection {@link Connection}, the event belongs to.
103: * @param ioEvent {@link IOEvent}.
104: */
105: void onIOEventDisableEvent(Connection connection, IOEvent ioEvent);
106:
107: // ---------------------------------------------------------- Nested Classes
108:
109: /**
110: * {@link ConnectionProbe} adapter that provides no-op implementations for all interface methods allowing easy extension
111: * by the developer.
112: *
113: * @since 2.1.9
114: */
115: @SuppressWarnings("UnusedDeclaration")
116: class Adapter implements ConnectionProbe {
117:
118: // ---------------------------------------- Methods from ConnectionProbe
119:
120: /**
121: * {@inheritDoc}
122: */
123: @Override
124: public void onBindEvent(Connection connection) {
125: }
126:
127: /**
128: * {@inheritDoc}
129: */
130: @Override
131: public void onAcceptEvent(Connection serverConnection, Connection clientConnection) {
132: }
133:
134: /**
135: * {@inheritDoc}
136: */
137: @Override
138: public void onConnectEvent(Connection connection) {
139: }
140:
141: /**
142: * {@inheritDoc}
143: */
144: @Override
145: public void onReadEvent(Connection connection, Buffer data, int size) {
146: }
147:
148: /**
149: * {@inheritDoc}
150: */
151: @Override
152: public void onWriteEvent(Connection connection, Buffer data, long size) {
153: }
154:
155: /**
156: * {@inheritDoc}
157: */
158: @Override
159: public void onErrorEvent(Connection connection, Throwable error) {
160: }
161:
162: /**
163: * {@inheritDoc}
164: */
165: @Override
166: public void onCloseEvent(Connection connection) {
167: }
168:
169: /**
170: * {@inheritDoc}
171: */
172: @Override
173: public void onIOEventReadyEvent(Connection connection, IOEvent ioEvent) {
174: }
175:
176: /**
177: * {@inheritDoc}
178: */
179: @Override
180: public void onIOEventEnableEvent(Connection connection, IOEvent ioEvent) {
181: }
182:
183: /**
184: * {@inheritDoc}
185: */
186: @Override
187: public void onIOEventDisableEvent(Connection connection, IOEvent ioEvent) {
188: }
189:
190: } // END Adapter
191:
192: }