Archive for July, 2010

RMI (Remote Method Invocation)

The Java Remote Method Invocation Application Programming Interface (API), or Java RMI, is a Java application programming interface that performs the object-oriented equivalent of remote procedure calls (RPC).

  1. The original implementation depends on Java Virtual Machine (JVM) class representation mechanisms and it thus only supports making calls from one JVM to another. The protocol underlying this Java-only implementation is known as Java Remote Method Protocol (JRMP).
  2. In order to support code running in a non-JVM context, a CORBA version was later developed.

Usage of the term RMI may denote solely the programming interface or may signify both the API and JRMP, whereas the term RMI-IIOP (read: RMI over IIOP) denotes the RMI interface delegating most of the functionality to the supporting CORBA implementation.

The programmers of the original RMI API generalized the code somewhat to support different implementations, such as a HTTP transport. Additionally, the ability to pass arguments “by value” was added to CORBA in order to support the RMI interface. Still, the RMI-IIOP and JRMP implementations do not have fully identical interfaces.

RMI functionality comes in the package java.rmi, while most of Sun’s implementation is located in the sun.rmi package. Note that with Java versions before Java 5.0 developers had to compile RMI stubs in a separate compilation step using rmic. Version 5.0 of Java and beyond no longer require this step.

Jini offers a more advanced version of RMI in Java. It functions similarly but provides more advanced searching capabilities and mechanisms for distributed object applications.[1]

원격 프록시

출처 : http://wiki.oracleclub.com/pages/viewpage.action?pageId=1507415

2. 원격프록시

2.1 원격프록시 개요

로컬 환경에 존재하면서, 원격객체에 대하여 대변자 역할을 하는 객체를 원격 프록시라고 한다.

  • 원격객체- 다른 JVM의 Heap영역에 살고있는 객체

2.2 원격에 있는 왕뽑기 기계를 감시하는 모니터링 프로그램 만들기


클라이언트 객체([GumballMonitor])에서는 원격객체([GumballMachine])의 메소드를 호출하는 것처럼 행동하지만, 실제로는 로컬 힙에 들어있는 원격객체 모양과 비슷한 ‘프록시’객체의 메소드를 호출하고 있는 것이다.
네트워크 통신과 관련된 저수준 작업은 이 프록시 객체에서 처리해준다.

2.3 원격메소드의 기초

  1. 클라이언트 객체에서 클라이언트 보조객체의 메소드를 호출한다.
  2. 클라이언트 보조객체에서는 메소드 호출에 대한 정보(인자, 메소드이름 등)를 잘 포장해서 네트워크를 통해 서비스 보조객체한테 전달한다.
  3. 서비스 보조객체에서는 클라이언트 보조객체로 부터 받은 정보를 해석하여 어떤 객체의 어떤 메소드를 호출할지 알아낸 다음 진짜 서비스객체의 ‘진짜 메소드’를 호출한다.
  4. 서비스객체의 메소드가 호출되고, 메소드 실행이 끝나면 서비스 보조객체에 결과를 리턴해준다.
  5. 호출결과로 리턴된 정보를 포장해서 서비스 보조객체에서 클라이언트 보조객체한테 전달한다.
  6. 클라이언트 보조객체에서는 리턴된 값을 해석하여 클라이언트 객체한테 리턴한다.

클라이언트 객체 입장에서는 메소드 호출이 어디로 전달되었었는지, 어디에서 왔는지 전혀 알 수 없다.

2.4 원격서비스 만들기

  1. 원격인터페이스 만들기
    클라이언트에서 호출가능한 메소드를 정의
  2. 서비스 구현 클래스 만들기
    실제 작업을 처리하는 클래스
  3. rmic를 이용하여 stub과 skeleton만들기
    클라이언트 및 서비스 보조객체 생성(rmic 툴을 이용하여 자동으로 생성)
  4. rmiregistry실행
    클라이언트에서 stub을 받아갈수 있는 장소
  5. 원격 서비스 시작
    서비스 객체를 가동. 서비스를 구현한 클래스에서 서비스의 인스턴스를 만들고 그 인스턴스를 RMI레지스트리에 등록

네이버 개발자센터 오픈프로젝트 이용하기

네이버 개발자센터 오픈프로젝트 이용하기

http://planmaster.tistory.com/263