Skip navigation.

CORBA Programming Reference

  Previous Next vertical dots separating previous/next from contents/index/pdf Contents View as PDF   Get Adobe Reader

 


DI.list_factories

Synopsis

Lists all of the application factory names and object references.

MIDL Mapping

HRESULT list_factories(
[in,out,optional] VARIANT* exceptionInfo,
[out,retval] VARIANT* returnValue);

Automation Mapping

Function list_factories([exceptionInfo])

Parameter

exceptionInfo

An optional input argument that enables the application to get additional exception data if an error occurred.

Exception

CannotProceed

This exception is raised if the FactoryFinder or the CORBAservices Naming Service encounter an internal error during the search with the error being written to the user log (ULOG). operations staff immediately if this exception is raised. Depending on the severity of the internal error, the server running the FactoryFinder or the CORBAservices Naming Service may have terminated. If a FactoryFinder service has terminated, start a new FactoryFinder service. If a CORBAservices Naming Service has terminated and there is another CORBAservices Naming Service running, start a new CORBAservices Naming Service. If there are no naming service servers running, restart the application.

RegistrarNotAvailable

This exception is raised if the FactoryFinder object cannot locate the CORBAservices Naming Service object. operations staff immediately if this exception is raised. It is possible that no naming service servers are running. Restart the application.

Description

This method instructs the FactoryFinder to return a list containing all of the factory keys and associated object references for application factories registered with the CORBAservices Naming Service.

Return Values

Returns a variant containing an array of DITobj_FactoryComponent objects. The FactoryComponent object consists of a variant containing an array of DICosNaming_NameComponent objects and an interface pointer to the application factory.

 


Programming Examples

This section describes how to program using the FactoryFinder interface.

Note: Remember to check for exceptions in your code.

Using the FactoryFinder Object

A FactoryFinder object is used by programmers to locate a reference to a factory object. The FactoryFinder object provides operations to obtain one or more references to factory objects based on the criteria specified.

There can be more than one FactoryFinder object in a process address space. Multiple references to a FactoryFinder object must be supported. A FactoryFinder object is semi-stateful in that it maintains state about the association between FactoryFinder objects within a domain and a particular IIOP Server Listener/Handler (ISL/ISH) through which to access the domain.

All FactoryFinder objects support the CosLifeCycle::FactoryFinder interface as defined in CORBAservices Specification, Chapter 6 "Life Cycle Service," December 1997, published by the Object Management Group. The interface contains one operation that is used to obtain one or more references to factory objects that meet the criteria specified.

Registering a Reference to a Factory Object

The following code fragment (Listing 5-8) shows how to use the TP Framework interface to register a reference to a factory object with a FactoryFinder.

Listing 5-8 Server Application: Registering a Factory

// Server Application: Registering a factory.
// C++ Example.

TP::register_factory( factory_obj.in( ), "TellerFactory" );

Obtaining a Reference to a FactoryFinder Object Using the CosLifeCycle::FactoryFinder Interface

The following code fragment (Listing 5-9) shows how to use of the CORBA-compliant interface to obtain one or more references to factory objects.

Listing 5-9 Client Application: Getting a FactoryFinder Object Reference

// Client Application: Obtaining the object reference
// to factory objects.

CosLifeCycle::Key_var factory_key = new CosLifeCycle::Key( );
factory_key ->length(1);
factory_key[0].id = string_dupalloc( "strlen("TellerFactory") +1 );
factory_key[0].kind = string_dupalloc(
strlen(""FactoryInterface") + 1);
strcpy( factory_key[0].id, ""TellerFactory" );
strcpy( facory_key[0].kind, "FactoryInterface" );
CosLifeCycle::Factories_var * flp = ff_np ->
find_factories( factory_key.in( ) );

Obtaining a Reference to a FactoryFinder Object Using the Extensions Bootstrap object

The following code fragment (Listing 5-10) shows how to use of the BEA Tuxedo extensions Bootstrap object to obtain a reference to a FactoryFinder object.

Listing 5-10 Client Application: Finding One Factory Using the Tobj Approach

// Client Application: Finding one factory using the Tobj
// approach.
Tobj_Bootstrap * bsp = new Tobj_Bootstrap( 
orb_ptr.in( ), host_port );
CORBA::Object_varptr ff_op = bsp ->
resolve_initial_references( "FactoryFinder" );
Tobj::FactoryFinder_ptrvar ff_np =
Tobj::FactoryFinder::_narrow( ff_op);

Note: You can used the BEA Tuxedo CORBA extensions to the CosLifeCycle::FactoryFinder interface if you use the Tobj_Bootstrap object, however, use of the Tobj_Bootstrap object is not required to locate a factory. If you use CORBA INS, you can use the find_factories() method provided by the CosLifeCycle::FactoryFinder interface.

Using Extensions to the FactoryFinder Object

BEA Tuxedo extends the FactoryFinder object with functionality to support similar capabilities to those provided by the operations defined by CORBA, but with a much simpler and more restrictive signature. The enhanced functionality is provided by defining the Tobj::FactoryFinder interface. The operations defined for the Tobj::FactoryFinder interface are intended to provide a focused, simplified form of the equivalent capability defined by CORBA. An application developer can choose to use the CORBA-defined or BEA Tuxedo extensions when developing an application. The interface Tobj::FactoryFinder is derived from the CosLifeCycle::FactoryFinder interface.

BEA Tuxedo extensions to the FactoryFinder object adhere to allthe same rules as the FactoryFinder object defined in the CORBAservices Specification, Chapter 6 "Life Cycle Service," December 1997, published by the Object Management Group.

The implementation of the extended FactoryFinder object requires users to supply either a CosLifeCycle::Key, as in the CORBA-defined CosLifeCycle::FactoryFinder interface, or a NULL-terminated string containing the identifier of a factory object to be located.

Obtaining One Factory Using Tobj::FactoryFinder

The following code fragment (Listing 5-11) shows how to use the BEA Tuxedo extensions interface to obtain one reference to a factory object based on an identifier.

Listing 5-11 Client Application: Finding Factories Using the BEA Tuxedo Extensions Approach

CosLifeCycle::Factory_ptrvar  fp_obj = ff_np ->
find_one_factory_by_id( "TellerFactory" );

Obtaining One or More Factories Using Tobj::FactoryFinder

The following code fragment (Listing 5-12) shows how to use the BEA Tuxedo extensions to obtain one or more references to factory objects based on an identifier.

Listing 5-12 Client Application: Finding One or More Factories Using the BEA Tuxedo Extensions Approach

CosLifeCycle::Factories * _var  flp = ff_np ->
find_factories_by_id( "TellerFactory" );

 

Skip navigation bar  Back to Top Previous Next