code cleanup for RMI registration in channel handlers

This commit is contained in:
nathan 2015-07-29 11:36:29 +02:00
parent 61f6e92614
commit ef94413cf8
3 changed files with 30 additions and 20 deletions

View File

@ -74,6 +74,13 @@ class RegistrationWrapper<C extends Connection> implements UdpServer {
} }
} }
/**
* @return true if RMI is enabled
*/
public boolean rmiEnabled() {
return endPoint.globalRmiBridge != null;
}
public public
KryoEncoder getKryoEncoder() { KryoEncoder getKryoEncoder() {
return this.kryoEncoder; return this.kryoEncoder;

View File

@ -15,6 +15,7 @@
*/ */
package dorkbox.network.connection.registration.local; package dorkbox.network.connection.registration.local;
import dorkbox.network.connection.Connection;
import dorkbox.network.connection.ConnectionImpl; import dorkbox.network.connection.ConnectionImpl;
import dorkbox.network.connection.RegistrationWrapper; import dorkbox.network.connection.RegistrationWrapper;
import dorkbox.network.connection.registration.MetaChannel; import dorkbox.network.connection.registration.MetaChannel;
@ -26,10 +27,10 @@ import io.netty.channel.ChannelPipeline;
import io.netty.util.ReferenceCountUtil; import io.netty.util.ReferenceCountUtil;
public public
class RegistrationLocalHandlerClient extends RegistrationLocalHandler { class RegistrationLocalHandlerClient<C extends Connection> extends RegistrationLocalHandler<C> {
public public
RegistrationLocalHandlerClient(String name, RegistrationWrapper registrationWrapper) { RegistrationLocalHandlerClient(String name, RegistrationWrapper<C> registrationWrapper) {
super(name, registrationWrapper); super(name, registrationWrapper);
} }
@ -92,7 +93,7 @@ class RegistrationLocalHandlerClient extends RegistrationLocalHandler {
// add our RMI handlers // add our RMI handlers
if (registrationWrapper.rmiEnabled()) {
/////////////////////// ///////////////////////
// DECODE (or upstream) // DECODE (or upstream)
/////////////////////// ///////////////////////
@ -103,6 +104,7 @@ class RegistrationLocalHandlerClient extends RegistrationLocalHandler {
// ENCODE (or downstream) // ENCODE (or downstream)
///////////////////////// /////////////////////////
pipeline.addFirst(LOCAL_RMI_DECODER, encoder); pipeline.addFirst(LOCAL_RMI_DECODER, encoder);
}
// have to setup connection handler // have to setup connection handler
pipeline.addLast(CONNECTION_HANDLER, connection); pipeline.addLast(CONNECTION_HANDLER, connection);

View File

@ -93,7 +93,7 @@ class RegistrationLocalHandlerServer<C extends Connection> extends RegistrationL
if (connection != null) { if (connection != null) {
// add our RMI handlers // add our RMI handlers
if (registrationWrapper.rmiEnabled()) {
/////////////////////// ///////////////////////
// DECODE (or upstream) // DECODE (or upstream)
/////////////////////// ///////////////////////
@ -104,6 +104,7 @@ class RegistrationLocalHandlerServer<C extends Connection> extends RegistrationL
// ENCODE (or downstream) // ENCODE (or downstream)
///////////////////////// /////////////////////////
pipeline.addFirst(LOCAL_RMI_DECODER, encoder); pipeline.addFirst(LOCAL_RMI_DECODER, encoder);
}
// have to setup connection handler // have to setup connection handler
pipeline.addLast(CONNECTION_HANDLER, connection); pipeline.addLast(CONNECTION_HANDLER, connection);