Listeners can now be chained
This commit is contained in:
parent
7237d03407
commit
f8a33377d6
@ -713,7 +713,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public final
|
public final
|
||||||
void add(Listener listener) {
|
ListenerBridge add(Listener listener) {
|
||||||
if (this.endPoint instanceof EndPointServer) {
|
if (this.endPoint instanceof EndPointServer) {
|
||||||
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
||||||
// meaning --
|
// meaning --
|
||||||
@ -736,6 +736,8 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||||||
this.endPoint.listeners()
|
this.endPoint.listeners()
|
||||||
.add(listener);
|
.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -753,7 +755,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public final
|
public final
|
||||||
void remove(Listener listener) {
|
ListenerBridge remove(Listener listener) {
|
||||||
if (this.endPoint instanceof EndPointServer) {
|
if (this.endPoint instanceof EndPointServer) {
|
||||||
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
||||||
// meaning --
|
// meaning --
|
||||||
@ -778,6 +780,8 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||||||
this.endPoint.listeners()
|
this.endPoint.listeners()
|
||||||
.remove(listener);
|
.remove(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -786,7 +790,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final
|
public final
|
||||||
void removeAll() {
|
ListenerBridge removeAll() {
|
||||||
if (this.endPoint instanceof EndPointServer) {
|
if (this.endPoint instanceof EndPointServer) {
|
||||||
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
||||||
// meaning --
|
// meaning --
|
||||||
@ -810,6 +814,8 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||||||
this.endPoint.listeners()
|
this.endPoint.listeners()
|
||||||
.removeAll();
|
.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -819,7 +825,7 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final
|
public final
|
||||||
void removeAll(Class<?> classType) {
|
ListenerBridge removeAll(Class<?> classType) {
|
||||||
if (this.endPoint instanceof EndPointServer) {
|
if (this.endPoint instanceof EndPointServer) {
|
||||||
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
// when we are a server, NORMALLY listeners are added at the GLOBAL level
|
||||||
// meaning --
|
// meaning --
|
||||||
@ -845,6 +851,8 @@ class ConnectionImpl extends ChannelInboundHandlerAdapter implements ICryptoConn
|
|||||||
this.endPoint.listeners()
|
this.endPoint.listeners()
|
||||||
.removeAll(classType);
|
.removeAll(classType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -119,7 +119,7 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public final
|
public final
|
||||||
void add(final Listener listener) {
|
ListenerBridge add(final Listener listener) {
|
||||||
if (listener == null) {
|
if (listener == null) {
|
||||||
throw new IllegalArgumentException("listener cannot be null.");
|
throw new IllegalArgumentException("listener cannot be null.");
|
||||||
}
|
}
|
||||||
@ -143,13 +143,13 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||||||
if (genericClass == this.baseClass || genericClass == null) {
|
if (genericClass == this.baseClass || genericClass == null) {
|
||||||
// we are the base class, so we are fine.
|
// we are the base class, so we are fine.
|
||||||
addListener0(listener);
|
addListener0(listener);
|
||||||
return;
|
return this;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (ClassHelper.hasInterface(Connection.class, genericClass) && !ClassHelper.hasParentClass(this.baseClass, genericClass)) {
|
else if (ClassHelper.hasInterface(Connection.class, genericClass) && !ClassHelper.hasParentClass(this.baseClass, genericClass)) {
|
||||||
// now we must make sure that the PARENT class is NOT the base class. ONLY the base class is allowed!
|
// now we must make sure that the PARENT class is NOT the base class. ONLY the base class is allowed!
|
||||||
addListener0(listener);
|
addListener0(listener);
|
||||||
return;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
// didn't successfully add the listener.
|
// didn't successfully add the listener.
|
||||||
@ -209,7 +209,7 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
@Override
|
@Override
|
||||||
public final
|
public final
|
||||||
void remove(final Listener listener) {
|
ListenerBridge remove(final Listener listener) {
|
||||||
if (listener == null) {
|
if (listener == null) {
|
||||||
throw new IllegalArgumentException("listener cannot be null.");
|
throw new IllegalArgumentException("listener cannot be null.");
|
||||||
}
|
}
|
||||||
@ -240,6 +240,8 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||||||
listener.getClass()
|
listener.getClass()
|
||||||
.getName());
|
.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -248,13 +250,15 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final
|
public final
|
||||||
void removeAll() {
|
ListenerBridge removeAll() {
|
||||||
onMessageReceivedManager.removeAll();
|
onMessageReceivedManager.removeAll();
|
||||||
|
|
||||||
Logger logger2 = this.logger;
|
Logger logger2 = this.logger;
|
||||||
if (logger2.isTraceEnabled()) {
|
if (logger2.isTraceEnabled()) {
|
||||||
logger2.trace("ALL listeners removed !!");
|
logger2.trace("ALL listeners removed !!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -264,7 +268,7 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final
|
public final
|
||||||
void removeAll(final Class<?> classType) {
|
ListenerBridge removeAll(final Class<?> classType) {
|
||||||
if (classType == null) {
|
if (classType == null) {
|
||||||
throw new IllegalArgumentException("classType cannot be null.");
|
throw new IllegalArgumentException("classType cannot be null.");
|
||||||
}
|
}
|
||||||
@ -281,6 +285,8 @@ class ConnectionManager<C extends Connection> implements ListenerBridge, ISessio
|
|||||||
classType.getClass()
|
classType.getClass()
|
||||||
.getName());
|
.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ interface ListenerBridge {
|
|||||||
* the connection is notified on that event (ie, admin type listeners)
|
* the connection is notified on that event (ie, admin type listeners)
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
void add(Listener listener);
|
ListenerBridge add(Listener listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a listener from this connection/endpoint to NO LONGER be notified
|
* Removes a listener from this connection/endpoint to NO LONGER be notified
|
||||||
@ -53,19 +53,19 @@ interface ListenerBridge {
|
|||||||
* the connection is removed
|
* the connection is removed
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
void remove(Listener listener);
|
ListenerBridge remove(Listener listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all registered listeners from this connection/endpoint to NO
|
* Removes all registered listeners from this connection/endpoint to NO
|
||||||
* LONGER be notified of connect/disconnect/idle/receive(object) events.
|
* LONGER be notified of connect/disconnect/idle/receive(object) events.
|
||||||
*/
|
*/
|
||||||
void removeAll();
|
ListenerBridge removeAll();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes all registered listeners (of the object type) from this
|
* Removes all registered listeners (of the object type) from this
|
||||||
* connection/endpoint to NO LONGER be notified of
|
* connection/endpoint to NO LONGER be notified of
|
||||||
* connect/disconnect/idle/receive(object) events.
|
* connect/disconnect/idle/receive(object) events.
|
||||||
*/
|
*/
|
||||||
void removeAll(Class<?> classType);
|
ListenerBridge removeAll(Class<?> classType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user