Corba and-java


Published on

Published in: Technology, Education
  • thanks
    Are you sure you want to  Yes  No
    Your message goes here

Corba and-java

  1. 1. CORBA and Java <ul><li>by Alex Chaffee </li></ul><ul><li>[email_address] </li></ul><ul><li> </li></ul><ul><ul><li>Java online resources </li></ul></ul><ul><li> </li></ul><ul><ul><li>Java training and consulting </li></ul></ul>
  2. 2. Abstract <ul><li>CORBA loves Java! CORBA provides a platform-independent, language-independent way to write applications that can invoke objects that live across the room or across the planet. Java is an object-oriented language that's ideal for writing the clients and servers living on the Object Bus. In this session, we examine the ways they interoperate programmatically, as we walk you step-by-step from a CORBA IDL, to a server and client both written in Java, running on top of a 100%-Java ORB. We also discuss the relationship between CORBA and RMI, and discuss some of the real-world issues involved in deploying a CORBA-based application. Recommended: some knowledge of CORBA, ability to read Java source code. </li></ul>
  3. 3. Introduction <ul><li>Purple Technology </li></ul><ul><ul><li> </li></ul></ul><ul><ul><li>Java Training and Consulting </li></ul></ul><ul><li>Alex Chaffee </li></ul><ul><ul><li>Creator of Gamelan </li></ul></ul><ul><ul><li>Cool Java Dude </li></ul></ul>
  4. 4. Part I: CORBA Overview
  5. 5. What is CORBA? <ul><li>Common Object Request Broker Architecture </li></ul><ul><li>Communication infrastructure for distributed objects </li></ul><ul><li>Allows a heterogeneous, distributed collection of objects to collaborate transparently </li></ul>
  6. 6. What is CORBA good for? <ul><li>Developing distributed applications </li></ul><ul><li>Locating remote objects on a network </li></ul><ul><li>Sending messages to those objects </li></ul><ul><li>Common interface for transactions, security, etc. </li></ul><ul><ul><li>CORBA Services (more later) </li></ul></ul>
  7. 7. Why Distributed Applications? <ul><li>Data is distributed </li></ul><ul><ul><li>Administrative and ownership reasons </li></ul></ul><ul><ul><li>Heterogeneous systems </li></ul></ul><ul><ul><li>Shared by multiple applications </li></ul></ul><ul><ul><li>Scalability </li></ul></ul>
  8. 8. Why Distributed Applications? <ul><li>Computation is distributed </li></ul><ul><ul><li>Scalability: multiprocessing </li></ul></ul><ul><ul><li>Take computation to data </li></ul></ul><ul><ul><li>Heterogeneous architectures </li></ul></ul><ul><li>Users are distributed </li></ul><ul><ul><li>Multiple users interacting and communicating via distributed applications </li></ul></ul>
  9. 9. Distributed Object Systems <ul><li>All entities are modeled as objects </li></ul><ul><li>Systems support location transparency </li></ul><ul><li>Interfaces, not implementations, define objects </li></ul><ul><li>Good distributed object systems are open, federated systems </li></ul>
  10. 10. What is the OMG? <ul><li>Designers of CORBA </li></ul><ul><li>Consortium of 700+ companies </li></ul><ul><ul><li>Not including Microsoft </li></ul></ul><ul><li>Members: </li></ul><ul><ul><ul><li>platform vendors </li></ul></ul></ul><ul><ul><ul><li>database vendors </li></ul></ul></ul><ul><ul><ul><li>software tool developers </li></ul></ul></ul><ul><ul><ul><li>corporate developers </li></ul></ul></ul><ul><ul><ul><li>software application vendors </li></ul></ul></ul>
  11. 11. It’s Just A Spec <ul><li>Has never been fully implemented </li></ul><ul><li>Probably never will be </li></ul><ul><li>Industry moves quickly and spec has to keep up </li></ul><ul><ul><li>Interoperability vs. portability </li></ul></ul><ul><ul><li>Pass-by-value </li></ul></ul>
  12. 12. Basic CORBA Architecture Client Server ORB ORB request response “ Object Bus”
  13. 13. CORBA Objects <ul><li>Examples </li></ul><ul><ul><li>Service </li></ul></ul><ul><ul><li>Client </li></ul></ul><ul><ul><li>Component </li></ul></ul><ul><ul><li>Business object </li></ul></ul><ul><li>CORBA objects approach universal accessibility </li></ul><ul><ul><li>Any Language </li></ul></ul><ul><ul><li>Any Host on network </li></ul></ul><ul><ul><li>Any Platform </li></ul></ul>
  14. 14. CORBA Elements <ul><li>1. ORB </li></ul><ul><li>2. CORBA Services </li></ul><ul><li>3. CORBA Facilities </li></ul><ul><li>4. Application Objects </li></ul>
  15. 15. ORB <ul><li>Object Request Broker </li></ul><ul><ul><li>“ Object Bus” </li></ul></ul><ul><li>Handles all communication among objects </li></ul><ul><li>Each host (machine) has its own ORB </li></ul><ul><li>ORBs know how to talk to each other </li></ul><ul><li>ORB also provides basic services to client </li></ul>
  16. 16. ORB Responsibilities <ul><li>Find the object implementation for the request </li></ul><ul><li>Prepare the object implementation to receive the request </li></ul><ul><li>Communicate the data making up the request </li></ul><ul><li>Retrieve results of request </li></ul>
  17. 17. Network of ORBs <ul><li>There’s an ORB on the server too </li></ul><ul><li>ORB receives request </li></ul>
  18. 18. IIOP <ul><li>Internet Inter-Orb Protocol </li></ul><ul><li>Network or “wire” protocol </li></ul><ul><li>Works across TCP/IP (the Internet protocol) </li></ul>
  19. 19. ORB Features <ul><li>Method invocations </li></ul><ul><ul><li>Static and Dynamic </li></ul></ul><ul><ul><li>Remote objects or CORBA services </li></ul></ul><ul><li>High-level language bindings </li></ul><ul><ul><li>Use your favorite language; ORB translates </li></ul></ul><ul><li>Self-describing </li></ul><ul><ul><li>Provides metadata for all objects and services </li></ul></ul>
  20. 20. ORB Features <ul><li>Local or remote </li></ul><ul><ul><li>Same API wherever target object lives </li></ul></ul><ul><li>Preserves context </li></ul><ul><ul><li>Distributed security and transactions </li></ul></ul><ul><li>Coexistence with legacy code </li></ul><ul><ul><li>Just provide a wrapper object </li></ul></ul>
  21. 21. What is an ORB really? <ul><li>Not a separate process </li></ul><ul><li>Library code that executes in-process </li></ul><ul><li>Listens to TCP ports for connections </li></ul><ul><ul><li>One port per local object </li></ul></ul><ul><li>Opens TCP sockets to other objects </li></ul><ul><ul><li>N ports per remote machine </li></ul></ul>
  22. 22. IDL <ul><li>Interface Definition Language </li></ul><ul><li>Defines protocol to access objects </li></ul><ul><li>Like a contract </li></ul><ul><li>Well-specified </li></ul><ul><li>Language-independent </li></ul>
  23. 23. IDL Example <ul><li>module Calc { </li></ul><ul><li>interface Adder { </li></ul><ul><li>long add(in long x, in long y); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>Defines an object called Adder with a method called add </li></ul>
  24. 24. Stubs and Skeletons <ul><li>Stub </li></ul><ul><ul><li>lives on client </li></ul></ul><ul><ul><li>pretends to be remote object </li></ul></ul><ul><li>Skeleton </li></ul><ul><ul><li>lives on server </li></ul></ul><ul><ul><li>receives requests from stub </li></ul></ul><ul><ul><li>talks to true remote object </li></ul></ul><ul><ul><li>delivers response to stub </li></ul></ul>
  25. 25. Stubs and Skeletons (Fig.) IIOP ORB Client Host Machine Client Object ORB Server Host Machine Stub Remote Object Skeleton
  26. 26. Client vs. Server <ul><li>in CORBA, a client is a client relative to a particular object </li></ul><ul><li>i.e. an object with a reference to a “server” object </li></ul><ul><li>A client may also act as a server </li></ul><ul><ul><li>If it has an IDL and stubs and skeletons </li></ul></ul><ul><li>Technically, a CORBA server contains one or more CORBA objects </li></ul>
  27. 27. Different Meanings of “Server” <ul><li>Host machine </li></ul><ul><li>Program running on host machine </li></ul><ul><li>CORBA object running inside program </li></ul><ul><ul><li>has IDL, stub, skeleton </li></ul></ul><ul><ul><li>Sometimes called a Servant </li></ul></ul>
  28. 28. Stubs and Skeletons -> Platform Independence <ul><ul><li>Client code has no knowledge of the implementation of the object or which ORB is used to access the implementation. </li></ul></ul>
  29. 29. CORBA Services <ul><li>APIs for low-level, common tasks </li></ul><ul><li>Life Cycle Service </li></ul><ul><ul><li>creating, copying, moving, removing objects </li></ul></ul><ul><li>Naming Service </li></ul><ul><ul><li>Register objects with a name </li></ul></ul><ul><ul><li>Look up objects by name </li></ul></ul>
  30. 30. CORBA Services <ul><li>Concurrency Control Service </li></ul><ul><ul><li>Obtain and release exclusive locks </li></ul></ul><ul><li>Transaction Service </li></ul><ul><ul><li>Two-phase commit coordination </li></ul></ul><ul><ul><li>Supports nested transactions </li></ul></ul><ul><li>Persistence Service </li></ul><ul><ul><li>Storing objects in a variety of databases </li></ul></ul><ul><ul><li>RDBMS, OODBMS, file systems </li></ul></ul>
  31. 31. CORBA Services <ul><li>Security Service </li></ul><ul><ul><li>Authentication, ACLs, encryption, etc. </li></ul></ul><ul><li>Event Service </li></ul><ul><ul><li>Uncoupled notifications </li></ul></ul>
  32. 32. CORBA Services <ul><li>Relationship </li></ul><ul><li>Externalization </li></ul><ul><li>Query </li></ul><ul><li>Licensing </li></ul><ul><li>Properties </li></ul><ul><li>Time </li></ul><ul><li>Trader </li></ul><ul><li>Collection </li></ul><ul><li>… and so on… </li></ul><ul><li>See what I mean about it never being implemented? </li></ul>
  33. 33. CORBA Facilities <ul><li>Frameworks for specialized applications </li></ul><ul><li>Distributed Document Component Facility </li></ul><ul><ul><li>OpenDoc </li></ul></ul><ul><li>In progress: </li></ul><ul><ul><li>Agents </li></ul></ul><ul><ul><li>Business Objects </li></ul></ul><ul><ul><li>Internationalization </li></ul></ul>
  34. 34. N-Tier Design with CORBA Client Tier Business Object Tier ORB ORB ORB DB DB TP Monitor ORB Storage “Tier” (after diagram in Orfali et al.) Service “Tier” ORB Data Object ORB ORB ORB ORB
  35. 35. Three Tiers <ul><li>User Interface Tier </li></ul><ul><li>Business Logic Tier </li></ul><ul><li>Data Storage Tier </li></ul><ul><li>Can use CORBA objects in each tier </li></ul>
  36. 36. Part II: Java IDL - Using CORBA from Java
  37. 37. Java CORBA Products <ul><li>The Java 2 ORB </li></ul><ul><li>VisiBroker for Java </li></ul><ul><li>OrbixWeb </li></ul><ul><li>Netscape Communicator </li></ul><ul><li>Various free or shareware ORBs </li></ul>
  38. 38. Java IDL <ul><li>Should be named “Java CORBA” </li></ul><ul><ul><li>More than just IDL </li></ul></ul><ul><ul><li>Full (?) implementation of CORBA in 100% Java </li></ul></ul><ul><li>Three Parts </li></ul><ul><ul><li>ORB </li></ul></ul><ul><ul><li>Naming Service </li></ul></ul><ul><ul><li>idltojava compiler </li></ul></ul><ul><li>Ships with JDK 1.2 </li></ul>
  39. 39. Transparent API <ul><li>JavaIDL turns IDL into direct method calls </li></ul><ul><li>Easy to program </li></ul><ul><li>Clients have no knowledge of implementation </li></ul><ul><li>Highly portable </li></ul>
  40. 40. The Java ORB <ul><li>100% Java </li></ul><ul><li>Generic </li></ul><ul><li>Allows Java IDL applications to run either as stand-alone Java applications, or as applets within Java-enabled browsers </li></ul><ul><li>Uses IIOP </li></ul>
  41. 41. Other Java ORBs <ul><li>Visigenic (Inprise) VisiBroker </li></ul><ul><ul><li>Netscape Communicator </li></ul></ul><ul><ul><li>Oracle Web Server 3.0 </li></ul></ul><ul><ul><li>Free download </li></ul></ul><ul><li>Iona OrbixWeb </li></ul>
  42. 42. IDL to Java Mapping <ul><li>Defined by OMG </li></ul><ul><li>Translates IDL concepts into Java language constructs </li></ul><ul><li>Everything is accessible by writing normal-looking Java code </li></ul>
  43. 43. IDL to Java Type Mapping <ul><li>IDL Type </li></ul><ul><li>boolean </li></ul><ul><li>char / wchar </li></ul><ul><li>octet </li></ul><ul><li>short / unsigned short </li></ul><ul><li>long / unsigned long </li></ul><ul><li>long long / unsigned long long </li></ul><ul><li>float </li></ul><ul><li>double </li></ul><ul><li>string / wstring </li></ul>Java Type boolean char byte short int long float double String
  44. 44. IDL vs. Java vs. C++ concepts <ul><li>IDL Java C++ </li></ul><ul><li>module package namespace </li></ul><ul><li>interface interface abstract </li></ul><ul><li>class </li></ul><ul><li>operation method member </li></ul><ul><li>function </li></ul><ul><li>attribute pair of pair of </li></ul><ul><li>methods functions </li></ul>
  45. 45. IDL Modules <ul><li>Map to Java packages </li></ul><ul><li>Unfortunately, it has the root level name of the module </li></ul><ul><li>Clutters up your package hierarchy </li></ul><ul><li>e.g. module Calc -> </li></ul><ul><ul><li>package Calc </li></ul></ul><ul><ul><li>interface Calc.Adder </li></ul></ul><ul><ul><li>not package ORG.omg.CORBA.modules.Calc </li></ul></ul>
  46. 46. IDL Interfaces <ul><li>Map to Java interfaces </li></ul>
  47. 47. IDL Operations <ul><li>Map to Java methods </li></ul>
  48. 48. IDL Attributes <ul><li>Map to pair of functions </li></ul><ul><li>IDL </li></ul><ul><ul><li>string name; </li></ul></ul><ul><li>Java </li></ul><ul><ul><li>public void name(String val); </li></ul></ul><ul><ul><li>public String name(); </li></ul></ul><ul><li>Yes, it looks stupid. Sorry. </li></ul>
  49. 49. idltojava <ul><li>Development tool </li></ul><ul><li>Automatically generates java stubs, skeletons, helpers, holders, ... </li></ul><ul><li>Generates stubs for specific remote interfaces </li></ul>
  50. 50. Stubs <ul><li>Java objects call stub methods </li></ul><ul><li>Stubs communicate with CORBA objects </li></ul><ul><ul><li>and vice versa </li></ul></ul><ul><li>Transparent integration </li></ul>
  51. 51. Skeletons <ul><li>ORB passes request to skeleton (like a stub) </li></ul><ul><li>Skeleton calls local implementation </li></ul>
  52. 52. Remote Interfaces and Stubs IDL Interface Stub Remote Object (Server) Client Skeleton implements implements extends
  53. 53. Show Me The Source Code <ul><li>OK, here it comes... </li></ul>
  54. 54. idltojava input <ul><li>Calc.idl </li></ul><ul><li>module Calc { </li></ul><ul><li>interface Adder { </li></ul><ul><li>long add(in long x, in long y); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  55. 55. idltojava output <ul><li>idltojava Calc.idl </li></ul><ul><ul><ul><li> (a Java interface that maps the IDL interface) </li></ul></ul></ul><ul><ul><ul><li> (a client stub) </li></ul></ul></ul><ul><ul><ul><li> (a server skeleton) </li></ul></ul></ul><ul><ul><ul><li> (a helper class) </li></ul></ul></ul><ul><ul><ul><li> (a holder class) </li></ul></ul></ul><ul><li>Must compile these files and put them in your CLASSPATH </li></ul>
  56. 56. <ul><li>Created for you by idltojava </li></ul><ul><li>package Calc; </li></ul><ul><li>public interface Adder </li></ul><ul><li>extends org.omg.CORBA.Object { </li></ul><ul><li>int add(int x, int y); </li></ul><ul><li>} </li></ul>
  57. 57. Implementing a server <ul><li>Extend base class </li></ul><ul><ul><li>Implement all methods declared in IDL </li></ul></ul><ul><li>Provide a main method </li></ul><ul><ul><li>Create an ORB instance </li></ul></ul><ul><ul><li>Create a server instance </li></ul></ul><ul><ul><li>Inform the ORB about the instance </li></ul></ul><ul><ul><li>Acquire a Naming Context </li></ul></ul><ul><ul><li>Register the instance in that Naming Context under some name </li></ul></ul>
  58. 58. <ul><li>class AdderServer extends _AdderImplBase </li></ul><ul><li>{ </li></ul><ul><li>public int add( int x, int y ) { </li></ul><ul><li>System.out.println(x + &quot; + &quot; + y + &quot; = &quot; + (x+y)); </li></ul><ul><li>return x + y; } </li></ul>
  59. 59. (cont.) <ul><li>public static void main(String args[]) { </li></ul><ul><li>// create and initialize the ORB </li></ul><ul><li>ORB orb = ORB.init(args, null); </li></ul><ul><li>// create server and register it with the ORB </li></ul><ul><li>AdderServer adderRef = new AdderServer(); </li></ul><ul><li>orb.connect(adderRef); </li></ul>
  60. 60. (cont.) <ul><li>// get the root naming context </li></ul><ul><li>org.omg.CORBA.Object objRef = </li></ul><ul><li>orb.resolve_initial_references(&quot;NameService&quot;); </li></ul><ul><li>NamingContext ncRef = NamingContextHelper.narrow(objRef); </li></ul><ul><li>// bind the Object Reference in Naming </li></ul><ul><li>NameComponent nc = new NameComponent(&quot;Adder&quot;, &quot;&quot;); </li></ul><ul><li>NameComponent path[] = {nc}; </li></ul><ul><li>ncRef.rebind(path, adderRef); </li></ul><ul><li>} </li></ul>
  61. 61. Implementing a client <ul><li>Create an ORB </li></ul><ul><li>Get a reference to the Naming Context </li></ul><ul><li>Look up the correct name in that Naming Context </li></ul><ul><li>Receive an object reference to that object </li></ul><ul><ul><li>Actually, to its Stub </li></ul></ul><ul><li>Invoke methods on the reference </li></ul>
  62. 62.
  63. 63. Object Reference <ul><li>Two Meanings </li></ul><ul><ul><li>1. An abstract concept referring to a specific object living on a specific host, attached to a specific ORB </li></ul></ul><ul><ul><li>2. A local Java reference to an object that relays messages to that object </li></ul></ul><ul><li>Obtained from </li></ul><ul><ul><li>new keyword </li></ul></ul><ul><ul><li>a Factory Object </li></ul></ul><ul><ul><li>the Naming Service </li></ul></ul>
  64. 64. Naming Service <ul><li>tnameserv </li></ul><ul><ul><li>t is for “transient” </li></ul></ul><ul><li>Maps name to object reference </li></ul><ul><li>An implementation of the CORBA Object Service (COS) name service </li></ul><ul><li>to run the Naming Service </li></ul><ul><ul><li>UNIX: tnameserv & </li></ul></ul><ul><ul><li>Win32: start /m tnameserv </li></ul></ul>
  65. 65. Fire it up <ul><li>start /m tnameserv </li></ul><ul><li>start java AdderServer </li></ul><ul><li>java AdderClient </li></ul><ul><li>2 + 2 = ? </li></ul>
  66. 66. CORBA Flow Client Virtual Machine Client Server Virtual Machine Stub Remote Object Skeleton Name Server Virtual Machine “ Fred” Server
  67. 67. CORBA Flow Client Virtual Machine Client Server Virtual Machine Stub Remote Object Skeleton Name Server Virtual Machine “ Fred” Server 1 2 1. Server Creates Remote Object 2. Server Registers Remote Object
  68. 68. CORBA Flow Client Virtual Machine Client Server Virtual Machine Stub Remote Object Skeleton Name Server Virtual Machine “ Fred” Server 4 3. Client requests object from Name Server 4. Name Server returns remote reference (and stub gets created) 3
  69. 69. RMI Flow Client Virtual Machine Client Server Virtual Machine Stub Remote Object Skeleton Name Server Virtual Machine “ Fred” Server 6 5. Client invokes stub method 6. Stub talks to skeleton 7. Skeleton invokes remote object method 5 7
  70. 70. Pseudo-objects <ul><li>The ORB is a pseudo-object </li></ul><ul><li>It works just like a remote object, only it’s local </li></ul>
  71. 71. The Basic Object Adapter (BOA) <ul><li>Another pseudo-object </li></ul><ul><li>Helps register objects with the ORB </li></ul><ul><li>Functions </li></ul><ul><ul><li>Maintain Implementation Repository </li></ul></ul><ul><ul><li>Generate and interpret object references </li></ul></ul><ul><ul><li>Activate and deactivate implementation objects </li></ul></ul><ul><ul><li>Invoke methods via skeletons </li></ul></ul>
  72. 72. Why do you need both an ORB and a BOA? <ul><li>I’m not really sure </li></ul><ul><li>Allows vendors to optimize or enhance functionality </li></ul><ul><ul><li>register many objects en masse </li></ul></ul><ul><ul><li>cache object state elsewhere </li></ul></ul><ul><li>E.g. Object database </li></ul>
  73. 73. Using the BOA <ul><li>Slightly different procedure for initializing objects </li></ul><ul><li>Hides name service from you </li></ul><ul><ul><li>Ask the BOA to register the object </li></ul></ul><ul><ul><li>Ask the Helper object to bind the object </li></ul></ul><ul><li>Once the object is created, interface is identical </li></ul><ul><ul><li>Just call methods using normal Java syntax </li></ul></ul>
  74. 74. BOA Object Activation <ul><li>Shared server </li></ul><ul><ul><li>Multiple objects, one server </li></ul></ul><ul><ul><li>Normal procedure </li></ul></ul><ul><ul><li>Multithreaded (handled by CORBA implementation) </li></ul></ul><ul><li>Unshared server </li></ul><ul><ul><li>New process for each object </li></ul></ul>
  75. 75. BOA Object Activation (cont.) <ul><li>Server-per-method </li></ul><ul><ul><li>Batch processing </li></ul></ul><ul><li>Persistent server </li></ul><ul><ul><li>Shared server, but object not created by ORB </li></ul></ul>
  76. 76. BOA Object Activation Scenario <ul><li>Server creates object instance </li></ul><ul><ul><li>obj = new MyObject(); </li></ul></ul><ul><li>Server registers object with BOA </li></ul><ul><ul><li>boa.create(interface_name, implementation_name, reference_data) </li></ul></ul><ul><ul><li>VisiBroker does this for you in superclass constructor </li></ul></ul>
  77. 77. BOA Object Activation Scenario (cont.) <ul><li>Server tells BOA the object is ready </li></ul><ul><ul><li>boa.obj_is_ready(obj) </li></ul></ul><ul><li>Server tells BOA that all objects are ready </li></ul><ul><ul><li>boa.impl_is_ready() </li></ul></ul><ul><li>Objects shut down </li></ul><ul><ul><li>boa.deactivate_obj(this) </li></ul></ul><ul><li>Server shuts down </li></ul><ul><ul><li>boa.deactivate_impl() </li></ul></ul>
  78. 78. Threads in JavaIDL <ul><li>Remote invocations happen on a separate thread </li></ul><ul><li>Must make sure your remote objects are thread-safe </li></ul>
  79. 79. Callbacks <ul><li>Pass in a reference to some CORBA object </li></ul><ul><li>The server object can invoke methods on that reference </li></ul><ul><li>ORB automatically generates a stub on the server side </li></ul><ul><li>The server has become the client, and vice versa </li></ul>
  80. 80. Obtaining Object References <ul><li>From the ORB </li></ul><ul><ul><li>orb.resolve_initial_references(“NameService”) </li></ul></ul><ul><li>From a Naming Context </li></ul><ul><li>From a Stringified reference </li></ul><ul><li>From another object </li></ul><ul><li>From a parameter to your remote method </li></ul>
  81. 81. Helper Objects <ul><li>How CORBA does casting </li></ul><ul><li>narrow method changes the type of an object reference </li></ul><ul><ul><li>// get the root naming context </li></ul></ul><ul><ul><li>org.omg.CORBA.Object objRef = </li></ul></ul><ul><ul><li>orb.resolve_initial_references(&quot;NameService&quot;); </li></ul></ul><ul><ul><li>NamingContext ncRef = NamingContextHelper.narrow(objRef); </li></ul></ul>
  82. 82. Naming Contexts <ul><li>Directory structure for CORBA </li></ul><ul><li>Naming Component = file </li></ul><ul><li>Naming Context = directory </li></ul><ul><li>Can add a Context as a Component </li></ul><ul><ul><li>like subdirectories </li></ul></ul><ul><li>Can add a Context on a different name server </li></ul><ul><ul><li>like symbolic links </li></ul></ul>
  83. 83. Stringification <ul><li>Stringified reference is ORB-independent </li></ul><ul><li>Object to string </li></ul><ul><ul><li>org.omg.CORBA.Object obj = ... </li></ul></ul><ul><ul><li>String str = orb.object_to_string(obj); </li></ul></ul><ul><li>String to object </li></ul><ul><ul><li>org.omg.CORBA.Object obj = orb.string_to_object(str); </li></ul></ul>
  84. 84. Visigenic: Caffeine <ul><li>Java to IDL compiler </li></ul>
  85. 85. Symantec: Visual Café 3.0 Enterprise Suite <ul><li>Java to IDL compiler </li></ul><ul><li>Automatic client adapter bean generation </li></ul><ul><ul><li>Makes a JavaBean that’s a proxy to a CORBA object </li></ul></ul><ul><li>Distributed debugging </li></ul><ul><ul><li>Follow call chain, examine variables, et al. </li></ul></ul><ul><ul><li>Across many VMs, many hosts, many OSs </li></ul></ul>
  86. 86. Part III: Example Application
  87. 87. Publish-Subscribe System <ul><li>Channel: an avenue for real-time data exchange </li></ul><ul><li>Consumers can subscribe to arbitrary data channels </li></ul><ul><li>Producers can publish data on channels </li></ul><ul><ul><li>Invokes callback method on consumer </li></ul></ul>
  88. 88. Object Model <ul><li>PSServer </li></ul><ul><ul><li>Channel getChannel(String channelName) </li></ul></ul><ul><ul><ul><li>creates channel if it doesn’t already exist </li></ul></ul></ul><ul><li>Channel </li></ul><ul><ul><li>void subscribe(Subscriber sub) </li></ul></ul><ul><ul><li>void publish(Object data) </li></ul></ul><ul><li>Subscriber </li></ul><ul><ul><li>void dataArrived(Object data) </li></ul></ul>
  89. 89. Flow: Subscriber-side <ul><li>Client acquires PSServer reference </li></ul><ul><li>Client acquires channel from PSServer </li></ul><ul><li>Client creates subscriber locally, passing reference to channel </li></ul><ul><li>Subscriber registers self with channel </li></ul><ul><ul><li>channel.subscribe(this) </li></ul></ul><ul><li>Client waits for callback to its dataArrived method </li></ul>
  90. 90. Flow: Publisher-side <ul><li>Client acquires PSServer reference </li></ul><ul><li>Client acquires channel from PSServer </li></ul><ul><li>Client creates publisher locally, passing reference to channel </li></ul><ul><li>Publisher acquires data </li></ul><ul><ul><li>From a database </li></ul></ul><ul><ul><li>From a data feed </li></ul></ul><ul><li>Publisher calls channel.publish(data) </li></ul>
  91. 91. Example Application: Stock data <ul><li>Channel name = stock symbol name </li></ul><ul><li>Source code available </li></ul>
  92. 92. Design issues <ul><li>Name space for channels </li></ul><ul><ul><li>TIBCO et al. use hierarchical directory structure </li></ul></ul><ul><li>Caching prior messages </li></ul><ul><ul><li>Subscribe should spawn a thread that sends previous N messages </li></ul></ul>
  93. 93. Design issues <ul><li>Maintain local cache of data sent </li></ul><ul><ul><li>Don’t want to go back across the network every time you draw a graph </li></ul></ul><ul><ul><li>Create local version of class </li></ul></ul>
  94. 94. Part IV: Advanced Topics
  95. 95. Exceptions <ul><li>CORBA exceptions are mapped to Java exceptions </li></ul><ul><li>System Exceptions </li></ul><ul><ul><li>They’re subclasses of RuntimeException, so the compiler won’t complain if you forget to catch them </li></ul></ul><ul><ul><li>Minor codes </li></ul></ul><ul><ul><ul><li>additional information </li></ul></ul></ul><ul><ul><ul><li>vendor-specific :-( </li></ul></ul></ul><ul><ul><li>Completion Status </li></ul></ul>
  96. 96. Exceptions (cont.) <ul><li>User Exceptions </li></ul><ul><ul><li>Generated by idltojava </li></ul></ul><ul><ul><li>Subclasses of Exception (declared) </li></ul></ul>
  97. 97. Dynamic Invocation Interface (DII) <ul><li>CORBA is fully self-aware </li></ul><ul><li>Methods for acquiring </li></ul><ul><ul><li>List of all services </li></ul></ul><ul><ul><li>List of known objects </li></ul></ul><ul><ul><li>Interfaces of known objects </li></ul></ul><ul><ul><li>Etc. </li></ul></ul><ul><li>Well-documented elsewhere </li></ul>
  98. 98. Interface Repositories <ul><li>JavaIDL clients do not typically need or use an Interface Repository </li></ul><ul><li>All of the needed type information is available in the stubs or is resolved by an object's server </li></ul><ul><li>JavaIDL supports access to Interface Repository information made available by other CORBA object implementations. </li></ul>
  99. 99. Implementation Repository <ul><li>contains information that allows the ORB to locate and activate implementations of objects </li></ul><ul><li>also store additional information associated with implementations of ORB objects. </li></ul><ul><ul><ul><li>Debugging information </li></ul></ul></ul><ul><ul><ul><li>Administrative control </li></ul></ul></ul><ul><ul><ul><li>Resource allocation </li></ul></ul></ul><ul><ul><ul><li>Security </li></ul></ul></ul>
  100. 100. Value Objects <ul><li>CORBA 3.0 </li></ul><ul><li>Blobs </li></ul><ul><li>Avoids network latency of pass-by-reference objects </li></ul>
  101. 101. RMI over IIOP <ul><li>In Development </li></ul><ul><li>Uses IIOP as transport protocol </li></ul><ul><li>Uses Value Objects to pass Java serialized objects </li></ul>
  102. 102. CORBA via RMI <ul><li>Possible using middleware server </li></ul><ul><li>RMI from client to middleware </li></ul><ul><li>IIOP from middleware to other servers </li></ul><ul><li>Can use Servlet as middleware </li></ul>
  103. 103. CORBA and EJB <ul><li>Transport </li></ul><ul><ul><li>EJB uses RMI interface, RMI uses IIOP </li></ul></ul><ul><li>CORBA 3.0 promises object compatibility with EJB </li></ul><ul><ul><li>Not quite sure what that means </li></ul></ul><ul><li>Some EJB Servers contain an ORB </li></ul><ul><ul><li>All EJB Objects are also CORBA objects </li></ul></ul>
  104. 104. CORBA and EJB (Cont.) <ul><li>All EJB Servers use CORBA Transactions (via JTS) </li></ul><ul><ul><li>That means that any client can make a distributed transaction that includes both CORBA and EJB Objects </li></ul></ul><ul><li>Not an either-or decision </li></ul><ul><ul><li>You can have both EJB and CORBA working together in a single system </li></ul></ul>
  105. 105. Java Transactions <ul><li>Java Transaction Service (JTS) </li></ul><ul><ul><li>A standard Java mapping of the OMG Object Transaction Service (OTS) </li></ul></ul><ul><ul><li>packages org.omg.CosTransaction and org.omg.CosTSPortability </li></ul></ul><ul><li>Java Transaction API (JTA) </li></ul><ul><ul><li>High-level transaction management specification </li></ul></ul><ul><ul><li>package javax.transaction </li></ul></ul><ul><ul><li>class UserTransaction </li></ul></ul>
  106. 106. Object Transaction Service (OTS) <ul><li>Distributed transaction specification </li></ul><ul><li>Part of CORBA, but also standalone </li></ul><ul><li>Transactions can span </li></ul><ul><ul><li>multiple queries </li></ul></ul><ul><ul><li>multiple objects </li></ul></ul><ul><ul><li>multiple servers </li></ul></ul><ul><ul><li>multiple databases </li></ul></ul><ul><ul><li>multiple vendors’ products </li></ul></ul>
  107. 107. OTS Features <ul><li>Distributed transactions </li></ul><ul><li>Flat or nested transactions </li></ul><ul><li>Two-phase commit </li></ul><ul><li>Vendor interoperability (?) </li></ul>
  108. 108. OTS Object Model <ul><li>Transactional Object </li></ul><ul><ul><li>Can participate in a transaction </li></ul></ul><ul><li>Recoverable Object </li></ul><ul><ul><li>Actually performs commit or rollback on its own data </li></ul></ul><ul><li>Resource </li></ul><ul><ul><li>A system or server that can commit or rollback data stored inside it </li></ul></ul><ul><ul><li>E.g. a database server </li></ul></ul>
  109. 109. OTS Object Model (Cont.) <ul><li>Current </li></ul><ul><ul><li>Reference/wrapper to currently active transaction </li></ul></ul><ul><li>Control / Coordinator / Terminator </li></ul><ul><ul><li>Registers objects </li></ul></ul><ul><ul><li>Performs distributed commit/rollback </li></ul></ul><ul><li>Synchronization </li></ul><ul><ul><li>An object that gets informed of the progress of the ongoing transaction </li></ul></ul><ul><ul><li>Implements callback methods </li></ul></ul>
  110. 110. Part V: CORBA/Java Case Studies
  111. 111. CORBA Case Study <ul><li>Kaiser Permanente Northern California </li></ul><ul><li>KAHUNA a/k/a WebChart </li></ul><ul><li> </li></ul>
  112. 112. Problem: Specific <ul><li>Medical records, patient histories, clinical schedules, lab results, and medical images all stored in disparate databases </li></ul><ul><li>Many patients per doctor, many doctors per patient </li></ul><ul><li>Need immediate access to all information </li></ul>
  113. 113. Problem: General <ul><li>getting data </li></ul><ul><ul><li>from a multitude of sources </li></ul></ul><ul><ul><li>in a multitude of media </li></ul></ul><ul><li>putting data </li></ul><ul><ul><li>into a single system </li></ul></ul><ul><li>distributing data </li></ul><ul><ul><li>to a wide variety of desktops </li></ul></ul><ul><ul><li>throughout a very large company </li></ul></ul>
  114. 114. Solution: Java/CORBA <ul><li>“ Not only did Java/CORBA solve all these problems, but Java/CORBA development is cheap, fast, scalable and works over the Internet.” </li></ul>
  115. 115. WebChart Architecture
  116. 116. This is your brain on Java. Any questions?
  117. 117. Conclusion
  118. 118. Where to Get More Information <ul><ul><li>Orfali & Harkey, Client/Server Programming with Java and CORBA (Wiley) </li></ul></ul><ul><ul><li>Orfali, Harkey & Edwards, Instant CORBA (Wiley) </li></ul></ul>
  119. 119. More Info: Links <ul><ul><li>This Presentation </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><li>JDK 1.2 CORBA documentation </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><li>Glerum, WebChart serves up Kaiser patients, JavaWorld </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul>
  120. 120. More Info: Links <ul><ul><li>Object Management Group - </li></ul></ul><ul><ul><li>Java Transactions </li></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><ul><li> </li></ul></ul></ul><ul><ul><ul><li> </li></ul></ul></ul>