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()); }*/ } }
about rmi interface
最新推荐文章于 2024-07-13 18:10:19 发布