SimpleUserEventChannelHandler Class — netty Architecture
Architecture documentation for the SimpleUserEventChannelHandler class in SimpleUserEventChannelHandler.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 3697745c_0fe4_e1c4_5616_b42c0f07aaca["SimpleUserEventChannelHandler"] a9ab9323_d93e_5cb2_887f_31914d0df7cf["SimpleUserEventChannelHandler.java"] 3697745c_0fe4_e1c4_5616_b42c0f07aaca -->|defined in| a9ab9323_d93e_5cb2_887f_31914d0df7cf 8943a317_0a3b_5b6f_f6ae_d355159ca91f["SimpleUserEventChannelHandler()"] 3697745c_0fe4_e1c4_5616_b42c0f07aaca -->|method| 8943a317_0a3b_5b6f_f6ae_d355159ca91f a1069d48_8d12_1058_95fc_15714a1c1c66["acceptEvent()"] 3697745c_0fe4_e1c4_5616_b42c0f07aaca -->|method| a1069d48_8d12_1058_95fc_15714a1c1c66 20aec001_020e_918e_26aa_68ae6031c37b["userEventTriggered()"] 3697745c_0fe4_e1c4_5616_b42c0f07aaca -->|method| 20aec001_020e_918e_26aa_68ae6031c37b 3390bf43_cc2d_74b7_ed0e_716e053b7efe["eventReceived()"] 3697745c_0fe4_e1c4_5616_b42c0f07aaca -->|method| 3390bf43_cc2d_74b7_ed0e_716e053b7efe
Relationship Graph
Source Code
transport/src/main/java/io/netty/channel/SimpleUserEventChannelHandler.java lines 42–120
public abstract class SimpleUserEventChannelHandler<I> extends ChannelInboundHandlerAdapter {
private final TypeParameterMatcher matcher;
private final boolean autoRelease;
/**
* see {@link #SimpleUserEventChannelHandler(boolean)} with {@code true} as boolean parameter.
*/
protected SimpleUserEventChannelHandler() {
this(true);
}
/**
* Create a new instance which will try to detect the types to match out of the type parameter of the class.
*
* @param autoRelease {@code true} if handled events should be released automatically by passing them to
* {@link ReferenceCountUtil#release(Object)}.
*/
protected SimpleUserEventChannelHandler(boolean autoRelease) {
matcher = TypeParameterMatcher.find(this, SimpleUserEventChannelHandler.class, "I");
this.autoRelease = autoRelease;
}
/**
* see {@link #SimpleUserEventChannelHandler(Class, boolean)} with {@code true} as boolean value.
*/
protected SimpleUserEventChannelHandler(Class<? extends I> eventType) {
this(eventType, true);
}
/**
* Create a new instance
*
* @param eventType The type of events to match
* @param autoRelease {@code true} if handled events should be released automatically by passing them to
* {@link ReferenceCountUtil#release(Object)}.
*/
protected SimpleUserEventChannelHandler(Class<? extends I> eventType, boolean autoRelease) {
matcher = TypeParameterMatcher.get(eventType);
this.autoRelease = autoRelease;
}
/**
* Returns {@code true} if the given user event should be handled. If {@code false} it will be passed to the next
* {@link ChannelInboundHandler} in the {@link ChannelPipeline}.
*/
protected boolean acceptEvent(Object evt) throws Exception {
return matcher.match(evt);
}
@Override
public final void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
boolean release = true;
try {
if (acceptEvent(evt)) {
@SuppressWarnings("unchecked")
I ievt = (I) evt;
eventReceived(ctx, ievt);
} else {
release = false;
ctx.fireUserEventTriggered(evt);
}
} finally {
if (autoRelease && release) {
ReferenceCountUtil.release(evt);
}
}
}
/**
* Is called for each user event triggered of type {@link I}.
*
* @param ctx the {@link ChannelHandlerContext} which this {@link SimpleUserEventChannelHandler} belongs to
* @param evt the user event to handle
*
* @throws Exception is thrown if an error occurred
*/
protected abstract void eventReceived(ChannelHandlerContext ctx, I evt) throws Exception;
}
Source
Frequently Asked Questions
What is the SimpleUserEventChannelHandler class?
SimpleUserEventChannelHandler is a class in the netty codebase, defined in transport/src/main/java/io/netty/channel/SimpleUserEventChannelHandler.java.
Where is SimpleUserEventChannelHandler defined?
SimpleUserEventChannelHandler is defined in transport/src/main/java/io/netty/channel/SimpleUserEventChannelHandler.java at line 42.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free