Transcript Document

Distributed Object Computing
Using Java and CORBA
Copyright © 2003 ProsoftTraining. All rights reserved.
Lesson 1:
Introduction to CORBA
Copyright © 2003 ProsoftTraining. All rights reserved.
Objectives
• Describe the role of CORBA in developing
enterprise applications
• Describe the role of the Object Management
Group
• Describe the CORBA architecture
CORBA
Overview
• Common Object Request Broker Architecture
• Object-oriented development
• Distributed-object computing
The Object
Management Group
• Controls the CORBA standard
• Provides a specification for CORBA
CORBA
Architecture
• Object Management Architecture
– Object Request Broker
– Object services
– Common facilities
– Application objects
– Internet InterORB Protocol
– Interface Definition Language
– Object adapters
– CORBA Services
Object
Request Broker
Client Process
Serv er Process
Object Ref erence
Object
Implementation
ORB
Internet
InterORB Protocol
Client Process
Serv er Process
Object Ref erence
Object
Implementation
ORB
ORB
IIOP
Interface
Definition Language
Client Process
Serv er Process
Object Ref erence
Object
Implementation
IDL Stubs
IDL
Skeleton
ORB
Interf ace
ORB
ORB
IIOP
Object
Adapter
Summary
 Describe the role of CORBA in developing
enterprise applications
 Describe the role of the Object Management
Group
 Describe the CORBA architecture
Lesson 2:
Interface Definition Language
Copyright © 2003 ProsoftTraining. All rights reserved.
Objectives
• Use the IDL to define the interface to CORBA
objects
• Describe the mapping of IDL nonclass data
types into Java
• Describe the purpose of IDL parameterpassing modes
• Model inheritance using IDL
• Define CORBA exceptions using IDL
Introduction to IDL
• IDL files
• IDL compilers
• Mapping IDL to Java
Basics
of IDL
• IDL constructs
– Modules
– Interfaces
– Attributes
– Operations
IDL
Primitives
IDL
Java
boolean
boolean
char, wchar
char
octet
byte
string, wstring
java.lang.String
short, unsigned short
short
long, unsigned long
int
long long, unsigned long long
long
float
float
double
double
Inheritance and IDL
• Java  no multiple inheritance support
• Java class  can inherit from only one other
class
• IDL  can be used to define an interface that
inherits from multiple super-interfaces
Nonclass
Data Types
•
•
•
•
Constants
Enumerations
Unions
Structures
• Type definitions
• Sequences
• Arrays
Parameter-Passing
Modes and Exceptions
• Parameter-passing modes
– in
– out
– inout
• Exceptions
– Use-defined exceptions inherit indirectly
from java.lang.Exception
– IDL operations must declare their ability to
raise an exception
Summary
 Use the IDL to define the interface to CORBA
objects
 Describe the mapping of IDL nonclass data
types into Java
 Describe the purpose of IDL parameterpassing modes
 Model inheritance using IDL
 Define CORBA exceptions using IDL
Lesson 3:
Building CORBA Clients
Copyright © 2003 ProsoftTraining. All rights reserved.
Objectives
• Use the IDL compiler to generate client stubs
• Initialize the ORB
• Use the naming service to obtain an object
reference
• Invoke remote methods
• Use out and inout parameters to invoke
remote methods
Client IDL Stubs
• Used to create client applications
• IDL-to-Java compiler named idlj
– Used to compile IDL files to generate client
stubs and server skeletons
Initializing the ORB
• The ORB class
– Is used to initialize the ORB
– Is not instantiated using its public
constructor
– Provides a static method named init that
initializes the ORB and returns an instance
of the ORB class
Using the
Naming Service
• Connecting to the naming service
• Using the naming service to obtain an object
reference
– Obtaining the initial naming context
– Retrieving an object reference
Example of
Namespace
Initial Naming Context
Customers
Employees
Officers
Boeing
Programmers
FAA
CEO
CFO
James Roos
Erik Novales
Invoking
Remote Methods
• Remote methods are invoked in the same way
that local methods are invoked
Using Out and
Inout Parameters
• Out parameters
– Used exclusively to return data from the
server to the client
• Inout parameters
– Passed both from the client to the server
and, following any changes, from the server
back to the client
Summary
 Use the IDL compiler to generate client stubs
 Initialize the ORB
 Use the naming service to obtain an object
reference
 Invoke remote methods
 Use out and inout parameters to invoke
remote methods
Lesson 4:
Building
CORBA Servers
Copyright © 2003 ProsoftTraining. All rights reserved.
Objectives
• Use the IDL compiler to generate server
skeletons
• Implement CORBA objects
• Initialize the ORB and wait for clients
• Use the naming service to publish an object
reference
• Use out and inout parameters
Server
IDL Skeletons
• A server skeleton provides a framework
for the implementation of a CORBA object
Implementing
CORBA Objects
MessageOperations
Object
Message
_MessageImplBase
MessageServant
IDLEntity
Server-side
implementation
Using the
Naming Service
• Instantiating a CORBA object
• Creating additional naming contexts
Example of
Naming Service
Initial Naming Context
Default
message1
Hello
message2
Waiting
for Invocation
• The wait method
– Called to pause the main thread of
execution
– Part of Java’s built-in threading facilities
Using Out and
Inout Parameters
• Out parameters
– Used exclusively to return data from the
server to the client
• Inout parameters
– Passed both from the client to the server
and, following any changes, from the server
back to the client
Summary
 Use the IDL compiler to generate server
skeletons
 Implement CORBA objects
 Initialize the ORB and wait for clients
 Use the naming service to publish an object
reference
 Use out and inout parameters
Lesson 5:
Factory and
Callback Objects
Copyright © 2003 ProsoftTraining. All rights reserved.
Objectives
• Describe the purpose of factory objects
• Use factory objects to obtain object
references
• Describe the purpose of callback objects
• Develop applications that use callback objects
Factory
Objects
• Types include:
– Generic
– Specific
– In-process
– Out-process
• FactoryFinder
• Using factory objects
• Designing factory objects
Callback
Objects
• Using callback objects
• Designing callback objects
Summary
 Describe the purpose of factory objects
 Use factory objects to obtain object
references
 Describe the purpose of callback objects
 Develop applications that use callback objects
Lesson 6:
CORBA Exceptions
Copyright © 2003 ProsoftTraining. All rights reserved.
Objectives
• Describe the purpose of CORBA exceptions
• Define an exception using IDL
• Develop CORBA objects that throw exceptions
Introduction to
CORBA Exceptions
• Throwing CORBA exceptions
• Catching CORBA exceptions
Summary
 Describe the purpose of CORBA exceptions
 Define an exception using IDL
 Develop CORBA objects that throw exceptions
Lesson 7:
Dynamic
Invocation Interface
Copyright © 2003 ProsoftTraining. All rights reserved.
Objectives
• Describe the purpose of the interface
repository
• Describe the Dynamic Invocation Interface
• Construct an argument list for use in dynamic
invocation
• Invoke a request using the DII
• Extract a return value following dynamic
invocation
Dynamic Invocation
Interface Introduction
• DII allows a client to access any CORBA
object even though it may not have a client
stub to provide a compile-time definition of an
object’s interface
Invoking a Remote
Method Using DII
•
•
•
•
Construct a list of arguments
Prepare a place to hold a return value
Invoke the remote method
Extract the return value
Summary
 Describe the purpose of the interface
repository
 Describe the Dynamic Invocation Interface
 Construct an argument list for use in dynamic
invocation
 Invoke a request using the DII
 Extract a return value following dynamic
invocation
Distributed Object Computing
Using Java and CORBA







Introduction to CORBA
Interface Definition Language
Building CORBA Clients
Building CORBA Servers
Factory and Callback Objects
CORBA Exceptions
Dynamic Invocation Interface