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
KryoEncoder getKryoEncoder() {
return this.kryoEncoder;

View File

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

View File

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