CHAP4
CHAP4
Contents
This chapter contains the following sections.
“Overview” 4-1
“Object Reference Operations” 4-4
“ORB and OA Initialization and Initial References” 4-8
“ORB Initialization” 4-8
“Obtaining Initial Object References” 4-10
“Current Object” 4-12
“Policy Object” 4-12
“Management of Policy Domains” 4-14
“Thread-related operations” 4-19
4.1 Overview
The ORB interface is the interface to those ORB functions that do not depend on
which object adapter is used. These operations are the same for all ORBs and all object
implementations, and can be performed either by clients of the objects or
implementations. Some of these operations appear to be on the ORB, others appear to
be on the object reference. Because the operations in this section are implemented by
the ORB itself, they are not in fact operations on objects, although they may be
described that way and the language binding will, for consistency, make them appear
that way. The ORB interface also defines operations for creating lists and determining
the default context used in the Dynamic Invocation Interface. Those operations are
described in the Dynamic Invocation Interface chapter.
module CORBA {
typedef unsigned short ServiceType;
typedef unsigned long ServiceOption;
typedef unsigned long ServiceDetailType;
struct ServiceDetail {
ServiceDetailType service_detail_type;
sequence <octet> service_detail;
};
struct ServiceInformation {
sequence <ServiceOption> service_options;
sequence <ServiceDetail> service_details;
};
Status create_list (
in long count,
out NVList new_list
);
Status create_operation_list (
in OperationDef oper,
out NVList new_list
);
To guarantee that an ORB will understand the string form of an object reference, that
ORB’s object_to_string operation must be used to produce the string. For all
conforming ORBs, if obj is a valid reference to an object, then
string_to_object(object_to_string(obj)) will return a valid
reference to the same object, if the two operations are performed on the same ORB.
For all conforming ORB's supporting IOP, this remains true even if the two operations
are performed on different ORBs.
get_service_information
boolean get_service_information (
in ServiceType service_type;
out ServiceInformation service_information;
);
module CORBA {
Status create_request (
in Context ctx,
in Identifier operation,
in NVList arg_list,
inout NamedValue result,
out Request request,
in Flags req_flags
);
Policy get_policy (
in PolicyType policy_type
);
DomainManagersList get_domain_managers ();
};
};
The create_request operation is part of the Object interface because it creates a
pseudo-object (a Request) for an object. It is described with the other Request
operations in the section Section 5.2, “Request Operations,” on page 5-5.
Services that maintain state that includes object references, such as bridges, event
channels, and base relationship services, might use this operation in their “idle time” to
sift through object tables for objects that no longer exist, deleting them as they go, as a
form of garbage collection. In the case of proxies, this kind of activity can cascade,
such that cleaning up one table allows others then to be cleaned up.
The value of this operation is not guaranteed to be unique; that is, another object
reference may return the same hash value. However, if two object references hash
differently, applications can determine that the two object references are not identical.
The maximum parameter to the hash operation specifies an upper bound on the hash
value returned by the ORB. The lower bound of that value is zero. Since a typical use
of this feature is to construct and access a collision chained hash table of object
references, the more randomly distributed the values are within that range, and the
cheaper those values are to compute, the better.
For bridge construction, note that proxy objects are themselves objects, so there could
be many proxy objects representing a given “real” object. Those proxies would not
necessarily hash to the same value.
Equivalence Testing
The is_equivalent() operation is used to determine if two object references are
equivalent, so far as the ORB can easily determine. It returns TRUE if the target object
reference is known to be equivalent to the other object reference passed as its
parameter, and FALSE otherwise.
If two object references are identical, they are equivalent. Two different object
references which in fact refer to the same object are also equivalent.
ORBs are allowed, but not required, to attempt determination of whether two distinct
object references refer to the same object. In general, the existence of reference
translation and encapsulation, in the absence of an omniscient topology service, can
make such determination impractically expensive. This means that a FALSE return
from is_equivalent() should be viewed as only indicating that the object references
are distinct, and not necessarily an indication that the references indicate distinct
objects.
A typical application use of this operation is to match object references in a hash table.
Bridges could use it to shorten the lengths of chains of proxy object references.
Externalization services could use it to “flatten” graphs that represent cyclical
relationships between objects. Some might do this as they construct the table, others
during idle time.
Policy get_policy (
in PolicyType policy_type
);
Parameters
policy_type The type of policy to be obtained.
Return Value
policy A policy object of the type specified by the policy_type
parameter.
Exceptions
CORBA::BAD_PARAM raised when the value of policy type is not valid either
because the specified type is not supported by this ORB
or because a policy object of that type is not associated
with this Object.
Return Value
The list of immediately enclosing domain managers of this object. At least one domain
manager is always returned in the list since by default each object is associated with at
least one domain manager at creation.
In addition, this manual provides a mapping of the PIDL initialization and object
reference operations to several languages.
The ORB and OA initialization operations must be ordered with ORB occurring before
OA: an application cannot call OA initialization routines until ORB initialization
routines have been called for the given ORB. The operation to initialize an application
in the ORB and get its pseudo-object reference is not performed on an object. This is
because applications do not initially have an object on which to invoke operations. The
ORB initialization operation is an application’s bootstrap call into the CORBA world.
The PIDL for the call (Figure 7-1) shows that the ORB_init call is part of the CORBA
module but not part of the ORB interface.
// PIDL
module CORBA {
typedef string ORBid;
typedef sequence <string> arg_list;
ORB ORB_init (inout arg_list argv, in ORBid orb_identifier);
};
Figure 7-1
The identifier for the ORB will be a name of type CORBA::ORBid. All ORBid strings
other than the empty string are allocated by ORB administrators and are not managed
by the OMG. ORBid strings other than the empty string are intended to be used to
uniquely identify each ORB used within the same address space in a multi-ORB
application. These special ORBid strings are specific to each ORB implementation
and the ORB administrator is responsible for ensuring that the names are
unambiguous.
If an empty ORBid string is passed to ORB_init, then the arg_list arguments shall be
examined to determine if they indicate an ORB reference that should be returned. This
is achieved by searching the arg_list parameters for one preceded by "-ORBid," for
example, "-ORBid example_orb" (the whitespace after the "-ORBid" tag is ignored) or
"-ORBidMyFavoriteORB" (with no whitespace following the "-ORBid" tag).
Alternatively, two sequential parameters with the first being the string "-ORBid"
indicates that the second is to be treated as an ORBid parameter. If an empty string is
passed and no arg_list parameters indicate the ORB reference to be returned, the
default ORB for the environment will be returned.
Other parameters of significance to the ORB can also be identified in arg_list, for
example, "Hostname," "SpawnedServer," and so forth. To allow for other parameters
to be specified without causing applications to be re-written, it is necessary to specify
the parameter format that ORB parameters may take. In general, parameters shall be
formatted as either one single arg_list parameter:
-ORB<suffix>
<value>
Regardless of whether an empty or non-empty ORBid string is passed to ORB_init, the
arg_list arguments are examined to determine if any ORB parameters are given. If a
non-empty ORBid string is passed to ORB_init, all ORBid parameters in the arg_list
are ignored. All other -ORB<suffix> parameters in the arg_list may be of significance
during the ORB initialization process.
The ORB_init operation may be called any number of times and shall return the same
ORB reference when the same ORBid string is passed, either explicitly as an argument
to ORB_init or through the arg_list. All other -ORB<suffix> parameters in the arg_list
may be considered on subsequent calls to ORB_init.
Initial references are obtained via operations on the ORB pseudo-object interface,
providing facilities to list and resolve initial object references. The PIDL for these
operations is shown below.
module CORBA {
interface ORB {
typedef string ObjectId;
typedef sequence <ObjectId> ObjectIdList;
}
The resolve_initial_references operation is an operation on the ORB rather than the
Naming Service’s NamingContext. The interface differs from the Naming Service’s
resolve in that ObjectId (a string) replaces the more complex Naming Service
construct (a sequence of structures containing string pairs for the components of the
name). This simplification reduces the name space to one context.
ObjectIds are strings that identify the object whose reference is required. To maintain
the simplicity of the interface for obtaining initial references, only a limited set of
objects are expected to have their references found via this route. Unlike the ORB
identifiers, the ObjectId name space requires careful management. To achieve this.
the OMG may, in the future, define which services are required by applications through
this interface and specify names for those services.
Currently, reserved ObjectIds for CORBA Core are RootPOA, POACurrent , and
InterfaceRepository; for CORBA Services, they are NameService,
TradingService, SecurityCurrent, and TransactionCurrent.
To allow an application to determine which objects have references available via the
initial references mechanism, the list_initial_services operation (also a call on the
ORB) is provided. It returns an ObjectIdList, which is a sequence of ObjectIds.
ObjectIds are typed as strings. Each object, which may need to be made available at
initialization time, is allocated a string value to represent it. In addition to defining the
id, the type of object being returned must be defined, i.e. "InterfaceRepository" returns
a object of type Repository, and “NameService" returns a CosNamingContext
object.
The application is responsible for narrowing the object reference returned from
resolve_initial_references to the type which was requested in the ObjectId. For
example, for InterfaceRepository the object returned would be narrowed to
Repository type.
In the future, specifications for Object Services (in CORBAservices: Common Object
Services Specification) will state whether it is expected that a service’s initial reference
be made available via the resolve_initial_references operation or not (i.e., whether
the service is necessary or desirable for bootstrap purposes).
Each ORB or CORBA service that needs its own context derives an interface from the
CORBA module's Current. Users of the service can obtain an instance of the
appropriate Current interface by invoking ORB::resolve_initial_references.
For example the Security service obtains the Current relevant to it by invoking
ORB::resolve_initial_references("SecurityCurrent")
A CORBA service does not have to use this method of keeping context but may choose
to do so.
module CORBA {
// interface for the Current object
interface Current {
};
};
Operations on interfaces derived from Current access state associated with the thread
in which they are invoked, not state associated with the thread from which the Current
was obtained. This prevents one thread from manipulating another thread's state, and
avoids the need to obtain and narrow a new Current in each method's thread context.
module CORBA {
typedef unsigned long PolicyType;
PolicyType defines the type of Policy object. The values of PolicyTypes are
allocated by OMG. New values for PolicyType should be obtained from OMG by
sending mail to [email protected]. In general the constant values that are allocated are
defined in conjunction with the definition of the corresponding Policy object.
Copy
Policy copy();
Return Value
This operation copies the policy object. The copy does not retain
any relationships that the policy had with any domain, or object.
Destroy
void destroy();
This operation destroys the policy object. It is the responsibility of
the policy object to determine whether it can be destroyed.
Exceptions
CORBA::NO_PERMISSION raised when the policy object determines that it
cannot be destroyed.
Policy_type
readonly attribute policy_type
Return Value
This readonly attribute returns the constant value of type
PolicyType that corresponds to the type of the Policy object.
Policy Domain
A policy domain is a set of objects to which the policy(ies) associated with that
domain applies. The objects are the domain members. The policy(ies) represent(s) the
rules and criteria that constrain activities of the objects which belong to the domain.
On object creation, the ORB implicitly associates the object with one or more policy
domains. Policy domains provide leverage for dealing with the problem of scale in
policy management by allowing application of policy at a domain granularity rather
than at an individual object instance granularity.
Policy Objects
A policy object encapsulates a policy of a specific type. The policy encapsulated in a
policy object is associated with the domain by associating the policy object with the
domain manager of the policy domain.
There may be several policies associated with a domain, with a policy object for each.
There is at most one policy of each type associated with a policy domain. The policy
objects are thus shared between objects in the domain, rather than being associated
with individual objects. Consequently, if an object needs to have an individual policy,
then must be a singleton member of a domain.
be resolved. The specification does not include explicit support for such overlapping
domains and, therefore, the use of policy composition rules required to resolve
conflicts at policy enforcement time.
Policy domain managers and policy objects have two types of interfaces:
• The operational interfaces used when enforcing the policies. These are the
interfaces used by the ORB during an object invocation. Some policy objects may
also be used by applications, which enforce their own policies.
The caller asks for the policy of a particular type (e.g., the delegation policy), and
then uses the policy object returned to enforce the policy. The caller finding a policy
and then enforcing it does not see the domain manager objects and the domain
structure.
• The administrative interfaces used to set policies (e.g., specifying which events to
audit or who can access objects of a specified type in this domain). The
administrator sees and navigates the domain structure, so is aware of the scope of
what he is administering.
Note that this specification does not include any explicit interfaces for managing the
policy domains themselves: creating and deleting them; moving objects between them;
changing the domain structure and adding, changing and removing policies applied to
the domains. Such interfaces are expected to be the province of other object services
and facilities such as Management Facilities and/or Collection Service in the future.
The ORB will establish these associations when the creating object calls
CORBA::BOA::create or an equivalent. Some or all of these associations may
subsequently be explicitly referenced and modified by administrative or application
activity, which might be specifically security-related but could also occur as a side-
effect of some other activity, such as moving an object to another host machine.
In some cases, when a new object is created, it needs to be created in a new domain.
Within a given domain a construction policy can be associated with a specific object
type thus causing a new domain (i.e., a domain manager object) to be created whenever
an object of that type is created and the new object associated with the new domain
manager. This construction policy is enforced at the same time as the domain
membership (i.e., by BOA::create or equivalent).
By default, the new object that is created is made a member of the domain to which the
parent object belongs. Non object applications on the client side are associated with a
default, per process policy domain by the ORB. Thus, when they create objects the
new objects are by default associated with the default domain associated with them.
Each domain manager has a construction policy associated with it, which controls
whether, in addition to creating the specified new object, a new domain manager is
created with it. This object provides a single operation make_domain_manager
which can be invoked with the constr_policy parameter set to TRUE to indicate to
the ORB that new objects of the specified type are to be created within their own
separate domains. Once such a construction policy is set, it can be reversed by
invoking make_domain_manager again with the constr_policy parameter set to
FALSE.
While the management interface to the construction policy object is standardized, the
interface from the ORB to the policy object is assumed to be a private one, which may
be optimized for different implementations.
If a new domain is created, the policies initially applicable to it are the policies of the
enclosing domain. The ORB will always arrange to provide a default enclosing domain
with default ORB policies associated with it, in those cases where there would be no
such domain as in the case of a non-object client invoking object creation operations.
The calling application, or an administrative application later, can change the domains
to which this object belongs, using the domain management interfaces, which will be
defined in the future.
This section also includes the interface to the construction policy object, as that is
relevant to domains. The basic definitions of the interfaces and operations related to
these are part of the CORBA module, since other definitions in the CORBA module
depend on these.
module CORBA
{
interface DomainManager {
Policy get_domain_policy (
in PolicyType policy_type
);
};
Domain Manager
The domain manager provides mechanisms for:
• Establishing and navigating relationships to superior and subordinate domains.
• Creating and accessing policies.
CORBA::DomainManager::get_domain_policy
This returns the policy of the specified type for objects in this domain.
Policy get_domain_policy (
in PolicyType policy_type
);
Parameters
policy_type The type of policy for objects in the domain which the application
wants to administer. For security, the possible policy types are
described in CORBAservices: Common Object Services
Specification, Security chapter, Security Policies Introduction
section.
Return Value
A reference to the policy object for the specified type of policy in
this domain.
Exceptions
CORBA::BAD_PARAM raised when the value of policy type is not valid
either because the specified type is not supported
by this ORB or because a policy object of that
type is not associated with this Object.
Construction Policy
The construction policy object allows callers to specify that when instances of a
particular interface are created, they should be automatically assigned membership in a
newly created domain at creation time.
CORBA::ConstructionPolicy::make_domain_manager
This operation enables the invoker to set the construction policy that is to be in effect
in the domain with which this ConstructionPolicy object is associated. Construction
Policy can either be set so that when an instance of the interface specified by the input
parameter is created, a new domain manager will be created and the newly created
object will respond to get_domain_managers by returning a reference to this
domain manager. Alternatively the policy can be set to associate the newly created
object with the domain associated with the creator. This policy is implemented by the
ORB during execution of BOA::create (or equivalent) and results in the
construction of the application-specified object and a Domain Manager object if so
dictated by the policy in effect at the time of the creation of the object.
void make_domain_manager (
in InterfaceDef object_type,
in boolean constr_policy
);
Parameters
object_type The type of the objects for which Domain Managers will be
created. If this is nil, the policy applies to all objects in the domain.
Note – These operations are defined on the ORB rather than on an object adapter to
allow the main thread to be used for all kinds of asynchronous processing by the ORB.
Defining these operations on the ORB also allows the ORB to support multiple object
adapters, without requiring the application main to know about all the object adapters.
The interface between the ORB and an object adapter is not standardized.
module CORBA
{
…
interface ORB {
...
boolean work_pending( );
void perform_work();
void shutdown( in boolean wait_for_completion );
void run();
4.9.1 work_pending
boolean work_pending( );
This operation returns an indication of whether the ORB needs the main thread to
perform some work.
A result of TRUE indicates that the ORB needs the main thread to perform some work
and a result of FALSE indicates that the ORB does not need the main thread.
4.9.2 perform_work
void perform_work();
It is platform specific how the application and ORB arrange to use compatible
threading primitives.
// C++
for (;;) {
if (orb->work_pending()) {
orb->perform_work();
}
// do other things
// sleep?
}
4.9.3 run
void run();
This operation returns when the ORB has shut down. If called by the main thread, it
enables the ORB to perform work using the main thread. Otherwise, it simply waits
until the ORB has shut down.
This operation can be used instead of perform_work() to give the main thread to
the ORB if there are no other activities that need to share the main thread. Even in a
pure multi-threaded server, calling run() in the main thread is useful to ensure that the
process does not exit until the ORB has been shut down.
4.9.4 shutdown
void shutdown(in boolean wait_for_completion);
This operation instructs the ORB to shut down. Shutting down the ORB causes all
object adapters to be shut down. If the wait_for_completion parameter is TRUE,
this operation blocks until all ORB processing (including request processing and object
deactivation or other operations associated with object adapters) has completed.