September 21, 2005 Dynamic Typing in CORBA Middleware Jeff Parsons ISIS Vanderbilt University...
-
Upload
ernest-robinson -
Category
Documents
-
view
217 -
download
0
Transcript of September 21, 2005 Dynamic Typing in CORBA Middleware Jeff Parsons ISIS Vanderbilt University...
September 21, 2005
Dynamic Typing in CORBA Middleware
Jeff ParsonsISIS
Vanderbilt UniversityNashville, TN
Jeff Parsons Dynamic Typing in CORBA Middleware
2
Static vs. Dynamic Typing• Static typing
– Type rules in compiler.– New types at
development time.– No new types at run
time.• Dynamic typing
– Type rules also implicit in source code.
– Enables new types at run time.
• Dynamic CORBA contains type rules for IDL, not target language.
type TYPE
TYPE type
compiler
type rules
TYPE
compiler
type rules
type
TYPE
type
TYPE
type rules
type TYPE
TYPE type
type TYPE
type
.
.
.
Static Typing Dynamic Typing
DevelopmentTime
CompileTime
RunTime
type rules
type
TYPE
type
Jeff Parsons Dynamic Typing in CORBA Middleware
3
Static Typing• All operation names and
signatures known at compile time.
• Advantages– Efficient marshaling.– Streamlined
invocation.• Disadvantages
– Larger generated code footprint.
– Inflexible.– Unacceptable in open-
ended systems.
IDL File#2
IDLCompiler
StaticSkeleton
IDL File#1
StaticSkeleton
IDL File#2
IDLCompiler
StaticInvocation
IDL File#1
IDLCompiler
StaticInvocation
Jeff Parsons Dynamic Typing in CORBA Middleware
4
Dynamic Typing• Discovery of operation
names and parameter types at runtime.
• Advantages– Smaller generated
code footprint.– Flexible & open-ended.
• Disadvantages– Larger ORB footprint.– Slower marshaling.– Pre- and post-
invocation overhead.
DynamicInvocation
IDL File#1
IDL File#2
IDL File#3
IFRLoader
InterfaceRepository
Jeff Parsons Dynamic Typing in CORBA Middleware
5
Dynamic CORBA Features
TYPE CODEANYNAMEDVALUE / NVLIST
DII
InterfaceRepository
IDLCompiler
Client OBJREF
Object(Servant)
in argsoperation()out args +
return
DIIIDL
STUBSORB
INTERFACE
IDLSKEL DSI
Object Adapter
ORB CORE GIOP/IIOP/ESIOPS
ImplementationRepository
TYPECODE FACTORYDYNAMIC ANY
DSI
INTERFACE REPOSITORYIFR LOADER
123
4
5
67
89
Jeff Parsons Dynamic Typing in CORBA Middleware
6
Type Codeunion foo switch (char) { case ‘a’: long num; case ‘b’: string str;};
struct bar { string<12> str_mem; foo u_mem; boolean b_mem;};
• Structural representation
• Basic TCs in ORB• New TCs from IDL
compiler or type code factory
kind(parameters)
member namekind
idnamemember count
(parameters)bound
member namekind(parameters)
nameid
discrim. kinddefault indexmember countmember labelmember name
kind(parameters)
member labelmember name
kind(parameters)bound
member namekind(parameters)
tk_struct
"str_mem"tk_string
"IDL:bar:1.0""bar"3
12"u_mem"
tk_union
"foo""IDL:foo:1.0"
tk_char-12'a'"num"
tk_long
'b'"str"
tk_string
0"b_mem"
tk_boolean
Legend With Values
Type Code for struct 'bar'
Jeff Parsons Dynamic Typing in CORBA Middleware
7
Any, NamedValue, NVListTypeCode
Value
Any
• Any– Represents generic IDL
value– Type code describes
value– Value is opaque– Overloaded insertion &
extraction operators• Basic types in ORB• New types from IDL
compiler• NamedValue
– Represents operation argument
– Any + name + direction• NVList
– Represents operation signature
– List of NamedValues
Name
NamedValue
Direction
TypeCode
Value
Any
.
.
.
NVList
Name
NamedValue
Direction
TypeCode
Value
Any
Name
NamedValue
Direction
TypeCode
Value
Any
Name
NamedValue
Direction
TypeCode
Value
Any
Jeff Parsons Dynamic Typing in CORBA Middleware
8
Dynamic Invocation Interface (DII)
Request Object
Object Reference
String
NVList
NamedValue
Flag
Exception List
Target Object
Operation Name
Arguments
Return Value
Oneway?
User-definedExceptions
• Used when IDL compiler generated code is not available.
• A request object is created by a local call on the target object reference.
• Dynamic Skeleton Interface (DSI) is the server-side counterpart to DII.
Jeff Parsons Dynamic Typing in CORBA Middleware
9
Type Code FactoryInterface
Repository
StaticApplication
DynamicApplication
ORB
TypeCodeFactorycreate_xx_tc( )
.
.
.
ORBcreate_xx_tc( )
.
.
.
InterfaceRepository
StaticApplication
DynamicApplication
• Problem: Creating a TypeCode at run-time.
• Forces:– Family of related
TypeCodes.– Optional use by
application.– Necessary to Interface
Repository.– Avoid penalty to static
application.• Solution: Abstract
Factory pattern and separate library.
Jeff Parsons Dynamic Typing in CORBA Middleware
10
The Interface Repository (IFR)• Problem: Providing run-time IDL type
information.• Forces:
– Need persistent storage.– Need OO database - query results are CORBA
objects.– Must preserve nested (scoped) structure.
• Solution:– View entries as meta-objects.– Use the Memento pattern to capture their state.– Use tree of hash tables for underlying storage.– Create query results on demand.
Jeff Parsons Dynamic Typing in CORBA Middleware
11
Managing the Interface RepositoryIDL Compiler Executable
IDL CompilerExecutable
FELibrary
IDL BELibrary
IDL BELibrary
FELibrary
IDL CompilerExecutable
IFR LoaderExecutable
IFRLoaderLibrary
• Problem: Providing a systematic way to manage the repository’s contents.
• Forces:– Load from IDL files.– Reuse IDL compiler’s
parsing and error checking.
– IDL compiler is built monolithically.
• Solution: Modularize the IDL compiler.– Reusable front end.– Pluggable back end.– Top-level executable.
Jeff Parsons Dynamic Typing in CORBA Middleware
12
result
response
invoke
Any
lookup_idget_operationsget_arg_typevalue
create_operation
create_interfaceIDLFile
Dynamic CORBA - Putting It All Together
Target
IFRLoader
InterfaceDefOperationDefcreate_type
Type CodeType Code
Factory
Interface Repository
Dynamic AnyDII RequestClientDynamic
AnyFactory
Jeff Parsons Dynamic Typing in CORBA Middleware
13
Evaluation of Dynamic CORBA Features• Interdependency
– Explicit– Implicit
• Hybrid Applications– Need not use dynamic
typing throughout.– May use subset of
features.• Generality vs. Overhead
– Tradeoff• Portability
– Widespread ORB vendor support.
TypeCode
Any
Dynamic Any
DII / DSI
NamedValue
NVList
TypeCodeFactory
IFR
Dependency Graph