660 likes | 981 Views
CORBA. NTU IM 蘇威圖 張健鴻 劉式鈜. Architecture. NTUIM. CORBA. is a specification for distributed object from the OMG ( Object Management Group ) . Distributed Object. Object distributed over the network - location not important Object interact through interface - invoke an action
E N D
CORBA NTU IM 蘇威圖 張健鴻 劉式鈜
Architecture NTUIM
CORBA is a specification for distributed object from the OMG ( Object Management Group )
Distributed Object • Object distributed over the network - location not important • Object interact through interface - invoke an action - obtain the result from the object • Interface hide the object implementation
Why CORBA • Network Transparency • Language Independence • Platform Independence • Object interoperability • OO : encapsulation、polymorphism、inheritance
CORBA • C:Component • O:Object • R:Request • B:Broker • A:Architecture
ORB(Object Request Broker) • Component bus • Local/Remote transparency • Invocation • Object (program or data object) can be on the same machine or across network • Self-description • High level language binding
CORBA • Interface: Client/Server binding contract • IDL:Interface Definition Language • Implement object in their own environment -various programming language
System level service • Naming :map a human-readable name (string) to an object relative to its context • Security • Property • Transaction:two phase commit for flat、nested transaction • ………..
Component bus →System level Service → AP framework →business object C C++ Java Other C C++ Java Other IDL IDL IDL IDL IDL IDL IDL IDL Client Server ORB Naming Security Transaction ……………..
Client Side • Client IDL Stub (Static Invocation) • Dynamic Invocation Interface • Interface Repository API • ORB Interface
Server Side • Server IDL Skeleton • Dynamic Skeleton Interface • Object Adapter • Implementation Repository • ORB Interface
Object Adapter • Register Server classes with the Implementation Repository • Instantiate a new object at run time • Generate and manage object reference • Broadcast the presence of the object server • Handle incoming call • Route the up-call to the appropriate method => BOA (Basic Object Adapter)
What’s next • Asynchronous method invocation • Integrating Universal Naming Service - X.500、LDAP • Real-Time extensions • Embedded CORBA
CORBA => C + ORB + A
Code Albert NTUIM
範例介紹 • 利用OMG IDL定義interface • 撰寫Server端程式 • 撰寫Client端程式 • 執行程式
IDL • MyRemoteInterface.idl module Example { interface MyRemoteInterface { string getRemoteIP(); }; };
IDL compiler • 利用compiler,我們可以產生出client stub、server skeleton及implement client或server端時所需的程式 • Sun在Java語言的部分就提供了一個叫idltojava的compiler idltojava -fno-cpp MyRemoteInterface.idl http://java.sun.com/products/jdk/1.2/docs/guide/idl/index.html 更多資訊
IDL compiler • _ MyRemoteInterfaceImplBase.java This abstract class is the server skeleton, providing basic CORBA functionality for the server. • _MyRemoteInterfaceStub.java This class is the client stub, providing CORBA functionality for the client.
IDL compiler • MyRemoteInterface.java This interface contains the Java version of our IDL interface. It contains the single method getRemoteIP();
server端程式 • Server端程式主要由下列兩個Class組成 CORBAserver MyRemoteInterfaceServant
server端程式 • CORBAserver是用來產生一個ORB實體,並且透過命名(naming)的方式註冊成CORBA的物件,提供給其他物件使用。 • MyRemoteInterfaceServantimplement在MyRemeoteInterface IDL中所定義的interface,所以其必須繼承自_MyRemoteInterfaceImplBase這個類別 (由idltojava compiler產生) 並且implement getRemoteIP() 這個method。
CORBAServer.java import Example.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; import java.net.*;
CORBAServer.java public class CORBAServer { public static void main(String args[]) { try { // 建立並且初始化ORB實體 ORB orb = ORB.init(args, null); // 建立MyRemoteInterfaceServant並且對ORB註冊 MyRemoteInterfaceServant mri = new MyRemoteInterfaceServant(); orb.connect(mri);
CORBAServer.java // 取得命名的環境(naming context) org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContext ncRef = NamingContextHelper.narrow(objRef); // 對物件命名 NameComponent nc = new NameComponent("MyRemoteInterface", ""); NameComponent path[] = {nc}; ncRef.rebind(path, mri);
CORBAServer.java // 等待client的連結 java.lang.Object sync = new java.lang.Object(); synchronized(sync) { sync.wait(); } } catch (Exception e) { System.err.println("ERROR: "+e); e.printStackTrace(System.out); }
CORBAServer.java class MyRemoteInterfaceServant extends _MyRemoteInterfaceImplBase { public String getRemoteIP() { InetAddress address = null; try { address = InetAddress.getLocalHost(); } catch(Exception e) {} return address.toString(); } }
Client端程式 • 在以下的程式中描述了使用一個遠端CORBA物件的方法,透過一個name server以look up物件名稱的方式,實際取得其CORBA物件的指標(reference),然後再呼叫(invoke)所需的method。
Client.java import Example.*; import org.omg.CosNaming.*; import org.omg.CORBA.*;
Client.java public class Client { public static void main(String args[]) { try { ORB orb = ORB.init(args, null); org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService") NamingContext ncRef = NamingContextHelper.narrow(objRef);
Client.java // 利用物件名稱取得其指標 NameComponent nc = new NameComponent("MyRemoteInterface", ""); NameComponent path[] = {nc}; MyRemoteInterface mri = MyRemoteInterfaceHelper.narrow(ncRef.res olve(path)); // 呼叫遠端物件並且列印出其結果 System.out.println(mri.getRemoteIP());
Client.java catch(Exception e) { System.out.println("ERROR : "+e); e.printStackTrace(System.out); }
執行程式 • Compile所有程式碼 javac *.java Example/*.java • 啟動name server tnameserv -ORBInitialPort 1050 • 啟動server程式 java HelloServer -ORBInitialPort 1050 • 啟動client程式 java HelloClient -ORBInitialPort 1050 The default value is 900
參考資料 • Clemens Szyperski, "Component Software," Addison-wesley, 1998. • Z. Yang, K. Duddy, "CORBA: A Platform for Distributed Object Computing," http://www.omg.org/corba/beginners.html, 1997. • "CORBA Overview," http://pent21.infosys.tuwien.ac.at/Research/Corba/OMG/arch2.htm, 1997
Success Story Martin NTUIM
Who establish CORBA • OMG (Object Management Group) • 1989年由七家公司贊助成立 • 為非營利組織 • 目的為推廣 OO 概念及訂定OO標準 • 目前成果: CORBA, UML, CWM
Developmet in CORBA • 1991年 , CORBA 規格被提出 • 1995年 , CORBA 規格更新為 2.0 版 • 目前 , CORBA 2.4 版為最新版本 • 未來 , CORBA 3 即將出爐
CORBA 3 • Internet Integration • Firewall Specification • Interoperable Name Service • Quality of Service Control • Asynchronous Messaging and QoS Control • Minimum, Fault-Tolerant, Real-Time CORBA • CORBAcomponents Package • CORBAcomponents and CORBAscripting
CORBA-based software • Orbix - IONA • Visibroker - Inprise • Java IDL - Sun • SOB - IBM • OLE COM - Microsoft • PDO - NeXT
Who use CORBA • AT&T • American Airlines • Boeing Commercial Airplanes Group • Cisco Systems, Inc. • CNN Interactive • Nokia Telecomunications • Harvard University • NASA Hubble Space Telescope • The SABRE Group • ……
Why They Use CORBA • Distribution and Object Oriented • Industry Standard • Interoperability • Reliability • Scalability • Security
Cisco Systems, Inc. • IPC(Internetworking Product Center) • B to B 電子商務架構 • 處理企業47%的訂單 • 主要來自Web, 其次來自私人EDI網路 • 每天 1000 萬美金的訂貨量
Cisco Systems, Inc. • 舊有IPC的Web架構 • CGI程式以 C和 Perl為主 • 8套以上的CGI程式與資料庫連結 • 負荷量接近極限 Nelson Carbonell(CEO of Alta Software) said : “There hasn’t been a lot of thought put into the architecture!”