《dynamicobjectrequest动态对象请求》由会员分享,可在线阅读,更多相关《dynamicobjectrequest动态对象请求(48页珍藏版)》请在金锄头文库上搜索。
1、Dynamic Object Requests,1,Dynamic Object Requests,Outline Motivating Examples Dynamic Invocation Reflection Designing Generic Applications,Dynamic Object Requests,2,Outline,Motivating Examples Dynamic Invocation The CORBA Dynamic Invocation Interface Reflection The CORBA Interface Repository Designi
2、ng Generic Applications Using CORBA,Dynamic Object Requests,3,Motivation,Dynamic Object Requests,4,What is a dynamic request?,Sometimes clients need to be built before their server interfaces are defined They need to defer request definition until they are executed These are dynamic requests Example
3、s: Object browser Generic bridges Scripting language interpreter,Motivating Example: Object Browser,Dynamic Object Requests,6,Motivating Example: Generic Bridge,Generic and request-level bridge,Dynamic Object Requests,7,Commonalities,Discovery of type information at run-time Use of type information
4、to build client objects that can cope with any type of server objects Definition of object requests at run-time Requires two primitives from middleware: Dynamic invocation interfaces Reflection mechanisms,Dynamic Object Requests,8,Dynamic Invocation,Dynamic Object Requests,9,Dynamic Requests: Princi
5、ples,Any object request has to identify server object operation name actual parameters data structure for operation result In Dynamic Requests: server object identified by object reference operation name identified by string actual parameters as list of name/value pairs operation result determined b
6、y an address,Dynamic Requests in CORBA,Dynamic Object Requests,11,Dynamic Requests in CORBA,Dynamic invocation interface (DII) supports dynamic creation of requests. Requests are objects themselves. Request objects have attributes for operation name, parameters and results. Request objects have oper
7、ations to change operation parameters, issue the request and obtain the request results.,Dynamic Request in CORBA,Dynamic Object Requests,13,Creating Dynamic CORBA Requests,interface Object ORBstatus create_request ( in Context ctx, / operation context in Identifier operation,/ operation to exec in
8、NVList arg_list, / args of operation inout NamedValue result,/ operation result out Request request / new request object in Flags req_flags / request flags ); . ;,Dynamic Object Requests,14,Manipulating Dynamic CORBA Requests,interface Request Status add_arg ( in Identifier name, / argument name in
9、TypeCode arg_type, / argument datatype in void * value, / argument to be added in long len, / length of argument value in Flags arg_flags / argument flags ); Status invoke ( in Flags invoke_flags / invocation flags ); Status delete (); Status send ( in Flags invoke_flags / invocation flags ); Status
10、 get_response ( in Flags response_flags / response flags ) raises (WrongTransaction); ;,Dynamic Object Requests,15,Transparency of Dynamic Invocation,Client programs have to be written differently Use of dynamic invocation interfaces is not transparent to client programmers Server objects are unawar
11、e of dynamic invocation Use of DII is transparent,Dynamic Object Requests,16,Reflection,Dynamic Object Requests,17,Reflection Principles,How do clients discover attributes & operations that servers have? Need to capture type information during interface compilation store type information persistentl
12、y provide an interface for clients to obtain type information during run-time Reflection interfaces provided by CORBA Interface Repository,Dynamic Object Requests,18,CORBA Interface Repository,Makes type information of interfaces available at run-time. Achieves type-safe dynamic invocations. Support
13、s construction of interface browser Used by CORBA implementations themselves Persistent storage of IDL interfaces in abstract syntax trees (ASTs),Interface repository persistently stores ASTs of IDL modules, interfaces, types, operations etc.,Abstract Syntax Trees (ASTs),Dynamic Object Requests,20,A
14、ST Node Types,Repository,Dynamic Object Requests,21,Container (node with children),interface Container : IRObject Contained lookup(in ScopedName search_name); sequence contents( in DefinitionKind limit_type, in boolean exclude_inherited); sequence lookup_name( in Identifier search_name, in long leve
15、ls_to_search, in DefinitionKind limit_type, in boolean exclude_inherited); . ;,Dynamic Object Requests,22,Contained (child),interface Contained : IRObject attribute Identifier name; attribute RepositoryId id; attribute VersionSpec version; readonly attribute Container defined_in; struct Description
16、DefinitionKind kind; any value; ; Description describe(); . ;,Dynamic Object Requests,23,Interface Definition,interface InterfaceDef : Container,Contained attribute sequence base_interfaces; boolean is_a(in RepositoryId interface_id); struct FullInterfaceDescription Identifier name; RepositoryId id; RepositoryId defined_in; RepositoryIdSequence base_interfaces; sequ