2. Distributed Object Programming course 2003
What is CORBA?
â
Specifications, not products
â
Vision is portability (between vendors)
â Rely on supporting OS/platform?
â Standards do not cover all needs (extensions)
â Standards and products evolve at different
rates
â
Not all vendors support every option
â
http://www.omg.org
4. Distributed Object Programming course 2003
Model
â
Focus is on objects
â Create remote objects and call their methods
â
Used like local objects
â
Contain state like normal objects
â
Creation mechanism is different
â
Uses âstubsâ and âskeletonsâ
â Multi-language
â
Bindings for C, C++, Java, Ada, âŠ
â
Available methods defined through IDL
5. Distributed Object Programming course 2003
Model (2)
â
Remote stateful objects
â Real objects, possibly shared and persistent
â
Rich API set
â Programmers directly control security,
transactions, finding object/servers by calling
methods
â
Quite far from stateless components
â External state, container properties
6. Distributed Object Programming course 2003
Model (3)
One standardised interface
One interface per object operation
ORB-dependent interface
One interface per object adapter
DynamicDynamic
InvocationInvocation
Client
Stubs
ORB
InterfaceInterface
Implementation
Skeletons
Client Object Implementation
ORB Core
Object
Adapter
8. Distributed Object Programming course 2003
More Services
â
Services
â Event
â Notification
â Externalization
â Life cycle
â Licensing
â Naming
â
Finding servers and load balancing
9. Distributed Object Programming course 2003
Services (3)
â
Services:
â Property
â Trading
â Persistence
â Relationship
â Security
â
Common to use SSL for lightweight authentication
and encryption
â
CORBA standard security service
â Time
10. Distributed Object Programming course 2003
Communications
â
Object invocations
â Synchronous
â One way
â Deferred synchronous
â
Events
â Consumer and Supplier
â Push model vs Pull model
11. Distributed Object Programming course 2003
CORBA Processes
â
Clients
â Simple to program
â IDL compiler creates a proxy implementation
â Interceptors: intercept request between
client and server.
â Request level â between client and proxy
â Message level â between ORB and network
13. Distributed Object Programming course 2003
Portable Object Adapter
â
Provides a consistent image of the object
â
(also called wrapper)
â
Makes server side code appears as CORBA
objects
â
Use a âservantâ - implement client
methods
â
Maps object Ids (references) to servants.
14. Distributed Object Programming course 2003
Naming
â
How do you find object or servers?
â Using a name server
â Directory of available objects
â
Server processes call name server when
they come up
â Advertising their services/objects
â
How do you find the name server?
â Call resolve_initial_references
â And local ORB âknowsâ location of NS
15. Distributed Object Programming course 2003
Naming (2)
â
Clients call name server to find the
location of a factory/object/server
â Up to the name server to match clients to
servers/objects
â Returns object reference (IOR?)
â
Includes location of server
â
Client calls server process (via ORB) to
access or create objects
16. Distributed Object Programming course 2003
Scaling
â
NS can support load balancing
â Multiple servers/processors register the
same service/object (object groups)
â Name server spreads out requests across
available objects
â Proprietary until CORBA 3
â
Extends IOR to IOGR.
17. Distributed Object Programming course 2003
Where is the IDL?
Client object
IDL stub (obj)
ORB
Network
services
Server object
IDL skel (obj)
ORB/POA
Network
services
Request
Request data
IIOP protocol
18. Distributed Object Programming course 2003
IDL Language
Itâs a declarative language to define client object/server object
interface. Itâs somehow a simplified object definition; no
implementation is defined. An exampleâŠ
module Bank {
struct Customer {
string name;
string address;
string id;
}
interface Account {
void debit( in unsigned long ammount );
void withdraw( in unsigned long ammount );
long balance();
}
interface AccountMgr {
Account getAccountByCustomer( Customer c );
}
}
19. Distributed Object Programming course 2003
Example
module Bank {
struct Customer {
string name;
string address;
string id;
}
interface Account {
void debit( in unsigned long ammount );
void withdraw( in unsigned long ammount );
long balance();
}
interface AccountMgr {
Account getAccountByCustomer( Customer c );
}
}
Core concept: 2 kinds of programming types:
Objects (interfaces) and non-objects (types)
Interfaces
Types
20. Distributed Object Programming course 2003
Language (2)
âą Operations in interfaces define callable methods.
Operations can have parameters, but not
implementation
âą Each parameter definition must say if it is an in ,
out or inout parameter and has a type and name
âą There are also support for: exception handling,
sequence templates, arrays; inheritance; abstract
interfaces and so on
21. Distributed Object Programming course 2003
Language (3)
âą Basic types: long, short, unsigned long, unsigned
short, float, double, boolean, octet (fits anything, as
sequence), any (really anything)
âą Constructed types: There are constructed types: struct,
union, enumeration type.
âą The any type.
Struct <identifier> { <declaration>; ⊠}
union <identifier> switch (<switch-type>) {
case <constant>: <declaration>;
âŠ
}
enum <identifier> { <identifier>, ⊠}
22. Distributed Object Programming course 2003
IDL Mapping
âą They must define the means of expressing in the language all
CORBA IDL constructs.
âą A complete language mapping will allow a programmer to
have access to all ORB functionality in a way that is
convenient for the particular programming language.
âą To support source portability, all ORB implementations
must support the same mapping for a particular language
(mapping specification).
23. Distributed Object Programming course 2003
IDL Mapping
Objects specification in IDL
Client code Server code
compiler
ïź Ada, C, C++, COBOL, Smalltalk, and Java, Lisp,
CORBA scripting language
ïź Java to IDL
24. Distributed Object Programming course 2003
IDL Mapping
interface myObj {
long op1 (in long arg1 );
}
typedef CORBA_Object myObj;
extern CORBA_long myObj_op1(
example1 o,
CORBA_long arg1,
CORBA_Environment *ev
);
class myObjOperations extends
org.omg.CORBA.IDLEntity {
void op1( ⊠);
âŠ};
class myObj extends MyObjOperations { ⊠}
âŠ
class myObj : virtual public
CORBA::Object { âŠ
public: âŠ
virtual void op1( ⊠);
}
C
Java
C++
26. Distributed Object Programming course 2003
IDL Mapping
Op1 correspond to method op1 in object interface.
in parameters are passed by value.
out and inout parameters are passed through
holder classes. For inout parameters, client must
initialise the holder class with a value before calling
the method.
As interfaces are mapped to java interfaces,
method and objectâs signatures are maintained.
operations and parameter
passing:
op1(in Ob1 x,
out Ob2 y,
inout Ob3 z)
JavaCORBA
27. Distributed Object Programming course 2003
IDL Mapping
IDL TYPE JAVA TYPE EXCEPTIONS
boolean boolean
Char char CORBA::DATA_CONVERSION
wchar char CORBA::DATA_CONVERSION
octec byte
String Java.lang.String CORBA::MARSHAL
CORBA::DATA_CONVERSION
wstring Java.lang.String CORBA::MARSHAL
CORBA::DATA_CONVERSION
short short
Unsigned short short
Long int
Unsigned long int
Long long long
Unsigned long long long
float float
double double
fixed Java.math.BidDecimal CORBA::DATA_CONVERSION
28. Distributed Object Programming course 2003
IDL Mapping
see specificationunion, sequence, arrays,
constants, etc.
final public class myStruct ... IDLEntity {
public int field1;
public String field2;
public myStruct() { } // empty!
public myStruct(int f1, String f2) { ... }
}
struct myStruct {
long field1;
string field2;
}
JavaCORBA
30. Distributed Object Programming course 2003
IDL Example
â
AccountManagerStub.java--Stub code for the AccountManager object on the
client side.
â
AccountStub.java--Stub code for the Account object on the client side.
â
ccount.java--The Account interface declaration.
â
AccountHelper.java--Declares the AccountHelper class, which defines helpful
utility methods.
â
AccountHolder.java--Declares the AccountHolder class, which provides a
holder for passing Account objects.
â
AccountManager.java--The AccountManager interface declaration.
â
AccountManagerHelper.java--Declares the AccountManagerHelper class,
which defines helpful utility methods.
â
AccountManagerHolder.java--Declares the AccountManagerHolder class,
which provides a holder for passing AccountManager objects.
31. Distributed Object Programming course 2003
IDL Example
â
AccountManagerOperation.java--This interface provides declares the method
signatures defined in the AccountManager interface in the Bank.idl file.
â
AccountManagerPOA.java--POA servant code (implementation base code) for the
AccountManager object implementation on the server side.
â
AccountManagerPOATie.java--Class used to implement the AccountManager
object on the server side using the tie mechanism,
â
AccountOperations.java--This interface provides declares the method signatures
defined in the Account interface in the Bank.idl file
â
AccountPOA.java--POA servant code (implementation base code) for the Account
object implementation on the server side.
â
AccountPOATie.java--Class used to implement the Account object on the server
side using the tie mechanism
â
StructType.java--Declares the StrucType class, which is used both by Client and
Server classes.
32. Distributed Object Programming course 2003
IDL Example
â
StructTypeHelper.java--Declares the StructTypeHelper class, which defines
helpful utitly methods.
â
StructTypeHolder.java--Declares the StructTypeHolder class, which provides a
holder for passing StructType objects.
33. Distributed Object Programming course 2003
Server Example
â
Steps for server setup
â Initialize ORB
â Create and setup POA
â Activate the POA Manager
â Activate objects
â Wait for client requests
34. Distributed Object Programming course 2003
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
// get a reference to the root POA
POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
// Create policies for our persistent POA
org.omg.CORBA.Policy[] policies = {
rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT)
};
// Create myPOA with the right policies
POA myPOA = rootPOA.create_POA( "bank_agent_poa", rootPOA.the_POAManager(),
policies );
// Create the servant
AccountManagerImpl managerServant = new AccountManagerImpl();
35. Distributed Object Programming course 2003
Code Example (cont)
// Decide on the ID for the servant
byte[] managerId = "BankManager".getBytes();
// Activate the servant with the ID on myPOA
myPOA.activate_object_with_id(managerId, managerServant);
// Activate the POA manager
rootPOA.the_POAManager().activate();
System.out.println(myPOA.servant_to_reference(managerServant) +
" is ready.");
// Wait for incoming requests
orb.run();
36. Distributed Object Programming course 2003
Client Example
â
Steps for client setup
â Initialize ORB
â Locate Server using location service (smart
agent)
â Obtains the balance of the Account using the
object reference returned by bind().
37. Distributed Object Programming course 2003
Client Example
Org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
// Get the manager Id
byte[] managerId = "BankManager".getBytes();
// Locate an account manager. Give the full POA name and
// the servant ID.
Bank.AccountManager manager = Bank.AccountManagerHelper.bind(orb,
"/bank_agent_poa", managerId);
// use args[0] as the account name, or a default.
// String name = args.length > 0 ? args[0] :
// "default account";
String name=args[0];
Integer initbalance=new Integer(args[1]);
38. Distributed Object Programming course 2003
Client Example (cont)
Bank.StructType stname= new Bank.StructType(initbalance.intValue(),name);
// Request the account manager to open a named account.
System.out.println(stname);
Bank.Account account = manager.open(stname);
// Get the balance of the account.
float balance = account.balance();
String strtime= account.getCalendar();
// Print out the balance.
System.out.println ("The balance in " + name +
"'s account is $" + balance +
"and time is "+ strtime);
Hinweis der Redaktion
CORBA IDL â Interface Definition Language DII â Dynamic Invocation Interface The ORB has very few services itself, most communication is performed by the stub/skeletons between clients and objects (servers)
Interface repository allows a process to find out during runtime to investigate how an interface looks like. Implementation repository provides all is needed to implement and activate objects. Collection â allows creating groups of object into lists, stacks, queues, sets, etc ... Query â constructs collections of object that can be investigated by a query language (adds to the collection service) Concurrency control â locking Transactions â allow objects to support transactions
Events â allows clients and objects to be interrupted Notification provides an advance asynchronous communications. Externalization â marshaling objects to be stored on disk or network. Life cycle â create/destroy/copy and move objects licensing â right of clients Naming â computer ids to human readable names.
Property service allows clients to associate attributes and values with objects, they describe the object not its state. Trading service â allows object to advertise their interfaces and clients to perform lookups. Persistence â storing information on disk transparently. Relationship â support organizing objects into schemes (like in databases).
Synchronous â at most once one way â best effort (no wait at all) deferred synchronous â at most once â can later block or check for reply. Event channel between consumer and supplier No mechanism to filter events, no persistent events. Filtering was added in the notification service.
IOR â Interoperable Object Reference â allows passing an object reference between processes.