com.alipay.remoting
Class RemotingServer

java.lang.Object
  extended by com.alipay.remoting.RemotingServer
Direct Known Subclasses:
RpcServer

public abstract class RemotingServer
extends Object

Server template for remoting.


Field Summary
protected  int port
           
 
Constructor Summary
RemotingServer(int port)
           
 
Method Summary
protected abstract  void doInit()
          Inject initialize logic here.
protected abstract  boolean doStart()
          Inject start logic here.
protected abstract  boolean doStart(String ip)
          Inject start logic here.
protected abstract  void doStop()
          Inject stop logic here.
 int getPort()
          Get the port of the server.
 void init()
          Initialize.
abstract  void registerDefaultExecutor(byte protocolCode, ExecutorService executor)
          Register default executor service for server.
abstract  void registerProcessor(byte protocolCode, CommandCode commandCode, RemotingProcessor<?> processor)
          Register processor for command with the command code.
abstract  void registerUserProcessor(UserProcessor<?> processor)
          Register user processor.
 boolean start()
          Start the server.
 boolean start(String ip)
          Start the server with ip and port.
 void stop()
          Stop the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

port

protected int port
Constructor Detail

RemotingServer

public RemotingServer(int port)
Parameters:
port -
Method Detail

init

public void init()
Initialize.


start

public boolean start()
Start the server.


start

public boolean start(String ip)
Start the server with ip and port.


stop

public void stop()
Stop the server.

Notice:

  • Remoting server can not be used any more after shutdown.
  • If you need, you should destroy it, and instantiate another one.


  • getPort

    public int getPort()
    Get the port of the server.

    Returns:

    doInit

    protected abstract void doInit()
    Inject initialize logic here.


    doStart

    protected abstract boolean doStart()
                                throws InterruptedException
    Inject start logic here.

    Throws:
    InterruptedException

    doStart

    protected abstract boolean doStart(String ip)
                                throws InterruptedException
    Inject start logic here.

    Parameters:
    ip -
    Throws:
    InterruptedException

    doStop

    protected abstract void doStop()
    Inject stop logic here.


    registerProcessor

    public abstract void registerProcessor(byte protocolCode,
                                           CommandCode commandCode,
                                           RemotingProcessor<?> processor)
    Register processor for command with the command code.

    Parameters:
    commandCode -
    processor -

    registerDefaultExecutor

    public abstract void registerDefaultExecutor(byte protocolCode,
                                                 ExecutorService executor)
    Register default executor service for server.

    Parameters:
    protocolCode -
    executor -

    registerUserProcessor

    public abstract void registerUserProcessor(UserProcessor<?> processor)
    Register user processor.

    Parameters:
    processor -


    Copyright © 2018. All rights reserved.