user manual

112 BES Developers Guide
apply. The initialization of the ORB determines the context returned by
resolve_initial_references().
For example, a C++ Client can locate the home interface to the ATMSession
bean, which has been registered with a JNDI string name "transaction/
corbaEjb/atm". You first obtain the initial naming context.
Object_ptr obj = orb->resolve_initial_refernces("NameService");
NamingContext initialNamingContext= NamingContext.narrow( obj );
if( initialNamingContext == NULL ) {
cerr << "Couldn't initial naming context" << endl;
exit( 1 );
}
Then you create a CORBA Naming Service name and initialize it according to
the mapping explained previously.
Name name = new Name( 1 );
name[0].id = "atm";
name[0].kind = "";
Now resolve the name on the initial naming context. Assume that you have
successfully performed the initialization and that you have the context of the
naming domain of the enterprise bean. We narrow the resulting CORBA object
to the expected type and make sure that the narrow was successful.
Object_ptr obj = initialNamingContext->resolve( name );
ATMSessionHome_ptr atmSessionHome = ATMSessionHome.narrow( obj );
if( atmSessionHome == NULL ) {
cerr << "Couldn't narrow to ATMSessionHome" << endl;
exit( 1 );
}
Mapping for transaction
A CORBA-based enterprise bean runtime environment that wants to enable a
CORBA client to participate in a transaction involving enterprise beans must
use the CORBA Object Transaction Service for transaction control.
When an enterprise bean is deployed it can be installed with different
transaction policies. The policy is defined in the enterprise bean's deployment
descriptor.
The following rules have been defined for transactional enterprise beans: A
CORBA client invokes an enterprise through stubs generated from the IDL
interfaces for the enterprise bean's remote and home interface. If the client is
involved in a transaction, it uses the interfaces provided by CORBA Object
Transaction Service. For example, a C++ client could invoke the ATMSession
bean from the previous example as follows:
try {
...
// obtain transaction current
Object_ptr obj = orb->resolve_initial_refernces("Current");