Java Tomcat+;RMI最好的方式?

Java Tomcat+;RMI最好的方式?,java,tomcat,rmi,Java,Tomcat,Rmi,与tomcat相比,使用RMI的最佳方式是什么 我可以为所有应用程序创建全局RMI池或一个RMI连接吗?我在包装RMI接口的控制器中使用静态类。RMI将把您的连接集中在服务器端,您不必在Tomcat中担心它。示例RMI public interface Account extends java.rmi.Remote { public double balance(int accountNumber) throws java.rmi.RemoteE

与tomcat相比,使用RMI的最佳方式是什么


我可以为所有应用程序创建全局RMI池或一个RMI连接吗?

我在包装RMI接口的控制器中使用静态类。RMI将把您的连接集中在服务器端,您不必在Tomcat中担心它。

示例RMI

public interface Account 
          extends java.rmi.Remote { 
    public double balance(int accountNumber) 
        throws java.rmi.RemoteException; 

} 

public class AccountImpl 
    extends 
      java.rmi.server.UnicastRemoteObject 
    implements Account { 
 public AccountImpl() 
        throws java.rmi.RemoteException { 
        super(); 
    } 

    public double add(int accountNumber) 
        throws java.rmi.RemoteException { 
        return 1000.0; 
    } 
}
示例Servlet

public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException 
{

Account service=request.getSession()!=null ?(Account)request.getSession().getAttribute(loginService.ACCOUNT_SERVICE.name()):null;

service=service!=null?service:getService();
if(service!=null)
{
request.getSession().setAttribute(loginService.ACCOUNT_SERVICE.name(), service);
}
    }
    }

}

. 为什么要这样做…?我需要从我的servlet中的stanbalone应用程序获取数据