about rmi interface

package rmi.all; import java.rmi.Remote; import java.rmi.RemoteException; import java.util.List; import log4j.entity.Page; public interface RmiLogger extends Remote { //获取所有日志 String getAllLogger() throws RemoteException; //无参写日志方法 void writeLogger() throws RemoteException; //写日志方法,带参数为String类型,后台进行解析 void writeLogger(String str) throws RemoteException; //按条件查询日志,str{字段=条件} Page queryLogger(Page page) throws RemoteException; //日志归档操作,将数据库中数据导出备份,并清除数据库中的已导出数据 void logManager() throws RemoteException; void logManager(String condition) throws RemoteException; //日志输出模块,将数据库表中的数据输出到指定类型的文件,如excel或文本文件等 //参数及返回数据暂未想好如何设置 void logOutput() throws RemoteException; } package rmi.all; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; import java.util.List; import log4j.appender.LogManager; import log4j.appender.LoggerService; import log4j.entity.Page; public class RmiLoggerImpl extends UnicastRemoteObject implements RmiLogger { private String Desc; public RmiLoggerImpl() throws RemoteException { super(); } public RmiLoggerImpl(String name) throws RemoteException { super(); Desc = name; System.out.println(name+"========================"); } public void writeLogger() throws RemoteException { // TODO Auto-generated method stub //return null; LoggerService.writeLogger(); //System.out.println("public void writeLogger() in class RmiLoggerImpl"); } public String getAllLogger() throws RemoteException{ //TestJdbcAppender td=new TestJdbcAppender(); System.out.println("public String getLogger()"); //TestJdbcAppender.send_database(); //send_database(); return "This is getLogger() in RmiLoggerImpl!"; } public void writeLogger(String str) throws RemoteException { //String str="ss/aa/gg/d"; // String s[]=str.split("/"); // for(int i=0;i queryLogger(String condition)"); String url = "rmi://10.161.0.5:1099/"; try { file://查找远程对象 System.out.println("1"); RmiLogger rl = (RmiLogger)Naming.lookup(url + "rmiQuery"); file://调用远程方法 //System.out.println("2"); return rl.queryLogger(page); }catch (Exception ex) { System.out.println("error "+ex); } return null; } } package rmi.all; import java.util.Iterator; import java.util.List; import log4j.entity.Page; public class test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub // for(int i=0;i<300;i++){ RmiLoggerClient.writeLogger("gaoms_sy/127.0.0.1/addCategory"+"i"+"/gvhng"); // } /**/ //在页面做一字符变量condition,标示出是查全部还是按条件查,如全部则将变量设为condition="" /* List l=RmiLoggerClient.queryLogger(""); //List l=RmiLoggerClient.queryLogger("where user_name='gaoms_sy'"); //System.out.println(Thread.currentThread()); Iterator it=l.iterator(); while(it.hasNext()){ System.out.println(it.next()); }*/ /* //=======更改后测试 Page p=new Page(); p.setIntPage(2); p.setIntPageSize(2); //queryLogger("",p); p.setCondition(""); Page p1=new Page(); p1.setIntPage(1); p1.setIntPageSize(2); //queryLogger("",p); p1.setCondition(""); Page l=RmiLoggerClient.queryLogger(p); Page l1=RmiLoggerClient.queryLogger(p1); //List l=RmiLoggerClient.queryLogger("where user_name='gaoms_sy'"); //System.out.println(Thread.currentThread()); Iterator it=l.getList().iterator(); while(it.hasNext()){ System.out.println(it.next()+"3490efdklbvmfdmbdkl"); } System.out.println("---------jkhj--------------"); Iterator it1=l1.getList().iterator(); while(it1.hasNext()){ System.out.println(it1.next()); }*/ } }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值