18.%20RMI?%20???%20??%20?? - PowerPoint PPT Presentation

About This Presentation
Title:

18.%20RMI?%20???%20??%20??

Description:

API ... ALL CAPS, Line Spacing=1 line * * 579 ... – PowerPoint PPT presentation

Number of Views:44
Avg rating:3.0/5.0
Slides: 39
Provided by: Nah95
Category:
Tags: 20rmi

less

Transcript and Presenter's Notes

Title: 18.%20RMI?%20???%20??%20??


1
18. RMI? ??? ?? ??
  • ??? ??? ?
  • ?? ??? ??
  • ???
  • ?????? ?? ??

2
??? ??? ?
  • ??? ??? ?? ?? ?? ???? ? ?? ???? ??????.
  • class Foo
  • void go()
  • Bar b new Bar()
  • b.doStuff()
  • public static void main(String args)
  • Foo f new Foo()
  • f.go()

doStuff()
Bar ??
Foo ??
3
?? ????? ???? ??? ???
JVM
JVM
??
?
4
?? ????? ???? ??? ???
doCalcUsingDatabase()
B
A
???
??
?
A? B? ?? ?? ???? ?? ??? A?? B? ?? ???? ??? ??
????.
RMI(?? ??? ?? Remote Method Invocation) !!!
5
?? ??? ??
????? ?
?? ?
????? ??
??? ??
6
?? ??? ??
????? ?
?? ?
????? ?? ??
????? ??
??? ??
??? ?? ??
7
?? ??? ??
????? ?
?? ?
doBigThing()
????? ?? ??
????? ??
??? ??
??? ?? ??
8
?? ??? ??
????? ?
?? ?
doBigThing()
??????? ??? ?????.
????? ?? ??
????? ??
??? ??
??? ?? ??
9
?? ??? ??
????? ?
?? ?
doBigThing()
doBigThing()
??????? ??? ?????.
????? ?? ??
????? ??
??? ??
??? ?? ??
10
?? ??
  • ?? ??(helper object)
  • ?? ?? ??? ???
  • ?? ? ???? ??? ????? ?? ??
  • ?????? ?? ??? ?? ???? ???? ??? ?? ???? ? ?
  • ??????? ????? ?? ???? ??? ?? ??? ??? ??
  • ?? ???? ??? ?? ???? ????? ?? ???? ?? ??? ??? ???
    ?? ??? ???? ?? ??? ??? ?? ?? ???? ??
  • ???? ??? ???? ?? ????? ??? ??

11
RMI
  • RMI (Remote Method Invocation)
  • ?? ???? ???? ? ??? ????? ??
  • ??? ? ?? ??
  • JRMP ??? ?? ???? ?? ????? ??
  • IIOP CORBA? ??.

?? ?
????? ?
RMI ????
RMI ???
??? ?? ??
??? ??
????? ??
????? ?? ??
12
?? ???? ??? ??
  1. ?? ????? ???
  2. ?? ?????? ??? ??? ???
  3. rmic? ???? ???? ???? ??
  4. RMI ?????(rmiregistry) ??
  5. ?? ??? ??

13
1. ?? ????? ???
  • java.rmi.Remote ??
  • ?? ????? RemoteException ??
  • ??? ???? ??? ??? ???? ??
  • import java.rmi.
  • public interface MyRemote extends Remote
  • public String sayHello() throws
    RemoteException

14
2. ?? ?????? ??? ???
  • ?? ????? ??
  • UnicastRemoteObject ??
  • RemoteException? ???? ??? ???
  • ???? RMI ?????? ??
  • puglic class MyRemoteImpl extends
    UnicastRemoteObject implements MyRemote
  • public MyRemoteImpl() throws RemoteException
  • public String sayHello()
  • return Server says, Hey
  • try
  • MyRemote service new MyRemoteImpl()
  • Naming.rebind(Remote_Hello, service)
  • catch(Exception ex)

15
3. ???/???? ??
  • ?? ?????? ??? ???? ?? rmic? ??

rmic MyRemoteImpl
101101 11010101 10101101 1010111 0100110
101101 11010101 10101101 1010111 0100110
MyRemoteImpl_Stub.class
MyRemoteImpl_Skel.class
16
4. rmiregistry ??
  • ???? ?? rmiregistry ??

rmiregistry
17
5. ??? ??
  • ?? ???? ?? ??? ??

java MyRemoteImpl
18
??????? ???? ?? ??
  • ??????? ???? ??? ?
  • ??? ??? ?? ???? ??
  • ??? ??? ??? ??? ?
  • RMI ??????? ???? ???

MyRemote service (MyRemote) Naming.lookup(rmi/
/127.0.0.1/Remote_Hello)
19
??????? ???? ?? ??
??
?????
????
????? ??
??? ??
???
Remote Hello
lookup()
???
RMI ?????
20
??? ???? ?? ??
  • ??? ???? ?? ?????? ??
  • ?? ??? ????
  • ??? ??? ?? ? ?? URL? ???? ??? ??? ??? ???
  • ???? ???? RMI ????? ???? ?? ????? ?? ? ??? ? URL?
    HTTP Get ??? ?? ???? ???

21
??? ??? ??
??
?????
????
????? ??
??? ??
???
???
101101 11011 101011
101101 11011 101011
101101 11011 101011
MyRemoteClient.class
MyRemoteImpl.class
MyRemoteImpl_Stub.class
101101 11011 101011
MyRemoteImpl_Stub.class
101101 11011 101011
101101 11011 101011
101101 11011 101011
MyRemote.class
MyRemote.class
MyRemoteImpl_Skel.class
22
??? (Servlet)
  • HTTP?? ? ??? ?? ???? ?? ????
  • CGI ?????? ?? ? ??? ????? ? ? ??
  • J2EE
  • ???? EJB(Enterprise Java Beans)? ???? ?? ??? ??
    ??
  • ???? EJB? ????? ??? ?
  • ???? EJB ???? RMI? ?? ??? ????

23
???
  • ???? ???? ?? ?? ??
  • servlets.jar? ??? ??? ??? ??
  • HttpServlet? ???? ??? ??? ???
  • public class MyServletA extends HttpServlet
  • ???? ???? HTML ??? ???
  • lta hrefServlets/MyServletAgtThis is the most
    amazing servlet.lt/agt
  • ???? HTML? ? ???? ??? ? ??? ???

24
???? JSP
  • JSP (Java Server Page)
  • ?????? ?? ???? HTML? ???? ?? ???? ???? ?
  • JSP??? ?? ??? ???? HTML ???? ???? ?
  • ???? ???? ??? ?? ????? ??? ??
  • ?? ???? ???? ??? ? ??? ???? JSP? ???? ??? ??? ? ??

25
EJB
  • RMI? ???? ?? ?? ??? ???? ??

?????
????
????? ??
?????? ?
????
EJB ??
26
?? (Jini)
  • ???? ????? (Adaptive discovery)
  • ???? ???? (self-healing network)
  • ????? ?? ?????? ?????? ?? ??? ???? ?? ? ??

27
???? ?????
?????. ?? ???.
?? ?? ???
28
???? ?????
scientificCalculator ?????. ??????.
?? ???
?? ?? ???
29
???? ?????
?? ???
?? ?? ???
?? ??????
scientificCalculator ??? ? ????
30
???? ?????
?? ???
?? ?? ???
?? ??????
?, ????. ?? ???? ?? ???.
31
???? ????
??? ?? ????. ? ??????.
?? ???
?? ?? ???
32
???? ????
???? ???? ???. ???? ???.
?? ?? ???
33
?? ??? ????
34
?? ??? ????
??
??? ????
Remote Hello
???
RMI ?????
35
?? ??? ????
??
??? ????
getServiceList()
getService(svc)
36
?? ??? ????
??? ????
37
?? ??? ???? ???/?????
ServiceServer
getServicesList() getService()
Service
getGuiPanel()
ServiceServerImpl
getServicesList() getService()
600607 ???? ???? ??? ?? ??????.
DiceService
getGuiPanel()
ServiceBrowser
main()
DayOfTheWeekService
getGuiPanel()
MiniMusicService
getGuiPanel()
38
??
  • ??? ???? ?????.
  • ?? ? ?? ??? ?? ??? ??? ??? ?? ??????.
  • ?? ??? ?? ???? ?????? ??? ?? ? ? ??? ??? ?? ????
    ???? ??? ? ???.
  • API ???? ? ?? ???? ??? ? ???? ?? ??? ?? ?????.
Write a Comment
User Comments (0)
About PowerShow.com