- 浏览: 358537 次
- 性别:
- 来自: 北京
-
文章分类
- 全部博客 (176)
- Lucene (7)
- Solr (16)
- Hadoop/hbase (10)
- Nutch (2)
- 收藏链接 (7)
- javascript-xml-ajax (6)
- clasification (1)
- java base (22)
- TokenAnalyse (1)
- regEX (2)
- 持久化 (6)
- Linux (25)
- C/C++ (9)
- httpclient (5)
- TOMCAT (4)
- ECLIPSE (2)
- Parser_html (15)
- Database (2)
- struts2-spring-hibernate (7)
- finance (1)
- SEO (1)
- PHP (12)
- win2003 (5)
- security (3)
最新评论
-
menghuannvxia:
您好,我通过java上传文件到hadoop速度特别慢,怎么回事 ...
hadoop hdfs 一些用法 -
ydsakyclguozi:
ydsakyclguozi 写道david.org 写道错了. ...
hadoop修改默认的心跳检测的时间 -
ydsakyclguozi:
david.org 写道错了. heartbeat.reche ...
hadoop修改默认的心跳检测的时间 -
mypotatolove:
我现在想做用HttpClient从微博中爬取微博动态,能不能跟 ...
httpclient 设置user-agent -
青春的、脚步:
再者请教:如果查询的字段没有在配置文件的字段中加 termVe ...
solr morelikethis功能
应用的是朋友的代码:
package com.cmsz.common.rmiServer; import java.rmi.Remote; import java.rmi.RemoteException; import java.util.ArrayList; /** * ********************************************************* * Copyright cmsz * 2007. All rights reserved. * * @file: RmiServerImpl * @date: 2007-2-8 * @brief: 远程调用server端接口 * @author: tangqy * @version: 0.0.1 * @since 1.0 * Change Log: * <author> <time> <version> <description> * tangqy 2007-2-8 0.0.1 create * ********************************************************** */ public interface RmiServerImpl extends Remote{ /** * author tangqy * 2007-2-8 * TODO 执行后台binary程序接口 * @param pm_sProcNm:程序名 * @param pm_sProcParams:程序参数 * @return 后台binary程序返回字符串 * @throws RemoteException */ public abstract String callStringProc(String pm_sProcNm, String pm_sProcParam) throws RemoteException; /** * author tangqy * 2007-2-8 * TODO 执行后台binary程序接口 * @param pm_sProcNm 程序名 * @param pm_sProcParams 程序参数 * @return List 第一个值为console输出,第二个值为process返回值 * @throws RemoteException */ public abstract ArrayList callProc(String pm_sProcNm,String pm_sProcParam) throws RemoteException; /** * author tangqy * 2007-2-8 * TODO 执行后台binary程序接口 * @param pm_sProcNm 程序名 * @param pm_sProcParams 程序参数数组 * @return 后台binary程序返回字符串 * @throws RemoteException */ public abstract String callStringProc(String pm_sProcNm, String[] pm_sProcParams) throws RemoteException; /** * author tangqy * 2007-2-8 * TODO 执行后台binary程序接口 * @param pm_sProcNm 程序名 * @param pm_sProcParams 程序参数数组 * @return ArrayList 第一个值为console输出,第二个值为程序returnCode * @throws RemoteException */ public abstract ArrayList callProc(String pm_sProcNm,String[] pm_sProcParams) throws RemoteException; /** * author tangqy * 2007-2-8 * TODO 执行后台Deamon程序接口 * @param pm_sProcNm 程序名 * @param pm_sProcParam 程序参数 * @throws RemoteException */ public abstract void callProcDeamon(String pm_sProcNm,String pm_sProcParam) throws RemoteException; }
package com.cmsz.common.rmiServer; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; import java.rmi.RemoteException; import java.rmi.server.UnicastRemoteObject; import java.util.ArrayList; /** * ********************************************************* * Copyright cmsz * 2007. All rights reserved. * * @file: RmiServerObject * @date: 2007-2-8 * @brief: 远程服务端实现类 * @author: tangqy * @version: 0.0.1 * @since 1.0 * Change Log: * <author> <time> <version> <description> * tangqy 2007-2-8 0.0.1 create * ********************************************************** */ public class RmiServerObject extends UnicastRemoteObject implements RmiServerImpl { public RmiServerObject() throws RemoteException { } /* (non-Javadoc) * @see com.cmsz.common.util.RmiServerImpl#callStringProc(java.lang.String, java.lang.String) */ public String callStringProc(String pm_sProcNm, String pm_sProcParams) throws RemoteException { String returnValue = ""; try { Process process = Runtime.getRuntime().exec(pm_sProcNm + " " + pm_sProcParams); InputStream ins = process.getInputStream(); StringBuffer strBuf = new StringBuffer(""); byte[] temp = new byte[1024]; while(ins.read(temp)!=-1) { strBuf.append(new String(temp)); } return strBuf.toString().trim(); } catch (IOException e) { returnValue = e.getMessage(); return returnValue; } } /* (non-Javadoc) * @see com.cmsz.common.util.RmiServerImpl#callBoolProc(java.lang.String, java.lang.String) */ public ArrayList callProc(String pm_sProcNm, String pm_sProcParams) throws RemoteException { try { Process process = Runtime.getRuntime().exec(pm_sProcNm+" "+pm_sProcParams); int returnVal = process.waitFor(); InputStream ins = process.getInputStream(); StringBuffer buf = new StringBuffer(""); ArrayList lsRet = new ArrayList(); byte[] temp = new byte[1024]; while(ins.read(temp)!=-1) { buf.append(new String(temp)); } lsRet.add(buf.toString()); lsRet.add(new Integer(returnVal)); return lsRet; } catch(Exception es) { System.out.println("Runtime异常!"+es.getMessage()); return null; } } /* (non-Javadoc) * @see com.cmsz.common.util.RmiServerImpl#callStringProc(java.lang.String, java.lang.String[]) */ public String callStringProc(String pm_sProcNm, String[] pm_sProcParams) throws RemoteException { String returnValue = ""; try { Process process = Runtime.getRuntime().exec(pm_sProcNm,pm_sProcParams); InputStream ins = process.getInputStream(); StringBuffer strBuf = new StringBuffer(""); byte[] temp = new byte[1024]; while(ins.read(temp)!=-1) { strBuf.append(temp); } return strBuf.toString().trim(); } catch (IOException e) { returnValue = e.getMessage(); return returnValue; } } /* (non-Javadoc) * @see com.cmsz.common.util.RmiServerImpl#callBoolProc(java.lang.String, java.lang.String[]) */ public ArrayList callProc(String pm_sProcNm, String[] pm_sProcParams) throws RemoteException { try { Process process = Runtime.getRuntime().exec(pm_sProcNm,pm_sProcParams); int returnVal = process.waitFor(); InputStream ins = process.getInputStream(); StringBuffer buf = new StringBuffer(""); ArrayList lsRet = new ArrayList(); byte[] temp = new byte[1024]; while(ins.read(temp)!=-1) { buf.append(new String(temp)); } lsRet.add(buf.toString()); lsRet.add(new Integer(returnVal)); return lsRet; } catch(Exception es) { System.out.println("Runtime异常!"+es.getMessage()); return null; } } /* (non-Javadoc) * @see com.cmsz.common.rmiServer.RmiServerImpl#callProcDeamon(java.lang.String, java.lang.String) */ public void callProcDeamon(String pm_sProcNm, String pm_sProcParam) throws RemoteException { try { Process process = Runtime.getRuntime().exec(pm_sProcNm + " " + pm_sProcParam); } catch (IOException e) { System.out.println(e.getMessage()); } } }
package com.cmsz.common.rmiServer; import java.net.MalformedURLException; import java.rmi.Naming; import java.rmi.NotBoundException; import java.rmi.RMISecurityManager; import java.rmi.RemoteException; import java.util.ArrayList; import com.cmsz.common.rmiServer.RmiServerImpl; /** * ********************************************************* * Copyright cmsz * 2007. All rights reserved. * * @file: RmiClient * @date: 2007-2-8 * @brief: 远程调用客户端 * @author: tangqy * @version: 0.0.1 * @since 1.0 * Change Log: * <author> <time> <version> <description> * tangqy 2007-2-8 0.0.1 create * ********************************************************** */ public class RmiClient { public RmiClient() { if(System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } } /** * author tangqy * 2007-2-8 * TODO 远程调用 * @param pm_sRmiHost RMIserver端主机名 * @param pm_iRmiPort RMIserver端端口号 * @param pm_sProcNm 远程程序名 * @param pm_sParams 远程调用程序参数 * @return */ public String callRemoteProcStr(String pm_sRmiHost,int pm_iRmiPort,String pm_sProcNm,String pm_sParams) { try { RmiServerImpl rmiObject = (RmiServerImpl)Naming.lookup(pm_sRmiHost+":"+pm_iRmiPort+"/RemoteRMI"); return rmiObject.callStringProc(pm_sProcNm,pm_sParams); } catch (MalformedURLException e) { e.printStackTrace(); return e.getMessage(); } catch (RemoteException e) { e.printStackTrace(); return e.getMessage(); } catch (NotBoundException e) { e.printStackTrace(); return e.getMessage(); } } /** * author tangqy * 2007-2-8 * TODO 远程调用 * @param pm_sRmiHost RMIserver端主机名 * @param pm_iRmiPort RMIserver端端口号 * @param pm_sProcNm 远程程序名 * @param pm_sParams 远程调用程序参数 * @return */ public ArrayList callRemoteProcInt(String pm_sRmiHost,int pm_iRmiPort,String pm_sProcNm,String pm_sParams) { try { RmiServerImpl rmiObject = (RmiServerImpl)Naming.lookup(pm_sRmiHost+":"+pm_iRmiPort+"/"+"RemoteRMI"); return rmiObject.callProc(pm_sProcNm,pm_sParams); } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (RemoteException e) { e.printStackTrace(); return null; } catch (NotBoundException e) { e.printStackTrace(); return null; } } /** * author tangqy * 2007-2-8 * TODO 远程调用 * @param pm_sRmiHost RMIserver端主机名 * @param pm_iRmiPort RMIserver端端口号 * @param pm_sProcNm 远程程序名 * @param pm_sParams 远程调用程序参数 * @return */ public ArrayList callRemoteProcInt(String pm_sRmiHost,int pm_iRmiPort,String pm_sProcNm,String[] pm_sParams,ArrayList pm_lsRet) { try { RmiServerImpl rmiObject = (RmiServerImpl)Naming.lookup(pm_sRmiHost+":"+pm_iRmiPort+"/RemoteRMI"); return rmiObject.callProc(pm_sProcNm,pm_sParams); } catch (MalformedURLException e) { e.printStackTrace(); return null; } catch (RemoteException e) { e.printStackTrace(); return null; } catch (NotBoundException e) { e.printStackTrace(); return null; } } /** * author tangqy * 2007-2-8 * TODO 远程调用 * @param pm_sRmiHost RMIserver端主机名 * @param pm_iRmiPort RMIserver端端口号 * @param pm_sProcNm 远程程序名 * @param pm_sParams 远程调用程序参数 * @return */ public String callRemoteProcStr(String pm_sRmiHost,int pm_iRmiPort,String pm_sProcNm,String[] pm_sParams) { try { RmiServerImpl rmiObject = (RmiServerImpl)Naming.lookup(pm_sRmiHost+":"+pm_iRmiPort+"/RemoteRMI"); return rmiObject.callStringProc(pm_sProcNm,pm_sParams); } catch (MalformedURLException e) { e.printStackTrace(); return e.getMessage(); } catch (RemoteException e) { e.printStackTrace(); return e.getMessage(); } catch (NotBoundException e) { e.printStackTrace(); return e.getMessage(); } } public void callRemoteProcDeamon(String pm_sRmiHost,int pm_iRmiPort,String pm_sProcNm,String pm_sParams) { try { RmiServerImpl rmiObject = (RmiServerImpl)Naming.lookup(pm_sRmiHost+":"+pm_iRmiPort+"/RemoteRMI"); rmiObject.callProcDeamon(pm_sProcNm,pm_sParams); } catch (MalformedURLException e) { e.printStackTrace(); } catch (RemoteException e) { e.printStackTrace(); } catch (NotBoundException e) { e.printStackTrace(); } } public static void main(String[] args) { RmiClient client = new RmiClient(); client.callRemoteProcDeamon("//132.32.20.133",1099,"/opt/mcb/tts/bin/PreMainMon.sh -start"," "); } }
package com.cmsz.common.rmiServer; import java.rmi.Naming; import java.rmi.RMISecurityManager; import java.rmi.registry.LocateRegistry; /** * ********************************************************* * Copyright cmsz * 2007. All rights reserved. * * @file: RmiServerMain * @date: 2007-2-8 * @brief: 启动远程调用服务端 * @author: tangqy * @version: 0.0.1 * @since 1.0 * Change Log: * <author> <time> <version> <description> * tangqy 2007-2-8 0.0.1 create * ********************************************************** */ public class RmiServerMain { public static void main(String[] args) { try { if(System.getSecurityManager() == null) { System.setSecurityManager(new RMISecurityManager()); } int rmiPort = 1099; if(args.length!=0) { rmiPort = Integer.parseInt(args[0]); } LocateRegistry.createRegistry(rmiPort); RmiServerObject rmiObject = new RmiServerObject(); Naming.rebind("//localhost:"+rmiPort+"/RemoteRMI", rmiObject); System.out.println("Remote Object is Ready"); } catch(Exception exception) { exception.printStackTrace(); } } }
发表评论
-
从本地读取图片保存为byte[]
2009-10-21 16:02 1636public void read(){ String ... -
myeclipse里面配置xml文件提示方法
2009-09-29 23:02 9271. 在windows-preferences里面,在 ... -
freemarker
2009-09-08 16:52 1595public class FreeMarkerFactor ... -
资源文件加载的的类
2009-09-03 09:18 946public class ReadProperties { ... -
ThreadLocal的用法
2009-08-23 22:02 3548package com.sodao.lucene; ... -
在MyEclipse中直接查看javaApi
2009-02-28 11:50 2017java每个版本的发布都会伴随发布一个 html ja ... -
GzipOutputStream及GzipInputStream的用法
2009-02-21 23:49 7434ByteArrayOutputStream array ... -
log4j 配制文件
2009-02-21 22:36 912#log4j中有五级logger #FATAL 0 #ER ... -
java 多线程问题
2009-02-04 19:22 910import java.util.ArrayList; im ... -
pr值的获取
2009-02-02 21:08 1098package com.sodao; /// < ... -
一句话设计模式
2009-01-10 23:32 103623种设计模式 - Pattern. 创建型 Abst ... -
编写java高效率代码注意事项
2009-01-09 14:41 16561.少用异常,多用判断。 2.将类的属性按种类分块,将方法的实 ... -
Eclipse中设置在创建新类时自动生成注释
2009-01-09 14:06 1538Eclipse中设置在创建新类时自动生成注释 windows- ... -
高质量JAVA代码编写规范
2009-01-09 09:48 23461. Java 命名约定 除 ... -
heritrix1.4.2安装
2009-01-06 16:07 13641、下载heritrix-1.14.2-src. ... -
MyEclipse/Eclipse的内存优化与内存不足的解决办法
2009-01-04 09:47 2890MyEclipse/Eclipse的内存优化与内存不足的解决办 ... -
Java编程经验汇总2(转载)
2008-12-09 21:03 1247笔者之前说的都是Struts- ... -
Java编程经验汇总1(绝对好文,转载)
2008-12-09 20:59 1654Java编程经验汇总 绝对 ... -
java tips and tricks
2008-12-08 15:54 867一、-Xmx512m 二、eclipse的插件的links安 ... -
Java Socket UDP Program
2008-12-07 23:09 2954import java.net.DatagramPacke ...
相关推荐
【标题】:“rmi.rar_The ...总的来说,“rmi.rar_The Program”不仅提供了阿拉伯数字和罗马数字转换的实用功能,还展现了如何在Java环境中利用RMI实现跨JVM的分布式服务调用,对于学习和理解RMI机制有着重要的价值。
Java 远程方法调用(Remote Method Invocation,RMI)是一种在分布式环境中执行对象方法的技术。它允许一个Java应用程序调用运行在不同JVM(Java虚拟机)上的另一个对象的方法,就像是在本地调用一样。在Java RMI中...
- 打开 `C:\Program Files\Java\jre\lib\security\java.policy` 文件,在末尾添加以下代码: ```plaintext grant { permission java.net.SocketPermission "*:1024-65535", "connect,accept"; permission java...
This application was written using RMI Java. It resolve "access to critical section " example problem. To use this program you should change in *.bat / *.sh files the java path according in your ...
标题"RMI.zip_remote"表明这是一个与RMI相关的代码示例压缩包,而描述中的"Remote Method Invocation Program code"进一步确认了这一点。接下来,我们将深入探讨RMI的关键概念和工作原理,并基于提供的文件名称...
使用RMI远程调用java程序,在MyEclipse2014测试成功。其中服务器端添加该Project中的RemotingService和Service,在客户端端添加RemotingClient和Service。先运行RemotingService中的Program再运行客户端中...
JavaServer Pages (JSP), servlets, Remote Method Invocation (RMI) and Enterprise JavaBeans (EJB) into a production-quality system that allows developers to benefit from the leverage and platform ...
此外,书中还涵盖了数值与静态变量、异常处理、图形用户界面(GUI)、文件输入/输出、网络编程、线程、集合与泛型、包、JAR文件部署以及远程方法调用(RMI)等高级主题,这些都是Java开发中不可或缺的知识点。...
- **分布性**:Java支持RMI(远程方法调用)技术,便于开发分布式应用。 - **简单性**:与C/C++相比,Java简化了许多编程细节,如不使用指针。 2. **Java程序的生命周期**: - **编译**:使用`javac`命令将.java...
JSA(Java Security Application Program Interface)是Java安全应用编程接口,用于实现安全策略和管理。 以上仅是Java及相关技术的一部分核心概念,它们共同构成了Java丰富的生态系统,为开发者提供了强大且灵活的...
远程方法调用(Remote Method Invocation,简称RMI)是一种Java技术,允许开发者在不同的JVM(Java虚拟机)之间通过网络进行对象间的通信。它使得在一台机器上的Java对象能够调用另一台机器上Java对象的方法,就像是...
The java.rmi.registry Package Section 18.6. The java.rmi.server Package Chapter 19. The JavaMail API Section 19.1. What Is the JavaMail API? Section 19.2. Sending Email Section 19.3. ...
A Simple Java Program 36 Comments 39 Data Types 40 Variables 44 Operators 46 Strings 53 Input and Output 63 Control Flow 71 Big Numbers 88 Arrays 90 Chapter 4: Objects and Classes 105 ...
-vm C:\Program Files\Java\jdk1.6.0_18\bin\javaw.exe --launcher.XXMaxPermSize 256m -vmargs -Xms40m -Xmx1024m ``` 这些参数分别设置了Eclipse使用的JVM路径、最大永久代大小以及最小和最大堆大小。 #### 六、...
java -Djava.security.policy=security.policy -Djava.rmi.server.hostname=127.0.0.1 -Djava.security.manager -jar CorbaDemoServer.jar ``` 此批处理文件用于启动服务器端程序。通过设置`java.security.policy`...
* The syntax to call this program is presented in next description: * * 1º param: command to be executed in the server. The program have 3: * * send * * receive * * convert * * 2º parametro: server'...
课程主要包括下列内容: ■ Java语言的发展及相关技术的介绍,Java技术和平台在网络计算及电子商务中的应用介绍; ■ Java语言的基础知识:Java语言的主要特点,设计思想,Java虚拟机,... ■ JavaBeans和RMI。
The same application (for a simple appointment-scheduling program) is used throughout the text. You learn how to use sockets, RMI, IDL/CORBA, and even servlets and JSPs to build different versions of...
11. **RMI (Remote Method Invocation)**:RMI允许Java对象在不同的Java虚拟机之间进行通信,调用远程对象的方法。 12. **CVS (Concurrent Versions System)**:CVS是一种版本控制系统,用于跟踪和管理源代码的更改...