Debian Codegraph @

proton-j/src/main/java/org/apache/qpid/proton/engine/BaseHandler.java

raw
1 /*
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.proton.engine;
22
23 import java.util.Iterator;
24 import java.util.LinkedHashSet;
25
26
27 /**
28 * BaseHandler
29 *
30 */
31
32 public class BaseHandler implements CoreHandler
33 {
34
35 public static Handler getHandler(Record r) {
36 return r.get(Handler.class, Handler.class);
37 }
38
39 public static void setHandler(Record r, Handler handler) {
40 r.set(Handler.class, Handler.class, handler);
41 }
42
43 public static Handler getHandler(Extendable ext) {
44 return ext.attachments().get(Handler.class, Handler.class);
45 }
46
47 public static void setHandler(Extendable ext, Handler handler) {
48 ext.attachments().set(Handler.class, Handler.class, handler);
49 }
50
51 private LinkedHashSet<Handler> children = new LinkedHashSet<Handler>();
52
53 @Override public void onConnectionInit(Event e) { onUnhandled(e); }
54 @Override public void onConnectionLocalOpen(Event e) { onUnhandled(e); }
55 @Override public void onConnectionRemoteOpen(Event e) { onUnhandled(e); }
56 @Override public void onConnectionLocalClose(Event e) { onUnhandled(e); }
57 @Override public void onConnectionRemoteClose(Event e) { onUnhandled(e); }
58 @Override public void onConnectionBound(Event e) { onUnhandled(e); }
59 @Override public void onConnectionUnbound(Event e) { onUnhandled(e); }
60 @Override public void onConnectionFinal(Event e) { onUnhandled(e); }
61
62 @Override public void onSessionInit(Event e) { onUnhandled(e); }
63 @Override public void onSessionLocalOpen(Event e) { onUnhandled(e); }
64 @Override public void onSessionRemoteOpen(Event e) { onUnhandled(e); }
65 @Override public void onSessionLocalClose(Event e) { onUnhandled(e); }
66 @Override public void onSessionRemoteClose(Event e) { onUnhandled(e); }
67 @Override public void onSessionFinal(Event e) { onUnhandled(e); }
68
69 @Override public void onLinkInit(Event e) { onUnhandled(e); }
70 @Override public void onLinkLocalOpen(Event e) { onUnhandled(e); }
71 @Override public void onLinkRemoteOpen(Event e) { onUnhandled(e); }
72 @Override public void onLinkLocalDetach(Event e) { onUnhandled(e); }
73 @Override public void onLinkRemoteDetach(Event e) { onUnhandled(e); }
74 @Override public void onLinkLocalClose(Event e) { onUnhandled(e); }
75 @Override public void onLinkRemoteClose(Event e) { onUnhandled(e); }
76 @Override public void onLinkFlow(Event e) { onUnhandled(e); }
77 @Override public void onLinkFinal(Event e) { onUnhandled(e); }
78
79 @Override public void onDelivery(Event e) { onUnhandled(e); }
80 @Override public void onTransport(Event e) { onUnhandled(e); }
81 @Override public void onTransportError(Event e) { onUnhandled(e); }
82 @Override public void onTransportHeadClosed(Event e) { onUnhandled(e); }
83 @Override public void onTransportTailClosed(Event e) { onUnhandled(e); }
84 @Override public void onTransportClosed(Event e) { onUnhandled(e); }
85
86 @Override public void onReactorInit(Event e) { onUnhandled(e); }
87 @Override public void onReactorQuiesced(Event e) { onUnhandled(e); }
88 @Override public void onReactorFinal(Event e) { onUnhandled(e); }
89
90 @Override public void onTimerTask(Event e) { onUnhandled(e); }
91
92 @Override public void onSelectableInit(Event e) { onUnhandled(e); }
93 @Override public void onSelectableUpdated(Event e) { onUnhandled(e); }
94 @Override public void onSelectableReadable(Event e) { onUnhandled(e); }
95 @Override public void onSelectableWritable(Event e) { onUnhandled(e); }
96 @Override public void onSelectableExpired(Event e) { onUnhandled(e); }
97 @Override public void onSelectableError(Event e) { onUnhandled(e); }
98 @Override public void onSelectableFinal(Event e) { onUnhandled(e); }
99
100 @Override public void onUnhandled(Event event) {}
101
102 @Override
103 public void add(Handler child) {
104 children.add(child);
105 }
106
107 @Override
108 public Iterator<Handler> children() {
109 return children.iterator();
110 }
111
112 @Override
113 public void handle(Event e) {
114 switch (e.getType()) {
115 case CONNECTION_INIT:
116 onConnectionInit(e);
117 break;
118 case CONNECTION_LOCAL_OPEN:
119 onConnectionLocalOpen(e);
120 break;
121 case CONNECTION_REMOTE_OPEN:
122 onConnectionRemoteOpen(e);
123 break;
124 case CONNECTION_LOCAL_CLOSE:
125 onConnectionLocalClose(e);
126 break;
127 case CONNECTION_REMOTE_CLOSE:
128 onConnectionRemoteClose(e);
129 break;
130 case CONNECTION_BOUND:
131 onConnectionBound(e);
132 break;
133 case CONNECTION_UNBOUND:
134 onConnectionUnbound(e);
135 break;
136 case CONNECTION_FINAL:
137 onConnectionFinal(e);
138 break;
139 case SESSION_INIT:
140 onSessionInit(e);
141 break;
142 case SESSION_LOCAL_OPEN:
143 onSessionLocalOpen(e);
144 break;
145 case SESSION_REMOTE_OPEN:
146 onSessionRemoteOpen(e);
147 break;
148 case SESSION_LOCAL_CLOSE:
149 onSessionLocalClose(e);
150 break;
151 case SESSION_REMOTE_CLOSE:
152 onSessionRemoteClose(e);
153 break;
154 case SESSION_FINAL:
155 onSessionFinal(e);
156 break;
157 case LINK_INIT:
158 onLinkInit(e);
159 break;
160 case LINK_LOCAL_OPEN:
161 onLinkLocalOpen(e);
162 break;
163 case LINK_REMOTE_OPEN:
164 onLinkRemoteOpen(e);
165 break;
166 case LINK_LOCAL_DETACH:
167 onLinkLocalDetach(e);
168 break;
169 case LINK_REMOTE_DETACH:
170 onLinkRemoteDetach(e);
171 break;
172 case LINK_LOCAL_CLOSE:
173 onLinkLocalClose(e);
174 break;
175 case LINK_REMOTE_CLOSE:
176 onLinkRemoteClose(e);
177 break;
178 case LINK_FLOW:
179 onLinkFlow(e);
180 break;
181 case LINK_FINAL:
182 onLinkFinal(e);
183 break;
184 case DELIVERY:
185 onDelivery(e);
186 break;
187 case TRANSPORT:
188 onTransport(e);
189 break;
190 case TRANSPORT_ERROR:
191 onTransportError(e);
192 break;
193 case TRANSPORT_HEAD_CLOSED:
194 onTransportHeadClosed(e);
195 break;
196 case TRANSPORT_TAIL_CLOSED:
197 onTransportTailClosed(e);
198 break;
199 case TRANSPORT_CLOSED:
200 onTransportClosed(e);
201 break;
202 case REACTOR_FINAL:
203 onReactorFinal(e);
204 break;
205 case REACTOR_QUIESCED:
206 onReactorQuiesced(e);
207 break;
208 case REACTOR_INIT:
209 onReactorInit(e);
210 break;
211 case SELECTABLE_ERROR:
212 onSelectableError(e);
213 break;
214 case SELECTABLE_EXPIRED:
215 onSelectableExpired(e);
216 break;
217 case SELECTABLE_FINAL:
218 onSelectableFinal(e);
219 break;
220 case SELECTABLE_INIT:
221 onSelectableInit(e);
222 break;
223 case SELECTABLE_READABLE:
224 onSelectableReadable(e);
225 break;
226 case SELECTABLE_UPDATED:
227 onSelectableWritable(e);
228 break;
229 case SELECTABLE_WRITABLE:
230 onSelectableWritable(e);
231 break;
232 case TIMER_TASK:
233 onTimerTask(e);
234 break;
235 case NON_CORE_EVENT:
236 onUnhandled(e);
237 break;
238 }
239 }
240 }