Debian Codegraph @

proton-j/src/main/java/org/apache/qpid/proton/engine/Event.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 org.apache.qpid.proton.reactor.Reactor;
24 import org.apache.qpid.proton.reactor.Selectable;
25 import org.apache.qpid.proton.reactor.Task;
26
27
28 /**
29 * Event
30 *
31 */
32
33 public interface Event extends Extendable
34 {
35 /**
36 * Event types built into the library.
37 */
38 public enum Type implements EventType {
39 REACTOR_INIT,
40 REACTOR_QUIESCED,
41 REACTOR_FINAL,
42
43 TIMER_TASK,
44
45 CONNECTION_INIT,
46 CONNECTION_BOUND,
47 CONNECTION_UNBOUND,
48 CONNECTION_LOCAL_OPEN,
49 CONNECTION_REMOTE_OPEN,
50 CONNECTION_LOCAL_CLOSE,
51 CONNECTION_REMOTE_CLOSE,
52 CONNECTION_FINAL,
53
54 SESSION_INIT,
55 SESSION_LOCAL_OPEN,
56 SESSION_REMOTE_OPEN,
57 SESSION_LOCAL_CLOSE,
58 SESSION_REMOTE_CLOSE,
59 SESSION_FINAL,
60
61 LINK_INIT,
62 LINK_LOCAL_OPEN,
63 LINK_REMOTE_OPEN,
64 LINK_LOCAL_DETACH,
65 LINK_REMOTE_DETACH,
66 LINK_LOCAL_CLOSE,
67 LINK_REMOTE_CLOSE,
68 LINK_FLOW,
69 LINK_FINAL,
70
71 DELIVERY,
72
73 TRANSPORT,
74 TRANSPORT_ERROR,
75 TRANSPORT_HEAD_CLOSED,
76 TRANSPORT_TAIL_CLOSED,
77 TRANSPORT_CLOSED,
78
79 SELECTABLE_INIT,
80 SELECTABLE_UPDATED,
81 SELECTABLE_READABLE,
82 SELECTABLE_WRITABLE,
83 SELECTABLE_EXPIRED,
84 SELECTABLE_ERROR,
85 SELECTABLE_FINAL,
86
87 /**
88 * This value must never be used to generate an event, it's only used as
89 * a guard when casting custom EventTypes to core {@link Type} via
90 * {@link Event#getType()}.
91 */
92 NON_CORE_EVENT {
93 @Override
94 public boolean isValid() { return false; }
95 };
96
97 @Override
98 public boolean isValid() {
99 return true;
100 }
101 }
102
103 /**
104 * @return type of the event. The event type can be defined outside of the
105 * proton library.
106 */
107 EventType getEventType();
108
109 /**
110 * A concrete event type of core events.
111 *
112 * @return type of the event for core events. For events generated by
113 * extensions a {@link Type#NON_CORE_EVENT} will be returned
114 */
115 Type getType();
116
117 Object getContext();
118
119 /**
120 * The {@link Handler} at the root of the handler tree.
121 * <p>
122 * Set by the {@link Reactor} before dispatching the event.
123 * <p>
124 * @see #redispatch(EventType, Handler)
125 * @return The root handler
126 */
127 Handler getRootHandler();
128
129 void dispatch(Handler handler) throws HandlerException;
130
131 /**
132 * Synchronously redispatch the current event as a new {@link EventType} on the provided handler and it's children.
133 * <p>
134 * Note: the <code>redispatch()</code> will complete before children of the current handler have had the current event dispatched, see {@link #delegate()}.
135 *
136 *
137 * @param as_type Type of event to dispatch
138 * @param handler The handler where to start the dispatch. Use {@link #getRootHandler()} to redispatch the new event to all handlers in the tree.
139 * @throws HandlerException A wrapper exception of any unhandled exception thrown by <code>handler</code>
140 */
141 void redispatch(EventType as_type, Handler handler) throws HandlerException;
142
143 /**
144 * dispatch the event to all children of the handler. A handler can call
145 * this method explicitly to be able to do more processing after all child
146 * handlers have already processed the event. If handler does not invoke
147 * this method it is invoked implicitly by {@link #dispatch(Handler)}
148 *
149 * @throws HandlerException
150 */
151 void delegate() throws HandlerException;
152
153 Connection getConnection();
154
155 Session getSession();
156
157 Link getLink();
158
159 Sender getSender();
160
161 Receiver getReceiver();
162
163 Delivery getDelivery();
164
165 Transport getTransport();
166
167 Reactor getReactor();
168
169 Selectable getSelectable();
170
171 Task getTask();
172
173 Event copy();
174
175 }