动态注册Java RMI的类

问题描述

假设我有此Java RMI方法

Optional<Comparable> executeRemotely(CustomAction action) 
   throws NotBoundException,remoteexception {
   // {...}
}

客户端实现了CustomAction


public class Incrementor {
    public Integer complexIncrementor(Integer source){
        // {...}
    }
}

public class IncrementValueAction implements CustomAction {
    
   Integer incrementValue;
   
   public IncrementValueAction(Integer incrementValue) {
     this.incrementValue = incrementValue;
   }
    
   @Override 
   public void execute(Entity entity) {
     Integer count = entity.getProperty("count");
     entity.setProperty("count",new Incrementor().complexIncrementor(count);
   }
}

但类本身未在RMI的服务器端定义。

呼叫RMI服务器

remoteClient.executeRemotely(new IncrementLikesAction(1000));

如何动态地注册使用的Incrementor类,以便服务器端在执行CustomAction时可以使用该类?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)