CORBA NTU IM 蘇威圖 張健鴻 劉式鈜 Architecture NTUIM CORBA is a specification for...

Preview:

Citation preview

CORBACORBANTU IMNTU IM蘇威圖張健鴻劉式鈜

ArchitectureArchitecture

NTUIM

CORBACORBAis a specification for

distributed object from the

OMG

( Object Management Group )

Distributed ObjectDistributed ObjectObject distributed over the network

- location not importantObject interact through interface

- invoke an action- obtain the result from the object

Interface hide the object implementation

Why CORBAWhy CORBANetwork TransparencyLanguage IndependencePlatform IndependenceObject interoperabilityOO :

encapsulation 、 polymorphism 、 inheritance

CORBACORBAC : ComponentO : ObjectR : RequestB : BrokerA : Architecture

ORBORB(Object Request (Object Request Broker)Broker)Component busLocal/Remote transparencyInvocationObject (program or data object) can be

on the same machine or across network

Self-descriptionHigh level language binding

Interface: Client/Server binding contract

IDL:Interface Definition LanguageImplement object in their own

environment

-various programming language

CORBACORBA

System level System level serviceserviceNaming :map a human-readable

name (string) to an object relative to its context

SecurityPropertyTransaction : two phase commit for

flat 、 nested transaction………..

Component bus →System level Service →

AP framework →business object

Naming Security Transaction ……………..

ORB

Client Server

C C++ Java Other

IDL IDL IDLIDL IDLIDL IDL IDL

C++C Java Other

CORBA CORBA ArchitectureArchitecture

Client SideClient SideClient IDL Stub (Static Invocation)Dynamic Invocation InterfaceInterface Repository APIORB Interface

Static InvocationStatic Invocation

Client Dynamic Client Dynamic InvocationInvocation

Server SideServer SideServer IDL SkeletonDynamic Skeleton InterfaceObject AdapterImplementation RepositoryORB Interface

Dynamic Serve Dynamic Serve InvocationInvocation

Object AdapterObject 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)

BOBOAA

What’s nextWhat’s nextAsynchronous method invocationIntegrating Universal Naming Service

- X.500 、 LDAPReal-Time extensions Embedded CORBA

CORBACORBA

CORBA=>

C + ORB + A

CodeCodeAlbert

NTUIM

範例介紹範例介紹利用 OMG IDL 定義 interface

撰寫 Server 端程式

撰寫 Client 端程式

執行程式

IDLIDL MyRemoteInterface.idl

module Example

{

interface MyRemoteInterface

{

string getRemoteIP();

};

};

IDL compilerIDL 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 compilerIDL 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 compilerIDL compiler MyRemoteInterface.java

This interface contains the Java version of our

IDL interface. It contains the single method

getRemoteIP();

serverserver 端程式端程式Server 端程式主要由下列兩個 Class 組

CORBAserver

MyRemoteInterfaceServant

serverserver 端程式端程式 CORBAserver 是用來產生一個 ORB 實體,並且透

過命名( naming )的方式註冊成 CORBA 的物件,提供給其他物件使用。

MyRemoteInterfaceServant implement 在MyRemeoteInterface IDL 中所定義的 interface ,所以其必須繼承自 _MyRemoteInterfaceImplBase這個類別

(由 idltojava compiler 產生) 並且 implement getRemoteIP() 這個 method 。

CORBAServer.javaCORBAServer.javaimport Example.*;

import org.omg.CosNaming.*;

import

org.omg.CosNaming.NamingContextPackage.*;

import org.omg.CORBA.*;

import java.net.*;

CORBAServer.javaCORBAServer.javapublic 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.javaCORBAServer.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.javaCORBAServer.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.javaCORBAServer.java class MyRemoteInterfaceServant extends _MyRemoteInterfaceImplBase { public String getRemoteIP() { InetAddress address = null; try { address = InetAddress.getLocalHost(); } catch(Exception e) {} return address.toString(); } }

ClientClient 端程式端程式在以下的程式中描述了使用一個遠端

CORBA 物件的方法,透過一個 name

server 以 look up 物件名稱的方式,實際取得其 CORBA 物件的指標( reference ),

然後再呼叫( invoke )所需的 method 。

Client.java Client.java

import Example.*;

import org.omg.CosNaming.*;

import org.omg.CORBA.*;

Client.java 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 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 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 StorySuccess StoryMartin

NTUIM

Who establish Who establish CORBACORBA

OMG OMG (Object Management Group)

1989 年由七家公司贊助成立為非營利組織目的為推廣 OO 概念及訂定 OO 標準目前成果 : CORBA, UML, CWM

Developmet in Developmet in CORBACORBA1991 年 , CORBA 規格被提出

1995 年 , CORBA 規格更新為 2.0 版

目前 , CORBA 2.4 版為最新版本

未來 , CORBA 3 即將出爐

CORBA 3CORBA 3Internet 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 CORBA-based softwaresoftwareOrbix - IONAVisibroker - InpriseJava IDL - SunSOB - IBMOLE COM - MicrosoftPDO - NeXT

Who use CORBAWho 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 Why They Use CORBACORBA

Distribution and Object Oriented

Industry StandardInteroperabilityReliabilityScalabilitySecurity

Cisco Systems, Inc.Cisco Systems, Inc.IPCIPC (Internetworking Product

Center)B to B 電子商務架構處理企業 47% 的訂單主要來自 Web, 其次來自私人 EDI 網路每天 1000 萬美金的訂貨量

Cisco Systems, Inc.Cisco Systems, Inc.舊有舊有 IPCIPC 的的 WebWeb 架構架構

CGI 程式以 C 和 Perl 為主8 套以上的 CGI 程式與資料庫連結負荷量接近極限

Nelson Carbonell(CEO of Alta Software) said :

“There hasn’t been a lot of thought put into the architecture!”

Cisco Systems, Inc.Cisco Systems, Inc.改造改造 IPCIPC

和 Alta Software 合作以 Java/CORBA 為基本架構將舊系統完全翻新原本多為 Solaris 使用者 , 因此技術人員迅速地熟稔 Java/CORBA 架構

Cisco Systems, Inc.Cisco Systems, Inc.成果成果

穩定性高高度延展性可管理性高和 ERP 系統 (Oracle) 相連結提供客製化服務

CNN InteractiveCNN InteractiveCNN’s websitesCNN’s websites

CNN.com

AllPolitics.com

CNN.com/CustomNews

CNNSI.com

CNNEnEspanol.com

CNN.passen.se

CNNemPortugues.com

Mirror sites: europe.cnn.com, japan.cnn.com

CNN InteractiveCNN Interactive網站流量網站流量 (1998(1998 年年 66 月月 ))

每分鐘 15000 - 25000 人次每個禮拜有 7700 萬個網頁供人參觀每個月有 1150 萬不同的人來參觀當時每個月還有 9% 的成長

CNN InteractiveCNN Interactive內部情況內部情況

使用 Solaris Server

程式設計師多用 C++ , Java

記者做無效率的工作

CNN InteractiveCNN Interactive發展發展 Distributed Web-publishing Distributed Web-publishing

SystemSystem

選擇 CORBA

和 IONA 合作採用 Orbix 環境 Java-based 使用者介面

CNN InteractiveCNN Interactive

TemplatesTemplatesTemplatesCNN

GeneratorHTMLHTMLHTML

IRCNN

ContentServers

CNN InteractiveCNN Interactive

CNN

Reuters

AP

ClassifierWire Services

Event Channel

CNN InteractiveCNN InteractiveCNN : “We deliver products one distributed component at a time , and then we build on those component”

Video System Wires Posting System Prioritizer UI

Magic Mover UI

Publisher Service Priority Service

Distributed Systems Generation Service Content Service

CNN InteractiveCNN Interactive成果成果

程式重用性高物件技術更純熟系統延展性高企業經營更進步

NIKENIKE當時情形 (1997 年 7 月 )

16000 名員工90 億美金的營收25 年內快速成長對 IT 的急迫性

NIKENIKE原本 IT 架構

EZBridgeDB2 MVS

SunOS

SolarisOracle

Non PC Client

FTP RPC

InternetX.25

NIKENIKE改造

選擇 CORBA

和 IONA 合作採用 Orbix 環境淘汰 SunOS

Client 端加入 win95 PC

NIKENIKE改造後 IT 架構

DB2 MVS

SolarisOracle

Mac

FTP Orbix

InternetX.25

Win95 PC

Orbix CTP

NIKENIKE改造成果

採用標準的溝通機制將 Client 端順利轉換為 win95 PC

移除有 Y2K 問題的元件富延展性的架構

NIKENIKE

Just do it !

Reuse legacy code

Remove an unwanted machine type

Install a new front-end client

Recommended