Presentation is loading. Please wait.

Presentation is loading. Please wait.

CORBA Details Three Tier Architecture CORBA API Holders and Helpers COS Naming and Naming Contexts Transient and Persistent Objects Properties Callbacks.

Similar presentations


Presentation on theme: "CORBA Details Three Tier Architecture CORBA API Holders and Helpers COS Naming and Naming Contexts Transient and Persistent Objects Properties Callbacks."— Presentation transcript:

1 CORBA Details Three Tier Architecture CORBA API Holders and Helpers COS Naming and Naming Contexts Transient and Persistent Objects Properties Callbacks

2 Three Tier Architecture Implements Business Logic and Does Most of Computation ClientServiceData Requests Services. Small Footprint and GUI Manages access to persistent data and its storage mechanisms

3 CORBA API org.omg.CORBA package –ORB –Object –exceptions –primitive holders –dynamic typing –Dynamic Invocation Interface (DII)

4 All CORBA exceptions from org.omg.CORBA.SystemException Standard CORBA container class for any IDL datatype: org.omg.CORBA.Any DII call methods on CORBA objects at runtime rather than compile time

5 Holders and Helpers Java’s parameter passing don’t support out and inout types holder classes provide this functionality A holder includes public data member that holds its value, and a pair of constructors, one with no argument and other with an initial value Helper contains static methods for manipulating that type

6

7

8 COS Naming and Name Contexts org.omg.CosNaming A CORBA service that allows CORBA objects to be named by means of binding a name to an object reference. The name binding may be stored in the naming service, and a client may supply the name to obtain the desired object reference.

9 Name Binding: The association of a name with an object reference. Name bindings are stored in a naming context. Name Space: A collection of naming contexts that are grouped together Names added or removed from namespace with bind(), rebind(), and unbind() Bootstrapping is process of connecting a client to a CORBA object from which it can locate the servers it wants to access. list_initial_services () and resolve_initial_references ()

10 A CORBA object that supports the NamingContext interface and functions as a sort of directory which contains (points to) other naming contexts and/or simple names. Similar to a directory structure, where the last item is a file and preceding items are directories, in a naming context, the last item is an object reference name, and the preceding items are naming contexts. Naming Context

11 import java.util.Properties; import org.omg.CORBA.*; import org.omg.CosNaming.*; public class NameClient { public static void main(String args[]) { try { Pr operties props = new Properties(); props.put("org.omg.CORBA.ORBInitialPort", "1050"); ORB orb = ORB.init(args, props); NamingContext ctx = NamingContextHelper.narrow(orb.resolve_initial_references("NameService")); NamingContext objref = ctx; NameComponent nc1 = new NameComponent("plans", "text"); NameComponent[] name1 = {nc1}; ctx.rebind(name1, objref); System.out.println("plans rebind sucessful!"); NameComponent nc2 = new NameComponent("Personal", "directory"); NameComponent[] name2 = {nc2}; NamingContext ctx2 = ctx.bind_new_context(name2); System.out.println("new naming context added.."); NameComponent nc3 = new NameComponent("schedule", "text"); NameComponent[] name3 = {nc3}; ctx2.rebind(name3, objref); System.out.println("schedule rebind sucessful!"); NameComponent nc4 = new NameComponent("calender", "text"); NameComponent[] name4 = {nc4}; ctx2.rebind(name4, objref); System.out.println("calender rebind sucessful!"); } catch (Exception e) { e.printStackTrace(System.err); }

12 rebind() binds naming context and object reference even if one already exists Name Component requires id and type Name Component array is path to desired object reference \Personal\Calendar >>{Personal,Calendar}

13 Transient & Persistent Objects Transient objects only exist for the life of the server that creates them Persistent Objects exist beyond life of server JavaIDL has Transient mechanism

14 Properties Subclasses hashtable and represents a persistent set of properties put(Object key, Object value) Represent application or applet specific properties

15 Callback

16 module HelloApp { interface HelloCallback { void callback(in string message); }; interface Hello { string sayHello(in HelloCallback objRef, in string message); };

17 import HelloApp.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; class HelloServant extends _HelloImplBase { public String sayHello(HelloCallback callobj, String msg) { callobj.callback(msg); return "\nHello world !!\n"; } }

18 public class HelloServer { public static void main(String args[]) { try{ // create and initialize the ORB ORB orb = ORB.init(args, null); // create servant and register it with the ORB HelloServant helloRef = new HelloServant(); orb.connect(helloRef); // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContext ncRef = NamingContextHelper.narrow(objRef); // bind the Object Reference in Naming NameComponent nc = new NameComponent("Hello", ""); NameComponent path[] = {nc}; ncRef.rebind(path, helloRef); // wait for invocations from clients java.lang.Object sync = new java.lang.Object(); synchronized (sync) { sync.wait(); } } catch (Exception e) { System.err.println("ERROR: " + e); e.printStackTrace(System.out);} }}

19 import HelloApp.*; import org.omg.CosNaming.*; import org.omg.CORBA.*; class HelloCallbackServant extends _HelloCallbackImplBase{ public void callback(String notification) { System.out.println(notification);}

20 public class HelloClient { public static void main(String args[]) { try{ // create and initialize the ORB ORB orb = ORB.init(args, null); // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContext ncRef = NamingContextHelper.narrow(objRef); // resolve the Object Reference in Naming NameComponent nc = new NameComponent("Hello", ""); NameComponent path[] = {nc}; Hello helloRef = HelloHelper.narrow(ncRef.resolve(path)); HelloCallbackServant helloCallbackRef = new HelloCallbackServant(); orb.connect(helloCallbackRef); // call the Hello server object and print results String hello = helloRef.sayHello(helloCallbackRef,"\ntest..\n"); System.out.println(hello); } catch (Exception e) { System.out.println("ERROR : " + e) ; e.printStackTrace(System.out); } } }

21 CORBA Callbacks The Good, The Bad, and The Ugly

22 Problems (or not) Security Restrictions are IN FORCE Need to specify security policy file to –Server –Appletviewer Parameters as well

23

24

25

26

27

28

29

30 Parameters

31

32

33


Download ppt "CORBA Details Three Tier Architecture CORBA API Holders and Helpers COS Naming and Naming Contexts Transient and Persistent Objects Properties Callbacks."

Similar presentations


Ads by Google