Home
ORBACUS, this manual
Contents
1. Caveats In these simple examples the factory objects do not maintain any references to the Product servants they create it is the responsibility of the client to ensure that it destroys a Product object when it is no longer needed This design has a significant potential for resource leaks in the server as it is quite possible that a client will not destroy its Product objects either because the programmer who wrote the client forgot to invoke dest roy or because the client program crashed before it had a chance to clean up You should keep these issues in mind when designing your own factory objects Obtaining the POA for a Servant As mentioned in the previous sections every servant inherits default function from its skeleton class The default implementation of this function returns the Root POA If you instantiate servants on anything but the Root POA you must override the function in the servant otherwise calls to this will create incorrect object references Usually this involves remembering the POA reference for a servant in a private member variable and returning that reference from a callto default POA Ifall servants for objects of a particular interface type use the same POA you can use a static member variable In you can use an approach similar to the following C class Product impl public virtual POA Product public virtual PortableServer RefCountSer
2. The implementation class Hello impl must inherit from the generated class He110POA As with the C implementation the say_hello method simply prints Hello World on standard output Save this class to the file Hello_imp1 java in the directory hello We also have to write a class which holds the server s main and run methods We call this class Server saved as the file Server java in the directory hello Java package hello public class Server public static void main String args java util Properties props System getProperties props put org omg CORBA ORBClass com ooc CORBA ORB props put org omg CORBA ORBSingletonClass com ooc CORBA ORBSingleton int status 0 org omg CORBA ORB orb null try orb org omg CORBA ORB init args props status run orb catch Exception ex printStackTrace status 1 if orb null try com ooc CORBA ORB orb destroy catch Exception ex printStackTrace ORBacus 25 Getting Started 36 37 38 39 40 41 I9 Z1 25 27 38 41 AN tQ NR No AN o status 1 System exit status These properties are necessary to use the ORBACUS ORB with JDK 1 2 or later The ORB must be initialized using ORB init The ORB class resides in the package
3. ORBacus 145 ORBacus Names 75 76 17 75 9 5 3 nc bind cName Several sample objects are created that will later be bound to our Naming Service These objects implement an interface called Named In this example the details of this interface are not important Named might even be an interface without any operations defined in it Create and bind some new contexts and bind the sample objects to these contexts Each binding name consists of several NameComponents that are similar to the path compo nents of a file located somewhere in a filesystem Objects are bound with the Naming Ser vice s bind operation for contexts the corresponding operation bind context is used In addition to the object s IOR both operations expect a unique binding name If a name already exists an AlreadyBound exception is thrown There are also other exceptions you might encounter at this stage e g I11egalName if an empty string was provided as part of a NameComponent Exceptions This code fragment deals with exceptions that may be thrown by the Naming Service operations Java catch NotFound ex System err print Got a NotFound exception switch ex why value case NotFoundReason missing nod System err print missing node break case NotFoundReason not context System err print not context break case NotFoundReason not object System err print not object break System e
4. and the reference count ing class Re CountServantBase An instance of the servant class A impl is created in the constructor for B impl In the destructor for B impl the reference count for the servant A impl is decremented which leads to the destruction of the servant getA returns an object reference to the A_imp1 servant implicitly creating and activating the CORBA object if necessary In Java the interfaces can be implemented like this Java public class A impl extends APOA 98 ORBacus Obtaining Object References OND T1715 17 20 public class B_impl extends BPOA org omg CORBA ORB A impl a public B impl org omg CORBA ORB orb orb orb a new A impl A getA return a_ _this orb_ The servant class A_imp1 is defined which inherits from the skeleton class APOA The servant class B impl is defined which inherits from the skeleton class BPOA B impl s constructor stores a reference to the orb and creates a new A impl servant getA returns an object reference to the A_imp1 servant implicitly creating and activating the CORBA object if necessary A client written in C could use code like the following to get references to A C B var b Get B object reference somehow A var a b gt getA And in Java Java Get a B object reference somehow A b getA In this examp
5. Using POA Managers 4 8 Retrieve the ooc orb conc model property and set it to threaded if its value is not 4 4 4 4 1 valid Initialize the ORB Using POA Managers The CORBA specification states that a POA Manager is used to control the flow of requests to one or more POAs In ORBACUS each POA Manager also encapsulates a set of network endpoints on which a server listens for new connections This design provides applications with a great deal of flexibility e endpoints can be activated and deactivated on demand e a group of endpoints can be controlled using a single POA Manager and serviced by one or more POAs Creating POA Managers When the Root POA is first resolved using resolve initial references a POA Manager is created to manage the Root POA Additional POA Managers are created implicitly when a ni1 value for the POA Manager argument is passed to the create POA operation In this text we ll refer to POA Managers created in this way as anonymous POA Managers By default each new POA Manager creates a single endpoint 1 POA Man ager will listen for new connections on a port Applications should therefore use caution to ensure that POA Managers are not created unnecessarily An application can control the endpoint configuration using configuration properties see ORB Properties on page 49 However properties cannot be specified for anonymous POA Managers therefore these POA Manage
6. catch java io IO Exception ex ex printStackTrace return 1 manager activate orb run return 0 0 A reference to the Root POA is obtained using the ORB reference and the Root POA is used to obtain a reference to its POA Manager A servant of type Hello impl is created and is used to incarnate a CORBA object The CORBA object is released automatically when it is not used anymore The object reference is stringi fied and written to a file The server enters its event loop to receive incoming requests Implementing the Client Save this to a file with the name Client java in the directory hello Java package hello public class Client public static void main String args Same as for the server static int run org omg CORBA ORB orb org omg CORBA Ob try ject obj null ORBacus 27 Getting Started 14 26 28 30 2 4 3 String refFile Hello ref java io BufferedReader in new java io BufferedReader new java io FileReader refFile String ref in readLine obj orb string to object ref catch java io IOException ex printStackTrace return 1 Hello hello HelloHelper narrow obj hello say hello return 0 This code is the same as for the server The stringified object reference is read and converted to an object The object reference is narr
7. C I impl tie impl new I impl tie POA I tie I impl tie gt tie pointer new POA I tie I impl tie impl 1 A new I impl tie is created with new An instance of POA tie parameterized with I impl tie is created taking implasa parameter All operation calls to t ie will then be delegated to imp1 In this example the lifetime of imp1 is coupled to the lifetime of the servant tie That is when the tie is destroyed delete imp1 is called by the tie s destructor In case you don t want the lifetime of imp1 to be coupled to the lifetime of the tie for example because you want to create a servant on the stack and not on the heap making it illegal to call delete on the tie use the following code C I impl tie impl POA I tie I impl tie gt tie new POA I tie I impl tie gt amp impl 0 new I impl tie is created this time on the stack not on the heap An instance of POA 1 tie is created The 0 parameter tells tie not to call delete on impl 1 You can also instantiate servants on the stack However this only works only for some POA pol icies so servants are usually instantiated on the heap 84 ORBacus Creating Servants 5 3 2 WH Hh Creating Servants using Java Every tie class generated by the IDL to Java translator has two constructors Java public class IPOATie extends IPOA public IPOATie IOperations delegate
8. ORBacus 347 Open Communications Interface Reference E 14 Interface OCI AccFactoryRegistry interface AccFactoryRegistry A registry for Acceptor factories See Also Acceptor AccFactory Operations add factory void add factory in AccFactory factory raises FactoryAlreadyExists Adds an Acceptor factory to the registry Parameters factory The Acceptor factory to add Raises FactoryAlreadyExists Ifa factory already exists with the same protocol id as the given factory get_factory AccFactory get factory in ProtocolId id raises NoSuchFactory Returns the factory with the given protocol id Parameters id The protocol id Returns The Acceptor factory Raises NoSuchFactory If no factory was found with a matching protocol id get factories 348 ORBacus Interface OCI AccFactoryRegistry AccFactorySeq get factories Returns all registered factories Returns The Acceptor factories ORBacus 349 Open Communications Interface Reference E 15 Interface OCI ConFactory interface ConFactory A factory for Connector objects See Also Connector ConFactoryRegistry Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute ProfileId tag The profile id tag Operations create connectors ConnectorSeq create connectors in in IOR ref CORBA PolicyList policies Returns a sequence of Connectors f
9. if strcmp orbModel threaded 0 amp amp strcmp orbModel reactive 0 props gt setProperty ooc orb conc model threaded CORBA ORB_var orb OBCORBA ORB_init argc argv props Create an OB Properties object that is based on the default properties Initialize the properties for the ORB After invoking OB ParseArgs props contains the ORB properties and argv no longer contains any ORB or OA command line argu ments The OB ParseArgs operation takes an optional Logger object which ParseArgs will use to display any warning or error messages In this example a custom Logger object is not used so the code passes a nil value Retrieve the ooc orb conc model property and set it to threaded if its value is not valid Initialize the ORB Java java util Properties props System getProperties args com ooc CORBA ORB ParseArgs args props null String orbModel props get ooc orb conc model if orbModel equals threaded props put ooc orb conc model threaded org omg CORBA ORB orb org omg CORBA ORB init arg props Create a java util Properties object Initialize the properties for the ORB After invoking com ooc CORBA ORB ParseArgs props contains the ORB properties The return value of ParseArgs is a String array with all ORB and OA arguments removed As in the C example a Logger object is not used 64 ORBacus
10. Assign an ID poa activate object with id id result return result gt _this The servant class Factory impl is defined as an implementation of the Factory inter face A new reference counted Product servant is instantiated The servant is assigned to a ServantBase var Which decrements the servant s reference count when it goes out of scope Activates the servant and returns an object reference to the client It is important to understand how the servant is eventually destroyed The RefCountServantBase class from which the servant inherits implements a reference count When the servant is instantiated the Re CountServantBase constructor sets this reference count to 1 When the servant is activated with the POA the POA increases the reference count by at least 1 When the ServantBase var we assigned the servant to goes out of scope the reference count is decremented by 1 This means that when createProduct returns only the POA is holding a reference to the servant Later then the servant is deactivated in dest roy the POA decrements the reference count by exactly the same number it used to increment the reference count upon activation This causes the reference count to drop to zero in which case the servant will be implicitly deleted 92 ORBacus Factory Objects 5 6 2 amp Qt AN Dos CQ E ER 12 Note that whenever the ORB s
11. cost which is defined to be read only Because the property is not mandatory an exporter does not need to supply a value for it at the time a service offer is exported However once a value has been defined for this prop erty it cannot subsequently be changed Service Offers A service offer is an instance of a service type and represents the advertisement of a ser vice by a service provider A service offer has the following characteristics e A service type name associates the offer with a particular service type e An object reference provides the pointer the object reference to the advertised object that is necessary for clients to invoke the service being offered e A set of properties describe this service offer and must conform to the property types defined by the service type The trader uses the definition of the specified service type to perform several validation steps on a new offer 1 The exporter must provide values for all mandatory properties including all mandatory properties that the service type inherits from its super types if any 2 The object must conform to the interface type defined by the service type The value types of all properties must match the value types as defined by the service type For example a value of type double is not allowed for a property whose type is defined as string in the service type Note ORBacus Trader allows an exporter to supply values for named prope
12. e Host and port The canonical hostname is incorrect or cannot be determined reliably so a hostname is specified e Multiple hosts and port The host is known by several names The client should attempt at least one connection to each address until finding one that succeeds or until all addresses have been exhausted e Bind A host has multiple network interfaces but the acceptor should only be bound to one of them The Bi directional OCI Plug in The ORBACUS Bi directional plug in offers a solution for distributed systems where secu rity restrictions interfere with a client s ability to receive callbacks This capability is especially useful in two common situations e Firewalls prevent the server from establishing a separate connection back to the client e Browser restrictions prevent an applet from accepting connections Note This plug in does not implement the Bi directional IIOP standard defined by CORBA 2 3 This plug in uses a proprietary protocol that is not interoperable with other ORBs How does it work The Bi directional plug in uses a layered design that theoretically enables any connection oriented OCI plug in to support bi directional functionality Initially however only bi directional IIOP is supported In Figure 19 1 a server is shown that is capable of receiving both bi directional IIOP con nections and regular IIOP connections ORBacus 271 The Open Communications Interface 19 6 2 Figu
13. public IPOATie IOperations delegate POA poa The second constructor allows a POA instance to be supplied which will be used as the return value for the tie Ss default method If the POA instance is not supplied the default method will return the root POA of the ORB with which the tie has been associated This example demonstrates how to create servants using Java Java I impl impl new I impl I impl anotherImpl new I impl Two servants impl and anotherImpl are created with new In case the servant class was written using the delegation approach an object implement ing the IOperations interface must be passed to the tie s constructor Java I impl tie impl new I impl tie IPOATie tie new IPOATie impl A new I impl ties created An instance of IPOATie is created taking impl as a parameter All operation calls to tie will then be delegated to imp1 The tie class also provides methods for accessing and changing the implementation object Java public class IPOATie extends IPOA public IOperations delegate public void _delegate IOperations delegate ORBacus 85 CORBA Objects 5 4 5 4 1 This method returns the current delegate i e implementation object This method changes the delegate object Activating Servants Servants must be activated in order to receive requests from clients Servant activa
14. 1 1 What is ORBacus ORBACUS is an Object Request Broker ORB that is compliant with the Common Object Request Broker Architecture CORBA specification as defined in The Common Object Request Broker Architecture and Specification 4 C Language Mapping 5 IDL Java Language Mapping 6 and Portable Interceptors 7 These are some of the highlights of ORBACUS Full CORBA IDL support e C and Java language mappings e Simple configuration and bootstrapping e Portable Object Adapter e Objects by Value e Portable Interceptors e Single and Multi threaded e Active Connection Management e Fault Tolerant Extensions e Dynamic Invocation and Dynamic Skeleton Interface e Dynamic Any ORBacus 15 Introduction 1 2 1 3 e Interface and Implementation Repository e Pluggable Protocols e IDL to HTML and IDL RTF documentation tools e Includes Naming Trading Event and Property Services For platform availability please refer to the ORBACUS home page at http www ooc com ob About this Document This manual is except for the Getting Started chapter no replacement for a good CORBA book This manual also does not contain the precise specifications of the CORBA standard which are freely available on line A good grasp of the CORBA speci fications in 4 6 and 6 is absolutely necessary to effectively use this manual In par ticular the chapters in 4 covering CORBA IDL a
15. 23 static char toString const TimeBase UtcT amp 24 static char toTimeString const TimeBase UtcT amp ORBacus 173 ORBacus Time 25 26 27 28 2 9 30 3 33 34 35 36 3 7 38 8 9 PO toh 13 14 15 16 17 18 19 20 21 22 23 08 28 36 static bool bool bool bool bool bool opera opera opera opera opera opera TimeBase TimeBase TimeBase char toString TimeBase TimeT tor lt const tor lt cons tor const tor gt cons tor cons tor cons UtcT opera UtcT opera UtcT opera TimeBase UtcT amp const TimeBase UtcT amp t TimeBase UtcT amp const TimeBase UtcT amp TimeBase UtcT amp const TimeBase UtcT amp t TimeBase UtcT amp const TimeBase UtcT amp t TimeBase UtcT amp const TimeBase UtcT amp t TimeBase UtcT amp const TimeBase UtcT amp tor const TimeBase UtcT amp TimeBase TimeT tor TimeBase TimeT const TimeBase UtcT amp tor const TimeBase UtcT amp TimeBase TimeT end of module OB The maximum value of the TimeT type The maximum value of the 1naccuracyT type Return the current UTC time Return the minimum UTC time Return the maximum UTC time Return the equivalent POSIX time Create an interval from a time value and its inaccuracy similar to UTC time to interval Create a UTC time from
16. The address and port are obtained and displayed on standard output The IIOP OCI Plug in The IIOP plug in implements the Internet Inter ORB Protocol as described in 4 By default the ORB automatically installs the client and server i e Connector Factory and Acceptor Factory components of the IIOP plug in and IIOP is the default protocol used by the ORB IIOP Acceptor Configuration The configuration parameters for the IIOP Acceptor are described in Table 19 2 ORBacus 275 The Open Communications Interface Table 19 2 IIOP Acceptor Configuration Parameters Name Type Description backlog unsigned short The maximum length of the listen backlog queue Note that the operating system may have a smaller limit which will override this value If not specified a default value of 50 is used in Java and 5 in C bind string The hostname or dotted decimal address of the network interface on which to bind the socket If not specified the socket will be bound to all available interfaces host CORBA StringSeq A sequence of one or more hostnames and or dotted decimal addresses representing the addresses that should be advertised in IORs Using IIOP 1 0 multiple addresses are represented as multiple tagged profiles Using IIOP 1 1 or later multiple addresses can be represented as either multiple tagged profiles or as a single tagged profile with a tagged component for each additiona
17. Transport TransportInfo Attributes addr readonly attribute InetAddr addr The local 32 bit IP address port readonly attribute unsigned short port The local port remote addr readonly attribute InetAddr remote addr The remote 32 bit IP address remote port readonly attribute unsigned short remote port The remote port 358 ORBacus Interface OCI ITOP ConnectorInfo E 21 Interface OCI IIOP ConnectorInfo interface ConnectorInfo inherits from OCI ConnectorInfo Information on an OCI Connector object See Also Connector ConnectorInfo Attributes remote_addr readonly attribute InetAddr remote_addr The remote 32 bit IP address to which this connector connects remote_port readonly attribute unsigned short remote_port The remote port to which this connector connects ORBacus 359 Open Communications Interface Reference E 22 Interface OCI IIOP AcceptorlInfo interface AcceptorInfo inherits from OCI AcceptorInfo Information on an IIOP OCI Acceptor object See Also Acceptor AcceptorInfo Attributes hosts readonly attribute CORBA StringSeq hosts Hostnames used for creation of object references addr readonly attribute InetAddr addr The local 32 bit IP address on which this acceptor accepts port readonly attribute unsigned short port The local port on which this acceptor accepts ORBacus Interface OCI IIOP AccF
18. ax Aj oj Cut Paste Delete Refresh 15 6 Managing Service Types With the console you can manage all aspects of the trader s service type repository Note Although ORBACUS Trader supports properties with user defined types the con sole only supports simple types and sequences of simple types Refer to Service Types on page 198 for more information on service types 220 ORBacus Managing Service Types 15 6 1 Adding a New Service Type To add a new service type do the following 1 Select Insert Service Type The New Service Type dialog box appears as shown below New Service Type Lx Service type name Interface Browse r Super types r Properties Add OK Cancel 2 Enter a name for the service type in the Service type name text box The name must be unique among all of the service types managed by the trader 3 Enter an interface repository identifier in the Interface text box If the interface repository service is available clicking the Browse button displays an interface ORBacus 221 ORBacus Trader Console repository browser as shown below Interface Repository Browser x Select an interface zs Interface Repository CosTrading CosTradingRepos CosTradingDynamic amp C LenderDemo D Lender ID IDL LenderDemosLender 1 0 OK Cancel The browser
19. portInfo in case the plug in implements IIOP See Also Transport Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute ProfileId tag The profile id tag connector info readonly attribute ConnectorInfo connector info The ConnectorInfo object for the Connector that created the Transport object that this Trans portInfo object belongs to If the Transport for this TransportInfo was not created by a Connec tor this attribute is set to the nil object reference acceptor info readonly attribute AcceptorInfo acceptor info The AcceptorInfo object for the Acceptor that created the Transport object that this Transport Info object belongs to If the Transport for this TransportInfo was not created by an Acceptor this attribute is set to the nil object reference Operations describe string describe 330 ORBacus Interface OCI TransportInfo Returns a human readable description of the transport Returns The description add close cb void add close cb in CloseCB cb Add a callback that is called before a connection is closed If the callback has already been reg istered this method has no effect Parameters cb The callback to add remove close cb void remove close cb in CloseCB cb Remove a close callback If the callback was not registered this method has no effect Parameters cb The callback to remove ORBacus 331 Open Communi
20. B narrow mustbe usedto geta B ptr which is assigned to a self managed B var in this example Java org omg CORBA ORB orb Get a reference to the ORB somehow java io BufferedReader in new java io BufferedReader new java io FileReader object ref String ref in readLine org omg CORBA Object obj orb string to object ref B b BHelper narrow obj The stringified object reference is read String to object creates an object reference from the string Use BHelper narrow to narrow the return value of string to object to B Using a URL It is sometimes inconvenient or impossible for clients to have access to the same filesys tem as the server in order to read a stringified object reference from a file A more flexible method is to publish the reference in a file that is accessible by clients as a URL Your cli ents can then use HTTP or FTP to obtain the contents of the file freeing them from any local filesystem requirements This strategy only requires that your clients know the appropriate URL and is especially suited for use in applets Note This example is shown only in Java because of Java s built in support for URLs but the strategy can also be used in C Java import java io import java net String location http www mywebserver object ref org omg CORBA ORB orb Get a reference to the ORB somehow URL url new URL location URLConnecti
21. CORBA String var s orb gt object to string hello const char refFile Hello ref ofstream out refFile out s endl out close manager activate orb run return EXIT SUCCESS ORBacus 21 Getting Started 16 20 22 23 2 32 AN Ql HB Wo Using the ORB reference resolve initial references is invoked to obtain a reference to the Root POA The Root POA is used to obtain a reference to its POA Manager A servant of type Hello impl is created and assigned to a ServantBase var variable The servant is then used to incarnate a CORBA object using the this operation ServantBase var and Hello_var like all var types are smart pointer i e servant and hello will release their assigned object automatically when they go out of scope The client must be able to access the implementation object This can be done by saving a stringified object reference to a file which can then be read by the client and converted back to the actual object reference The operation object to string converts a CORBA object reference into its string representation The server must activate the POA Manager to allow the Root POA to start processing requests and then inform the ORB that it is ready to accept requests Save the code for main and run to a file with the name Server cpp Implementing the Client In sev
22. Execute the query for the Printer service type The client indicates that it wants a maxi mum of 100 offers to be returned Additional offers will be obtained via the iterator After examining the results the client must destroy the iterator if one was returned ORBacus 213 ORBacus Trader 214 ORBacus owns ORBacus Trader Console The ORBACUS Trader Console allows you to manage all aspects of ORBACUS Trader The functionality provided by this application includes Managing service types offers proxy offers and links Performing queries e Configuring the trader attributes ORBacus 215 ORBacus Trader Console 15 1 15 1 1 15 1 2 15 2 Synopsis Usage com ooc CosTradingConsole Main windows motif mac look CLASS h help windows Use the Windows Look amp Feel if available motif Use the Motif Look amp Feel if available mac Use the Macintosh Look amp Feel if available look CLASS Use the specified JTC Look amp Feel class h MS Display the command line options supported by the program CLASSPATH Requirements The ORBACUS Trader Console requires the classes in OB jar OBTrading jar OBUtil jar and the Java Foundation Classes JFC Note JFC is part of version 1 2 or greater of JDK Main Window The ORBACUS Trader Console main window appears as shown in Figure 15 1 216 ORBacus Terminology Figure 15 1 The Trader Con
23. RESPONSE exception is raised The default value is 1 which means no timeout 304 ORBacus Interface OB ConnectionReusePolicy B 3 Interface OB ConnectionReusePolicy interface ConnectionReusePolicy inherits from CORBA Policy The connection reuse policy This policy determines whether connections may be reused or are pri vate to specific objects Attributes value readonly attribute boolean value If an object has a ConnectionReusePolicy set with value set to FALSE then other object references will not be permitted to use connections made on behalf of this object If set to TRUE then connections are shared The default value is TRUE ORBacus 305 ORBacus Policy Reference B 4 Interface OB InterceptorPolicy interface InterceptorPolicy inherits from CORBA Policy The interceptor policy This policy can be used to control whether interceptors are called on method invocations on both the client and the server side Attributes value readonly attribute boolean value If an object has an InterceptorPolicy set and value is FALSE then any installed intercep tors are not called Otherwise interceptors are called for each method invocation The default value is TRUE 306 ORBacus Interface OB LocationTransparencyPolicy B 5 Interface OB LocationTransparencyPolicy interface Location TransparencyPolicy inherits from CORBA Policy The location transpar
24. Synopsis 7 u uninstall d debug h Display the command line options supported by the server E Install the service The service must be started manually install S E Install the service The service will be started automatically start install u Uninstall the service uninstall d Run the service debug mode In order to use the Naming Service as a native Windows NT service it is first necessary to add the ooc naming port configuration property to the HKEY LOCAL MACHINE NT registry key see Using the Windows NT Registry on page 60 for more details If the service is to be persistent the path to the database file must be stored in the following property HKEY LOCAL MACHINENSoftwareNOOCNMPropertiesNoocNnamingNdatabase Next the service should be installed with ntnameservice i This adds the ORBacus Naming Service entry to the Services dialog in the Control Panel To start the naming service select the ORBacus Naming Service entry and press Start If the service is to be started automatically when the machine is booted select the ORBacus Naming Service entry then click Startup Next select Startup Type Automatic and press OK Alternatively the service could have been installed using the s option which configures the service for automatic start up ntnameservice s If you want to remove the service run ntnameservice u Pl
25. The name you use for the property must not be the same as any existing properties Click OK to add the property to the Properties table Note Once the property has been added to the Properties table you can edit it directly just as you can with any other property If you later decide that you do not want to include the property with the proxy offer simply uncheck the property s checkbox If you wish to make a property dynamic select the property and click the Dynamic button The Dynamic Property dialog box appears as shown in Adding a New Offer on page 224 Select a method for specifying an object reference as outlined in step 3 above If you wish to include additional data select a type from the drop down list and enter a value in the text box Click OK to save the dynamic property The property table displays dynamic as the value of a dynamic property To clear the value of a property select the property and click Reset You can use this command to convert a property from a dynamic property to a regular property 230 ORBacus Managing Proxy Offers 10 Use the Add Edit and Delete buttons to manipulate the policies to be passed on to the target object Clicking the Add or Edit buttons displays the Policy dialog box as shown below Policy x Name Type boolean m Value OK Cancel 11 Click OK to add the new proxy offer The application
26. calls to read write close are strictly non compliant A handle value of 1 indicates that the protocol plug in does not support selectable Trans ports Operations close void close Closes the Transport After calling close no operations on this Transport object and its associ ated TransportInfo object may be called To ensure that no messages get lost when close is called shutdown should be called first Then dummy data should be read from the Transport 326 ORBacus Interface OCT Transport using one of the receive operations until either an exception is raised or until connection clo sure is detected After that its save to call close i e no messages can get lost Raises COMM FAILURE In case of an error shutdown void shutdown Shutdown the Transport Upon a successful shutdown threads blocking in the receive opera tions will return or throw an exception After calling shutdown no operations on associated TransportInfo object may be called To fully close the Transport c1ose must be called Raises COMM FAILURE In case of an error receive void receive in Buffer buf in boolean block Receives a buffer s contents Parameters buf The buffer to fill block If set to TRUE the operation blocks until the buffer is full If set to FALSI ation fills as much of the buffer as possible without blocking Raises COMM FAILURE
27. do the following 1 Select View Links to display the links in the item list 2 Select the link you wish to modify 232 ORBacus Configuring the Trader Attributes 3 Select Edit Modify The Edit Link dialog box appears as shown below ES Edit Link TestLink x Default follow rule Local Only w Limiting follow rule Local Only OK Cancel 4 Update the settings for the link follow rules 5 Click OK to update the link 15 9 3 Removing a Link To remove a link do the following B W Noe Select View Links to display the links in the item list Select the link you wish to remove Select Edit Delete A confirmation dialog appears Click Yes to remove the link 15 10 Configuring the Trader Attributes To configure the trader attributes select Tools Attributes The Attributes dialog box appears containing a tabbed folder with four tabs The tabs provide access to the attributes from the following four IDL interfaces CosTrading CosTrading CosTrading CosTrading SupportAttributes ImportAttributes LinkAttributes Admin Each of the tabs is described below Click OK when you have finished modifying the attributes ORBacus 233 ORBacus Trader Console 15 10 1Support Attributes Support Import Link Admin NI Supports modifiable properties R Supports dynamic properties vj Supports proxy offers Servic
28. org omg CORBA You must either import this package or as shown in this example you must use org omg CORBA explicitly The run helper function is called This code catches and prints all CORBA exceptions raised by ORB init or run If the ORB was successfully created it is destroyed This releases the resources used by the ORB If destroy raises a CORBA exception this exception is caught and printed The cast to com ooc CORBA ORB is required when using JDK 1 2 but not when using JDK 1 1 or JDK 1 3 The exit status is returned If there was no error 0 is returned or 1 otherwise Now we write the run method Java static int run org omg CORBA ORB orb throws org omg CORBA UserException org omg PortableServer POA rootPOA org omg PortableServer POAHelper narrow orb resolve initial references RootPOA org omg PortableServer POAManager manager rootPOA the POAManager Hello impl helloImpl new Hello impl Hello hello hellorimpl this orb try String ref orb object_to_string hello String refFile Hello ref java io PrintWriter out new java io PrintWriter new java io FileOutputStream refFile 26 ORBacus Implementing the Example in Java 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 22223 15 28 30 31 2 4 2 AN WH amp out println ref out close
29. the property ooc orb trace connections 5 is stored in the registry as the following key contain ing a value named connections with a SZ data member equal to 5 1 ORBACUS for Java also accepts a URL specification as the filename 2 Use caution when defining ORBACUS properties in the registry as they become global proper ties that will be used in every ORBACUS for C application For example subtle errors can occur if the ooc iiop port property is defined on a global basis 60 ORBacus Configuring the ORB and Object Adapter 4 3 7 UNAK Software O00C Properties ooc orb trace Reg Update The ORBACUS distribution includes a utility called RegUpdate The tool first removes all sub keys defined under the specified registry key Next all values defined in an ORBA cus configuration file are transferred to the registry Synopsis RegUpdate HKEY LOCAL MACHINE HKEY CURRENT USER config file Example RegUpdate HKEY LOCAL MACHINE ob conf This command reads the properties defined in the file ob conf and writes the values under the following registry key HKEY LOCAL MACHINENSoftwareNOOCMProperties Defining Properties Properties in Java Java applications can use the standard Java mechanism for defining system properties because ORBACUS will also search the system properties during ORB initialization For example Java java util Prope
30. title font size SIZE Title font size in points heading font size SIZE Heading font size in points Options for irgen h help v version no skeletons no type codes locality contrained no virtual inheritance tie impl impl all c suffix SUFFIX h suffix SUFFIX skel suffix SUFFIX header dir DIR other header dir DIR output dir DIR file list FILE dll import DEF with interceptors args no local copy Use font NAME as the font for headings ORBacus 39 The ORBacus Code Generators 3 9 3 10 These options are the same as for the id1 command The argument to irgen is the pathname to use as the base name of the output filenames For example if the pathname you supply is output file then irgen will produce output file cpp output file h output file skel cpp and output file skel h Note that irgen will generate code for all of the type definitions contained in the Inter face Repository server See Chapter 16 for more information on the Interface Repository The IDL to C Translator and the Interface Repository The ORBACUS IDL to C and IDL to Java translators internally use the Interface Repository for generating code That is these programs have their own private Interface Repository that is fed with the specified IDL files All code is generated from that private Interface Repository It is also possible to generate C code
31. 1 Prefix refers to the value of the oragma prefix statement in an IDL file For example the statement pragma prefix ooc com defines com as the prefix The prefix is included in the Interface Repository identifiers for all types defined in the IDL file 36 ORBacus Options for hidl 3 6 Specifies a directory where jid1 will place the generated Java files Without this option the current directory is used clone Generates a clone method for struct union enum exception valuetype and abstract interface types For valuetypes only an abstract method is generated The valuetype implementer must supply an implementation for clone impl Generates example servant implementation classes For IDL interface types a class is generated in the same package as the interface classes having the same name as the inter face with the suffix _imp1 The generated class extends POA class of the interface For IDL valuetypes a class is generated in the same package as the valuetype with the suf fix ValueFactory impl You must not use no skeletons in combination with this option impl tie Similar to impl but implementation classes for interfaces implement the Operations interface to facilitate the use of TIE classes You must not use no skeletons in com bination with this option with interceptors args Generate code with support for arguments result and exception list values for intercep tor
32. 100 271 Portable Object Adapter 76 Programming Examples Event Service 190 Implementation Repository 126 Interface Repository 247 Name Service 142 270 Policies 251 Property Service 162 Time Service 176 Trading Service 210 Properties ooc bidir node 280 ooc bidir peer 280 ooc config 49 ooc event max events 183 ooc event max_retries 184 ooc event port 184 ooc event pull_interval 184 ooc event retry_multiplier 184 ooc event retry_timeout 184 ooc event trace events 184 ooc event trace lifecycle 184 ooc event typed_service 184 ooc ifr options 245 ooc ifr port 245 ooc iiop acceptor manager backlog 56 ooc iiop acceptor manager bind 57 ooc iiop acceptor manager host 57 ooc iiop acceptor manager multi profile 57 ooc iiop acceptor manager numeric 57 ooc iiop acceptor manager port 58 ooc iiop backlog 55 368 ORBacus ooc iiop bind 55 ooc iiop host 56 ooc iiop multi_profile 56 ooc iiop numeric 56 ooc iiop port 56 ooc imr dbdir 120 ooc imr trace oad 1 20 121 ooc naming callback timeout 138 ooc naming database 138 ooc naming no updates 138 ooc naming port 138 ooc naming timeout 138 ooc naming trace level 138 ooc orb client shutdown timeout 49 ooc orb client timeout 50 ooc orb conc model 50 ooc orb default init ref 50 ooc orb default wcs 50 ooc orb giop max message size 50 ooc orbid 51 ooc orb init_iiop 51 ooc orb native_cs 51 ooc orb native_wcs 51 ooc orb oa conc_model 53 ooc orb oa host 54 ooc orb oa
33. 13 Object Management Group 1998 CORBA Messaging ftp ftp omg org pub docs orbos 98 05 06 pdf Framingham MA Object Management Group Object Management Group 1998 CORBAservices Common Object Services Specification ftp www omg org pub docs formal 98 12 09 pdf Framingham MA Object Management Group Object Management Group 1999 Naming Service Specification ftp ftp omg org pub docs ptc 99 12 03 pdf Framingham MA Object Management Group Object Oriented Concepts 2000 ORBACUS http www ooc com jtc Billerica MA Object Oriented Concepts Object Oriented Concepts 2000 JTHREADS C User s Manual Billerica MA Object Oriented Concepts Object Oriented Concepts 2000 ORBACUS http www ooc com ob Billerica MA Object Oriented Concepts Schmidt D C 1995 Reactor An Object Behavioral Pattern for Concurrent Event Demultiplexing and Event Handler Dispatching In Pattern Languages of Program Design ed James O Coplien and Douglas C Schmidt Reading MA Addison Wesley 364 ORBacus A Applet 104 B Basic Object Adapter 76 Bindings 140 BOA 76 Boot Manager 106 C Callbacks 68 Code Generators 31 Command line Options 58 Concurrency Models Blocking 256 Reactive 257 Thread Pool 262 Threaded 259 Thread per Client 260 Thread per Request 261 Configuration File 59 Currently Executing Request 95 D demo program 17 Documenting IDL Files 41 E Event Channel 187 Event Consum
34. C and Java persistent Hello World servers may be found in the demo hello imr directories of the ORBACUS for C and Java distributions 126 ORBacus Programming Example AND GOB WN HB ki WHE Q 12 16 The Hello World server presented in Chapter 2 uses the Root POA to activate its Hello servant Since the Root POA uses the TRANSIENT life span policy the object reference it creates will not be persistent Hence the Hello World server must be modified so that the Hello servant is activated using a child POA with the PERSISTENT life span policy The new child POA will also use the USER object identification policy so that the mkref utility may be used Further the Hello servant is no longer activated under the Root POA so it becomes necessary for it to override the _default_POA method The modified servant s class declaration is shown below C include Hello skel h class Hello impl public POA Hello public PortableServer RefCountServantBase PortableServer POA var poa public Hello impl PortableServer POA ptr virtual void say hello throw CORBA SystemException virtual PortableServer POA ptr default POA Private member to store the servant s default A constructor must be defined to allow the assignment of the servant s default POA Declaration of the _default_POA method The remainder o
35. FileMenu 132 The Edit Menu 133 The View Menu 133 The Toolbar and the Popup Menu 134 ORBacus Names 135 Synopsis 135 Usage 135 6 ORBacus CHAPTER 10 CHAPTER 11 Windows NT Native Service 136 Configuration Properties 138 Persistence 138 CLASSPATH Requirements 139 Connecting to the Service 139 Using the Naming Service with the IMR 139 Naming Service Concepts 140 Bindings 140 Name Resolution 141 Programming Example 142 Initialization 142 Binding 144 Exceptions 146 The Event Loop 147 Releasing Resources 148 ORBacus Names Console 149 Synopsis 149 Usage 149 CLASSPATH Requirements 150 Naming Service Lookup 150 The Menus 150 The File Menu 150 The Edit Menu 152 The View Menu 153 The Tools Menu 154 The Toolbar 155 The Popup Menu 156 ORBacus Properties 157 Synopsis 157 Usage 157 Configuration Properties 158 CLASSPATH Requirements 158 Connecting to the Service 158 Using the Property Service with the IMR 159 ORBacus CHAPTER 12 CHAPTER 13 Property Service Concepts 159 Creating Properties 159 Querying for Properties 160 Deleting Properties 161 Programming Example 162 ORBacus Time 165 Compliance Statement 165 Criteria to Be Followed for Secure Time 165 Proxies and Time Uncertainty 166 Synopsis 166 Usage 166 Configuration Properties 167 CLASSPATH Requirements 167 Time Service Concepts 167 Representation of Time 167 Basic Types 168 Enumerations 169 Exceptions 170 The Un
36. For more information on the Event Service and for the complete definitions of the IDL interfaces please refer to the official Event Service specification ORBacus 193 ORBacus Events 194 ORBacus ow a ORBacus Trader The Trading Service and the Naming Service are similar in that they both provide facili ties for object location and discovery As discussed in Chapter 9 an object in the Naming Service is located by name In the Trading Service on the other hand an object does not have a name Rather a server advertises an object in the Trading Service based on the kind of service provided by the object A client locates objects of interest by asking the Trading Service to find all objects that provide a particular service The client can further restrict the search to select only those objects with particular characteristics ORBACUS Trader is compliant with 9 and conforms to the specification s definition of a full service trader meaning that the service supports all of the functionality described in the specification This chapter does not provide a complete description of the service It only provides an overview suitable to get you started For more information please refer to the specifica tion ORBacus 195 ORBacus Trader 14 1 14 1 1 14 1 2 Synopsis Usage com ooc CosTrading Server help v version i ior I d dbdir DIR t timeout MINS h 3 peip
37. IIOP plug in a OCI TransportInfo must be narrow d to OCI 1IOP TransportInfo 19 2 7 Class Diagram Figure 19 1 shows the classes and interfaces of the OCI except for the Buffer and Info ORB o 1 OA 1 Connector Acceptor Factory Factory Registry Registry n n Connector C i n A Acceptor Fac tory onnector ranspori cceptor Factory creates creates creates creates poena Protocol Protocol Protocol Specific Specific Specific xi Connector Transport Acceptor cceptor Factory Factory Figure 19 1 OCI Class Diagram interfaces ORBACUS provides abstract base classes for the interfaces Connector Factory Connector Transport Acceptor Factory and Acceptor The protocol plug in must inherit from these classes in order to provide concrete implementations for a specific protocol ORBACUS also provides concrete classes for the interfaces Buffer Connector Factory Registry and Acceptor Factory Registry Instances of Connector Factory Registry and Acceptor Factory Registry can be obtained via the ORB operation resolve initial references using the identifiers OCIConFactoryRegistry and OCIAccFactoryRegistry respectively Concrete implementations of Connector Factory ORBacus 269 The Open Communications Interfa
38. In case of an error receive detect boolean receive detect in Buffer buf in boolean block Similar to receive but it signals a connection loss by returning FALSE instead of raising COMM FAILURE Parameters buf The buffer to fill block If set to TRUE the operation blocks until the buffer is full If set to FALSI ation fills as much of the buffer as possible without blocking ORBacus 327 Open Communications Interface Reference Returns FALSE if a connection loss is detected TRUE otherwise Raises COMM FAILURE In case of an error receive timeout void receive timeout in Buffer buf in unsigned long timeout Similar to receive but it is possible to specify a timeout On return the caller can test whether there was a timeout by checking if the buffer has been filled completely Parameters buf The buffer to fill timeout The timeout value in milliseconds A zero timeout is equivalent to calling receive buf FALSE Raises COMM FAILURE In case of an error send void send in Buffer buf in boolean block Sends a buffer s contents Parameters buf The buffer to send block Ifsetto TRUE the operation blocks until the buffer has completely been sent If set to FALSE the operation sends as much of the buffer s data as possible without blocking Raises COMM FAILURE In case of an error send detect boole
39. Interface OCI ConFactoryRegistry ConFactorySeq get factories Returns all registered factories Returns The Connector factories ORBacus 355 Open Communications Interface Reference E 18 Interface OCI Current interface Current inherits from CORBA Current Interface to access Transport and Acceptor information objects related to the current request Operations get oci transport info TransportInfo get oci transport info This method returns the Transport information object for the Transport used to invoke the cur rent request get oci acceptor info AcceptorInfo get oci acceptor info This method returns the Acceptor information object for the Acceptor which created the Trans port used to invoke the current request 356 ORBacus Module OCI IIOP E 19 Module This module contains interfaces to support the IIOP OCI plug in Aliases InetAddr typedef octet InetAddr 4 Alias for an array of four octets This alias will be used for address information from the various information classes The address will always be in network byte order Constants TAG IIOP const ProtocollId TAG IIOP 1330577409 The protocol id for the OOC IIOP plug in ORBacus 357 Open Communications Interface Reference E 20 Interface OCI IIOP Transportlnfo interface TransportInfo inherits from OCI TransportInfo Information on an IIOP OCI Transport object See Also
40. OB BootManagerHelper narrow bmgrObj byte objId MyObjectId getBytes bootManager add binding objId obj Get a reference to the Boot Manager object by invoking resolve initial references see 6 5 1 on page 108 on the ORB Create the object id Create the new binding corbaname URLs A corbaname URL provides additional flexibility by incorporating use of the Naming Service in the string to object operation The corbaname URL extends the capa bilities of the corbaloc URL to allow the object key to identify a binding in a Nam ing Service For example consider this URL corbaname ns1 5001 NameService ctx MyObject When the ORB interprets this URL it attempts to resolve a naming context object located at host ns1 on port 5001 and having the object key NameService Once the naming con text has been resolved the ORB attempts to lookup the binding named MyOb ject in the naming context ctx If successful the result of string to object is the object refer ence associated with the binding file URLs A ile URL provides a convenient way to obtain object references using an IOR or URL reference that is in a file The format of a file URL is file absolute file name Using the file URL and given that the file object ref is located in the tmp direc tory the client side example of 6 3 1 on page 101 may be simplified as follows C CORBA ORB var orb Get a reference to the ORB somehow CORB
41. ORBACUS that are related to transparent re sending of failed messages A level of 1 or higher produces information about re sending of messages and a level of 2 or higher also produces information about use of individual IOR profiles The default level is 0 which produces no output OA Properties Configuring an object adapter is achieved by setting properties on POA Managers These properties are grouped into two categories global properties and properties specific to a particular POA Manager Global properties have the prefix ooc orb oa while properties specific to a particular POA Manager have the prefix ooc orb poamanager where name is the name of the POA Manager see foo Unless otherwise noted a POA Manager will search for configuration properties using the following algorithm First use properties defined specifically for that POA Manager e Next use global properties e Finally use default settings See Using POA Managers on page 65 for more information on POA Managers ooc orb oa conc model Value reactive threaded thread per client thread per request thread pool Selects the server side concurrency model The reactive concurrency model is not available in ORBACUS for Java The default value is react ive for C applications and threaded for Java applications See Chapter 18 for more information on concurrency models If this property is set to thread pool then the property ooc orb oa thread pool
42. Parameters timeout The timeout value in milliseconds Returns The new Transport object Raises TRANSIENT If the server cannot be contacted COMM FAILURE In case of other errors get usable profiles ProfileInfoSeq get usable profiles in IOR ref in CORBA PolicyList policies From the given IOR and list of policies get basic information about all profiles for which this Connector can be used Parameters ref The IOR from which the profiles are taken policies The policies that must be satisfied Returns The sequence of basic information about profiles If this sequence is empty there is no pro file in the IOR that matches this Connector and the list of policies equal boolean equal in Connector con Find out whether this Connector is equal to another Connector Two Connectors are considered equal if they are interchangeable Parameters con The connector to compare with Returns TRUE if the Connectors are equal FALSE otherwise 334 ORBacus Interface OCI Connector get info ConnectorInfo get info Returns the information object associated with the Connector Returns The Connector information object ORBacus 335 Open Communications Interface Reference E 7 Interface OCI ConnectorInfo interface ConnectorInfo Information on a OCI Connector object Objects of this type must be narrowed to a Connector information object for a concrete protocol impl
43. Service Type 224 Managing Offers 224 Adding a New Offer 224 Modifying an Offer 226 Withdrawing Offers 227 Managing Proxy Offers 229 Adding a New Proxy Offer 229 Withdrawing Proxy Offers 231 Managing Links 232 Adding a New Link 232 Modifying a Link 232 Removing a Link 233 Configuring the Trader Attributes 233 Support Attributes 234 Import Attributes 235 Link Attributes 237 Admin Attributes 237 Executing Queries 238 Connecting toa New Trader 240 The Interface Repository 243 Synopsis 243 Usage 243 Windows NT Native Service 244 Configuration Properties 245 Connecting to the Interface Repository 246 Configuration Issues 246 Interface Repository Utilities 246 irfeed 246 irdel 247 Programming Example 247 CHAPTER 17 CHAPTER 18 CHAPTER 19 Using Policies 249 Overview 249 Supported Policies 250 Programming Examples 251 Connection Reuse Policy 251 Timeout Policy 253 Concurrency Models 255 Introduction 255 What is a Concurrency Model 255 Why different Concurrency Models 255 ORBacus Concurrency Models Overview 256 Single Threaded Concurrency Models 256 Blocking Clients 256 Reactive Clients and Servers 257 Multi Threaded Concurrency Models 259 Threaded Clients and Servers 259 Thread per Client Server 260 Thread per Request Server 261 Thread Pool Server 262 Selecting Concurrency Models 263 The Reactor 263 What is a Reactor 263 Available Reactors 263 The Open Communications Interface 267 Wha
44. Service administrator can remove individual offers one at a time using the unique identifier associated with each offer Exporters that will eventually need to clean up obso lete service offers are responsible for remembering the identifiers assigned to their service offers ORBacus 205 ORBacus Trader 14 4 4 Multiple service offers can be removed using an operation that accepts a service type and a constraint expression Every offer of the service type that matches the constraint expres sion is withdrawn Offers that match the constraint and have a service type that is a sub type of the specified service type are removed as well A simple way of removing all of the offers for a service type is to use TRUE for the constraint expression Dynamic Properties In many situations an exporter will need to periodically update the properties of a service offer to reflect changing conditions The interest rate on a loan is an example of a property that might fluctuate frequently throughout the day The requirement for an exporter to keep all of its offers up to date may become overly burdensome so the Trading Service supports a feature called dynamic properties that can simplify these activities Rather than supplying a static value for a property an exporter can substitute a special data structure containing an object reference implementing the CosTradingDynamic DPEval interface When a trader requires the value of a dynamic prope
45. Window toggle button If the console is connected to ORBACUS Names as described in Chapter 9 the console can display timestamp information for each binding by making use of proprietary features of ORBACUS Names This information is shown in the binding table if the Details display mode instead of the Simple List mode is active Usually the console sorts the items in the binding table in ascending alphabetical order with naming contexts being listed at the top You can change this order with the options available in the Sort menu Bindings can be sorted by their ID or Kind fields If the extended attributes are displayed items can also be sorted by date and time You can reverse the sort order by selecting the current sorting mode a second time in the View menu or by clicking on the table header cells In this case the display switches from ascending to descending order and vice versa If the contents of a naming context have been changed by a third party and you want to update the information displayed in the console window selecting Refresh updates the dis play If the console is connected to ORBACUS Names a refresh is done automatically each time a change occurs The Tools Menu The operations available in this menu are meant as tools for your everyday work Ping Checks the accessibility of the selected items Clean up Unbinds inaccessible objects from the current context Sometimes it is useful to check if an object bound to a n
46. adopted 110 ORBacus Initial Services 6 5 3 void register initial reference in ObjectId id in Object obj raises InvalidName For example in C CORBA O0bject var obj Get a name service reference somehow orb gt register initial reference NameService obj Get a reference to the naming service for example by reading a stringified object refer ence and converting it with string to object or by any other means Add the reference to the ORB s list of initial references Or in Java Java org omg CORBA Object obj Get a name service reference somehow orb register initial reference NameService obj This is the same as the C version above The Initial Service Locator In addition to providing the ORBACUS Implementation Repository the imr server see Chapter 7 acts as an initial service locator That is assuming that the imr server is prop erly configured the name of the host running the imr server is the only information needed to find a particular initial service To locate an initial service with name oo the imr server must first be configured with the initial reference of this service This may be done with the ORBInitRef command line option or ooc orb service configuration property see Chapter 4 for details Next the client that wishes to connect to oo must be configured with the default initial refer ence specify
47. and the Interface Repository on page 40 for an example Options for idl h help Show a short help message 32 ORBacus Options for idl v version Show the ORBACUS version number e cpp NAME Use NAME as the preprocessor program d debug Print diagnostic messages This option is for ORBACUS internal debugging purposes only Defines NAME as 1 This option is directly passed to the preprocessor Defines NAME as DEF This option is directly passed to the preprocessor Removes any definition for NAME This option is directly passed to the preprocessor IDIR Adds DIR to the include file search path This option is directly passed to the preprocessor i Runs the source files through the preprocessor without generating code no skeletons Don t generate skeleton classes no type codes Don t generate type codes and insertion and extraction functions for the Any type Use of this option will cause the translator to generate more compact code locality constrained Generate locality constrained objects no virtual inheritance Don t use virtual C inheritance If you use this option you cannot use multiple interface inheritance in your IDL code and you also cannot use multiple C inheritance to imple ment your servant classes tie ORBacus 33 The ORBacus Code Generators Generate tie classes for delegate
48. are cre ated under servers The Modify menu item applies to all objects However servers are currently the only objects that have attributes that can be modified To delete an object the Delete menu item is used This operation recursively deletes all children under the selected item The Cut and Paste menu items only apply to servers and are used to move servers to differ ent hosts Note that OAD for the desired host must be selected when using Paste In very rare circumstances it s possible for the IMR and OAD to become confused as to the state of a server In this case it might be necessary to manually reset the state of the server using the Reset menu item It also necessary to use this item if the server continually crashes on startup and has reached the maximum number of retries specified by its max spawns attribute This prevents the OAD from continually starting the same broken server The View Menu The View menu contains the Refresh menu item The Refresh menu item is used to update the console when the contents of the IMR have been changed from outside the console Note that clicking or expanding an item will refresh the item ORBacus 133 The Implementation Repository Console 8 3 The Toolbar and the Popup Menu In addition to the operations offered by the menu bar some frequently needed functions are available by icons located in the toolbar The toolbar contains all of the items of the Edit menu and the Re
49. based interface implementations Tie classes depend on the corresponding skeleton classes i e you must not use no skeletons in combina tion with t ie fwd Generate separate header files for forward declarations impl Generate example servant implementation classes An input file Foo id1 will generate the files Foo impl h and Foo impl cpp These files will not be overwritten therefore you must first remove the existing files before new ones can be generated You must not use no skeletons in combination with this option impl all Similar to impl but function signatures are generated for all inherited operations and attributes You must not use no skeletons in combination with this option c suffix SUFFIX Use SUFFIX as the suffix for source files The default value is cpp h suffix SUFFIX Use SUFFIX as the suffix for header files The default value is h skel suffix SUFFIX Use SUFFIX as the suffix for skeleton files The default value is _skel all Generate code for included files instead of inserting include statements See Include Statements on page 40 no relative When generating code idl assumes that the same I options that are used with 141 are also going to be used with the C compiler Therefore id1 will try to make all include statements relative to the directories specified with 1 The option no relative suppresses this behavior in which case id1 will not make
50. be used in a servant class method implementation C CORBA Object_var baseCurrent orb gt resolve initial references OCICurrent OCI Current var current OCI Current narrow baseCurrent OCI TransportInfo var info current gt get oci transport info OCI IIOP TransportInfo var iiopInfo OCI IIOP TransportInfo narrow info 272 ORBacus OCI for the Application Programmer g 10 if CORBA is_nil iiopInfo 11 12 OCI IIOP InetAddr remoteAddr iiopInfo gt remote addr 13 CORBA UShort remotePort iiopInfo remote port 14 15 cout Call from 16 remoteAddr 0 remoteAddr 1 17 remoteAddr 2 remoteAddr 3 18 lt lt lt lt remotePort lt lt endl 19 2 4 The current object is requested and narrow d to the correct OCI Current type 6 8 The info object for the transport is requested and narrow d to an transport info object 10 The remainder of the example code is only executed if this was really an transport info object 12 18 The address and the port of the client calling this operation are obtained and printed on standard output The Java version looks as follows 1 Java 2 org omg CORBA Object baseCurrent 3 orb resolve_initial_references OCICurrent 4 com ooc OCI Current current 5 com ooc OCI CurrentHelper narrow baseCurrent 6 7
51. built in ORB Therefore in order to write applets using ORBACUS 4 you will need to disable or replace Netscape s built in ORB The Netscape ORB classes are contained in the file iiop10 jar located in the java classes subdirectory of the Netscape installation To disable the ORB rename this file e g to 1iop10 old jar With the ORB disabled applets can download the ORBACUS classes along with the applet 72 ORBacus Applets 4 7 2 4 7 3 4 7 4 To replace the built in ORB with ORBACUS rename the iiop10 jar file as described above and copy the OB jar file to the same directory giving it the name iiop10 jar For example cd lt netscape home gt java classes mv iiopl0 jar iiop10 old jar cp orbacus home lib OB jar 10 Initializing the Java ORB for Applets A different overloading of ORB init is provided for use by applets Java import org omg CORBA public void init ORB orb ORB init this new java util Properties Adding ORBacus Applets to Web Pages Like any other applet ORBACUS applets can be added to HTML pages with the APPLET tag APPLET CODE Client class ARCHIVE OB jar WIDTH 500 HEIGHT 300 gt APPLET It is necessary to tell the Web browser where to find the ORBACUS Java classes This is best done with the ARCHIVE attribute as shown above An alternative is to use the CODEBASE attribute and to extract the OB j
52. calls to get number of properties and get all properties Deleting Properties If a property has become obsolete it can be deleted from the PropertySet with delete property ORBacus 161 ORBacus Properties 11 5 AN DGB WH HB N N NH NH NH DAN Q Q IDL void delete property in PropertyName property name raises PropertyNotFound InvalidProperty FixedProperty As you might have guessed by this operation s signature there are properties that cannot be deleted at all This kind of property is called a FixedProperty The Property Service defines several other special property types such as read only properties Please refer to the OMG Property Service 9 specification for details Programming Example The Property Service test suite which is part of the ORBACUS distribution provides a good example of how to create properties and query for their values The code below is based on excerpts of this test suite which is located in the directory property test We will concentrate on an example in Java here As with the previous examples the Java code is very similar to what is necessary in C The example demonstrates how to create prop erties and how to get a list of all the properties defined within a PropertySet Java org omg CORBA Object obj null try obj orb resolve_initial_references Property
53. com ooc OCI TransportInfo info current get oci transport info 8 com ooc OCI IIOP TransportInfo iiopInfo 9 com ooc OCI IIOP TransportInfoHelper narrow baseInfo 10 11 if iiopInfo null i2 13 int remoteAddr Converter addr iiopInfo remote addr 14 int remotePort Converter port iiopInfo remote port 15 16 System out println Call from Ly remoteAddr 0 18 remoteAddr 1 19 remoteAddr 2 ORBacus 273 The Open Communications Interface 20 21 2 11 13 14 16 20 19 4 4 AN Dost WN RR Q 17 UNAK remoteAddr 3 remotePort This code is equivalent to the C version Again the port number must be converted from short to int This is also equivalent to the C version Determining a Server s IP Address To determine the server s IP address and port that an object will attempt to connect to the following code can be used C CORBA O0bject var obj Get an object reference somehow OCI ConnectorInfo var info obj gt get oci connector info OCI IIOP ConnectorInfo var iiopInfo OCI IIOP ConnectorInfo narrow info if CORBA is nil iiopInfo OCI IIOP InetAddr var remoteAddr iiopInfo gt remoteAddr CORBA UShort remotePort iiopInfo gt remote port cout Will connect to remoteAddr 0 remoteAddr
54. components Create a UTC time from an interval similar to TIO time Return the string representation of the UTC time See description of C versions above Various relational and arithmetic operators Programming Example This section presents a simple program that uses ORBACUS Time to implement a stop watch The program is presented in C but the Java implementation is similar The pro gram is split into three functions main run and stopwatch main only cre ates the ORB initializes the Time Service and calls run C include lt OB CORBA h gt include lt OB TimeService h gt include lt OB TimeHelper h gt include lt iostream gt using namespace std int run CORBA ORB ptr int stopwatch CosTime TimeService ptr int main int argc char argv int status EXIT_SUCCESS CORBA ORB_ var orb try orb CORBA ORB_init argc argv OB TimeServicelInit orb argc argv status run orb catch const CORBA Exception amp ex cerr lt lt ex lt lt endl 176 ORBacus Programming Example 24 28 29 30 31 32 33 34 35 36 34 38 39 40 41 42 43 44 20 14 20 21 22 30 41 ROW DN DA GAA E Ra status EXIT FAILURE if CORBA is_nil orb try orb gt destroy catch const CORBA Exception amp ex cerr lt lt ex lt lt endl status EXIT_FAILUR
55. delegation based implementation For our interface I it is therefore necessary to implement all operations in a single servant class I impl regardless of whether those operations are defined in I or in an interface from which is derived Java public class I impl extends IPOA public void op a public void op b public void op i The servant class I implis defined which implements op i as well as the inherited operations op a and op b Implementing Servants using Delegation Sometimes it is not desirable to use an inheritance based approach for implementing an interface This is especially true if the use of inheritance would result in overly complex inheritance hierarchies for example because of use of an existing class library that requires extensive use of inheritance Therefore another alternative is available for implementing servants which does not use inheritance A special class known as a tie class can be used to delegate the implementation of an interface to another class Delegation using C The ORBACUS IDL to C translator can automatically generate tie class for an inter face in the form of a template class A tie template class is derived from the corresponding skeleton class and has the same name as the skeleton with the suffix _t ie appended 1 Note that tie classes are rarely necessary Not only is the inheritance implementation less com plex but it also avoids a number
56. determines how many threads are in the pool This property is also used to determine the default value of the communications concur rency model for POA Managers see ooc orb poamanager manager conc model below If the value of ooc orb oa conc model is reactive the default value for the ORBacus 53 ORB and Object Adapter Initialization communications concurrency model is react ive otherwise the default value is threaded ooc orb oa host Deprecated See ooc iiop host ooc orb oa numeric Deprecated See ooc iiop numeric ooc orb oa port Deprecated See ooc iiop port ooc orb oa thread pool Value n gt 0 Determines the number of threads to reserve for servicing incoming requests The default value is 10 This property is only effective when the ooc orb oa conc model property has the value thread pool ooc orb oa version Value 1 0 1 1 or 1 2 Specifies the GIOP version to be used in object references The default value is 1 2 This option is useful for backward compatibility with older ORBs that reject object references using a newer version of the protocol ooc orb poamanager manager conc model Value reactive threaded Specifies the communications concurrency model used by the POA Manager with name manager The default value is determined by ooc orb oa conc model See Chapter 18 for more information on concurrency models ooc orb poamanager manager host Deprecated See ooc iiop acceptor mana
57. entries in the binding table The current table selection can be inverted using Invert Selection The View Menu The operations in this menu control the appearance of the console window as well as the presentation of the Naming Service data Toolbar Toggles the toolbar visibility Status Bar Toggles the statusbar visibility Error Window Toggles the error message window visibility Simple List Displays minimum object information Details Displays additional object information Sort Sets sorting mode for object list Refresh Updates the complete window contents A toolbar that gives access to frequently needed operations is normally present below the menu If you don t have a need for this toolbar or if you just want to save space on the screen you can switch it off with the Toolbar toggle button The same applies to the status bar where information about the currently selected item is displayed The status bar dis plays an object s repository ID the host where this object is located and the port it is bound to If an item with a nil object reference is selected or if multiple items are selected the status bar is empty ORBacus 153 ORBacus Names Console 10 2 4 If an error occurs while editing bindings the console automatically displays a new win dow with information about what went wrong Usually this information consists of excep tion data The visibility of this window can be explicitly controlled with the Error
58. filesystem A file in a filesystem is analogous to an object binding in the Naming Service The equivalent for a folder in a filesystem is a naming context in Naming Service terms The pieces of information stored in a Naming Service are called bindings A binding consists of an object s name and its type as defined in the CosNaming module IDL typedef string Istring struct NameComponent Istring id Istring kind typedef sequence lt NameComponent gt Name enum BindingType nobject ncontext struct Binding Name binding name BindingType binding type As you see each name consists of or more components like a file is fully speci fied by its path in a filesystem Each name component consists of two strings id and kind which could be likened to a file s name and its extension Generally the filesystem analogy works very well when describing the Naming Service structures A new Naming Service entry i e a binding is created with the following operations IDL void bind in Name n in Object obj raises NotFound CannotProceed InvalidName AlreadyBound 140 ORBacus Naming Service Concepts 9 4 2 void bind context in Name n in NamingContext nc raises NotFound CannotProceed InvalidName AlreadyBound amingContext new context NamingContext bind new context Name n raises NotFound CannotProceed InvalidName AlreadyBound bind register
59. first called for the Root POA However an applica tion can also manually create the Root POA Manager if a special configuration is desired This capability is useful in that it allows the application to use the Root POA with custom ized endpoints Note that an application must create the Root POA Manager before resolving the Root POA Otherwise the ORB will have already created the Root POA Manager and the application will receive an exception when it attempts to create the Root POA Manager When using the POA Manager Factory the name of the Root POA Manager is always RootPOAManager ORBacus 67 ORB and Object Adapter Initialization 4 4 3 4 4 4 4 4 5 AN O Ci X WH NH RRR Daw S Dispatching Requests As explained in 4 a POA Manager is initially in the holding state where incoming requests on the POA Manager s endpoints are queued To dispatch requests the POA Manager must be activated using the activate operation Callbacks In mixed client server applications in which callbacks occur it is important to remember that callbacks will not be dispatched until the POA Manager has been activated If the POA Manager has not been activated the application will likely hang In general applica tions should activate the POA Manager prior to making any request that might result in a callback Advanced Configuration Example The create poa manager operation demonstrated
60. from a global Interface Repository First the com mand irserv must be used to start the Interface Repository Then the Interface Reposi tory must be fed with the IDL code using the command irfeed Finally the irgen command can be used to generate the C code For example irserv ior IntRep ref amp irfeed ORBrepository cat IntRep ref file idl irgen ORBrepository cat IntRep ref file The IDL to C translator idl performs all these steps at once in a single process with a private Interface Repository Thus you only have to run a single command idl file idl See Chapter 16 for more information on the Interface Repository Include Statements If you use the include statement in your IDL code the ORBACUS IDL to C transla tor idl does not create code for included IDL files Instead the translator inserts the appropriate include statements in the generated header files Please note that there are several restrictions on where to place the include statements in your IDL files for this feature to work properly e finclude may only appear at the beginning of your IDL files All include statements must be placed before the rest of your IDL code 40 ORBacus Documenting IDL Files 3 11 e Type definitions such as interface or struct definitions may not be split among several IDL files In other words no include statement may appear within such definitions If you don t want these restrictio
61. further information on configur ing a service with the IMR refer to Getting Started with the Implementation Repository on page 124 ORBacus 197 ORBacus Trader 14 4 Trading Service Concepts 14 4 1 Basic Concepts Roles The client of a trading service also known as a trader plays one of two roles at any partic ular point in time If the client is advertising a service it is playing the role of an exporter If the client is searching for a service it is playing the role of an importer Service Types A service type is used to define a particular type of service and is similar to a database schema or a class in NDS All of the service type definitions are stored in a service type repository managed by the Trading Service An exporter that advertises a service must associate the service with a service type A service type consists of the following information e lt A service type name uniquely identifies the service type e Aninterface type defines the IDL interface to which an advertised object of this type must conform e Acollection of property types defines additional attributes of the service offer Service Type Names Each service type in the repository has a unique name Although the specification is not completely clear about the format of these names ORBACUS Trader supports two formats Scoped names These names have formats such as One Two Other supported variations include Thre
62. i e without blocking the user thread execution The separate receiver thread allows messages to be received and buffered for later retrieval by the user thread with DII operations such as get response or poll response Like a threaded client a threaded server uses separate threads for receiving requests from clients and sending replies Additionally there is a separate thread dedicated to accepting incoming connection requests so that a threaded server can serve more than one client at a time ORBACUS s threaded server concurrency model allows only one active thread in the user code This means that even though many requests can be received simultaneously the execution of these requests is serialized This is shown in Figure 18 4 For simplicity the dispatch arrows and the corresponding return arrows are omitted in this and all follow ing diagrams In the example the threaded server has two clients connected to it and thus ORBacus 259 Concurrency Models 18 3 2 D amp I 90 Mex E Client A Threaded Server Client B Figure 18 4 Threaded Server two receiver threads sender threads not shown First A calls on the server If before returns B tries to call another operation g this request is delayed until returns The same is true for A s call to n which must wait until g returns Allowing only one active thread
63. in section 4 4 1 is a simple way to create a POA Manager with a single endpoint In some architectures however it may be more appropriate to configure a POA Manager with multiple endpoints Using the create poa manager with config operation the application can instruct the POA Manager Factory to create a POA Manager with a specific endpoint configura tion In terms of the ORBACUS Open Communications Interface OCI the application is configuring the POA Manager s acceptors see Chapter 19 for more information on the OCI The example below illustrates how to configure the Root POA Manager with two acceptors C include OB CORBA h include OB OCI IIOP h OBPortableServer POAManagerFactory var factory resolve OBPortableServer POAManagerFactory AcceptorConfigSeq config config length 2 config 0 id OCI IIOP TAG IIOP config 0 params length 1 config 0 params 0 name CORBA string dup port config 0 params 0 value lt lt CORBA UShort 3000 config 1 id OCI IIOP TAG IIOP config 1 params length 1 config 1 params 0 name CORBA string dup port config 1 params 0 value lt lt CORBA UShort 3001 PortableServer POAManager var manager 68 ORBacus Using POA Managers L4 18 19 20 26 18 19 20 Fa ba Fa ka ka At WHE DH AND GOS factory gt create poa
64. information without explicitly knowing about each other Often a server isn t even aware of the nature and number of clients that are inter ested in the data the server has to offer A special mechanism is required that provides decoupled data transfer between servers and clients This issue is addressed by the CORBA Event Service ORBACUS Events is compliant with 9 This chapter does not provide a complete descrip tion of the service It only provides an overview suitable to get you started For more information please refer to the specification Synopsis Usage ORBACUS includes functionally equivalent implementations of the Event Service in C and Java C eventserv E help v version i ior t typed service untyped service ORBacus 181 ORBacus Events Java com ooc CosEvent Server eR help v version i iof typed service u untyped service Options h 7 eshte Display the command line options supported by the server 21 Display the version of the server version num Print the stringified IOR of the server to standard output et Run a typed event service typed servic u T Run an untyped event service This is the default behavior untyped servic 13 1 2 Windows NT Native Service The C version of ORBACUS Events is also available as a native Windows NT service nteventservice h help i instal
65. interface provides access to and the object ID for an executing request Note that these operations must be invoked only from within the context of an executing opera tion inside a servant otherwise they raise NoContext The Current object provides a useful way to obtain access to a servant s POA and object ID without having to store the ORBacus 95 CORBA Objects POA reference in a member variable at the cost of being accessible only from within an operation implementation You can obtain a reference to the Current object from resolve initial references In the code looks something like this C CORBA ORB var orb Get the ORB somehow CORBA Object_var obj orb gt resolve initial references POACurrent PortableServer Current var current PortableServer Current narrow obj if CORBA is nil current Got Current object OK You can keep the reference to the Current object in a variable and use it from within any executing operation in a servant There is no need to refresh the Current reference for the current operation not even for threaded servers The ORB takes care of ensuring that operation invocations on the Current object return the correct data In Java the code to obtain the Current reference looks like this Java org omg CORBA ORB orb Get the ORB somehow org omg CORBA Object obj orb resolve initial references POACurrent org omg PortableServer Cu
66. is defined The createProduct operation returns the object ref erence of a new Product Factory Objects using C First we ll implement the Product interface C class Product impl public virtual POA Product public virtual PortableServer RefCountServantBase public virtual void destroy throw CORBA SystemException PortableServer POA_var poa _default_POA PortableServer ObjectId var id poa gt servant to id this poa deactivate object id The servant class Product impl is defined as an implementation of the Product inter face In addition Product impl inherits from Re CountServantBase which makes the servant reference counted ORBacus 91 CORBA Objects MND GSB NR El Q 11 14 The destroy operation deactivates the servant with the POA As aresult the POA will release all references it maintains to the servant Since there are no other references to the servant left the servant s reference count will drop to zero and thus the servant is destroyed Next we ll implement the factory C class Factory impl public virtual Factory public virtual Product_ptr createProduct throw CORBA SystemException PortableServer ServantBase_var result new Product impl orb PortableServer POA var poa Get servant s POA PortableServer ObjectId var id
67. its different components Create a UTC time from an interval similar to TIO time Return the string representation of the UTC time e toString const TimeBase UtcT amp returns the time and date toTimeString const TimeBase UtcT amp returns only the time and e toString TimeBase TimeT returns a string of the form seconds milliseconds Use CORBA string_free to free the return value Various relational and arithmetic operators Similar operations are available in Java Declarations are as follows 174 ORBacus Time Service Extensions WH NH 8 9 10 121 12 13 14 15 16 287 18 D 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 10 22 13 14 15 Java package com ooc CosTime import org omg CORBA import org omg TimeBase public class TimeHelper puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi puoi public public public lig lic lic lic lig lic lic Lae lic lic lic lic lic lic lig lic lic lic lic lic final static long MaxTimeT OxffffffffffffffffL final static long MaxInaccuracyT OxffffffffffffL Q0 0000 0 ta ta ta ta ta ta tic tiG tic tic tic tuu static S S S S S Q0 o000000 0 ta ta ta ta ta ta ta ta ta ta ta ta Ea tic tic tic CEG tic ti
68. list of bindings ORBacus 141 ORBacus Names 9 5 9 5 1 ND GO B WwW NY IDL typedef sequence lt Binding gt BindingList void list in unsigned long how_many out BindingList bl out BindingIterator bi If the number of bindings is especially large BindingIterator interface is provided so that you don t have to query for all available bindings at once Simply get a certain number of bindings specified with how many and get the rest if any using the BindingIterator IDL interface BindingIterator boolean next_one out Binding b boolean next_n in unsigned long how_many out BindingList bl void destroy Make sure that you destroy the iterator object when it is no longer needed Programming Example ORBACUS includes simple C and Java examples that demonstrate how to use the CORBA Naming Service These examples are located in the folder naming demo We will concentrate on the Java example but the C example works similarly The example expects a Naming Service server to be already running and that the server s initial refer ence can be resolved by the ORB Because of its volume we have split the code into sev eral parts for the discussion below Initialization The first code fragment deals with initializing the ORB Java java util Properties props System getProperties props put org omg CORBA ORBClass com ooc CORBA ORB props put org omg CORBA
69. long how many out Properties nproperties void destroy 160 ORBacus Property Service Concepts 11 4 3 If you are only interested in a list of property names you can get this list by calling get all property names IDL void get_all_property_names in unsigned long how_many out PropertyNames property_names out PropertyNamesIterator rest As with get a11 propertiesa list of names as well as an iterator is returned This iter ator implements the PropertyNamesIterator interface IDL interface PropertyNamesIterator void reset boolean next one out PropertyName property name boolean next n in unsigned long how many out PropertyNames property names void destroy The iterators should always be destroyed when they are no longer needed Sometimes it is useful to know of how many properties PropertySet consists of This information is provided by get number of properties IDL unsigned long get number of properties Note that you have to be careful if you intend to use the return value of get number of properties as the input value for the how many parameter of get all properties in order to get a complete property list You always have to check the PropertiesIterator for properties that were not returned as part of the Properties sequence returned by get a1l properties otherwise you might miss a property that was defined by another process between your
70. name ORBnaming ior ooc orb service NameService ior ORBreactive ooc orb conc model reactive ORBrepository ior ooc orb service InterfaceRepository ior ORBserver name string GOC OE De server_name string ORBservice name ior ooc orb service name ior ORBthreaded ooc orb conc model threaded ORBtrace connections level ooc orb trace connections level 4 3 5 ORBtrace retry level ooc orb trace retry level Table 4 1 Command line Options A few additional command line options are supported that do not have equivalent proper ties These options are described in Table 4 2 Option Description ORBconfig filename Causes the ORB to load the configuration file specified by filename ORBversion Causes the ORB to print its version to standard output Table 4 2 Additional Command line Options Using a Configuration File A convenient way to define a group of properties is to use a configuration file A sample configuration file is shown below Concurrency models ooc orb conc_model threaded ooc orb oa conc_model thread_pool ooc orb oa thread_pool 5 Initial services ooc orb service NameService corbaloc myhost 5000 NameService ORBacus 59 ORB and Object Adapter Initialization 4 3 6 ooc orb service EventService corbaloc myhost 5001 DefaultEventChannel ooc orb service TradingService corbaloc myhos
71. not force a connection shutdown If the property is not set a default timeout value of two seconds is used ooc orb server timeout Value timeout gt 0 The server actively closes a connection that has been idle for timeout seconds once that connection has no more outstanding replies Note that the application must use one of the threaded server side concurrency model if connection timeouts are desired If this prop erty is set to Zero or not set at all then the server does not close idle connections ooc orb service name Value ior Adds an initial service to the ORB s internal list This list is consulted when the applica tion invokes the ORB operation resolve_initial_references name is the key that is associated with an IOR or URL For example the property ooc orb service NameService adds NameService to the list of initial services See Initial Services on page 108 for more information ooc orb trace connections Value level gt 0 Defines the output level for diagnostic messages printed by ORBACUS that are related to connection establishment and closure A level of 1 or higher produces information about 52 ORBacus Configuring the ORB and Object Adapter 4 3 2 connection events and a level of 2 or higher produces code set exchange information The default level is 0 which produces no output ooc orb trace retry Value level gt 0 Defines the output level for diagnostic messages printed by
72. numeric 54 55 ooc orb oa port 54 ooc orb oa thread pool 54 ooc orb oa version 54 ooc orb poamanager manager conc_model 54 ooc orb poamanager manager host 54 ooc orb poamanager manager numeric 55 ooc orb poamanager manager port 55 ooc orb poamanager manager version 55 ooc orb raise dii exceptions 5 ooc orb server name 52 ooc orb server shutdown timeout 52 OOC Orb server timeout 52 ORBacus 369 ooc orb service name 52 ooc orb trace connections 52 ooc orb trace retry 53 ooc property port 158 ooc time inaccuracy 167 ooc trading allow_nil_objects 196 ooc trading dbdir 196 ooc trading port 196 ooc trading timeout 196 ooc trading use_ir 196 Property Service 157 R Reactor 263 Recursion 151 RTF 41 S Security 74 Servants 76 Activation 86 C 84 Deactivation 89 Delegation 79 Inheritance 77 Java 85 T Time Service 165 Toolbar 1 34 155 Trader Console 215 Trader Federation 207 Trading Service 195 U URL 103 105 corbaloc 105 corbaname 107 file 107 370 ORBacus relfile 108 Windows NT Registry 60 Windows Reactor 265 X X11 Reactor 264 ORBacus 371
73. object Objects of this type must be narrowed to an Acceptor information object for a concrete protocol implementation for example to OCI torInfo in case the plug in implements See Also Acceptor Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute ProfileId tag The profile id tag Operations describe string describe Returns a human readable description of the transport Returns The description add accept cb void add accept AcceptCB cb IIOP Accep Add a callback that is called whenever a new connection is accepted If the callback has already been registered this method has no effect Parameters ORBacus Interface OCI AcceptorInfo cb The callback to add remove accept cb void remove accept AcceptCB cb Remove an accept callback If the callback was not registered this method has no effect Parameters cb The callback to remove ORBacus 343 Open Communications Interface Reference E ll Interface OCI AcceptCB interface AcceptCB An interface for an accept callback object See Also AcceptorInfo Operations accept_cb void accept TransportInfo transport info Called after a new connection has been accepted If the application wishes to reject the connec tion CORBA NO PERMISSION may be raised Parameters transport info The TransportInfo for the new conne
74. object reference Although narrow for CORBA objects works similar to dynamic cast for plain C objects dynamic cast must not be used for CORBA object references That s because in contrast to dynamic cast narrow might have to query the server for type information The say hel110o operation on the he11o object reference is invoked causing the server to print Hello World Finally dest roy is called on the ORB This releases the resources used by the ORB Save this code into the file Client cpp Compiling and Linking Both the client and the server must be linked with the compiled Hello cpp which usu ally has the name Hello o under Unix and Hello obj under Windows The compiled Hello skel cpp and Hello impl cpp are only needed by the server Compiling and linking is to a large degree compiler and platform dependent Many com pilers require unique options to generate correct code To build ORBACUS programs you must at least link with the ORBACUS library 1ibOB a Unix or ob 1ib Windows ORBacus 23 Getting Started 2 3 4 2 4 2 4 1 Ka SHU DAN DAA WHE Additional libraries are required on some systems such as libsocket aand libnsl a for Solaris or wsock32 1ib for Windows The ORBACUS distribution includes various README files for different platforms which give hints on the options needed for compiling and the libraries necessary for linking Please consult these README fil
75. of problems that arise with the life cycle of objects particularly in threaded servers We suggest that you use the tie approach only if you have no other option ORBacus 79 CORBA Objects 9 O X WH Rs For the interface 1 from C example above the template tie is generated and must be instantiated with a class that implements all operations of 1 By convention the name of this class should be the name of the interface with impl tie appended In contrast to the inheritance based approach it is not necessary for the class implement ing I s operations i e I_imp1_tie to be derived from a skeleton class Instead an instance of POA_I_tie delegates all operation calls to I_imp1_tie as shown in Figure 5 2 POA_I 1 7 impl Tate gates to Figure 5 2 Class Hierarchy for Delegation Implementation in C Here is our definition of I impl tie C class I impl tie public virtual void op a throw CORBA virtual void op b throw CORBA virtual void op i throw CORBA SystemException SystemException SystemException I impl tie is defined and not derived from any other class I impl tie must implement all of 1 s operations including inherited operations 1 Again you are free to choose whatever name you like This is just a recommendation 80 ORBacus Implementing Serv
76. opera tion the trader will always search its own set of service offers but may also forward the request on to any linked traders The matching local offers plus any offers found by the linked traders are returned to the importer The importer is not aware of the query propa gation but can use policies to control the trader s use of links 1 The trader will require the value of a property if the property is used in a constraint or preference expression or if the property is one of the desired properties requested by the importer ORBacus 207 ORBacus Trader A link is a unidirectional point to point connection from one trader to another The tar get trader is not notified when a new link to it is created in another trader Of course bi directional links can be established by creating a link in each trader referring to the other trader Each link has a name that is unique among all links in a trader In a trader network a particular trader can be identified by a path composed of the names of the links that must be traversed to navigate from a starting trader to the desired one In addition to the link name the other attributes of a link consist of the object reference of the target trader s CosTrading Lookup object and rules that govern query propagation for that particular link As you can imagine there are significant performance issues associated with the use of links therefore the Trading Service pro
77. policy and no response is available for a request after value millisec onds CORBA NO RESPONSE exception is raised 250 ORBacus Programming Examples 17 3 17 3 1 OB RetryPolicy This policy is used to specify whether requests should be retried after communication fail ures OB TimeoutPolicy If an object has this policy and a connection cannot be established or no response is avail able for a request after value milliseconds a CORBA NO RESPONSE exception is raised If an object has OB Connect TimeoutPolicy or RequestTimeoutPolicy set those policies have precedence Programming Examples Connection Reuse Policy The following examples demonstrate how to set OB Connect ionReusePolicy at both the ORB level and the object level in C and Java Setting a policy at the ORB level means that the ORB will honor this policy for all newly created objects Existing objects maintain their current set of policies Setting a policy at the object level overrides any ORB level policies applied to that object Setting the connection reuse policy to false at the ORB level means that the ORB will create a new connection from the client to the server for each new proxy object instead of reusing existing ones Setting the connection reuse policy to false at the object level means that the client does not reuse connections to the server only for a particular proxy object If the connect
78. sequence of Connector factories Structs ProfileInfo struct ProfileInfo ObjectKey key octet major octet minor ProfileId id unsigned long index ORBacus 321 Open Communications Interface Reference TaggedComponentSeq components Basic information about IOR profile Profiles for specific protocols contain additional data For example an IIOP profile also contains a hostname and a port number Members key The object key major The major version number of the ORB s protocol For example the major GIOP version if the underlying ORB uses GIOP minor The minor version number of the ORB s protocol For example the minor GIOP version if the underlying ORB uses GIOP id The id of the profile that contains this information index The position index of this profile in an IOR components A sequence of tagged components Param struct Param string name any value parameter represented as a name value pair Members name The parameter name value The parameter value Exceptions InvalidParam exception InvalidParam Param p string reason parameter is invalid Either the name is unrecognized the value has the wrong type or the value is invalid Members p The offending parameter 322 ORBacus Module OCI reason The reason why this parameter is invalid FactoryAlreadyExists exception FactoryAlreadyExists ProtocolI
79. server is started the ORBserver option is automatically added to the argu ment list 8 Create object references for use by the clients A server can always be used to create references for its objects However if an object is created by a POA that uses the SYSTEM ID object identification policy then the mkref utility can also be used to create a reference for the object Using the mkref utility is discussed below Assume each servers has a single primary object Server1 uses Object 1 for its Object ID and Server2 uses Ob ject2 Also each server creates a persistent POA called Main to hold its objects To create object references for these objects run the following on master mkref ORBconfig usr local ORBacus etc imr conf Serverl Objectl Main gt Objectl ref mkref ORBconfig usr local ORBacus etc imr conf Server2 Object2 Main Object2 ref The imr conf configuration file contains the properties needed by the mkref utility After all OADs servers and POAs are registered it is recommended to restart the IMR in non administrative mode This will prevent any accidental or unauthorized modifica tions Programming Example In this section we will show how to modify the C version of the Hello World server see Chapter 2 to use a persistent object reference This will allow the server to use the IMR for indirect binding Modifications to the Java version of the server are similar The code for both the
80. that you can use to move bindings between different contexts Data is transferred to the clipboard using the Cut or Copy commands Cut moves the currently selected items to the clipboard and deletes the original entries whereas Copy 152 ORBacus The Menus 10 2 3 simply creates a copy in the clipboard but keeps the source entry unchanged When new data is transferred to the clipboard the old clipboard contents are replaced Using Paste you can add the clipboard data into a naming context The clipboard contents are not changed by this operation i e you can Paste the same items several times Note that if naming contexts are transferred to the clipboard their contents are not evaluated before they are pasted It is during the Paste operation that the bindings of a context are dupli cated This means that if new bindings are added to a context after a Cut or Copy opera tion these bindings will be present after pasting this context An item registered with the Naming Service has three modifiable attributes its ID its Kind and its IOR The ID and Kind attributes can be edited by simply double clicking the ID or Kind field in the table You can also change binding attributes with the correspond ing menu operations Change ID Change Kind and Change IOR Entering a new IOR for an existing name effectively replaces an object registered with the Naming Service by another object with the same name Use Select all to select all of the
81. the cost property has a value less than 7 5 Preference The preference is an expression that indicates how the Trading Service should order the matching offers before it returns them to the importer The specification defines the fol lowing five forms of a preference expression max expression The offers are sorted in descending order based on the value of the numeric expression e min expression The offers are sorted in ascending order based on the value of the numeric expression ORBacus 203 ORBacus Trader e with expression The offers are ordered based on the boolean expression such that all offers for which the expression is TRUE are returned before those for which the expression evaluates to FALSE e random The offers are returned in a random order e first The offers are returned in the order they are discovered by the Trading Service The expression associated with max min and with is defined using the constraint lan guage If the expression cannot be evaluated for a service offer that offer is still returned because it is a matching offer However the offer is returned after all offers for which the expression could be successfully evaluated For example the preference expression min cost would order the matching offers in ascending order based on the value of the cost property Policies Policies provide a means for importers to exert additional influence over the query o
82. the servant s POA by calling default This assumes that default is correctly overridden to return the appropriate POA if the servant is not activated with the Root POA The call to servant to idon the servant s POA returns the object ID with which the servant is activated The call to deactivate object breaks the association between the CORBA object and the servant Note that deactivate object returns immediately even though the servant may still be executing requests possibly in a number of different threads Deactivation of Servants using Java Deactivation of a servant in Java is analogous to C Java org omg PortableServer POA poa impl default POA byte id poa servant to id impl poa deactivate object id Transient and Persistent Objects A POA has either the TRANSIENT or the PERSISTENT policy value A transient POA gen erates transient object references A transient object reference remains functional only for ORBacus 89 CORBA Objects 5 6 as long as its POA remains in existence Once the POA for a transient reference is destroyed the reference becomes permanently non functional and client requests on such a reference raise either OBJECT NOT EXIST or TRANSIENT depending on whether or not the server is running at the time the request is sent Transient references remain non func tional even if you restart the server and re create a transient PO
83. the trader uses a default preference expression of first 5 If you wish to specify which properties are returned in the matching offers click Desired properties to activate the text box below and enter the names of the properties in the text box Use commas to separate the property names 6 To include importer policies click the Policies button The Policies dialog box appears as shown below Next to each field label is a checkbox You must check the box for a policy for it to be included in your query Click the Defaults button to load 238 ORBacus Executing Queries the trader s default import attributes into the fields of the dialog box Click OK to accept your changes Query Policies Exact type match vi Use modifiable properties v Use dynamic properties _ Use proxy offers _ Search cardinality 1 Match cardinality 1 Return cardinality 1 Link follow policy Link hop count No bi Yes Yes x Yes v 2147483647 2147483647 2147483647 Always v 5 Defaults 7 Click Query to execute the query operation If matching offers were found the Query Results dialog box appears as shown below You can scroll through the matching ORBacus 239 ORBacus Trader Console offers with the and buttons Click Close when you have finished examining the results S Query Results x Offer 1 II of 4 Object referen
84. thus plays the client role in the link to the channel Pull suppliers on the other hand are polled by the event channel and supply an event in response if a new event is available Polling is done by the try pu11 operation if it is to be non blocking or by the blocking pull call IDL interface PullSupplier any pull raises Disconnected any try_pull out boolean has_event raises Disconnected void disconnect_pull_supplier Event Channel Policies The untyped event channel implementation included in the ORBACUS distribution features a simple event queue policy Events are buffered in the form of a queue i e a certain number of events are stored and in case of a buffer overflow the oldest events are dis carded Event Channel Factories The standard CORBA Event Service provides no support for managing the lifecycle of event channels as a result applications requiring multiple channels are often forced to run a separate instance of the Event Service for each channel To remedy this situation ORBACUS Events provides optional proprietary interfaces for event channel administra tion The OBEventChannelFactory EventChannelFactory interface describes the fac tory for untyped event channels IDL module OBEventChannelFactory typedef string Channelld typedef sequence lt ChannellId gt ChannelldSeg exception ChannelAlreadyExists 188 ORBacus Event Servic
85. to display a file 224 ORBacus Managing Offers selection dialog box If the trading service is configured to allow ni1 objects and you do not wish to specify an object reference for this offer you may leave the object reference blank 4 Enter values for the properties in the Properties table All properties have a checkbox to the left of the property name For a mandatory property the checkbox is disabled meaning that a value must be provided for this property For an optional property you can use the checkbox to indicate whether this property should be included with the offer To enter a value for a property double click on the property value field For properties with sequence types you can enter multiple values by separating them with commas Press Return when you are finished entering the value for a property 5 Click the Add button if you wish to add a property that is not defined by the service type The Add Property dialog box appears as shown below Enter a name for the property select the property s type from the drop down list and enter a value in the text box The name you use for the property must not be the same as any existing properties Click OK to add the property to the Properties table Property Lx Name Type boolean Value OK Cancel Note Once the property has been added to the Properties table you can edit it directly just as you can wi
86. unbind cName 3 nc unbind bName 4 nc unbind aName 5 nc unbind alName 6 nc unbind a2Name 7 nc unbind a3Name 8 nc unbind nc2Name 9 nc unbind nclName 10 11 catch RuntimeException ex 12 13 status 1 14 TS 16 if orb null 17 18 try 19 20 orb destroy 21 22 catch const RuntimeException ex 23 24 status 1 25 26 d 28 System exit status 2 9 bindings are unbound 16 26 destroy is called on the ORB This releases the resources used by the ORB The complete example can be found in the folder naming demo included with the ORBA CUS distribution 148 ORBacus ORBacus Names Console CHAPTER 10 ORBACUS Names includes a graphical client for administering the service called the ORBACUS Names Console The application can manage any CORBA compliant Naming Service but additional features are provided when used with ORBACUS Names 10 1 Synopsis 10 1 1 Usage com ooc CosNamingConsole Main efy e frle PILE iz ior n no updates look CLASS windows f FILE file FILE no updates motif mac h help 7535 version Read the Naming Service IOR from FILE Print the stringified IOR of the Naming Service to standard output Disables automatic updates i e callbacks that notify interested clients of changes to the naming service look CLASS Use the specified Look amp Feel class windows Use the Windows
87. 1 Programming Example A number of sample programs are included with ORBACUS Trader You can find the source code for these programs in the demo subdirectory In this section we will discuss the example application in demo printer The Print Server The source code for the print server can be found in demo printer Server java The server performs the following steps e Resolve the initial reference of the trading service e Withdraw any existing offers e Install the service type if necessary e Export new offers Resolving the Trading Service The server uses the standard operation resolve initial references to obtain the object reference of the trading service org omg CORBA Object obj orb resolve initial references TradingService The reference must then be narrowed The interface type supported by the reference is CosTrading Lookup org omg CosTrading Lookup result null result org omg CosTrading LookupHelper narrow obj Withdrawing Offers Before exporting new offers the server withdraws any existing offers static final String SERVICE TYPE Printer org omg CosTrading Register reg trader register if reg withdraw using constraint SERVICE TYPE TRUE This code demonstrates the easiest way to withdraw all offers of a given service type Invoking the withdraw using constraint operation with a constraint of TRUE matches every offer for that service type
88. 2 remoteAddr 2 remoteAddr 3 lt lt lt lt remotePort lt lt endl Get the OCI connector info and narrow to an connector info The if block is only executed if this really was an IIOP connector info The address and port are obtained and displayed on standard output The Java version looks as follows Java org omg CORBA Object obj Get an object reference somehow org omg CORBA portable ObjectImpl objImpl org omg CORBA portable ObjectImpl obj com ooc CORBA Delegate objDelegate 274 ORBacus The IIOP OCI Plug in 10 11 T2 13 14 15 16 17 18 19 20 21 22 23 24 16 23 19 5 19 5 1 com ooc CORBA Delegate objImpl get delegate com ooc OCI ConnectorInfo info objDelegate get oci connector info com ooc OCI IIOP ConnectorInfo iiopInfo com ooc OCI IIOP ConnectorInfoHelper narrow info if iiopInfo null int remoteAddr Converter addr iiopInfo remote addr int remotePort Converter port iiopInfo remote port System out println Will connect to remoteAddr 0 remoteAddr 1 remoteAddr 2 remoteAddr 3 remotePort We need to retrieve the ORBACUS specific Delegate object so that we can get the con nector info Get the OCI connector info and narrow to an IIOP connector info The if block is only entered if this really was an connector info
89. 210 ORBacus Programming Example WH NH HB NB C0 WW 0 0 0 WH WH NH es e b E b HH AN Oi X F2 DH AN O Oi X DH DN DOK OD Installing a Service To install the Printer service type the server obtains the object reference of the ServiceTypeRepository object and invokes the type operation org omg CORBA Object obj trader type repos org omg CosTradingRepos ServiceTypeRepository repos org omg CosTradingRepos ServiceTypeRepositoryHelper narrow obj PropStruct props new PropStruct 5 for int i 0 i lt props length i props i new PropStruct int n 0 org omg CORBA TypeCode stringTC orb get_primitive_tc org omg CORBA TCKind tk_string props n name bldg props n value_type stringTC props n mode PropertyMode PROP_NORMAL ntt props n name color props n value type orb get primitive tc org omg CORBA TCKind tk boolean props n mode PropertyMode PROP NORMAL ntt props n name cost per page props n value type orb get primitive tc org omg CORBA TCKind tk float props n mode PropertyMode PROP NORMAL ntt props n name ppm props n value type orb get primitive tc org omg CORBA TCKind tk ushort props n mode PropertyMode PROP NORMAL ntt props n
90. 4 ORBacus CHAPTER 4 CHAPTER 5 ORB and Object Adapter Initialization 47 ORB Initialization 47 Initializing the C ORB 47 Initializing the Java ORB for Applications 47 Initializing the Java ORB in JDK 1 2 1 3 48 Object Adapter Initialization 48 Initialization of the Object Adapter 48 Configuring the ORB and Object Adapter 49 ORB Properties 49 OA Properties 53 IIOP Properties 55 Command line Options 58 Using a Configuration File 59 Using the Windows NT Registry 60 Defining Properties 61 Precedence of Properties 63 Advanced Property Usage 63 Using POA Managers 65 Creating POA Managers 65 The Root POA Manager 67 Dispatching Requests 68 Callbacks 68 Advanced Configuration Example 68 ORB Destruction 70 Destroying the C ORB 70 Destroying the Java ORB 70 Server Event Loop 71 Applets 72 Compatibility with Netscape 72 Initializing the Java ORB for Applets 73 Adding ORBacus Applets to Web Pages 73 Defining ORB Options for an Applet 73 Defining the ORB Class Parameters 74 Security Issues 74 CORBA Objects 75 Overview 75 ORBacus CHAPTER 6 Implementing Servants 76 Implementing Servants using Inheritance 77 Implementing Servants using Delegation 79 Creating Servants 83 Creating Servants using C 84 Creating Servants using Java 85 Activating Servants 86 Implicit Activation of Servants using C 86 Implicit Activation of Servants using Java 87 Explicit Activation of Servants using C 87 Explicit Act
91. 4 47 9 5 2 t NH HB Wow i5 16 17 18 19 20 21 22 23 24 25 26 27 28 28 30 If calling resolve initial references was successful the object reference is checked and narrowed in order to verify that it supports the interface CosNaming NamingContext Ext If the narrow operation raises CORBA BAD PARAM the object does not support the interface This is considered to be an error because we explicitly asked for a Naming Service instance Binding In the next step some sample bindings are created and bound to the Naming Service Java Named impl implA new Named impl amed impl implAl new Named impl amed impl implA2 new Named impl Named impl implA3 new Named impl amed impl implR new Named impl Named impl implC new Named impl Named a implA this orb Named al implA1 this orb amed a2 implA2 this orb Named implA3 this orb amed b implB this orb Named c implC this try NameComponent nclName new NameComponent 1 nclName 0 new NameComponent nciName 0 id nci nclName 0 kind NamingContext ncl wi nc bind new context nclName NameComponent nc2Name new NameComponent 2 nc2Name 0 new NameComponent nc2Name 0 id nci nc2Name 0 kind nc2Name 1 new NameComponent nc2Name 1 id nc2 nc2
92. A orb resolve initial references RootPOA Resolve the ORBACUS POA Manager Factory See section 4 4 1 for an example Initialize a configuration sequence with two elements ORBacus 69 ORB and Object Adapter Initialization Xl 14 20 21 235 24 25 4 5 4 5 1 4 5 2 Configure acceptor to listen on port 3000 Configure an IIOP acceptor to listen on port 3001 Create the Root POA Manager The Root POA Manager must be created before resolving the Root POA ORB Destruction Destroying the C ORB Applications must destroy the ORB before returning from main so that resources used by the ORB are properly released To destroy the ORB invoke dest roy on the ORB C CORBA ORB_var orb Initialize the orb Tike deis orb destroy Destroying the Java ORB As in C Java must destroy the ORB so that resources are properly released In Java the ORB is destroyed as follows Java org omg CORBA ORB orb Initialize the orb ds orb destroy In JDK 1 2 the ORB interface does not define the standard dest roy method To work around this problem an application can be compiled using the Xbootclasspath option to ensure that the ORBACUS classes i e OB jar are located before the JDK s runtime classes Alternatively an application can cast the ORB reference to the type com ooc CORBA ORB when calling destroy as shown below Java org omg CORBA ORB orb Initi
93. A Object_var obj orb string to object file tmp object ref B var b B _narrow obj Java ORBacus 107 Locating Objects 6 4 4 6 5 6 5 1 org omg CORBA ORB orb Get a reference to the ORB somehow org omg CORBA Object obj orb string to object file tmp object ref B b BHelper narrow obj relfile URLs ORBACUS also provides the proprietary re1file URL This URL is the same as the file URL except that it takes a relative file name instead of an absolute file name Initial Services The CORBA specification provides a standard way to bootstrap an object reference through the use of initial services which denote a set of unique services whose object ref erences if available can be obtained using the ORB operation resolve initial references which is defined as follows IDL module CORBA interface ORB typedef string ObjectId exception InvalidName Object resolve_initial_references in ObjectId identifier raises InvalidName Initial services are intended to have well known names and the has standardized the names for some of the CORBAservices 9 For example the Naming Service has the name NameService and the Trading Service has the name TradingService Resolving an Initial Service An example in which the ORB is queried for a Naming Service object reference will dem onstrate how to use resolve initial references The example ass
94. A with the same name as was used previously Transient POAs almost always use the SYSTEM ID policy as a mat ter of convenience although the combination of TRANSIENT and USER ID is legal Object references created on a persistent POA continue to be valid beyond the POA s life time That is if you create a persistent reference on a POA destroy the POA and then rec reate that POA again with the same POA name the original reference continues to denote the same CORBA object even if the server was shut down and restarted Persis tent references require the same POA name and object ID to be used to denote the same object This means that persistent references rely on the combination of PERSISTENT and USER ID USER ID must be used in conjunction with NO IMPLICIT ACTIVATION SO servants for persistent references are always activated explicitly Factory Objects Itis quite common to use the Factory 2 design pattern in CORBA applications In short a factory object provides access to one or more additional objects In CORBA applica tions a factory object can represent a focal point for clients In other words the object ref erence of the factory object can be published in a well known location and clients know that they only need to obtain this object reference in order to gain access to other objects in the system thereby minimizing the number of object references that need to be published The Fact
95. Asserts G0 NOR Index for sequence operator or remove function was out of range This message appears if the argument to the sequence member functions operator or remove exceeds the sequence length Null pointer was used to initialize T var type This message indicates an attempt to initialize a var type with a null pointer operator gt was used on null pointer or nil object reference This message indicates an attempt to use operator on an uninitialized _var type Application tried to dereference a null pointer Some CORBA var types have built in conversion operators to a C reference type i e some var types for type T have a conversion operator to T amp This message appears if an application uses this conversion operator on an uninitialized var type Null pointer was passed as string parameter or return value According to IDL to C mapping specification no null pointers may be passed as string parameters or return values This message appears if an application tries to do so Self assignment caused a dangling pointer This message appears if the content of a var type is assigned to itself For example the following code will lead to this error message Somehow get a pointer to a variable struct AVariableStruct var var AVariableStruct ptr var var ptr This will result in a dangling pointer because var will free its own content on assignment Replacement of Any content b
96. Attributes of UtcT structure containing the same attributes as the Return a UTO with the absolute time corresponding to the relative time of the UTO Will raise CORBA DATA CONVERSION exception in the case that the operation would result in a overflow Compare the time of the UTO parameter with the time of the UTO the time of the UTO parameter is the second parameter in the comparison See Enumerations on page 169 for details Will raise a CORBA BAD PARAM exception if the UTO parameter is nil or if its inaccuracy attribute is greater then the maximum allowable inaccuracy Return a TIO representing the time interval between the time of the UTO and the time of the UTO parameter Will raise a CORBA BAD PARAM exception if the UTO parameter is nil or if its inaccuracy attribute is greater then the maximum allowable inaccuracy Return a TIO representing the error envelope of the UTO The Time Interval Object The Time Interval Object TIO represents a time interval and provides various operations related to time intervals The TIO is declared in the CosTime module as follows IDL module CosTime interface TIO readonly attribute TimeBase IntervalT time_interval OverlapType spans in UTO time out TIO overlap ORBacus 171 ORBacus Time 8 OverlapType overlaps in TIO interval out TIO overlap 9 UTO time 10 H ERE ae 6 The ti
97. B jar file You might also want to use a C server together with a Java client or vice versa This is one of the primary advantages of using CORBA if something is defined in CORBA IDL the programming language used for the implementation is irrelevant CORBA applica tions can talk to each other regardless of the language they are written in Summary At this point you might be inclined to think that this is the most complicated method of printing a string that you have ever encountered in your career as a programmer At first glance a CORBA based approach may indeed seem complicated On the other hand think of the benefits this kind of approach has to offer You can start the server and client applications on different machines with exactly the same results Concerning the commu nication between the client and the server you don t have to worry about platform specific methods or protocols at all provided there is a CORBA ORB available for the platform and programming language of your choice If possible get some hands on experience and start the server on one machine the client on another As you will see CORB A based applications run interchangeably in both local and network environments One last point to note you likely won t be using CORBA to develop systems as simple as our Hello World example The more complex your applications become and today s 1 Note that after the startup of the server program you have to co
98. BA SetOverrideType ADD_OVERRIDE DAN WN kh 1 10 This is equivalent to the version Note that you can also set the timeout policy at the ORB level 254 ORBacus CHAPTER 18 Concurrency Models 18 1 Introduction 18 1 1 18 1 2 What is a Concurrency Model A concurrency model describes how an Object Request Broker ORB handles communi cation and request execution There are two main categories of concurrency models sin gle threaded concurrency models and multi threaded concurrency models Single threaded concurrency models describe how an ORB behaves while a request is sent or received in a single threaded environment For example one model is to simply let the ORB block on sending and receiving messages Another model is to let the ORB do some work while sending and receiving messages for example to receive user input through a keyboard or a GUI or to simply transfer buffered messages Multi threaded concurrency models describe how the ORB makes use of multiple threads for example to send and receive messages in the background Multi threaded concur rency models also describe how several threads can be active in the user code and the strategy the ORB employs to create these threads Why different Concurrency Models There is no one size fits all approach with respect to concurrency models Each concur rency model provides a unique set of properties each h
99. BACUS for C or Java How ever the interaction between clients and the IMR is strictly specified by the GIOP specifi cation so any client that is CORBA compliant may interact with the IMR 1 Binding refers to the process of opening a connection and associating an object reference with its servant ORBacus 113 The Implementation Repository 7 1 7 1 1 7 1 2 Background How It All Works When a server is using the IMR object references created by one of its persistent POAs refer to the IMR rather than to the server itself When the client makes a request using this reference the IMR receives the request activates the server if necessary using the OAD and returns a new object reference to the client that identifies the server at its current host and port The client then establishes a connection with the server using the new object ref erence and communicates directly with the server without the intervention of the IMR However should the server fail a well behaved client will contact the IMR again which may restart the server and allow the client to resume its activities Information Managed by the IMR The IMR provides support for the indirect binding and automatic activation of servers within a given domain In order to provide this support the IMR manages three types of entities OADs servers and POAs OADs An OAD is responsible for the activation of servers on a given host Each OAD is regis ter
100. Bacus The Bi directional OCI Plug in 19 6 3 19 6 4 the same peer ID host port and object key Conversely if an object reference is transient then the peer ID can vary along with the host port and object key POA Managers When using the Bi directional plug in a POA Manager must be created specifically for accepting bi directional connections If the application only wishes to accept bi direc tional connections then only one POA Manager is required If the application wishes to accept both bi directional and regular IIOP connections then at least two POA Managers are required There are really two ways a POA Manager can accept an incoming bi directional IIOP connection Bylistening on a port for new TCP IP connections just like with regular IIOP e listening for new callback connections on existing outgoing connections A server will typically want to enable both options but a security restricted client will only want to enable the second option since listening on a port is often forbidden or pointless if a firewall prevents incoming TCP IP connections The implication of enabling only the second option is that a server wishing to connect to a client will only be able to do so if there is an existing bi directional connection from the client to the server If not the server will receive a TRANSIENT exception Initialization and Configuration The initialization steps can be summarized as follows e Ini
101. CES Minor Exception Code MinorInvalidBinding Portable Interceptor operation not supported in binding 20 1 10BAD_INV_ORDER Minor Exception Code inorDependencyPreventsDestruction Dependency exists in Interface Repository prevents destruction of object inorIndestructibleObject Attempt to destroy indestructible object in Interface Repository inorDestroyWouldBlock Operation would deadlock inorShutdownCalled ORB has shutdown inorInvalidPICall Invalid Portable Interceptor call inorServiceContextExists A service context already exists with the given ID inorPolicyFactoryExists A factory already exists for the given PolicyType inorBadConcModel Invalid concurrency model inorORBRunning ORB run already called inorRequestAlreadySent Request has already been sent inorRequestNotSent Request has not yet been sent MinorResponseAlreadyReceived Response has already been received 292 ORBacus Non Compliant Application Asserts 20 1 11 TRANSIENT Minor Exception Code MinorRequestCancelled Request has been cancelled MinorConnectFailed Request has been cancelled x MinorCloseConnection Got a close connection message Active connection management closed Mi ActiveC tionM E inorActiveConnectionManagemen connection Forced connection shutdown because of Mi F h in
102. Con nection Control Part part of SS 7 or SAAL Signaling ATM Adaptation Layer Non reliable or non connection oriented protocols can also be used if the protocol plug in itself takes care of reliability and connection management For example UDP IP can be used if the protocol plug in provides for packet ordering and packet repetition in case of a packet loss Interface Summary Buffer An interface for a buffer A buffer can be viewed as an object holding an array of octets and a position counter which determines how many octets have already been sent or received ORBacus 267 The Open Communications Interface 19 2 2 19 2 3 19 2 4 19 2 5 19 2 6 Transport The Transport interface allows the sending and receiving of octet streams in the form of Buffer objects There are blocking and non blocking send receive operations available as well as operations that handle time outs and detection of connection loss Acceptor and Connector Acceptors and Connectors are Factories 2 for Transport objects A Connector is used to connect clients to servers An Acceptor is used by a server to accept client connection requests Acceptors and Connectors also provide operations to manage protocol specific IOR pro files This includes operations for comparing profiles adding profiles to IORs or extract ing object keys from profiles Acceptor and Connector Factories Acceptor and Connector Factories are used by clients
103. DIX C APPENDIX D APPENDIX E ORBacus Policy Reference 301 Module OB Interface OB Interface OB Interface OB Interface OB Interface OB Interface OB Interface OB Interface OB 301 ConnectTimeoutPolicy 304 ConnectionReusePolicy 305 interceptorPolicy 306 LocationTransparencyPolicy 307 ProtocolPolicy 308 RequestTimeoutPolicy 309 RetryPolicy 310 TimeoutPolicy 311 Reactor Reference 313 Interface OB Reactor 313 Logger Reference 317 Interface OB Logger 317 Open Communications Interface Reference 319 Module OCI Interface OCI Interface Interface Interface Interface OCI Interface OCI Interface Interface Interface OCI Interface Interface 319 Buffer 324 Transport 326 TransportInfo 330 CloseCB 332 Connector 333 ConnectorInfo 336 ConnectCB 338 Acceptor 339 AcceptorInfo 342 AcceptCB 344 AccFactory 345 ORBacus 13 Interface OCI AccFactoryInfo 347 Interface OCI AccFactoryRegistry 348 Interface OCI ConFactory 350 Interface OCI ConFactoryInfo 352 Interface OCI ConFactoryRegistry 354 Interface OCI Current 356 Module OCI IIOP 357 Interface OCI 1OP TransportInfo 358 Interface OCI HOP ConnectorInfo 359 Interface OCI 1OP AcceptorInfo 360 Interface OCI IOP AccFactoryInfo 361 Interface OCI IOP ConFactoryInfo 362 References 363 14 ORBacus owe INtroduction
104. Display the command line options supported by the server Ani Display the version of the server version um Prints the stringified IOR of the server to standard output d DIR Enables persistence for the server All of the data created by the server will dbdir DIR be saved to files in the specified directory DIR t MINS Specifies the timeout in minutes after which a persistent server timeout MINS automatically compacts its database The default timeout is five minutes Configuration Properties In addition to the standard configuration properties described in Chapter 4 ORBACUS Trader also supports the following properties ooc trading dbdir DIR Equivalent to the d command line option ooc trading timeout MINS Equivalent to the t command line option ooc trading allow nil objects Determines whether the server should allow an offer to be exported with a nil object reference ooc trading port PORT Specifies the port number on which the service should listen for new connections Note that this property is only considered if the ooc oa port property is not set ooc trading use ir Determines whether the server should validate offers and service types using the Interface Repository 196 ORBacus Connecting to the Service 14 1 3 CLASSPATH Requirements 14 2 14 3 ORBACUS Trader requires the classes in OB jar OBTrading jar and OBUtil jar Connecting to the Service The object key of the Trading Servi
105. E return status Several header files are included OB CORBA h provides standard CORBA definitions OB TimeService h provides ORBACUS Time definitions and OB TimeHelper h pro vides definitions for ORBACUS Time extensions Forward declarations for the run and stopwatch functions Initialize the ORB Initialize the Time Service Call the run helper function If the ORB was successfully created it is destroyed The run method resolves the Time Service initial reference and calls stopwatch C int run CORBA ORB ptr orb CORBA Object_var obj try obj orb gt resolve initial references TimeService catch const CORBA ORB InvalidName amp ORBacus 177 ORBacus Time 12 13 14 15 16 17 18 Lg 20 21 22 23 24 25 26 27 28 28 30 Ou 33 2 3 23 RoR cerr lt lt Can t resolve TimeService lt lt endl return EXIT FAILURE if CORBA is nil obj cerr lt lt TimeService is a nil object reference lt lt endl return EXIT FAILURE CosTime TimeService var ts CosTime TimeService narrow obj if CORBA is nil ts cerr TimeService is not a TimeService lt lt object reference lt lt endl return EXIT FAILURE return stopwatch ts Using the ORB reference resol
106. ET gt Security Issues Web browsers generally place several security restrictions on applets that you need to be aware of when developing an applet using ORBACUS Applets can only communicate with the host from which the applet was downloaded e Applets cannot accept connections from any host The first limitation forces you to run any CORBA server applications that your applet communicates with on your Web server host The second limitation prevents your applet from acting as a CORBA server which is often necessary when a client wishes to receive callbacks from a server These limitations are the most common causes of security exceptions in an applet You must ensure that any object references used by your applet refer to objects on the Web server host Furthermore you must not attempt to enable CORBA server functionality in your applet by using the POA 1 For example Netscape v4 has a built in ORB 2 Netscape v4 also does not normally allow CORBA applets to be loaded from a local i e filesys tem HTML file causing a SecurityException when the applet attempts to connect to the CORBA server To work around this problem CORBA applets must be downloaded from a Web server 74 ORBacus CHAPTER 5 CORBA Objects 5 1 Overview A CORBA object is an object with an interface defined in CORBA IDL CORBA objects have different representations in clients and servers e server implements a CORBA obje
107. Hello h Hello cpp Hello skel hand Hello skel cpp Implementing the Server To implement the server we need to define an implementation class for the He11o inter face To do this we create a class He110o impl that is derived from the skeleton class POA Hello defined in the file Hello_skel h The definition for He11o impl looks like this 18 ORBacus Implementing the Example in C DAN DAA AN DOB Nn C include lt Hello_skel h gt class Hello_impl public POA_Hello public PortableServer RefCountServantBase public virtual void say hello throw CORBA SystemException Since our implementation class derives from the skeleton class 110 we must include the file Hello_skel h Here we define Hello impl as a class derived from POA_Hello and RefCountServantBase RefCountServantBase is part of the PortableServer namespace and provides reference counting Our implementation class must implement all operations from the IDL interface In this case this is just the operation say hello The implementation for He110_imp1 looks as follows C include lt iostream h gt include lt OB CORBA h gt include lt Hello_impl h gt void Hello impl say hello throw CORBA SystemException cout Hello World endl We must include OB CORBA h which contains definitions for the standard CORBA classes as wel
108. Look amp Feel if available ORBacus 149 ORBacus Names Console 10 1 2 10 1 3 10 2 10 2 1 motif Use the Motif Look amp Feel if available mac Use the Macintosh Look amp Feel if available h jim Display the command line options supported by the program CLASSPATH Requirements The ORBACUS Names Console requires the classes in OB jar OBNaming jar OBUtil jar and the Java Foundation Classes JFC Note JFC is part of version 1 2 or greater of JDK Naming Service Lookup In order to locate a Naming Service the application takes the following steps on start up e First it checks whether a Naming Service reference was given with the f option e fthis is not the case then the initial Naming Service is used as provided to ORB with options like ORBservice or ORBconfig If both of the above steps fail an error window is displayed and the Names console exits The Menus The menus provide access to all of the features of the application In addition the most common actions are also available in the toolbar as well as in a popup menu that is displayed when pressing the right mouse button over an item in the binding table or context tree The File Menu This menu contains operations that create bindings and define the current root context New Window Opens an additional control window Switch Root Context Selects a new root naming context Load Context Recursively loads a naming co
109. MR Database The imrdbupgrade utility is used to upgrade an earlier version of the IMR database Command line usage is as follows imrdbupgrade database directory The database directory parameter is used to specify the IMR database directory ORBacus 123 The Implementation Repository 7 5 Getting Started with the Implementation Repository To use the IMR several steps must be taken These steps are presented below and are explained by way of example In this example we assume that ORB ACUS has been installed in the directory usr local ORBacus and the executables imr imradmin and mkref all exist in a directory that is in the search path 1 Determine the physical architecture In this example we have a network with three hosts master slave1 and slave2 The host master is used to run only the IMR The hosts slave1 and slave2 are used to run individual CORBA servers 2 Create a configuration file for the IMR and OADs First create a configuration file for the IMR containing the following 4 imr conf ooc imr admin 10000 ooc imr forward port 10001 ooc imr slave port 10002 ooc imr mode master ooc imr dbdir usr local ORBacus db This file is placed in the usr local ORBacus etc directory on host master This configuration file can also be used by the mkref utility Second create a configuration file for the OADs containing the following oad conf ooc orb service IMR corbaloc master 10000 IMR ooc imr slave_
110. Name 1 kind NamingContext nc2 nc bind new context nc2Name 144 ORBacus Programming Example 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 NameComponent aName new NameComponent 1 aName 0 new NameComponent aName 0 id a aName 0 kind nc bind aName a NameComponent alName new NameComponent 1 alName 0 new NameComponent alName 0 id al alName 0 kind nc bind alName al NameComponent a2Name new NameComponent 1 a2Name 0 new NameComponent a2Name 0 id a2 a2Name 0 kind nc bind a2Name a2 NameComponent a3Name new NameComponent 1 a3Name 0 new NameComponent a3Name 0 id a3 a3Name 0 kind nc bind a3Name a3 NameComponent bName new NameComponent 2 bName 0 new NameComponent bName 0 id nci bName 0 kind bName 1 new NameComponent bName 1 id p bName 1 kind nc bind bName b NameComponent cName new NameComponent 3 cName 0 new NameComponent cName 0 id nci cName 0 kind cName 1 new NameComponent cName 1 id nc2 cName 1 kind cName 2 new NameComponent cName 2 id c cName 2 kind
111. OATie java the tie class that inherits from and delegates all requests to an instance of IOperations To implement our servant class using delegation we need to write a class that implements the IOperations interface ORBacus 81 CORBA Objects 1 Java 2 public class I impl tie implements IOperations 3 4 public void op a 5 6 8 public void op b 9 10 11 12 public void op i 13 14 2 The servant class I impl tie is defined to implement the IOperations interface 4 14 I impl tie must implement all of 1 s operations including inherited operations Figure 5 3 illustrates the relationship between the classes generated by the IDL to Java translator and the servant implementation classes IPOA I impl IPOATie EEA A IOperations I impl tie Figure 5 3 Class Hierarchy for Inheritance and Delegation Implementation in Java ORBacus Creating Servants 5 3 ABW NH No Ra Fa ka ka ka ka ka GV HOHE DH DN WHE 25 As noted earlier Java s lack of multiple inheritance makes it impossible to inherit an implementation from another servant class Using tie classes however does allow imple mentation inheritance but only in certain situations For example let s implement each of our sample interfaces using del
112. ORBSingletonClass com ooc CORBA ORBSingleton org omg CORBA ORB orb null 142 ORBacus Programming Example 8 try 9 10 11 12 E3 14 L5 16 I 18 19 20 21 22 23 24 25 26 27 28 2 9 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 orb ORB init args props org omg CORBA Object poaObj null try poaObj orb resolve_initial_references RootPOA catch org omg CORBA ORBPackage InvalidName ex throw new RuntimeException POA rootPOA POAHelper narrow poaObj POAManager manager rootPOA the POAManager org omg CORBA Object obj null try obj orb resolve_initial_references NameService catch org omg CORBA ORBPackage InvalidName ex throw new RuntimeException if obj null throw new RuntimeException NamingContextExt nc null try nc NamingContextExtHelper narrow obj catch org omg CORBA BAD_PARAM throw new RuntimeException 10 22 Usually the application is initialized in the main method For more information on ORB initialization see Chapter 4 ORBacus 143 ORBacus Names 24 32 In the next step we try to connect to the Naming Service by supplying NameService to resolve initial references lf InvalidName is thrown there is no Naming Ser vice available because the ORB doesn t know anything about this service 3
113. ORBacus For C and Java Version 4 0 3 Copyright c 2000 Object Oriented Concepts Inc All Rights Reserved Object Oriented Concepts ORBacus and JThreads C are trademarks or regis tered trademarks of Object Oriented Concepts Inc OMG CORBA and Object Request Broker are trademarks or registered trade marks of the Object Management Group Java is a trademark of Sun Microsystems Inc Netscape is a registered trademark of Netscape Communications Corporation Other names products and services may be the trademarks or registered trademarks of their respective holders ORBacus CHAPTER 1 CHAPTER 2 CHAPTER 3 Introduction 15 What is ORBacus 15 About this Document 16 Getting Help 16 Getting Started 17 The Hello World Application 17 The IDL Code 18 Implementing the Example in C 18 Implementing the Server 18 Implementing the Client 22 Compiling and Linking 23 Running the Application 24 Implementing the Example in Java 24 Implementing the Server 24 Implementing the Client 27 Compiling 28 Running the Application 29 Summary 29 Where to go from here 30 The ORBacus Code Generators 31 Overview 31 Synopsis 31 Description 32 Options for idl 32 Options for jid 36 Options for hid 37 Options for ridl 38 Options for irgen 39 The IDL to C Translator and the Interface Repository 40 Include Statements 40 Documenting IDL Files 41 Using javadoc 4
114. ORBacus 159 ORBacus Properties 11 4 2 void define property in PropertyName in any property value raises InvalidPropertyName ConflictingProperty UnsupportedTypeCode UnsupportedProperty ReadOnlyProperty As a property consists of a name value pair both the name and the value are the parame ters to this operation Querying for Properties As soon as a property is defined PropertySet can be queried for the property s value with the get property value operation IDL any get property value in PropertyName property name raises PropertyNotFound InvalidPropertyName For a particular property name this call either returns the Any associated with that name or throws an exception if a property with the name does not exist You can not only query for a particular property value but also for a list of all the proper ties defined within a PropertySet The get_all_properties operation serves this purpose IDL void get_all_properties in unsigned long how_many out Properties nproperties out PropertiesIterator rest This operation works similar to the 1ist call offered by the Naming Service In both cases the maximum number of items to be returned at once is specified An iterator imple menting the PropertiesIterator interface gives access to the remaining items if any IDL interface PropertiesIterator void reset boolean next_one out Property aproperty boolean next n in unsigned
115. ORBserver name EventServer where EventServer refers to the server name con figured with the IMR When the IMR is configured to start the Event Service this option is automatically added to the service s arguments However when the Event Service is started manually the option must be present For further information on configuring a ser vice with the IMR refer to Getting Started with the Implementation Repository on page 124 186 ORBacus Event Service Concepts 13 4 13 4 1 13 4 2 Event Service Concepts The Event Channel The Event Service distributes data in the form of events The term event in this context refers to a piece of information that is contributed by an event source An event channel instance accepts this information and distributes it to a list of objects that previously have connected to the channel and are listening for events The Event Service specification defines two distinct kinds of event channels untyped and typed Whereas an untyped event channel forwards every event to each of the registered clients in the form of a CORBA Any a typed event channel works more selectively by supporting strongly typed events which allow for data filtering We will only discuss the untyped event channel here For information on typed event channels and more details on the Event Service in general please refer to the official Event Service specification 9 Event Suppliers and Consumers Applica
116. Qsee reference Adds a See also note since since text Comment related to the availability of new features 42 ORBacus Documenting IDL Files EF ele tik yee Tubi eee teie CENE 8 E hd m BRE GG a T I 1 Tha Dj n OCD The defiboon s ii Ls pds g unifeira pxbeiface H probar ele Tha eure plage af cee ar other Communion ech pio Sur the QC Purtburzars prozaj unpinrarrigipns raad miy ba be writan once arad run hs reed wih OCT ccanpliazi SE Por mare formato phass aus ihe OC drcumartalian Aliases typedef maguexrecHuffars buffer Sag Tiap Tora pepene typedef DHF ID Airt Tor an DOR tyguedmaZz LEIE Praftlazd TrpfilaIdz Tes 4 kd Seq typmi Peofideid gt 1 ABk Tor a tygsdaZ maguexreczrtart Jes for an object key pn of INST Fn E Figure 3 2 Documentation generated with the IDL to RTF translator version version The interface s version number Like javadoc hidl and use the first sentence in the documentation comment as the summary sentence This se
117. R jar OBUtil jar and the Java Foundation Classes JFC Note JFC is part of version 1 2 or greater of JDK Implementation Repository Service Lookup In order to locate an IMR Service the application uses the initial IMR Service as pro vided to the ORB with options such as ORBservice or ORBconfig If the service is not found an error is displayed and the IMR Console exits The Menus The menus provide access to all of the features of the application In addition the most common actions are also available in the toolbar as well as in a popup menu that is dis played when pressing the right mouse button over an item in the binding table or context tree The File Menu The File menu contains the Exit menu item which is used to exit the ORBACUS IMR Con sole 132 ORBacus The Menus 82 2 8 2 3 The Edit Menu The operations in the Edit menu provide the means for manipulating OADs servers and POAs Create Create a new OAD server or POA Modify Modify the selected object Delete Delete the selected object Cut Move the selected server to the clipboard Paste Insert the server contained in the clipboard under the selected OAD Start Start the selected server Stop Stop the selected server Reset Reset the state of the selected server The Create menu item creates a child object under the selected object OADs are created under the IMR Domain root object servers are created under OADs and POAs
118. RB orb set delegate impl Explicit Activation of Servants using C If NO IMPLICIT ACTIVATION and SYSTEM ID are in effect for servant s POA you activate the servant by calling activate object I impl impl PortableServer POA var poa impl default POA poa activate object amp impl The code instantiates a servant To activate a servant we need the servant s POA activate object creates a unique ID for the servant ORBacus 87 CORBA Objects Ojo 5 4 4 NOR Once a servant is activated calls to this on the servant return an object reference that contains the ORB assigned ID for the object If NO IMPLICIT ACTIVATION and USER ID are in effect for servant s POA you acti vate the servant by supplying the ID value as an octet sequence to activate object with id I impl impl PortableServer POA var poa impl default POA PortableServer ObjectId var oid PortableServer string to ObjectId MyObjectName poa gt activate object with id oid amp impl The string to Object id helper function converts a string into an octet sequence activate object with id uses the octet sequence as the object ID for the servant You can use any suitable key value as an object ID Typically the key will be part of the object s state such as a social security number However you can also use keys that are not directly related to object state such as databas
119. RB var orb CORBA ORB init argc argv he EE The CORBA ORB_init call interprets arguments starting with ORB and All of these arguments passed through the argc and argv parameters are automatically removed from the argument list Initializing the Java ORB for Applications A Java application can initialize the ORB in the following manner Java import org omg CORBA public static void main String args ORBacus 47 ORB and Object Adapter Initialization 4 1 3 4 2 4 2 1 ORB orb ORB init args new java util Properties The ORB init call interprets arguments starting with ORB and Unlike the C version these arguments are not removed see Advanced Property Usage on page 63 for more information Initializing the Java ORB in JDK 1 2 1 3 The ORB implementation included in JDK 1 2 and beyond can be considered a minimal ORB suitable primarily for use in basic client oriented tasks In order to use the ORBA CUS ORB instead of the JDK s default ORB you must start your application with the fol lowing properties java Dorg omg CORBA ORBClass com ooc CORBA ORB Dorg omg CORBA ORBSingletonClass com ooc CORBA ORBSingleton MyApp An alternative is to set these properties in your program before initializing the ORB For example Java import org omg CORBA public static void main String args java util Properties props System getProperti
120. Selects all of the items in the item list Clone Creates a clone of the selected item The appropriate dialog box is dis played to allow you to create a new item but the fields of the dialog box are initialized with the values from the selected item Modify Edits the currently selected item Delete Permanently removes the selected items There are some issues to be aware of when using the cut copy and paste operations First service types and links must have unique names therefore you will not be able to paste one of these items if an item already exists in the trader with the same name Secondly a certain amount of forethought is advised when you wish to cut and paste ser vice types Since service types can inherit from other service types you cannot cut a ser vice type that has subtypes If you wish to cut or delete a number of service types and if inheritance relationships exist between any of them you must cut the types without any subtypes first The same principle applies to pasting service types in that you cannot paste a type if its supertypes do not exist or have not yet been pasted It is recommended that you only operate on one service type at a time when using the cut copy paste or delete commands Some types of items namely service types and proxy offers cannot be modified The Modify command and its toolbar equivalent are disabled while these types are dis played The Clone and Modify commands operate on a singl
121. Seq typedef sequence ProfileId ProfileIdSeg Alias for a sequence of profile ids ObjectKey typedef CORBA OctetSeq ObjectKey Alias for an object key which is a sequence of octets TaggedComponentSeq typedef IOP TaggedComponentSeq TaggedComponentSeq Alias for a sequence of tagged components Handle typedef long Handle Alias for a system specific handle type ProtocolId typedef unsigned long Protocolld Alias for a protocol id ProfileInfoSeq typedef sequence lt ProfileInfo gt ProfileInfoSeq Alias for a sequence of basic information about profiles ParamSeq typedef sequence lt Param gt ParamSeq Alias for a sequence of parameters CloseCBSeq typedef sequence lt CloseCB gt CloseCBSeq 320 ORBacus Module OCI Alias for a sequence of close callback objects ConnectorSeq typedef sequence lt Connector gt ConnectorSeg Alias for a sequence of Connectors ConnectCBSeq typedef sequence lt ConnectCB gt ConnectCBSeq Alias for a sequence of connect callback objects AcceptorSeq typedef sequence lt Acceptor gt AcceptorSeqg Alias for a sequence of Acceptors AcceptCBSeq typedef sequence lt AcceptCB gt AcceptCBSeq Alias for a sequence of accept callback objects AccFactorySeq typedef sequence lt AccFactory gt AccFactorySeq Alias for a sequence of AccFactory objects ConFactorySeq typedef sequence lt ConFactory gt ConFactorySeq Alias for a
122. Service catch org omg CORBA ORBPackage InvalidName ex An error occurred Property Service is not available if obj null The object reference is invalid PropertySetDefFactory factory null try factory PropertySetDefFactoryHelper narrow obj catch org omg CORBA BAD_PARAM ex This object does not implement the Property Servic 162 ORBacus Programming Example 24 28 29 30 31 32 33 34 32 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 PropertySetDef set factory create propertysetdef Any anyLong orb create any Any AnyString orb create any Any anyShort orb create any anyLong insert long 12345L anyString insert string Foo anyShort insert short short 0 try set define property LongProperty anyLong set define property StringProperty anyString set define property ShortProperty anyShort catch ReadOnlyProperty ex An error occurred catch ConflictingProperty ex An error occurred catch UnsupportedProperty ex An error occurred catch UnsupportedTypeCode ex An error occurred catch InvalidPropertyName ex An error occurred PropertiesHolder ph new PropertiesHolder PropertiesIteratorHolder ih new PropertiesIteratorHolder set get all pro
123. a new console window then select Console Connect to connect the new window to another trader ORBacus 241 ORBacus Trader Console 242 ORBacus CHAPTER 16 The Interface Repository 16 1 16 1 1 A CORBA Interface Repository IFR is essential for applications using the dynamic fea tures of CORBA such as the Dynamic Invocation Interface and DynAny The IFR holds IDL type definitions and can be queried and traversed by applications The ORBACUS Interface Repository is compliant with 4 This chapter does not provide a complete description of the IFR For more information please refer to the specification Synopsis Usage The ORBACUS Interface Repository is currently only provided with ORBACUS for C irserv h help v version e NAME cpp NAME d debug i ior DNAME DNAME DEF UNAME IDIR E case sensitive FILE h Display command line options supported by the server x Display the version of the server version ORBacus 243 The Interface Repository 16 1 2 NAME Use as the preprocessor program cpp NAME d Print diagnostic messages This option is for ORBACUS internal debug debugging purposes only I 4 pic Print the stringified of the server to standard output ior DNAME Defines NAME as DEF or 1 if DEF is no
124. actoryInfo E 23 Interface OCI IIOP AccFactorylInfo interface AccFactoryInfo inherits from OCI AccFactoryInfo Information on an IIOP OCI Acceptor Factory object See Also AccFactory ORBacus 361 Open Communications Interface Reference E 24 Interface OCI IIOP ConFactoryInfo interface ConFactoryInfo inherits from OCI ConFactoryInfo Information on an IIOP OCI Connector Factory object See Also ConFactory ConFactoryInfo 362 ORBacus References Buschman F et al 1996 Pattern Oriented Software Architecture A System of Patterns New York Wiley Gamma E et al 1994 Design Patterns Reading MA Addison Wesley Henning M and S Vinoski 1999 Advanced CORBA Programming with C Reading MA Addison Wesley Object Management Group 1999 The Common Object Request Broker Architecture and Specification Revision 2 3 1 ftp www omg org pub docs formal 99 10 07 pdf Framingham MA Object Management Group Object Management Group 1999 C Language Mapping ftp www omg org pub docs formal 99 07 45 pdf Framingham MA Object Management Group Object Management Group 1999 IDL Java Language Mapping ftp www omg org pub docs formal 99 07 53 pdf Framingham MA Object Management Group Object Management Group 1999 Portable Interceptors ftp ftp omg org pub docs orbos 99 12 02 pdf Framingham MA Object Management Group ORBacus 363 References 12
125. ag Operations describe string describe Returns a human readable description of the transport Returns The description add_connect_cb void add connect cb in ConnectCB cb Add a callback that is called whenever a new connection is established If the callback has already been registered this method has no effect Parameters cb The callback to add ORBacus Interface OCI ConFactoryInfo remove connect cb void remove connect cb in ConnectCB cb Remove a connect callback If the callback was not registered this method has no effect Parameters cb The callback to remove ORBacus 353 Open Communications Interface Reference E 17 Interface OCI ConFactoryRegistry interface ConFactoryRegistry A registry for Connector factories See Also Connector ConFactory Operations add factory void add factory in ConFactory factory raises FactoryAlreadyExists Adds a Connector factory to the registry Parameters factory The Connector factory to add Raises FactoryAlreadyExists Ifa factory already exists with the same protocol id as the given factory get_factory ConFactory get factory in ProtocolId id raises NoSuchFactory Returns the factory with the given protocol id Parameters id The protocol id Returns The Connector factory Raises NoSuchFactory If no factory was found with a matching protocol id get factories 354 ORBacus
126. alize the orb com ooc CORBA ORB orb destroy Note that using this cast is ORBACUS specific therefore an application wishing to remain strictly portable must use a workaround such as Xbootclasspath For example javac Xbootclasspath p path to OB jar MyApp java 70 ORBacus Server Event Loop 4 6 AN CQ E RR NR Oo The p suffix indicates that the ORBACUS classes should be prepended to the JVM s boot classpath See the JDK documentation for more information Server Event Loop A server s event loop is entered by calling POAManager activate on each POA Man ager and then calling ORB run For example in Java Java org omg CORBA ORB orb Initialize the orb org omg PortableServer POAManager manager Get Root POA manager manager activate orb run And in C C CORBA ORB_var orb Initialize the orb PortableServer POAManager_var manager Get the Root POA manager manager activate orb run You can deactivate a server by calling ORB shutdown which causes ORB run to return For example consider a server that can be shut down by a client by calling a deactivate operation on one of the server s objects First the IDL code IDL interface ShutdownObject void deactivate On the server side Shut downOb ject be implemented like this class ShutdownObject impl publ
127. ame still exists or if the object ref erence associated with it has become invalid for example because of a server crash To perform such a check select all the objects you want to check and start the Ping operation The console tries to contact each of the selected objects and displays the time it took to get a connection to them in a separate window This is very similar to the Windows or Unix ping command for an IP address or a host name If there is a time out while trying to con tact an object this information is displayed in the Ping Window and the console continues with the next object If you want objects that cannot be contacted for example because of a server breakdown to be unbound from the current context Clean up does the job Clean up non recursively tries to connect to the selected objects If there is a communication failure or the 154 ORBacus The Toolbar 10 3 Topid Llukr srftwarr fzuket dr JopEsd damzmzgpha azr rzuwr da Sophed Luks arZfrmars btzuker dsj Wophed Piim opsel EI s Tinging Sopked irmisophz csr bruker dgj 2 Tinging Sophed luks zzZftwears tcukimr daij Fingin Iophed jdemzimogphe asmr rzuker ds E Pirim lake get ec ded s WopEel Leese Sse Pere Lukz srftwarr fzuker dr damzzapha asr bcukwr daj Pitnqing Jopksed iLucs arfrmar
128. an send detect in Buffer buf in boolean block Similar to send but it signals a connection loss by returning FALSE instead of raising COMM FAILURE 328 ORBacus Interface OCT Transport Parameters buf The buffer to fill block If set to TRUE the operation blocks until the entire buffer has been sent If set to FALSE the operation sends as much of the buffer s data as possible without blocking Returns FALSE if a connection loss is detected TRUE otherwise Raises COMM FAILURE In case of an error send timeout void send timeout in Buffer buf in unsigned long timeout Similar to send but it is possible to specify a timeout On return the caller can test whether there was a timeout by checking if the buffer has been sent completely Parameters buf The buffer to send timeout The timeout value in milliseconds A zero timeout is equivalent to calling send buf FALSE Raises COMM FAILURE In case of an error get info TransportInfo get info Returns the information object associated with the Transport Returns The Transport information object ORBacus 329 Open Communications Interface Reference E 4 Interface OCI Transportlnfo interface TransportInfo Information on an OCI Transport object Objects of this type must be narrowed to a Transport information object for a concrete protocol implementation for example to OCI 110P Trans
129. and interface stubs yFile cpp Source file containing MyFile idl s translated data types and interface stubs yFile skel h Header file containing skeletons for MyFile idl s interfaces yFile skel cpp Source file containing skeletons for MyFile idl s interfaces 1141 translates IDL files into Java files For every construct in the IDL file that maps to a Java class or interface a separate class file is generated Directories are automatically cre ated for those IDL constructs that map to a Java package e g a module 1141 can also add comments from the IDL file starting with to the generated Java files This allows you to use the javadoc tool to produce documentation from the gener ated Java files See Using javadoc on page 44 for additional information hidl creates HTML files from IDL files An HTML file is generated for each module and interface defined in an IDL file Comments in the IDL file are preserved and javadoc style keywords are supported The section Documenting IDL Files on page 41 provides more information ridl creates Rich Text Format RTF files from IDL files An RTF file is generated for each module and interface defined in an IDL file Comments in the IDL file are preserved and javadoc style keywords are supported The section Documenting IDL Files on page 41 provides more information irgen generates C code directly from the contents of an Interface Repository See The IDL to C Translator
130. ants e 0 t MN Hh ER N A servant class for I can then be defined using the skel tie template typedef POA I tie I impl tie gt I impl The servant class I impl is defined as a template instance tie parameterized with I impl tie The tie template generated by the IDL compiler contains functions that permit you change the instance denoted by the tie C template lt class T class POA I tie public POA I public T tied object void tied object T amp obj void tied object T obj CORBA Boolean release 1 The tied object function permits you to retrieve and change the implementation instance that is currently associated with the tie The first modifier function calls delete on the current tied instance before accepting the new tied instance if the release flag is currently true the release flag for the new tied instance is set to false The second mod ifier function also calls delete on the current tied instance before accepting the new instance but sets the release flag to the passed value Delegation using Java For every IDL interface the IDL to Java mapping generates an operations interface containing methods for the IDL attributes and operations This operations interface is also used to support delegation based servant implementation For an interface 1 the following additional class is generated e IP
131. ar archive in the directory defined by CODEBASE For more information please consult your Java Development Kit documenta tion Defining ORB Options for an Applet The PARAM tag is used in HTML to define parameters for an applet When initialized by an applet the ORB looks for the ORBparams parameter whose value should be command line options separated by spaces For example the HTML code below uses the ORBconfig option to specify the URL of the ORB configuration file APPLET CODE Client class ARCHIVE OB jar WIDTH 500 HEIGHT 300 gt lt PARAM NAME ORBparams VALUE ORBconfig http www orb cfg ORBacus 73 ORB and Object Adapter Initialization 4 7 5 4 7 6 lt APPLET gt Your applet can also define ORBACUS configuration properties using Java system proper ties or using the java util Properties object passed to org omg CORBA ORB init See ORB Properties on page 49 for more information Defining the ORB Class Parameters Some Web browsers have a built in ORB In order to use ORBACUS instead of this built in ORB you must set the following applet parameters lt APPLET CODE Client class ARCHIVE 0B jar WIDTH 500 300 gt lt PARAM NAME org omg CORBA ORBClass VALUE com ooc CORBA ORB gt lt PARAM NAME org omg CORBA ORBSingletonClass VALUE com ooc CORBA ORBSingleton gt lt APPL
132. ation resolve initial references and no match is found the ORB appends a slash character and the service identifier to the specified URL and invokes string to object to obtain the initial reference ooc orb default wcs Value string Specifies the default wide character code set for the ORB Note that the CORBA specifi cation states that a default wide character code set does not exist Therefore this option should only be used when communicating with a broken ORB that expects a particular wide character code set and does not correctly support the negotiation of wide character code sets ooc orb giop max message size Value max gt 0 50 ORBacus Configuring the ORB and Object Adapter Specifies the maximum GIOP message size in bytes If set to 0 no maximum message size will be used If a message is sent or received that exceeds the maximum size the ORB will raise the IMP LIMIT system exception ooc orb id Value id Specifies the identifier of the ORB to be used by the application ooc orb init iiop Value none client server both Specifies to what extent the ORB should initialize the IIOP protocol plug in The default value is both For security reasons applications may wish to disable the client and or server capabilities of the plug in Note that the values server and both do not require that the application must be a server This property simply determines which protocol ser vices are ins
133. ava com ooc CosNaming Server h help v version i ior n no updates s start d database FILE t timeout MINS c callback timeout SECS Options h shop Display the command line options supported by the server v s Display the version of the server version i ah reas Prints the stringified IOR of the server to standard output ior n Disables automatic updates i e callbacks that notify interested no updates clients of changes to the naming service s Use this option only when starting a persistent server using a start new database Enables persistence for the server All of the bindings created by d FILE the server will be saved to the specified file If you are starting database FILE the server for the first time using this database you must also use the s command line option ES Specifies the timeout in minutes after which a persistent server automatically compacts its database The default timeout is five timeout MINS minutes Specifies the timeout in seconds to be used for the ORBACUS timeout policy OB TimeoutPolicy The default timeout is five seconds See Chapter 17 for more information c SECS callback timeout SECS 9 1 2 Windows NT Native Service The C version of ORBACUS Names is also available as a native Windows NT service ntnameservice h help i install s start install 136 ORBacus
134. aving advantages and disadvan ORBacus 255 Concurrency Models 18 1 3 16 2 18 2 1 tages For example applications using callbacks must have a concurrency model that allows nested method invocations to avoid deadlocks Other applications must be opti mized for speed in which case a concurrency model with the least overhead will be cho sen Some ORBs are highly specialized providing only the most frequently used concurrency models for a specific domain ORBACUS takes a different approach by supporting several concurrency models ORBacus Concurrency Models Overview ORBACUS allows different concurrency models to be established for the client and server activities of an application The client side concurrency models are Blocking Reactive and Threaded The server side concurrency models are Reactive Threaded Thread per Client Thread per Request and Thread Pool Single Threaded Concurrency Models Blocking Clients The blocking concurrency model is the simplest one It only applies to the client side and means that the ORB blocks while sending requests A special case are oneway requests which do not block the ORB If the ORB determines that sending the oneway request would cause blocking it puts the oneway request into a request buffer Whenever the client tries to send another request to the same server this buffer s contents are sent first Because of its simplicity the blocking concurrency model is t
135. ayed in the other one Using two windows you can easily transfer bindings from one context to another using Cut amp Paste Complete naming contexts can be loaded from a special file with naming context informa tion Such a file which was previously created with Save Context As is loaded with Load Context The bindings saved to this file are added to the current naming context When saving a naming context the console checks each context for accessibility If a con text cannot be accessed i e if its contents cannot be saved a message is displayed in the error window You also get an error message if the console detects a recursion The bind ings contained in the naming context leading to the recursion is not saved Use Save IOR to File in order to create a file that contains the stringified IOR of the cur rently selected binding or context With Close Window the current window is closed Closing the last window causes the application to terminate Exit can be used to terminate the application regardless of how many windows are open ORBacus 151 ORBacus Names Console 10 2 2 The Edit Menu The operations in this menu provide the means for creating and deleting objects and for changing the Naming Service structure New Context Creates a new naming context New Binding Creates a new binding for an object Delete Deletes the selected items Link Creates a new binding for an existing naming context Unlink Unbinds
136. c tic tic tic EEG tic tic Lic UtcT UtcT UtcT long long utcNow long inaccuracy utcMin utcMax toJavaMillis UtcT utc toJavaMillis long time IntervalT toIntervalT long time long inaccuracy UtcT toUtcT long time long inaccuracy short tdf Ute toUtcT long time long inaccuracy Ute toUtcT IntervalT inter String toString UtcT utc String toTimeString UtcT utc String toString long time boolean lessThan UtcT a UtcT b boolean lessThanEqual UtcT a UtcT b boolean greaterThan UtcT a UtcT b boolean greaterThanEqual UtcT a UtcT b boolean equal UtcT a UtcT b boolean notEqual UtcT a UtcT b UtcT UtcT UtcT add UtcT a long t add long t UtcT a subtract UtcT a long t The maximum value of the TimeT type The maximum value of the 1naccuracyT type Return the current UTC time Return the minimum UTC time Return the maximum UTC time Return the equivalent POSIX time in milliseconds ORBacus 175 ORBacus Time 16 17 18 19 21 23 25 33 12 5 Ci 4 amp OS NH Oi X w I DH DAN DAK DOD Return the equivalent POSIX time in milliseconds Create an interval from a time value and its inaccuracy similar to UTC time to interval Create a UTC time from its different
137. cations Interface Reference E 5 Interface OCI CloseCB interface CloseCB An interface for a close callback object See Also TransportInfo Operations close cb void close cb in TransportInfo transport info Called before a connection is closed Parameters transport info The TransportInfo for the new closeion 332 ORBacus Interface OCI Connector E 6 Interface OCI Connector interface Connector An interface for Connector objects A Connector is used by CORBA clients to initiate a connection to a server It also provides operations for the management of IOR profiles See Also ConFactory Transport Attributes id readonly attribute ProtocolId ig The protocol id tag readonly attribute ProfileId tag The profile id tag Operations connect Transport connect Used by CORBA clients to establish a connection to a CORBA server It returns a Transport object which can be used for sending and receiving octet streams to and from the server Returns The new Transport object Raises TRANSIENT If the server cannot be contacted COMM FAILURE In case of other errors connect timeout Transport connect timeout in unsigned long timeout ORBacus 333 Open Communications Interface Reference Similar to connect but it is possible to specify a timeout On return the caller can test whether there was a timeout by checking whether a nil object reference was returned
138. ce 316 ORBacus ww Logger Reference Interface OB Logger interface Logger The ORBacus message logger interface Operations info void info in string msg Log an informational message Parameters msg The message error void error in string msg Log an error message Parameters ORBacus 317 Logger Reference msg The error message warning void warning in string msg Log a warning message Parameters msg The warning message trace void trace in string category in string msg Log a trace message Parameters category The trace category msg The trace message 318 ORBacus Open Communications Interface Reference E l Module OCI The Open Communications Interface OCI The definitions in this module provide a uniform inter face to network protocols This allows for easy plug in of new protocols or other communication mechanisms into ORBs that implement the OCI Furthermore protocol implementations need only to be written once and can then be reused with all OCI compliant ORBs For more information please see the OCI documentation Aliases BufferSeq typedef sequence lt Buffer gt BufferSeq Alias for a sequence of buffers IOR typedef IOP IOR IOR Alias for an IOR ProfileId typedef IOP ProfileId ProfileIg ORBacus 319 Open Communications Interface Reference Alias for a profile id ProfileId
139. ce 280 ORBacus The Bi directional OCI Plug in 19 6 5 Because the Bi directional plug in can be layered upon the IIOP plug in the IIOP config uration properties are still applicable See Chapter 4 for more information Several common scenarios are described in detail below Notes e In general the plug in should be initialized prior to resolving the RootPOA e The POA Manager returned by createPOAManager must be passed to create for all POAs you want associated with that POA Manager Scenario Server accepts only bi directional IIOP connections Solution Configure the Root POA Manager for bi directional IIOP As long as no other POA Manager is created the server will accept only bi directional connections Scenario Server accepts both regular and bi directional IIOP connections Solution Use the Root POA Manager for regular IIOP connections and create a new POA Manager for bi directional connections Remember that each POA Manager must be activated in order to dispatch requests to its POAs Scenario Client only accepts connections on existing outgoing bi directional connections Solution Use the Root POA Manager in client mode i e do not listen on a port This is accomplished by setting the ooc bidir mode property to client For details on how to create POA Managers see Creating POA Managers on page 65 A complete example of using the Bi directional plug in is provided in the subdirec
140. ce must be registered with the Connector Factory Registry and concrete implementations of Acceptor Factory must be registered with the Acceptor Factory Registry 19 3 OCI Reference This chapter does not contain a complete reference of the OCI It only explains OCI basics and in the remainder of this chapter how it is used from the application programmer s point of view for the most common tasks For more information on how to use the OCI to write your own protocol plug ins and for a complete reference please refer to Appendix E 19 4 OCI for the Application Programmer The following information only applies to the standard ORBACUS IIOP plug in For other plug ins please refer to the plug in s documentation 19 4 1 A Converter Class for Java As you will see in the following examples the OCI info objects return port numbers as IDL unsigned short values and IP addresses as an array of 4 IDL unsigned octet values This works fine for C but in Java this causes a problem because there are no unsigned types in Java The Java mapping simply maps unsigned types to signed types Consider for example the IP address 126 127 128 129 In Java the OCI will return this as 126 127 128 127 because 128 and 129 if bit wise mapped to the Java byte type are 128 and 127 To avoid this problem we will use a helper class which converts port numbers and IP addresses to Java int types This helper class looks as follows 1 Java 2
141. ce IOR 000000000000001 a49444c3a4c656e64657 24 4656d6f Properties Name Value product id LOAN A1 rate 7 0 pct down 20 0 years 30 Note The Query Results dialog box cannot be used to edit offers 15 12 Connecting to a New Trader When the console is started the first console window to appear is already connected to the trader you specified using the command line options If you are managing multiple trad 240 ORBacus Connecting to a New Trader ers you can connect to a different trader with the Console Connect command The Con nect dialog appears as shown below Connect x Trader IOR IOR from file Link TestLink v OK Cancel There are three methods of connecting to the trader 1 To provide the stringified object reference select the Trader IOR option and paste the IOR into the text box 2 To obtain the stringified object reference from a file select IOR from file and enter the filename in the text box or click the Browse button to display a file selection dialog box 3 To connect to a linked trader select the Link option and choose the link from the drop down list Click OK to connect to the trader The contents of the current console window are updated to reflect the new trader Note If you want to be connected to two or more traders at the same time use the Con sole New Window command to create
142. ce The object keys and corresponding interface types are shown in Table 13 1 Object Key Interface Type Event CosEventChannelAdmin DefaultEventChannel Service EventChannel Typed Event CosTypedEventChannelAdmin ype DefaultTypedEventChannel YP Service TypedEventChannel Table 13 1 Primary Object Keys and Interface Types The object key can be used when composing URL style object references For example the following URL identifies the untyped event service running on host evhost at port 10000 corbaloc evhost 10000 DefaultEventChannel Refer to Chapter 6 for more information on URLs and configuring initial services ORBACUS Events also provides proprietary factory interfaces which allow construction and administration of multiple event channels in a single service The object keys and cor responding interface types of the factories are shown in Table 13 2 Object Key Interface Type Event OBE tCh lFact ven anne actory Channel DefaultEventChannelFactory Y EventChannelFactory Factory Typed Event OBT dE tCh lFact edEven annelFactory Channel DefaultTypedEventChannelFactory x TypedEventChannelFactory Factory Table 13 2 Factory Object Keys and Interface Types ORBacus 185 ORBacus Events 13 3 For a description of the factory interfaces please refer to the documented IDL files event idl OBEventChannelFactory idl and event idl OBTypedEventChannelFact
143. ce is TradingService which identifies an object of type CosTrading Lookup The object key can be used when composing URL style object references For example the following URL identifies the trading service running on host traderhost at port 10000 corbaloc traderhost 10000 TradingService Refer to Chapter 6 for more information on URLs and configuring initial services Using the Trading Service with the IMR The Trading Service may be used with the Implementation Repository IMR However if used with the IMR it is important to note that the corbaloc URL style object reference described in the previous section cannot be used If the IMR is used the object reference for the Trading Service must be created using one of the following methods where TradingServer refers to the server name configured with the IMR e start the Trading Service with the options ior ORBserver name TradingServer causing the Trading Service to print its reference to standard output e use the mkref utility mkref TradingServer TradingService TradingServicePOA When using the Trading Service with the IMR the service must be started with the option ORBserver_name TradingServer where TradingServer refers to the server name configured with the IMR When the IMR is configured to start the Trading Service this option is automatically added to the service s arguments However when the Trading Ser vice is started manually the option must be present For
144. ckage E java For I java the generated code looks as follows Java package M IDL M I 1 0 This is a comment related to interface I author Uwe Seimet version 1 0 public interface I extends org omg CORBA Object IDL M I S 1 0 The description for operation S param arg A dummy argument return A dummy string exception M IPackage E Raised under certain circumstances ORBacus 45 The ORBacus Code Generators public String S int arg EJ throws M IPackage l D Note that jid1 automatically inserts the fully qualified Java name for the exception 1 M IPackage Ein this case These are the contents of IPackage E java Java package M IPackage IDL M I E 1 0 This comment describes exception E final public class E extends org omg CORBA UserException public E Now you can use javadoc to extract the comments from the generated Java files and pro duce nicely formatted HTML documentation For additional information please refer to the javadoc documentation 46 ORBacus CHAPTER 4 ORB and Object Adapter Initialization 4 1 4 1 1 4 1 2 ORB Initialization Initializing the C ORB In C the ORB is initialized with CORBA ORB init For example C int main int argc char argv CORBA O
145. ct in a concrete programming language for example in C or Java This is done by writing an implementation class for the CORBA object and by instantiating this class The resulting implementation object is called a servant e Aclientthat wants to make use of an object implemented by a server creates an object that delegates all operation calls to the servant via the ORB Such an object is called a proxy When a client invokes a method on the local proxy object the ORB packs the input parameters and sends them to the server which in turn unpacks these parameters and invokes the actual method on the servant Output parameters and return values if any fol low the reverse path back to the client From the client s perspective the proxy acts just like the remote object since it hides all the communication details within itself A servant must somehow be connected to the ORB so that the ORB can invoke a method on the servant when a request is received from a client This connection is handled by the Portable Object Adapter POA as shown in Figure 5 1 ORBacus 75 CORBA Objects 5 2 AN O Rs lo Client Proxy Server Servant OA ORB Figure 5 1 Servants Proxies and the Object Adapter The Portable Object Adapter in ORBACUS replaces the deprecated Basic Object Adapter BOA The BOA was deprecated by the OMG becau
146. ction 344 ORBacus Interface OCI AccFactory E 12 Interface OCI AccFactory interface AccFactory An interface for an AccFactory object which is used by CORBA servers to create Acceptors See Also Acceptor AccFactoryRegistry Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute ProfileId tag The profile id tag Operations create acceptor Acceptor create acceptor in ParamSeq params raises InvalidParam Create an Acceptor using the given configuration parameters Refer to the plug in documenta tion for a description of the configuration parameters supported for a particular protocol Parameters params The configuration parameters Returns The new Acceptor Raises InvalidParam If any of the parameters are invalid ORBacus Open Communications Interface Reference get info AccFactoryInfo get info Returns the information object associated with the Acceptor factory Returns The Acceptor 346 ORBacus Interface OCI AccFactoryInfo E 13 Interface OCI AccFactoryInfo interface AccFactoryInfo Information on an OCI AccFactory object See Also AccFactory Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute ProfileId tag The profile id tag Operations describe string describe Returns a human readable description of the transport Returns The description
147. d A factory with the given protocol id already exists Members id The protocol id NoSuchFactory exception NoSuchFactory ProtocolId id No factory with the given protocol id could be found Members id The protocol id ORBacus 323 Open Communications Interface Reference E 2 Interface OCI Buffer interface Buffer An interface for a buffer A buffer can be viewed as an object holding an array of octets and a posi tion counter which determines how many octets have already been sent or received The IDL inter face definition for Buffer is incomplete and must be extended by the specific language mappings For example the C mapping defines the following additional functions Octet data Returns a C pointer to the first element of the array of octets which repre sents the buffer s contents Octet rest Similar to data this operation returns a C pointer but to the n th ele ment of the array of octets with n being the value of the position counter Attributes length readonly attribute unsigned long length The buffer length pos attribute unsigned long pos The position counter Note that the buffer s length and the position counter don t depend on each other There are no restrictions on the values permitted for the counter This implies that it s even legal to set the counter to values beyond the buffer s length Operations advance void advance in
148. d if ooc oa port property is not set ORBacus 245 The Interface Repository 16 2 16 3 Connecting to the Interface Repository The object key of the IFR is DefaultRepository which identifies an object of type CORBA Repository The object key can be used when composing URL style object references For example the following URL identifies the IFR running on host ifrhost at port 10000 corbaloc ifrhost 10000 DefaultRepository Refer to Chapter 6 for more information on URLs and configuring initial services Configuration Issues Although applications can interact with the IFR as with any other CORBA server it does have special status within the ORB Specifically use of the standard operation Object get interface requires the presence of an IFR PIDL interface Object InterfaceDef get interface The exact semantics of get interface can be a source of confusion In ORBACUS as with most other ORBs the get interface operation is a remote operation That is when client invokes get interface on an object reference the request is sent to the server The server knows the interface type of the object reference and interacts with the IFR to locate the appropriate CORBA InterfaceDef object to return to the client Therefore the server must be configured for the IFR It is not necessary to configure the client for the IFR if the client s only interaction with the IFR is via get i
149. de of the network firewall Otherwise anyone can mimic the IMR and cause an OAD to run any command they decide For additional security the information managed by the IMR may only be modified when the IMR is running in administrative mode That is e OAD registration and removal server registration and removal e modification of server attributes and e registration and removal are only possible when the IMR is running in administrative mode An attempt to modify the information managed by the IMR when it is not running in administration mode will result in CORBA NO PERMISSION exception 116 ORBacus Synopsis 722 7 2 1 Synopsis Usage The IMR and OAD are currently implemented using ORBACUS for C but ORBACUS for Java servers can also be launched by the IMR Both the IMR and OAD are contained in the imr server which may be started in one of three modes master Start only the IMR slave Start only the OAD dual Start both the IMR and OAD Command line usage is as follows imr 5 help v version m master s slave a administrative d database A admin port F forward port 5 slave port ORBacus 117 The Implementation Repository 7 2 2 Options h help version m master 5 slave a administrative d DIRECTORY database DIRECTORY A PORT admin port PORT F PORT forward
150. displays only modules and interfaces When you select an interface its identifier is displayed in the ID text box below Click OK to accept the identifier you have selected 4 Use the Add and Delete buttons to add and remove super types Clicking the Add button displays the Super Types dialog box as shown below Select any service types you wish to use as super types for the new type and click OK The order in which you add super types is not important Super Types x Select super types Mortgage OK Cancel 5 Use the Add Edit and Delete buttons to manipulate the properties for this service type Clicking the Add or Edit buttons displays the Property dialog box as shown 222 ORBacus Managing Service Types below Enter a name for the property select a property type and use the checkboxes to indicate the mode of this property Click OK to add the new property Property x Name Type boolean Mode i 1 Mandatory _ Read only OK Cancel 6 Click OK on the New Service Type dialog box to add the new service type 15 6 2 Removing a Service Type 15 6 3 To remove a service type do the following Select View Service Types to display the service types in the item list Select the service type you wish to remove Select Edit Delete A confirmation dialog appears Bop qe m Click Yes to permanently remove the service ty
151. ductory Java books Java public class Greeter public static void main String args System out printin Hello World ORBacus 17 Getting Started 2 2 2 3 2 3 1 Qj NH BH These applications simply print Hello World to standard output and that is exactly what this chapter is about Printing Hello World with a CORB A based client server applica tion In other words we will develop a client program that invokes a say hel1o opera tion on an object in a server program The server responds by printing Hello World on its standard output The IDL Code How do we write a CORBA based Hello World application The first step is to create a file containing our IDL definitions Since our sample application isn t a complicated one the IDL code needed for this example is simple IDL interface Hello void say hello An interface with the name 110 is defined An IDL interface is conceptually equivalent to a pure abstract class in C or to an interface in Java The only operation defined is say hello which neither takes any parameters nor returns any result Implementing the Example in C The next step is to translate the IDL code to C using the IDL to C translator Save the IDL code shown above to a file called He110 id1 Now translate the code to C using the following command idl Hello idl This command will create the files
152. e Four and simply Five Interface repository identifiers These names adhere to the format of interface repository identifiers The most common format is IDL prefix Module Interface X Y Note Although both naming formats follow interface repository conventions service type names are never used to lookup information in the interface repository 198 ORBacus Trading Service Concepts Interface Types An interface type describes the computational signature of the advertised service The interface type is a string whose format should be a scoped name or an interface repository identifier as described above for service type names When a new service is exported ORBACUS Trader may use the interface repository to confirm that the object being adver tised conforms to the interface defined by the interface type Property Types A service type can have zero or more property types representing additional information that can be associated with an advertised service A property type definition consists of a name a value type and a mode The value type is a CORBA TypeCode and the mode indicates whether a property is mandatory and whether it is read only The property modes have the following semantics e Mandatory The exporter must provide a value for a mandatory property at the time the service is exported Mandatory properties cannot be removed e Read only Once an exporter has supplied a value for a r
153. e 48 bit inaccuracy value Represents a time interval Enumerations Enumerations used by the Time Service are declared in the CosTime module An over view of the various enumerations follow IDL module CosTime enum ComparisonType IntervalC MidC enum TimeComparison TCEqualTo TCLessThan TCGreaterThan r CIndeterminate enum OverlapType OTContainer OTContained OTOverlap ORBacus 169 ORBacus Time 21 22 23 16 21 12 3 4 12 3 5 UNAK OTNoOverlap This enumeration defines two types of time comparisons IntervalC comparisons take into account the error envelope MidC comparisons ignore the error envelope and per forms the comparison based solely on the time values This enumeration defines the possible results of a time comparison MidC comparisons can never result in TCIndeterminate IntervalC comparisons result in TCIndeterminate if the error envelops overlap This enumeration defines the type of overlap between two intervals e OTContainer implies that interval A wholly contains interval B The overlap interval is equal to interval B e OTContained implies that interval B wholly contains interval A or intervals A and B are equal The overlap interval is equal to interval A Note the specification does not define the result comparing equivalent intervals e OTOverlap indicates that neither interval wholly contains the other but
154. e Concepts exception ChannelNotAvailable interface EventChannelFactory CosEventChannelAdmin EventChannel create channel in ChannelId id raises ChannelAlreadyExists CosEventChannelAdmin EventChannel get channel by id in ChannelId id raises ChannelNotAvailable ChannelldSeq get channels void shutdown The OBTypedEventChannelFactory TypedEventChannelFactory interface describes the factory for typed event channels IDL module OBTypedEventChannelFactory interface TypedEventChannelFactory CosTypedEventChannelAdmin TypedEventChannel create channel in OBEventChannelFactory ChannelId id raises OBEventChannelFactory ChannelAlreadyExists CosTypedEventChannelAdmin TypedEventChannel get channel by id in OBEventChannelFactory ChannellId id raises OBEventChannelFactory ChannelNotAvailable OBEventChannelFactory ChannelldSeq get channels void shutdown At start up the untyped Event Service creates a single channel having the identifier DefaultEventChannel and the typed Event Service creates a single channel having the identifier DefaultTypedEventChannel A channel s identifier also serves as its object key therefore a channel can be located using a corbaloc URL see corbaloc URLs ORBacus 189 ORBacus Events on page 105 For example a channel with the identifier Telemet r
155. e Type Repository IOR From file IOR 000000000000003649444c3aBf6d67 2e8f7 267 2143617 354 Supports modifiable properties If enabled the trader considers offers with modifiable properties that is properties that are not read only during a query unless the importer requests otherwise with the use modifiable properties policy If disabled the trader does not consider offers with modifiable properties regardless of the importer s wishes This setting also deter mines the behavior of the modi y operation in the CosTrading Register interface If enabled the server allows modification of offers If disabled the modify operation raises the Not Implemented exception Supports dynamic properties If enabled the trader considers offers with dynamic properties during a query unless the importer requests otherwise with the use dynamic properties policy If disabled the trader does not consider offers with dynamic properties regardless of the importer s wishes The trading service specification does not define the behavior of a trader when this option is disabled and an offer is exported that contains dynamic properties however ORBACUS TRADER always accepts offers containing dynamic properties Supports proxy offers If enabled the trader considers proxy offers during a query unless the importer requests otherwise with the use proxy offers policy If disabled the trader does not consider proxy offers regardless o
156. e bzrurer dsj Firing Gophed pdemsenphe esr prumer de Fiii 3opeel Lous SRE Care 1 iis F Sop drgmassopha car frulxr dg i I SppEsd Lnks scftwars bzukmr da pphksd idsmimaphe smr rzuker ds U iLuks apfrmare pruer dej a Figure 10 2 The Ping Window non existent operation returns true for a particular object the corresponding bind ing is automatically removed Clean up should be used with care The Toolbar In addition to the operations offered by the menu bar some frequently needed functions are available by icons located in the toolbar as shown in Figure 10 3 i 4 Bale XX Figure 10 3 A closer look at the toolbar The icon on the toolbar s left is the Upwards icon which changes the naming context to the parent of the context currently being displayed The next five icons correspond to the New Context New Binding Cut Copy Paste and Delete items as described in The Edit Menu on page 152 ORBacus 155 ORBacus Names Console 10 4 The Simple List and Details items from the View menu are the next two icons in the toolbar They determine whether the binding table displays only the ID and Kind fields or if ORBACUS Names is available also the date and time the binding was last modified The last item in the menubar corresponds to the Refresh operation from the View menu The Popup Menu When selecting an item in the binding table or a tree n
157. e item at a time If more than one item is currently selected the application uses the first of the selected items The View menu You use the View menu to select the type of items you wish to be displayed in the item list Selecting a new type of item from this menu is equivalent to changing the setting of the item type selector The Refresh command causes the application to retrieve an updated list of items from the trader and display them in the item list This command can be useful if you know or sus pect that the list of items has been changed by some other client of the trading service ORBacus 219 ORBacus Trader Console 15 4 4 The Insert menu 15 4 5 15 5 You use the Insert menu when you want to create a new item It displays a dialog box in which you can supply the information about the new item If you need to create a new item that is similar to an existing item you can also use the Edit Clone command The Tools menu The commands available in the Tools menu provide access to additional features of the trading service Query Perform query operations on the trader and review the matching offers Attributes Configure the trader attributes Withdraw Offers Removes offers using a constraint expression Mask Type Masks the selected service type Unmask Type Unmasks the selected service type The Toolbar The toolbar contains buttons for the most common menu commands New Item Copy Edit Query
158. e oad host tree server server name set server server name exec host args rundir mode activate_poas update timeout failure timeout max spawns value start server server name stop server server name reset server server name Register a server under the OAD specified by host with the given exec attribute Register a POA for the specified server Unregister an OAD Unregister a server Unregister a POA Get the status of an OAD Get the attributes and state information for a server Get the status of a POA List all OADs List all servers List all POAs Display all OADs servers and POAs in a tree like format Display an OAD and its associated servers and POAs in a tree like format Display a server and its associated POAs in a tree like format Set an attribute of a server e g set server srv max spawns 2 sets the max spawns attribute for the server srv to 2 Start a server Stop a server Reset a server Note that the imradmin utility also needs to be configured with the IMR initial reference see Connecting to the Service on page 121 The host argument is optional If host is not specified the local host name is used The server name argument refers to the name of the server The format of the poa name argument is poal poa2 poa3 where poa1 is a child of the Root POA poa2 is a child of 122 ORBacus Utilities 7 4 2 7 4 3 poa
159. e record identifiers Once the servant is activated calls to this on the servant return an object reference that contains the ID you assigned to the object Explicit Activation of Servants using Java Servant activation in Java also uses activate object for SYSTEM ID and activate object with id for USER ID With SYSTEM ID the code looks as fol lows I impl impl new I impl orb omg PortableServer POA poa impl default POA poa activate object impl For USER ID you must provide the Object ID I impl impl new I impl org omg PortableServer POA poa impl default POA byte id MyObjectName getBytes poa activate object with id id impl 88 ORBacus Deactivating Servants 5 5 5 5 1 5 5 2 5 5 3 Aa UNAK Wow NOR Deactivating Servants Deactivation of Servants using C A servant can be deactivated Deactivating a servant breaks the association between the CORBA object and the servant requests that arrive from clients thereafter result in an OBJECT_NOT_EXIST exception or a TRANSIENT exception if the server is down at the time a request is made To deactivate a servant call the deactivate object member function on the servant s POA ff C PortableServer POA var poa impl default POA PortableServer ObjectId var id poa gt servant to id amp impl poa deactivate object id The code obtains a reference to
160. e size exceeded inorThreadLimit Can t create new thread 20 1 6 COMM FAILURE Minor Exception Code MinorRecv failed MinorSend send failed MinorRecvZero returned zero inorSendZero send returned zero inorSocket socket failed inorSetsockopt setsockopt failed inorGetsockopt getsockopt failed inorBind bind failed MinorListen listen failed MinorConnect connect failed inorAccept accept failed inorSelect select failed inorGethostname gethostname failed inorGethostbyname gethostbyname failed inorWSAStartup WSAStartup failed MinorWSACleanup WSACleanup failed MinorNoGIOP Not a GIOP message 288 ORBacus CORBA System Exceptions MinorUnknownMessage Unknown GIOP message MinorWrongMessage Wrong GIOP message MinorMessageError Got a message error message MinorFragment Invalid fragment message MinorUnknownReqid Unknown request ID ORBacus 289 Exceptions and Error Messages 20 1 7 MARSHAL Minor Exception Code MinorNoValueFactory Unable to locate value factory MinorReadOverflow Input stream buffer overflow MinorReadBooleanOverflow Overflow while reading boolean MinorReadCharOverflow Overflow while reading char MinorReadWCharOverflow Overflow
161. ead only property that property cannot be modified A read only property can be removed e Mandatory and Read only A property that is both mandatory and read only must have a value when the service is exported and cannot subsequently be changed or removed A property that is neither mandatory nor read only is considered optional and can be changed and removed ORBACUS Trader accepts Java style identifiers as property names meaning a property name must start with a letter and may consist of letters numbers and underscores Super Types Service types can inherit from other service types which enables the definition of super types that encapsulate behavior and characteristics common to many service types When a new service type is created that has super types the trader performs several validation steps 1 super types must already exist in the service type repository 1 An object conforms to an interface if it implements that interface or if it implements a subclass of that interface ORBacus 199 ORBacus Trader 2 Any property type definitions in the new service type that have the same name as a definition in a super type must be compatible with the super type definition For two property definitions to be compatible their value types must match and the mode of the new definition must be the same as or stronger than the mode of the property in the super type 3 The interface type of the new service
162. ease note that services do not have access to network drives so the path to the database must be on a local hard drive ORBacus 137 ORBacus Names 9 1 3 9 1 4 Note If the executable for the Naming Service is moved it must be uninstalled and re installed Any trace information provided by the service will be placed in the Windows NT Event Viewer with the title NamingService To enable tracing information add the desired trace configuration property 1 ooc naming trace level property or one of the ooc orb trace properties to the HKEY LOCAL MACHINE NT registry key with a REG SZ value of at least 1 Configuration Properties In addition to the standard configuration properties described in Chapter 4 ORBACUS Names also supports the following properties ooc naming callback timeout SECS Equivalent to the c command line option ooc naming database FILE Equivalent to the d command line option ooc naming no updates Equivalent to the n command line option ooc naming port PORT Specifies the port number on which the service should listen for new connections Note that this property is only considered if the ooc oa port property is not set ooc naming timeout MINS Equivalent to the t command line option ooc naming trace_level LEVEL Defines the output level for diagnostic messages printed by ORBACUS Names The default level is 0 which produces no output A level of 1 or higher p
163. eater than the maximum value the importer s policy value is overridden and the maximum value is used instead Search cardinality The number of offers to be searched during a query The corresponding importer policy is search card Match cardinality The number of matched offers to be ordered during a query The corresponding importer policy is match card ORBacus 235 ORBacus Trader Console Return cardinality The number of ordered offers to be returned by a query The corresponding importer pol icy is return card Link hop count The depth of links to be traversed during a query The corresponding importer policy is hop count Link follow policy The trader s behavior when considering whether to follow a link during a query The default value is used if an importer does not specify a value for the 1ink follow rule policy The maximum value overrides the policy established for a link as well as the link follow rule policy proposed by an importer Maximum list count The maximum number of items to be returned from any operation that returns a list such as the list offers operation in CosTrading Admin or the next n operation CosTrading OfferIterator This attribute may override the number of items requested by a client 236 ORBacus Configuring the Trader Attributes 15 10 3Link Attributes Support Import Link Admin Maximum link follow policy Always v Maxi
164. ed Object References The CORBA specification defines two operations on the ORB interface for converting object references to and from strings IDL module CORBA interface ORB string object_to_string in Object obj Object string to object in string ref Using stringified object references is the simplest way of bootstrapping your first object reference In short the server must create a stringified object reference for an object and make the string available to clients A client obtains the string and converts it back into an object reference and can then invoke on the object The examples discussed in the sections below are based on the IDL definitions presented at the beginning of this chapter Using a File One way to publish a stringified object reference is for the server to create the string using object_to_string and then write it to a well known file Subsequently the client can read the string from the file and use it as the argument to string to object This method is shown in the following C and Java examples First we ll look at the relevant server code C CORBA ORB var orb Get a reference to the ORB somehow B impl bImlp new B impl ORBacus 101 Locating Objects LUNAK PortableServer ServantBase var servant bImpl B var b bImpl gt this CORBA String var s orb gt object to string b ofstream out object ref o
165. ed in the IMR using a host name The IMR also maintains the status of each OAD If the OAD is running and in a ready state it will have a status of up otherwise its status will be down Servers Servers are registered with a name that is unique within the domain and the host corre sponding to the OAD that is responsible for the server Since the name is unique within the domain it is not currently possible to register the same server with multiple OADs The server name that is registered in the IMR can be any string but it must be the same as the name used by the server 1 the name specified by the ORBserver name option or equivalent property The attributes of a server that are stored by the IMR are summarized below host The host corresponding to the OAD that is responsible for the server exec The path of server executable the exe extension must be included on Windows platforms If this attribute is not set then the IMR will not activate the server 114 ORBacus Background args The arguments to be supplied when startingthe server executable Note that ORBserver name server name is automatically appended to the arguments before the server process is started rundir The directory that the server process will be started from If this attribute is not set then the server process will be started from the root directory mode The activation mode The possible values are shared only one server proces
166. egation Java public class A impl implements AOperations public void op a public class B_impl implements BOperations public void op b public class I impl extends B_impl implements IOperations public void op_a public void op i Class A impl is defined as implementing AOperations Class B impl is defined as implementing BOperations Class I impl inherits the implementation of op b from B impl and provides an imple mentation of op a and op Since a Java class can only extend one class it s not possi ble for I impl to inherit the implementations of both a and op b Creating Servants Servants are created the same way in both C and Java once your servant class is writ ten you simply instantiate a servant with nex ORBacus 83 CORBA Objects 5 3 1 UNAK Aa UNAK Creating Servants using C Here is how to create servants using C C I impl servant pointer new I impl I impl another servant pointer new I impl Two servants are created with new Note that this merely instantiates the servants but does not inform the ORB that these servants exist yet The ORB server side run time only learns of the existence of the servants once you activate them In case the servant class was written using the delegation approach an object of the class implementing I s operations must be passed to the servant s constructor
167. eives the timestamp and returns it to the caller ORBACUS Time prevents this problem from occurring by requiring a Time Service imple mentation in every address space that will need to make Time Service calls Synopsis Usage As stated in 12 1 2 ORBACUS Time can only be used as a collocated server so there is no server executable In C the Time Service is initialized with OB TimeServiceInit which is declared in OB TimeService h For example C int main int argc char argv CORBA ORB_var orb CORBA ORB_init argc argv OB TimeServicelInit orb argc argv In Java the Time Service is initialized in a similar manner Java public static void main String args java util Properties props System getProperties props put org omg CORBA ORBClass com ooc CORBA ORB props put org omg CORBA ORBSingletonClass com ooc CORBA ORBSingleton 166 ORBacus Time Service Concepts 12 2 2 12 2 3 12 3 12 3 1 org omg CORBA ORB orb org omg CORBA ORB init args null com ooc CosTime TimeService init orb args To obtain a reference to the Time Service after initialization the client must invoke resolve initial references TimeService onthe ORB In addition to the standard command line arguments described in Chapter 4 clients that use ORBACUS Time accept the following command line option TIMEinaccuracy VALUE Specifies the inaccuracy o
168. ementation for example to OCI IIOP Connec torInfo in case the plug in implements See Also Connector Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute ProfileId tag The profile id tag Operations describe string describe Returns a human readable description of the transport Returns The description add connect cb void add connect ConnectCB cb Add a callback that is called whenever a new connection is established If the callback has already been registered this method has no effect Parameters 336 ORBacus Interface OCI ConnectorInfo cb The callback to add remove connect cb void remove connect cb in ConnectCB cb Remove a connect callback If the callback was not registered this method has no effect Parameters cb The callback to remove ORBacus 337 Open Communications Interface Reference E 8 Interface OCI ConnectCB interface ConnectCB An interface for a connect callback object See Also ConnectorInfo Operations connect cb void connect cb in TransportInfo transport info Called after a new connection has been established If the application wishes to reject the con nection CORBA NO PERMISSION may be raised Parameters transport info The TransportInfo for the new connection 338 ORBacus Interface OCI Acceptor E 9 Interface OCI Acceptor int
169. ency policy This policy is used to control how strict the ORB is in enforcing location transparency This is useful for performance reasons Attributes value read LOCA LOCA LOCA mance reason will be ignor only a ION ION ION ttribu RANSPA RANSPA ed and p RANSPA te short value R R RENCY_STRICT ENCY_STRICT ensures strict location transparency is followed ENCY_RELAXED relaxes the location transparency guarantees for perfor s Specifically for collocated method invocations the dispatch concurrency model olicy overrides are not removed The default value is ORBacus 307 ORBacus Policy Reference Interface OB ProtocolPolicy interface ProtocolPolicy inherits from CORBA Policy The protocol policy This policy is used to force the selection of a specific protocol Attributes value readonly attribute OCI ProtocolId value Ifa ProtocolPolicy is set then the protocol with the given identifier will be used if possible If it is not possible to use this protocol a CORBA NO_RESOURCES exception will be raised By default the ORB chooses the protocol to be used 308 ORBacus Interface OB RequestTimeoutPolicy B 7 Interface OB RequestTimeoutPolicy interface RequestTimeoutPolicy inherits from CORBA Policy The request timeout policy This policy can be used to specify a maximum time limit for reques
170. entation object 296 ORBacus Boot Manager Reference Interface OB BootManager interface BootManager Interface to manage bootstrapping of objects Exceptions NotFound exception NotFound This exception indicates that a binding has not been found Already Exists exception AlreadyExists This exception indicates that a binding already exists ORBacus 297 Boot Manager Reference Operations add binding void add binding in PortableServer ObjectId oid in Object obj raises AlreadyExists Add a new binding to the internal table Parameters oid The object id to bind obj The object reference Raises AlreadyExists Thrown if binding already exists remove binding void remove binding in PortableServer ObjectId oid raises NotFound Remove a binding from the internal table Parameters oid The object id to remove Raises NotFound Thrown if no binding found set locator void set locator in BootLocator locator Set the BootLocator The BootLocator is called when a binding for an object id does not exist in the internal table Parameters locator The BootLocator reference See Also BootLocator 298 ORBacus Interface OB BootLocator A 2 Interface OB BootLocator interface BootLocator Interface used by BootManager to assist in locating objects See Also BootManager Operations locate void locate
171. ents of the URL are as follows e iiop This is the default protocol for corbaloc URLs and therefore is optional e version The version number in ma jor minor format The default is 1 0 e host The hostname of the server e port The port on which the server is listening The default is 2089 e object key A stringified object key The specification allows a URL to contain multiple addresses but the semantics are ven dor specific In ORBACUS each address is used in turn until one is found that works or until the ORB has tried them all and failed to contact the object The rir protocol is a shortcut for the ORB operation resolve initial references The corbaloc URL for the rir protocol has the following structure corbaloc rir id The components of the URL are as follows e rir The protocol ORBacus 105 Locating Objects DN Nnm Co 1 id The identifier of the service to be resolved The identifier NameService is used if idis not supplied Some examples of corbaloc URLs are corbaloc nshost 10000 NameService corbaloc myhost 10000 MyObjectId corbaloc rir NameService In the above examples NameService and MyOb ject 1d are used as object keys Nor mally object keys contain the information necessary to uniquely identify a POA and a ser vant within the POA However the object keys used above do not contain information which identifies both the POA and the ser
172. er view of the various structure follow IDL module TimeBase unsigned long long TimeT unsigned long long InaccuracyT short TdfT struct TimeT time unsigned long inacclo unsigned short inacchi TdfT tdf struct IntervalT imeT lower_bound imeT upper bound 168 ORBacus Time Service Concepts 14 18 12 3 3 AN Qt No AN An absolute or relative time The value of inaccuracy in an absolute or relative time in units of 100 nanoseconds The inaccuracy defines an error envelope around a time value that has a lower bound of max 0 time inaccuracy andan upper bound of min maximum time time inaccuracy Only the first 48 bits of the 64 available bits are used to hold inaccuracy Using a value requiring more than 48 bits as an inaccuracy argument of a Time Service operation will raise a CORBA BAD PARAM exception The time displacement factor is in the form of minutes of displacement from the Green wich Meridian Displacements East of the meridian are positive and displacements West are negative Hence adding the time displacement factor to an absolute time will give the time in the local time zone Represents an absolute or relative time along with its associated inaccuracy and time dis placement factor Note that inacclo and inacchi together make th
173. eral respects the client program is similar to the server program The code to initial ize and destroy the ORB is the same C include lt OB CORBA h gt include lt Hello h gt include lt fstream h gt int run CORBA ORB ptr int main int argc char argv Same as for the server int run CORBA ORB_ptr orb 1 If your application contains more than one object you do not need to save object references for all objects Usually you save the reference of one object which provides operations that can sub sequently return references to other objects 22 ORBacus Implementing the Example in C 15 16 17 18 19 20 21 22 23 24 29 26 27 22 24 2 3 3 const char refFile Hello ref ifstream in refFile char s 2048 gt gt s CORBA Object_var obj orb gt string to object s Hello var hello Hello narrow obj hello gt say hello return 0 In contrast to the server the client does not need to include He110 impl h Only the gen erated file Hello h is needed This code is the same as for the server The stringified object reference written by the server is read and converted to a CORBA Ob ject object reference It s not necessary to obtain a reference to the Root POA or its POA Manager because they are only needed by server applications The narrow operation generates a Hello object reference from the CORBA Object
174. erface Acceptor An interface for an Acceptor object which is used by CORBA servers to accept client connection requests It also provides operations for the management of IOR profiles See Also AccRegistry AccFactory Transport Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute ProfileId tag The profile id tag handle readonly attribute Handle handle The handle for this Acceptor Like with the handle for Transports the handle may only be used with operations like select A handle value of 1 indicates that the protocol plug in does not support selectable Transports Operations close void close Closes the Acceptor accept or listen may not be called after close has been called Raises COMM FAILURE In case of an error ORBacus 339 Open Communications Interface Reference listen void listen Sets the acceptor up to listen for incoming connections Until this method is called on the accep tor new connection requests should result in a connection request failure Raises COMM FAILURE In case of an error accept Transport accept in boolean block Used by CORBA servers to accept client connection requests It returns a Transport object which can be used for sending and receiving octet streams to and from the client Parameters block If set to TRUE the operation blocks until a new connection has been accepted If set t
175. ermitted INTERNAL Internal error in ORB ARSHAL Error marshalling a parameter or result INITIALIZE Failure when initializing ORB O_IMP LEMENT Operation implementation unavailable Table 20 1 Standard CORBA System Exceptions ORBacus 283 Exceptions and Error Messages BAD TYPECODE Bad typecode I BAD OPERATION Invalid operation NO RESOURCES Insufficient resources for a request NO RESPONSI LH Response to a request is not yet available PERSIST STORI E Persistent storage failure BAD_INV_ORDER Routine invocation out of order TRANSIE Transient failure request can be reissued FREE_ME Cannot free memory INV_IDE Invalid identifier syntax INV_FLAG Invalid flag was specified INTF_REPOS Error accessing interface repository BAD_CONTEXT Error processing context object OBJ_ADAPTER Failure detected by object adapter DATA_CONVERS ION Error in data conversion OBJECT_NOT_EXIST Non existent object references should be discarded RANSACTION_REQUIRED Active transaction context required TRANSACTION_ROLLEDBACK Transaction has rolled back or is marked to be rolled back INVALID_TRANSACTIO Invalid transaction context INV_POLICY Invalid Policy CODESET_INCOMPATIBLE Incompatible client and serve
176. ers 187 Event Loop 7 1 Event Service 181 Event Suppliers 187 Exceptions 283 H Hostname 100 271 HTML 41 ORBacus 365 l IFR 243 HOP Configuration 55 Installation 51 Implementation Repository 113 Implementation Repository Administration 121 IMR 113 IMR Console 131 included IDL files 40 Initial Services 108 Configuring 110 Resolving 108 Interface Repository 243 IP Address 272 274 irdel 247 irfeed 246 J javadoc 44 JDK 1 2 48 M mailing list 16 N Name Service Configuration 138 Initialization 142 Persistence 138 Names Console 149 Netscape 72 113 Object Activation Daemon 113 Object Adapter Configuration 53 Initialization 48 Object Key 101 366 ORBacus Object References 97 Objects Locating 97 Persistent 89 Transient 89 oct 267 Acceptor 268 Acceptor Factory 268 Bi directional Plug in 277 Connector 268 Connector Factory 268 Plug in 275 Info Objects 268 Registries 268 Transport 268 Open Communications Interface 267 Options hid 37 idl 32 irgen 39 jidi 36 38 ORB Configuration 49 Destruction 70 Initialization 47 ORBacus Names 135 P POA 76 116 POA Manager 65 Creating 65 Root POA Manager 67 Policies 249 ConnectionReusePolicy 250 ConnectTimeoutPolicy 250 InterceptorPolicy 250 LocationTransparencyPolicy 250 ProtocolPolicy 250 ORBacus 367 RequestTimeoutPolicy 250 RetryPolicy 251 TimeoutPolicy 251 Popup Menu 156 Port
177. erver The thread pool model uses threads from a pool to carry out requests so that threads have to be created only once and can then be reused for other requests Figure 18 7 shows an Client Thread Pool Server Figure 18 7 Thread Pool Server example with one client and a thread pool server with three threads in the pool Sender and receiver threads are not shown The first three operation calls g and h can be car ried out immediately since there are three threads in the pool However the fourth request iis delayed until at least one of the other requests returns Since there is no time consuming thread creation the thread pool concurrency model per forms better than the thread per request model The thread pool is a good trade off if on 262 ORBacus Selecting Concurrency Models 16 4 18 5 18 5 1 18 5 2 the one hand frequent thread creation and destruction result in unacceptable performance but on the other hand delaying the execution of concurrent method calls is also not desired Selecting Concurrency Models Concurrency models can be selected either by properties or command line parameters see Chapter 4 The default concurrency models are shown in Table 18 1 Client Server Java Blocking Threaded Blocking Reactive Table 18 1 Default Concurrency Models The Reactor What is a Reactor In reactive mode see Reactive Clie
178. ervice must be created using one of the following methods where PropertyServer refers to the server name configured with the IMR e start the Property Service with the options ior ORBserver name PropertyServer causing the Property Service to print its reference to standard output e use the mkref utility mkref PropertyServer PropertyService PropertyServicePOA When using the Property Service with the IMR the service must be started with the option ORBserver_name PropertyServer where PropertyServer refers to the server name configured with the IMR When the IMR is configured to start the Property Service this option is automatically added to the service s arguments However when the Property Service is started manually the option must be present For further information on config uring a service with the IMR refer to Getting Started with the Implementation Reposi tory on page 124 Property Service Concepts Creating Properties A property handled by the CORBA Property Service consists of two components the property s name and its value The name is a CORBA string and the associated value is represented by a CORBA Any IDL typedef string PropertyName struct Property PropertyName property_name any property_value New properties are created using a factory object implementing the PropertySet inter face A new property is created using the de ine property operation IDL
179. es props put org omg CORBA ORBClass com ooc CORBA ORB props put org omg CORBA ORBSingletonClass com ooc CORBA ORBSingleton ORB orb ORB init args props Object Adapter Initialization Initialization of the Object Adapter In ORBACUS the object adapter is not initialized until the Root POA is first resolved For example C CORBA Object_var poaObj orb gt resolve initial reference RootPOA 48 ORBacus Configuring the ORB and Object Adapter 4 3 4 3 1 Java org omg CORBA Object poaObj orb resolve_initial_references RootPOA Upon completion the ORB will have created the Root POA and its POA Manager and will have initialized the ORB s server side functionality Configuring the ORB and Object Adapter ORBACUS applications can tailor the behavior of the ORB and object adapters using a col lection of properties These properties can be defined in a number ways e using the Windows Registry Windows NT C e using a configuration file using system properties Java e using command line options programmatically at run time The ORBACUS configuration properties are described in the sections below Unless other wise noted every property can be used in both C and Java applications ORB Properties ooc config Value filename Selects the default configuration file This property is only available in Java applications and is equivale
180. es for details Running the Application Our Hello World application consists of two parts the client program and the server program The first program to be started is the server because it must create the file Hello ref that the client needs in order to connect to the server As soon as the server is running you can start the client If all goes well the Hello World message will appear on the screen Implementing the Example in Java In order to implement this application in Java the interface specified in IDL is translated to Java classes similar to the way the C code was created The ORBACUS IDL to Java translator jid1 is used like this jidl package hello Hello idl This command results in several Java source files on which the actual implementation will be based The generated files are Hello java HelloHelper java HelloHolder java HelloOperations java HelloPOA java and _HelloStub java all generated in a directory with the name hello Implementing the Server The server s Hello implementation class looks as follows Java package hello public class Hello_impl extends HelloPOA public void say hello System out printin Hello World 24 ORBacus Implementing the Example in Java DGS CQ C www lv lv e be s b b bk bk kk At WHE DH AN DA GAA OH DN DOS lo
181. f the Hello_imp1 class 20 ORBacus Implementing the Example in C 16 I 19 22 24 34 36 AN Dos WN N Nl NH NH NH HH iX DH DAN DAK A forward declaration for the run function The first thing a CORBA program must do is initialize the ORB This operation expects the parameters with which the program was started These parameters may or may not be used by the ORB depending on the CORBA implementation ORBACUS recognizes cer tain options that will be explained later The run helper function is called This code catches and prints all CORBA exceptions raised by ORB init or run If the ORB was successfully created it is destroyed This releases the resources used by the ORB If destroy raises a CORBA exception this exception is caught and printed The exit status is returned If there was no error EXIT SUCCESS is returned or EXIT_FAILURE otherwise Now we write the run function C int run CORBA ORB ptr orb CORBA Object_var poaObj orb gt resolve initial references RootPOA PortableServer POA var rootPoa PortableServer POA narrow poaObj PortableServer POAManager var manager rootPoa gt the POAManager Hello impl helloImpl new Hello impl PortableServer ServantBase var servant helloImpl Hello var hello helloImpl gt _this
182. f the class declaration is unchanged The definition of the constructor and _default_POaA method follow C Hello impl Hello impl PortableServer POA ptr poa poa PortableServer POA duplicate poa PortableServer POA ptr Hello impl default POA ORBacus 127 The Implementation Repository return PortableServer POA duplicate poa The modified portion of the server program is shown below 1 2 3 int 4 run CORBA ORB ptr orb int argc E 6 CORBA Object_var poaObj 7 orb gt resolve_initial_references RootPOA 8 PortableServer POA_var rootPoa 9 PortableServer POA narrow poaObj 10 11 PortableServer POAManager var manager 12 rootPoa gt the POAManager 14 CORBA PolicyList 2 15 pl length 2 16 pl 0 rootPOA gt create lifespan policy 17 PortableServer PERSISTENT 18 pl 1 rootPOA gt create id assignment policy 19 PortableServer USER ID 20 21 PortableServer POA var helloPOA 22 rootPOA gt create_POA hello manager pl 23 24 Hello impl helloImpl new Hello impl helloPOA 25 PortableServer ServantBase var servant helloImpl 26 PortableServer ObjectId var oid 27 PortableServer string to ObjectId hello 28 helloPOA activate object with id oid servant 29 Hello var hello helloImpl gt _this 30 31 CORBA String var s orb gt object to string hello 32 ofst
183. f the importer s wishes This setting also determines the behavior of the proxy if attribute in the CosTrading SupportAttributes interface If 234 ORBacus Configuring the Trader Attributes enabled proxy if returns the reference of the server s CosTrading Proxy object If disabled proxy if returns nil Service Type Repository The IOR of the service type repository currently in use by the trader is displayed in the text box In order to change the service type repository you first need to select a method for specifying its object reference Select the IOR toggle if you want to paste the stringified IOR into the text box If you want the application to read the reference from a file select From file and enter the filename in the text box or click the Browse button to display a file selection dialog box 15 10 2Import Attributes Default Maximum Search cardinality 2147483647 2147483647 Match cardinality 2147483647 2147483647 Return cardinality 2147483647 2147483647 Link hop count 5 2147483647 Link follow policy Always v Always Maximumlistcount 2147483647 Many of the Import attributes have default and maximum values The default value is used if an importer does not supply a value for the corresponding importer policy The maxi mum value is used as the allowable upper limit for the importer policy If an importer sup plies a policy value that is gr
184. f time in 100 nanosecond units The default is 0 Configuration Properties In addition to the standard configuration properties described in Chapter 4 ORBACUS Time also supports the following property ooc time inaccuracy VALUE Equivalent to the TIMEinaccuracy command line option CLASSPATH Requirements ORBACUS Time for Java requires the classes in OB jar and OBTime jar Time Service Concepts The section presents an overview of the Time Service specification For details refer to 9 ORBACUS specific extensions are also presented Representation of Time The Time Service uses the Universal Time Coordinated UTC representation from the X Open DCE Time Service Absolute UTC time is defined as follows Time units 100 nanoseconds 107 seconds ORBacus 167 ORBacus Time 12 3 2 1 2 3 4 5 6 7 8 3 10 11 12 13 14 15 16 17 18 19 Base time 15 Oct 1582 00 00 00 Approximate range AD 30 000 Absolute UTC time in the Time Service always refers to time in Greenwich Time GMT Zone Note that the base time used in the Time Service differs from the base time of the com monly used POSIX time representation The base time of the POSIX time representation is 1 January 1970 00 00 00 Relative UTC time is defined as follows Time units 100 nanoseconds 107 seconds Approximate range 30 000 Basic Types Data structures used by the Time Service are declared in the TimeBase module An ov
185. ference is invalid ctx CosNaming NamingContext _narrow obj if CORBA is_nil ctx This object does not implement NamingContext This is the equivalent to the Java version above Configuring the Initial Services When an application uses initial services that are not locality constrained the application must register the object references for these objects with the ORB ORBACUS supports the standard ORBInitRef and ORBDefaultInitRef command line options for register ing initial service object references ORBInitRef name URL ORBDefaultInitRef URL For example starting an application as shown below will enable the client to resolve the NameService initial reference myclient ORBInitRef NameService corbaloc nshost 10000 NameService The ORBconfig option is an alternative method for defining a list of initial services and is often preferable when a number of services must be defined See Configuring the ORB and Object Adapter on page 49 for more information on these command line options Also refer to the INS specification 10 for detailed information on the standard options ORBInitRef and ORBDefaultInitRef In addition to using command line parameters a program can add to the list of initial ser vices using the ORB operation register initial re ferencel IDL module CORBA interface ORB 1 This will become part of the ORB interface when the Portable Interceptor specification is
186. ffer contains e the object reference of an object implementing the CosTrading Lookup interface e boolean value if match 11 which indicates to the trader performing a query that it should consider this proxy offer a match if the service type matches In other words if this value is TRUE the trader does not need to evaluate the importer s constraint against the properties of this offer if the service type matches then the proxy offer is considered a match e aconstraint recipe which specifes how the trader should rewrite the query constraint before passing it to the proxy offer s target object Zero or more policies that the trader should pass on to the proxy offer s target object An importer can specify a policy during a query that causes the trader to exclude all proxy offers One of the common uses for proxy offers is wrapping a legacy application with a CORBA object that implements the CosTrading Lookup interface A single proxy offer is exported containing a reference to this wrapper object The object can implement the query operation to invoke the legacy application passing it the constraint expres sion The trader s ability to rewrite the query constraint helps to minimize the amount of work that needs to be done by the wrapper object The results returned by the legacy appli cation can be translated into service offers and returned to the importer ORBacus 209 ORBacus Trader 14 5 14 5
187. ffer dialog box appears as shown below SS Edit Offer Mortgage 1 x r Properties L Peer vawe down 20 0 F product id LOAN_B2 Dynamic rate 6 5 years 15 Reset OK Cancel You can modify a property by double clicking on the property value Press Return when you have finished editing a property value You can remove an existing property from the offer if it is an optional property by unchecking its checkbox Similarly you can add a property to the offer by checking its checkbox and entering a value for the property See the discussion of adding a new offer above for details on adding new properties and configuring dynamic properties Click OK to update the offer Withdrawing Offers There are two distinct ways to withdraw offers The first way is by selecting individual offers as outlined below 1 2 3 4 Select View Offers to display the offers in the item list Select the offer s you wish to withdraw Select Edit Delete A confirmation dialog appears Click Yes to withdraw the offers The above method is suitable for withdrawing a limited number of specific offers A more efficient method for removing a large quantity of offers for a single type or for removing ORBacus 227 ORBacus Trader Console offers without having to manually search for the right ones is by withdrawing offers with a constraint expression 1 Select T
188. final class Converter 3 if 4 static int port short s 5 6 if s lt 0 return Oxffff int s 1 8 else 9 return int s 10 11 12 static int addr byte bArray 13 14 int iArray new int 4 270 ORBacus OCI for the Application Programmer 15 16 17 18 19 20 21 22 23 19 4 2 DGS 9 4 DOR n DO for int 1 0 i 4 itt if bArray i lt 0 iArray i Oxff int bArray i 1 else iArray i int bArray i return iArray Converts short port numbers to int Converts byte IP addresses to int The converter class is used throughout the examples in the sections below Getting Hostnames and Port Numbers The following code fragments show how it is possible to find out on what hostnames and port numbers a server is listening First the C version C OCI AcceptorSeq var acceptors poaManager gt get acceptors for CORBA ULong i 0 i lt acceptors gt length i OCI AcceptorInfo var info acceptors i gt get info OCI IIOP AcceptorInfo var iiopInfo OCI IIOP AcceptorInfo narrow info if CORBA is nil iiopInfo CORBA StringSeq var hosts iiopInfo gt hosts CORBA UShort port iiopInfo gt port cout lt lt host lt lt host 0 lt lt endl cout lt lt port lt lt port lt lt endl The list of regis
189. flow while reading boolean array MinorReadCharArrayOverflow Overflow while reading char array MinorReadWCharArrayOverf Overflow while reading wchar array MinorReadOctetArrayOverflow Overflow while reading octet array MinorReadShortArrayOverf Overflow while reading short array MinorReadUShortArrayOverflow Overflow while reading ushort array MinorReadLongArrayOverflow Overflow while reading long array MinorReadULongArrayOverflow Overflow while reading ulong array MinorReadLongLongArrayOverflow Overflow while reading longlong array x MinorReadULongLongArrayOverflow Overflow while reading ulonglong array MinorReadFloatArrayOverflow Overflow while reading float array MinorReadDoubleArrayOverflow Overflow while reading double array MinorReadLongDoubleArrayOverflow Overflow while reading longdouble array MinorReadInvTypeCodeIndirection Invalid type code indirection MinorWriteObjectLocal Attempt to marshal a locality constrained object MinorLongDoubleNotSupported Long double is not supported ORBacus 291 Exceptions and Error Messages 20 1 8 NO IMPLEMENT Minor Exception Code MinorMissingLocalValueImplementation Missing local value implementation MinorIncompatibleValueImplementationVersion Incompatible value implementation version 20 1 9 NO_RESOUR
190. fresh item of the View menu The toolbar is shown below in Figure 8 1 Da xe gt When selecting an OAD server or POA with the right mouse button a popup menu with a choice of operations will be displayed as shown in Figure 8 2 This popup menu provides Create Modify Delete Cut Start Reset Refresh Figure 8 2 The popup menu the same operations as the toolbar 134 ORBacus CHAPTER 9 ORBacus Names 9 1 9 1 1 A CORBA object is often represented by an object reference in the form of a stringified IOR a lengthy string that is difficult to read and cumbersome to use It is much more nat ural to think of an object in terms of its name which is a core feature of the CORBA Nam ing Service In the Naming Service objects are registered with a unique name which can later be used to resolve their associated object references ORBACUS Names is compliant with 10 This chapter does not provide a complete description of the service It only provides an overview suitable to get you started For more information please refer to the specification Synopsis Usage ORBACUS includes functionally equivalent implementations of the Naming Service in C and Java C nameserv h help v version i ior n no updates s start d database FILE t timeout MINS c callback timeout SECS ORBacus 135 ORBacus Names J
191. fying the object reference of the target CosTrading Lookup object for this proxy offer Select the IOR toggle if you want to paste the stringified interoperable object reference into the text box If you want the application to read the reference from a file select From file and enter the filename in the text box or click the Browse button to display a file selection dialog box Enter the constraint recipe in the text box Select If match all if a matching service type is all that is required for this proxy offer to be considered a match during a query Enter values for the properties in the Properties table All properties have a checkbox to the left of the property name For a mandatory property the checkbox is disabled meaning that a value must be provided for this property For an optional property you can use the checkbox to indicate whether this property should be included with the offer To enter a value for a property double click on the property value field For properties with sequence types you can enter multiple values by separating them with commas Press Return when you are finished entering the value for a property If you wish to add a property that is not defined by the service type click the Add button The Add Property dialog box appears as shown in Adding a New Offer on page 224 Enter a name for the property select the property s type from the drop down list and enter a value in the text box
192. ger Resolve the POA Manager Factory Create a new POA Manager with the name MyPOAManager And in Java 66 ORBacus Using POA Managers 4 4 2 Java org omg CORBA Object obj orb resolve initial references POAManagerFactory com ooc OBPortableServer POAManagerFactory factory com ooc OBPortableServer POAManagerFactoryHelper narrow 0bj org omg PortableServer POAManager myPOAManager factory create poa manager MyPOAManager Resolve the POA Manager Factory Create a new POA Manager with the name MyPOAManager Now we can configure the IIOP port used by our new POA Manager with the following property ooc iiop acceptor MyPOAManager port 5001 When experimenting with various endpoint configurations it can be very useful to enable connection tracing diagnostics With diagnostics enabled the ORB will display its end point information allowing you to confirm that the application s endpoints are configured correctly Diagnostics can be enabled using the ORBtrace connections command line option or using the equivalent property ooc orb trace connections See Con figuring the ORB and Object Adapter on page 49 for more information on the supported configuration properties and command line options The Root POA Manager As its name suggests the Root POA Manager is the POA Manager of the Root POA The Root POA Manager is usually created by the ORB when resolve initial references is
193. ger host 54 ORBacus Configuring the ORB and Object Adapter 4 3 3 ooc orb poamanager manager numeric Deprecated See ooc iiop acceptor manager numeric ooc orb poamanager nanager port Deprecated See ooc iiop acceptor manager port ooc orb poamanager manager version Value 1 0 1 1 or 1 2 Specifies the GIOP version to be used in object references generated by a particular POA Manager This option is useful for backward compatibility with older ORBs that reject object references using a newer version of the protocol The default value is determined by the value of ooc orb oa version IIOP Properties An application can configure endpoints with properties having the prefix ooc iiop As with the object adapter properties described in the previous section IIOP properties are also grouped into global and POA Manager specific categories See Using POA Manag ers on page 65 for more information on POA Managers and their relationship to IIOP endpoints ooc iiop backlog Value 0 lt backlog lt 65535 Specifies the length of the queue for incoming connection requests Note that the operat ing system may override this setting if the value exceeds the maximum allowed by the operating system ooc iiop bind Value hostname or IP address Specifies that the server should bind its socket to a specific network interface If not speci fied the server will bind its socket to all available network interfaces Thi
194. guages including comparative functions substring matching set mem bership and mathematical and logical operators The most important aspect of the con straint language however is its ability to refer to the properties of a service offer enabling importers to include or exclude a potential service offer on the basis of its properties If the offer does not contain a property that is necessary in order to completely evaluate the con straint that offer is skipped Constraint expressions are restricted to operating only on properties of the following types e boolean short unsigned short long unsigned long float double char string sequences of the above types This restriction does not imply that more complex property types are forbidden However properties of complex types cannot be referred to in a constraint expression except in the context of the exist operator which simply tests for the existence of a property The simplest constraint is TRUE which evaluates to TRUE for every potential service offer effectively matching every offer that is considered Using this constraint importers have a simple means of obtaining all of the offers for a particular service type Using the example service type ServiceTypeB we can form a more complex constraint example name and cost lt 7 5 In this example we are searching for all offers of type ServiceTypeB where the name property contains the string Bill and
195. handler belongs to h The event handler s handle ORBacus 313 Reactor Reference unregister handler void unregister handler in EventHandler handler Remove an event handler from the Reactor Parameters handler The event handler to remove dispatch boolean dispatch in TypeMask type mask Dispatch events Parameters type mask If not zero this operation will return once all registered event handlers that match the type mask have unregistered Returns TRUE if all event handlers that match the type mask have unregistered or FALSE if event dispatching has been interrupted interrupt dispatch void interrupt dispatch Interrupt event dispatching After calling this operation interrupt will return with FALSI dispatch one event boolean dispatch one event in long timeout Dispatch at least one event Parameters timeout The timeout in milliseconds A negative value means no timeout i e the opera tion will not return before at least one event has been dispatched A zero timeout means that the operation will return immediately if there is no event to dispatch Returns TRUE if at least one event has been dispatched or FALSE otherwise event ready boolean event ready 314 ORBacus Interface OB Reactor Check whether an event is available Returns TRUI E if an event is ready or FALSI E otherwise ORBacus 315 Reactor Referen
196. he fastest model available There is no overhead neither for calls to operations like select because the ORB is allowed to block on a single connection nor for any thread creation or context switches 1 A oneway request is a request for which no reply is received Therefore a oneway request cannot return any results and there is no guarantee that a oneway request was properly executed by a server 2 select is used for synchronous I O multiplexing For more information see the select Unix manual page 256 ORBacus Single Threaded Concurrency Models 18 2 2 Reactive Clients and Servers Reactive servers use calls to operations like select in order to simultaneously accept incoming connection requests to receive requests from multiple clients and to send back replies This is shown in Figure 18 1 connect ME l accept dispatch a connect accept gt dispatch 1 disconnect DUCES c lt q close disconnect close Ly SSS L p Client A Server Client B Figure 18 1 Reactive Server Reactive clients also use operations like select to avoid blocking This means that while a request to a server is sent or a reply from that server is received the client can simulta neously send buffered requests to other servers or receive and buffer replies This is
197. ic ShutdownObject public PortableServer RefCountServantBase CORBA ORB var orb public ShutdownObject impl CORBA ORB ptr orb orb CORBA ORB duplicate orb ORBacus 71 ORB and Object Adapter Initialization 13 14 LS 16 Vy 18 T9 4 7 4 7 1 virtual void deactivate throw CORBA SystemException orb_ gt shutdown false servant class for Shut downOb ject is defined For more information on how to imple ment servant classes see Chapter 5 An ORB is needed to call shutdown The constructor initializes the ORB member deactivate calls shutdown on the ORB Note that shutdown is called with the argu ment false to avoid a deadlock A false argument instructs shutdown to terminate request processing without waiting for executing operations to complete A t rue argu ment instructs shutdown to return only once all operations have completed If shut down were to be called with a true argument in this example it would deadlock That is because shutdown true would be invoked from within an operation and therefore could not ever return The client can use the deactivate call as shown below Ef ShutdownObject var shutdownObj Get a reference somehow shutdownObj gt deactivate Applets Compatibility with Netscape The Java mapping in ORBACUS 4 uses the portable stream based stubs as specified in 6 These stubs are not compatible with Netscape s
198. implemen tation class I impl only inherits from the skeleton class and no implementation class inherits from impl It is not strictly necessary to have an implementation class for every interface For exam ple it is sufficient to only have the class implaslongas I impl implements all inter face operations including the operations of the base interfaces C class I impl virtual public POA I public virtual void op_a throw CORBA SystemException virtual void op_b throw CORBA SystemException virtual void op i throw CORBA SystemException Now I impl is only derived from but not from the other servant classes I impl must implement all operations from the interface 1 as well as the operations of all interfaces from which I is derived Inheritance using Java Several files are generated by the ORBACUS IDL to Java translator for an interface I including e I java which defines a Java interface I containing public methods for the operations and attributes of I and e IPOA java which is an abstract skeleton class that serves as the base class for servant classes 78 ORBacus Implementing Servants AND GOB HB Wo T5 In contrast to C Java s lack of multiple inheritance currently makes it impossible for a servant class to inherit operation implementations from other servant classes except when using
199. in PortableServer ObjectId oid out Object obj out boolean add raises BootManager NotFound Locate the object coresponding to the given object id Parameters oid The object id obj The object reference to associate with the id add Whether the binding should be added to the internal table Raises NotFound Raised if no binding found ORBacus 299 Boot Manager Reference 300 ORBacus ws ORBacus Policy Reference 1 Module OB Constants CONNECTION_REUSE_POLICY_ID const CORBA PolicyType CONNECTION_REUSE_POLICY_ID 1330577411 This policy type identifies the connection reuse policy CONNECT_TIMEOUT_POLICY_ID const CORBA PolicyType CONNECT_TIMEOUT_POLICY_ID 1330577416 This policy type identifies the connect timeout policy INTERCEPTOR_POLICY_ID const CORBA PolicyType INTERCEPTOR_POLICY_ID 1330577415 This policy type identifies the interceptor policy LOCATION_TRANSPARENCY_POLICY_ID const CORBA PolicyType LOCATION_TRANSPARENCY_POLICY_ID 1330577414 ORBacus 301 ORBacus Policy Reference This policy type identifies the location transparency policy LOCATION TRANSPARENCY RELAXED const short LOCATION TRANSPARENCY The LOCATION TRANSPARENCY LOCATION TRANSPARENCY STRICT const short LOCATION TRANSPAR ENCY STRICT D 1 RELAXED LocationTransparencyPolicy
200. in the ORB level policy manager object Add the policies to the ORB level policy manager And here is the same example in Java Java org omg CORBA Any boolAny orb create any boolAny insert boolean false org omg CORBA Policy policies new org omg CORBA Policy 1 policies 0 orb create policy com ooc OB CONNECTION REUSE POLICY value boolAny org omg CORBA PolicyManager pm org omg CORBA PolicyManagerHelper narrow orb resolve initial references ORBPolicyManager pm add policy overrides policies This is equivalent to the C version Connection Reuse Policy at Object Level And now the same example but at the object level C first Life CEF CORBA Any boolAny boolAny lt lt CORBA Any from boolean 0 CORBA PolicyList policies 1 policies length 1 252 ORBacus Programming Examples DN Oo DAN WwW NH La La 1 17 3 2 AN WH NH policies 0 orb gt create policy REUSE POLICY boolAny CORBA Object_var newObj obj gt set policy overrides policies CORBA ADD_OVERRIDES This is the same as in the example for the ORB level Set the policy on the object by using the set policy overrides method This method returns a new object that has the set of policies applied And here is the same example in Java Java org
201. in user code has the advantage of the user code not hav ing to take care of any kind of thread synchronization This means that the user code can be written as if for a single threaded system but without losing the advantage of the ORB optimizing its operation by using multiple threads internally The threaded concurrency model is still fast No calls to operations like select are required Time consuming thread creation is only necessary when a new client is connect ing but not for each request However thread context switching makes this approach slower than the reactive concurrency model at least on a single processor computer Thread per Client Server The thread per client server concurrency model is very similar to the threaded server con currency model except that the ORB allows one active thread per client in the user code This is shown in Figure 18 5 A s call to and B s call to g are carried out simultaneously each in its own thread However if A tries to call another operation h for example by sending requests from different threads in a multi threaded client or by using the DII oper ation send deferred in a single threaded client as long as f has not finished yet the execution of h is delayed until returns 260 ORBacus Multi Threaded Concurrency Models 90 h T Client Thread per Client Clien
202. include state ments for included files relative to the paths specified with the I option header dir DIR This option can be used to make include statements for header files relative to the spec ified directory 34 ORBacus Options for idl this header dir DIR Like the header dir option this option can be used to make include statements for header files relative to the specified directory However this option only applies to include statements for the header files of this IDL file other header dir DIR Like the header dir option this option can be used to make include statements for header files relative to the specified directory However this option only applies to include statements for the header files corresponding to IDL files that were included in this IDL file output dir DIR Write generated files to directory DIR file list FILE Write a list of all generated files to file FILE dll import DEF Put DEF in front of every symbol that needs an explicit DLL import statement with interceptors args Generate code with support for arguments result and exception list values for intercep tors no orb mediation By default invocations on collocated servants are mediated by the ORB Specify this option to disable ORB mediation no local copy To ensure strict compliance with CORB A s location transparency semantics the default behavior of the translator
203. ing the host running the imr server The ORBDefault InitRef command line option or the ooc orb default init ref configuration property may be used to configure the default initial reference For example given that the imr server is running on imr host then the client can be started with the option ORBDefaultInitRef corbaloc imr host When the client is configured with this default initial reference it may invoke resolve initial references foo on the ORB to obtain a reference to foo ORBacus 111 Locating Objects 112 ORBacus CHAPTER 7 The Implementation Repository The ORBACUS Implementation Repository IMR provides support for the indirect bind ing of persistent object references The key advantage of indirect binding is that it loosens the coupling between clients and servers so that the location of the server can change with out affecting the client In practical terms this is accomplished by providing the client with an IOR that actually refers to the IMR rather than to the server itself The IMR also provides the ability to start servers on demand using the Object Activation Daemon OAD The CORBA specification does not standardize how servers and the IMR interact it only suggests functionality for vendors to implement Hence the interface between servers and the IMR is strictly proprietary Due to the proprietary interface between servers and the IMR servers using the IMR must be developed using OR
204. initial amount of time in milliseconds that the service waits between successive retries The default value is 1000 A double that defines the factor by which the retry timeout property should be multiplied for each successive retry Defines the output level for event diagnostic mes sages printed by ORBACUS Events The default levelis 0 which produces no output A level of 1 or higher produces event processing information and a level of 2 or higher produces event creation and destruction information Defines the output level for lifecycle diagnostic messages printed by ORBACUS Events The default level is 0 which produces no output A level of 1 or higher produces lifecycle information e g creation and destruction of Suppliers and Consumers Equivalent to the t command line option ORBACUS Events generates diagnostic messages if the ooc orb trace level property 184 ooc event max_retries ooc event port port ooc event pull_interval msec ooc event reap_frequency sec ooc event retry_timeout msec ooc event retry_multiplier n ooc event trace events LEVEL ooc event trace lifecycle LEVEL ooc event typed servic Diagnostics is set to 2 ORBacus Connecting to the Service 13 1 5 CLASSPATH Requirements 13 2 ORBACUS Events for Java requires the classes in OB jar and OBEvent jar Connecting to the Service The object key of the Event Service depends on whether it is running as a typed or untyped servi
205. ion property 1 one of the imr trace properties or one of the ooc orb trace properties to the HKEY LOCAL MACHINE NT registry key with a REG SZ value of at least 1 ORBacus 119 The Implementation Repository 7 2 3 Configuration Properties In addition to the standard configuration properties described in Chapter 4 the IMR also supports the following properties ooc imr mode Value master slave dual Specifies the mode in which the imr server will be started ooc imr administrative Value true false If set to true then run the IMR in administrative mode For details refer to the a com mand line option ooc imr dbdir Value directory Equivalent to the d command line option ooc imr admin port Value port Equivalent to the A command line option oocimr forward port Value port Equivalent to the F command line option ooc imr slave_port Value port Equivalent to the s command line option ooc imr trace peer status Value level gt 0 120 ORBacus Connecting to the Service 7 3 7 4 7 4 1 Defines the output level for IMR diagnostic messages related to communications with the OADs The default level is 0 which produces no output ooc imr trace process control Value level gt 0 Defines the output level for IMR diagnostic messages related to the forking and death of server processes The default level is 0 which produces no output ooc im
206. ion reuse policy is set to t rue at some later point communications channels that were previously created with a connection reuse policy set to false will not be reused That is the connection reuse policy is sticky in the sense that the reuse policy that was in effect at the time that a communications channel is created stays with it Setting the reuse policy at the object level means that for a client the ORB will not reuse the commu nications channel that is associated with the proxy object Connection Reuse Policy at ORB Level Our first example shows how the connection reuse policy can be set at the ORB level First in C C CORBA Any boolAny ORBacus 251 Using Policies Oi Ww E t MN Rh ER 1 11 amp bw HB boolAny lt lt CORBA Any from_boolean 0 CORBA PolicyList policies policies length 1 policies 0 orb gt create policy REUSE POLICY boolAny CORBA Object_var pmObj orb resolve_initial_references ORBPolicyManager CORBA PolicyManager_var pm CORBA PolicyManager narrow pmObj pm gt add_policy_overrides policies Create an any and insert the value 0 false Create a sequence containing one policy object Ask the ORB to create a connection reuse policy Pass the any that contains the value for this policy Obta
207. is to generate code that copies valuetype argument and result values for collocated invocations Specify this option to disable strict compliance and gen erate more efficient code case sensitiv The semantics of OMG IDL forbid identifiers in the same scope to differ only in case This option relaxes these semantics but is only provided for backward compatibility with non compliant IDL ORBacus 35 The ORBacus Code Generators 3 5 Options for jidl h help v version e cpp NAMI d debug DNAME DNAME DEE UNAME IDIR E no skeletons locality constrained all tie file list FILE no local copy case sensitiv These options are the same as for the id1 command no comments The default behavior of jid1 is to add any comments from the IDL file starting with to the generated Java files Specify this option if you don t want these comments added to your Java files package PKG Specifies a package name for the generated Java classes Each class will be generated rel ative to this package prefix package PRE PKG Specifies a package name for a particular prefix Each class with this prefix will be gener ated relative to the specified package auto packag Derives the package names for generated Java classes from the IDL prefixes The prefix for example results in the package com output dir DIR
208. isplay the version of the server version e Prints the stringified IOR of the server to standard output Configuration Properties In addition to the standard configuration properties described in Chapter 4 ORBACUS Properties also supports the following properties ooc property port PORT Specifies the port number on which the service should listen for new connections Note that this property is only considered if the ooc oa port property is not set CLASSPATH Requirements ORBACUS Properties for Java requires the classes in OB jar and OBProperty jar Connecting to the Service The object key of the Property Service is PropertyService which identifies an object of type CosPropertyService PropertySetDefFactory The object key can be used when composing URL style object references For example the following URL identifies the Property Service running on host prophost at port 10000 corbaloc prophost 10000 PropertyService Refer to Chapter 6 for more information on URLs and configuring initial services 158 ORBacus Using the Property Service with the IMR 11 3 11 4 11 4 1 Using the Property Service with the IMR The Property Service may be used with the Implementation Repository IMR However if used with the IMR it is important to note that the corbaloc URL style object reference described in the previous section cannot be used If the IMR is used then the object refer ence for the Property S
209. ivation of Servants using Java 88 Deactivating Servants 89 Deactivation of Servants using C 89 Deactivation of Servants using Java 89 Transient and Persistent Objects 89 Factory Objects 90 Factory Objects using C 91 Factory Objects using Java 93 Caveats 94 Obtaining the POA for a Servant 94 Getting the POA for a Currently Executing Request 95 Locating Objects 97 Obtaining Object References 97 Lifetime of Object References 100 Hostname 100 Port Number 100 Object Key 101 Stringified Object References 101 Using a File 101 Using a URL 103 Using Applet Parameters 104 Object Reference URLs 105 corbaloc URLs 105 corbaname URLs 107 file URLs 107 relfile URLs 108 Initial Services 108 ORBacus CHAPTER 7 CHAPTER 8 CHAPTER 9 Resolving an Initial Service 108 Configuring the Initial Services 110 The Initial Service Locator 111 The Implementation Repository 113 Background 114 How It All Works 114 Information Managed by the IMR 114 IMR Security 116 Synopsis 117 Usage 117 Windows NT Native Service 118 Configuration Properties 120 Connecting to the Service 121 Utilities 121 Implementation Repository Administration 121 Making References 123 Upgrading the IMR Database 123 Getting Started with the Implementation Repository 124 Programming Example 126 The Implementation Repository Console 131 Synopsis 132 Usage 132 CLASSPATH Requirements 132 Implementation Repository Service Lookup 132 The Menus 132 The
210. iversal Time Object 170 The Time Interval Object 171 The TimeService Object 172 Time Service Extensions 173 Programming Example 176 ORBacus Events 181 Synopsis 181 Usage 181 Windows NT Native Service 182 Configuration Properties 183 Diagnostics 184 CLASSPATH Requirements 185 Connecting to the Service 185 Using the Event Service with the IMR 186 Event Service Concepts 187 The Event Channel 187 ORBacus CHAPTER 14 CHAPTER 15 Event Suppliers and Consumers 187 Event Channel Policies 188 Event Channel Factories 188 Programming Example 190 ORBacus Trader 195 Synopsis 196 Usage 196 Configuration Properties 196 CLASSPATH Requirements 197 Connecting to the Service 197 Using the Trading Service with the IMR 197 Trading Service Concepts 198 Basic Concepts 198 Importing Service Offers 202 Offer Management 205 Dynamic Properties 206 Trader Federation with Links 207 Supporting Legacy Applications with Proxy Offers 209 Programming Example 210 The Print Server 210 The Client 213 ORBacus Trader Console 215 Synopsis 216 Usage 216 CLASSPATH Requirements 216 Main Window 216 Terminology 217 The Trader Console Menus 218 The Console menu 218 The Edit menu 218 The View menu 219 The Insert menu 220 The Tools menu 220 The Toolbar 220 ORBacus CHAPTER 16 Managing Service Types 220 Adding a New Service Type 221 Removing a Service Type 223 Masking a Service Type 223 Unmasking a
211. l S Install and start the service start install u Uninstall the service uninstall d eer Run the service in debug mode In order to use the imr server as a native Windows NT service first add the desired config uration properties to the HKEY_LOCAL_MACHINE NT registry key see Using the Win dows NT Registry on page 60 for more details For example add the ooc imr admin_port ooc imr forward_port and ooc imr slave_port proper ties so that the IMR and OAD will use non default ports Next the service should be installed with ntimrservice i This adds the ORBacus Implementation Repository entry to the Services dialog in the Control Panel To start the service select the ORBacus Implementation Repository entry and press Start If the service is to be started automatically when the machine is booted select the ORBacus Implementation Repository entry then click Startup Next select Startup Automatic and press OK Alternatively the ser vice could have been installed using the s option which configures the service for auto matic start up ntimrservice s If you want to remove the service run ntimrservice u Note If the executable for the service is moved it must be uninstalled and re installed Any trace information provided by the service is be placed in the Windows NT Event Viewer with the title IMRService To enable tracing information add the desired trace configurat
212. l s start install 7 u uninstall d debug h x Display the command line options supported by the server i Install the service The service must be started manually install 5 Install and start the service start install u 3 Uninstall the service uninstall d pus Run the service in debug mode 182 ORBacus Synopsis 13 1 3 In order to use the Event Service as a native Windows NT service it is first necessary to add the ooc event port property to the HKEY LOCAL MACHINE NT registry key see Using the Windows NT Registry on page 60 for more details Next the service should be installed with nteventservic al This adds the ORBacus Event Service entry to the Services dialog in the Control Panel To start the event service select the ORBacus Event Service entry and press Start If the service is to be started automatically when the machine is booted select the ORBacus Event Service entry then click Startup Next select Startup Automatic and press OK Alternatively the service could have been installed using the s option which configures the service for automatic start up nteventservic S If you want to remove the service run nteventservic u Note If the executable for the Event Service is moved it must be uninstalled and re installed Any trace information provided by the service is be placed in the Wi
213. l and poa3 is a child of poa2 Refer to Information Managed by the IMR on page 114 for further details In very rare circumstances it s possible for the IMR and OAD to become confused as to the state of a server In this case it might be necessary to manually reset the state of the server using the reset server command It is also necessary to use this command if the server continually crashes on startup and has reached the maximum number of retries specified by its max spawns attribute This prevents OAD from continually starting the same broken server Making References The mkref utility creates IMR based object references for use by clients Since the Object ID is required to create a reference this utility can only be used to create references for objects created by POAs using the USER ID object identification policy Its usage is shown below mkref H imr host server name object id poal poa2 poan imr host The host that the imr server is running on If the host is not specified then localhost is used server name The name of the server as registered in the IMR object id The Object ID used by the object poal poa2 poan The POA which creates the object where poal is a child of the Root POA poa2 is a child of poal and so on The mkref utility uses the ooc imr forward port property see Configuration Prop erties on page 120 If this property is not set then mkref will use 9998 Upgrading the I
214. l address The multi profile parameter determines how multiple addresses are represented in IIOP 1 1 or later If this parameter is not specified the canonical hostname is used multi profile boolean If true multiple addresses in the host parameter are represented as multiple tagged profiles in an IOR If false multiple addresses are represented as a single tagged profile using the first address in the host sequence as the primary address with all additional addresses represented as alternate addresses in tagged components If IIOP 1 0 is in use multiple addresses are always represented as multiple tagged profiles because IIOP 1 0 does not support tagged components If not specified the default value is false numeric boolean If true and if host is not specified then the canonical dotted decimal address is advertised in IORs If not specified the default value is false port unsigned short Specifies the port on which the acceptor should listen for new connections If not specified the default value is 0 which causes the operating system to select an unused port Typical configurations include the following 276 ORBacus The Bi directional OCI Plug in 19 6 19 6 1 e parameters The Acceptor will use the canonical hostname and a port selected by the operating system e Port only Specifying a port is typically required to create persistent object references
215. l as for other useful things We must also include the He110 impl class definition contained in the header file Hello impl h The say hello function simply prints Hello World on standard output Save the class definition of Hello_imp1 in the file Hello impl h and the implementa tion of Hello implin the file He11o impl cpp ORBacus 19 Getting Started AN Q HB C CQ ww t lv Il Pl NN E E bL b b bk kk At DH AN DA Oi DH DAN WHE 36 Now we need to write the server program To simplify exception handling and ORB destruction we split our server into two functions main and run main only cre ates the ORB and calls run C include lt OB CORBA h gt include lt Hello_impl h gt include lt fstream h gt int run CORBA ORB ptr int main int argc char argv int status EXIT_SUCCESS CORBA ORB_ var orb try orb CORBA ORB_init argc argv status run orb catch const CORBA Exception status EXIT FAILURE Em if CORBA is nil orb try orb destroy catch const CORBA Exception status EXIT FAILURE En return status Several header files are included Of these OB CORBA h provides the standard CORBA definitions and Hello impl h contains the definition o
216. le once your application has a reference to a B object it can obtain a refer ence to an A object using get A The question that arises however is How do I obtain a reference to a B object This chapter answers that question by describing a number of ways an application can bootstrap its first object reference ORBacus 99 Locating Objects 6 2 6 2 1 6 2 2 Lifetime of Object References All of the strategies described in this chapter involve the publication of an object reference in some form A common source of problems for newcomers to CORBA is the lifetime and validity of object references Using IIOP an object reference can be thought of as encapsulating several pieces of information hostname e port number e object key If any of these items were to change any published object references containing the old information would likely become invalid and its use might result in a TRANSIENT or OBJECT_NOT_EXIST exception The sections that follow discuss each of these compo nents and describe the steps you can take to ensure that a published object reference remains valid Hostname By default the hostname in an object reference is the canonical hostname of the host on which the server is running Therefore running the server on a new host invalidates any previously published object references for the old host ORBACUS provides the OAhost option to allow you to override the hostname in any object
217. le to add the threaded concurrency model to a property set that is used to ini tialize the ORB C OB Properties var dflt OB Properties getDefaultProperties OB Properties var props new OB Properties dflt 62 ORBacus Configuring the ORB and Object Adapter 4 3 8 4 3 9 props gt setProperty ooc orb conc model threaded CORBA ORB var orb OBCORBA ORB init argc argv props Create an OB Properties object that is based on the default properties This is impor tant because unlike org omg CORBA ORB init OBCORBA ORB init does not read the default properties if the property parameter is not null Define ORBACUS properties Initialize the ORB using the ORBACUS specific OBCORBA ORB init operation Precedence of Properties Given that properties can be defined in several ways it s important to establish the order of precedence used by ORBACUS when collecting and processing the property definitions The order of precedence is listed below from highest to lowest Properties defined at a higher precedence override the same properties defined at a lower precedence 1 Command line options 2 Configuration file specified at the command line 3 User supplied properties 4 Configuration file specified by the ORBACUS CONF IG environment variable C or the config system property Java 5 System properties Java only HKEY_CURRENT_USER Software 00C Propertie
218. manager with config RootPOAManager config PortableServer RootPOA var rootPOA orb gt resolve initial references RootPOA Resolve the ORBACUS POA Manager Factory See section 4 4 1 for an example Initialize a configuration sequence with two elements Configure an IIOP acceptor to listen on port 3000 Configure an IIOP acceptor to listen on port 3001 Create the Root POA Manager The Root POA Manager must be created before resolving the Root POA Java import com ooc OBPortableServer POAManagerFactory import com ooc OBPortableServer POAManagerFactoryPackage POAManagerFactory factory resolve AcceptorConfig config new AcceptorConfig 2 config 0 new AcceptorConfig config 0 id com ooc OCI IIOP TAG IIOP value config 0 params new com ooc OCI Param 1 config 0 params 0 new com ooc OCI Param config 0 params 0 name port config 0 params 0 value orb create config 0 params 0 value insert ushort short 3000 config 1 new AcceptorConfig config 1 id com ooc OCI IIOP TAG IIOP value config 1 params new com ooc OCI Param 1 config 1 params 0 new com ooc OCI Param config 1 params 0 name port config 1 params 0 value orb create any config 1 params 0 value insert ushort short 3001 org omg PortableServer POAManager manager factory create poa manager with config RootPOAManager config org omg PortableServer POA rootPO
219. me interval represented by the TIO 7 Compare the time interval of the TIO interval A with the associated error envelope of the UTO parameter interval B See Enumerations on page 169 for details Will raise a CORBA BAD PARAM exception if the UTO parameter is nil or if its inaccuracy attribute is greater then the maximum allowable inaccuracy 8 Compare the time interval of the TIO interval A with the time interval of the TIO param eter interval B See Enumerations on page 169 for details Will raise a CORBA BAD PARAM exception if the TIO parameter is nil or if its lower bound is greater than its upper bound 9 Return a UTO with an associated error envelop equal to the time interval of the TIO and a time equal to the midpoint of the time interval Will raises a CORBA DATA CONVERSION exception if the resulting inaccuracy is greater than the maximum allowable inaccuracy 12 3 7 The TimeService Object The TimeService Object provides operations for getting the current time and creating arbi trary UTOs and TIOs The TimeService is declared in the CosTime module as follows 1 IDL 2 module CosTime 3 4 interface TimeServic 5 6 UTO universal time 7 raises TimeUnavailable 8 UTO secure universal time 9 raises TimeUnavailable 10 UTO new universal time in TimeBase TimeT time 11 in TimeBase InaccuracyT inaccuracy 12 in TimeBase TdfT tdf 13 UTO uto from TimeBase UtcT utc 14 TIO new inte
220. mum link follow policy Determines the server s upper bound on the value of a link s limiting follow rule at the time of creation or modification of a link The server raises the LimitingFollowTooPermissive exception if a link s limiting follow rule exceeds the value of this attribute 15 10 4Admin Attributes Support Import Link Admin Request identifier stem Request identifier stem The request identifier stem is used as a prefix by the server to generate unique request identifiers during a federated query Although the IDL attribute request_id_stem ORBacus 237 ORBacus Trader Console 15 11 returns a sequence of octets this property is defined in terms of a string with the charac ters of the string comprising the octets of the stem You need to provide a value for this property only if the server will have links to other traders and you want to ensure that cir cular links are handled correctly Executing Queries To execute a query do the following 1 Select Tools Query The Query dialog box appears as shown below Ei Query x Service type Mortgage v Constraint Preference _ Desired properties Query Policies Close 2 Select a service type from the drop down list 3 Enter a constraint expression in the Constraint text box 4 Optional Enter a preference expression in the Preference text box If this field is blank
221. n be propagated to a depth of at most four from the originating trader To prevent infinite loops traders can be configured to generate unique identifiers to be passed along when a query request is propagated to other traders If the request happens to 208 ORBacus Trading Service Concepts 14 4 6 be propagated back to the originating trader it will recognize the unique identifier it gen erated and will take no further action on that request Links provide a great deal of flexibility to system designers They can be used in a manner similar to partitions in NDS where responsibility for resources is distributed among mul tiple independent but interconnected entities Links can also be applied in a more con trolled fashion where administrators selectively make the service offers of one trader available to one or more other traders Supporting Legacy Applications with Proxy Offers A proxy offer is a special kind of service offer in that it has properties like a service offer and can be matched during a query like a service offer But rather than returning the offer to the importer the trader formulates a modified query request and forwards it to an object specified by the proxy offer that implements the CosTrading Lookup interface In this way the match of a single proxy offer can result in a number of service offers being returned to the importer In addition to the information contained in a service offer a proxy o
222. n can be ignored here because other events aren t of interest After extracting the string it is displayed in the console window 192 ORBacus Programming Example AND WH HB N NON ON Roh ask ka ka ska ka ka a b li CDH AND Oi X 9 Q o 24 15 23 In contrast to the push consumer the pull consumer has to actively query the event chan nel for new events This is how the pull consumer loop looks Java while supplier null Any any null try any supplier_ pull catch Disconnected ex Supplier was diconnected from event channel try String s any extract string System out println s catch MARSHAL ex Ignore unknown event data A CORBA Any is prepared for later use Using pull the consumer polls the event channel for new events The event channel acts as a pull supplier in this case The pu11 operation blocks until a new event is avail able The consumer expects a string wrapped in a CORBA Any The string value is extracted and displayed If an exception is raised the Any contained some other data type which is simply ignored In all of these examples the event channel acts either as a consumer if the clients are sup pliers or a supplier if the clients are consumers of events Actually each client is not directly connected to the event channel but to a proxy that receives or sends events on behalf of the channel
223. name queue props n value type stringTC props n mode PropertyMode PROP NORMAL Tib String superTypes new String 0 ORBacus 211 ORBacus Trader 41 42 5 37 39 41 42 AND GOs Ql HB E WH 17 16 repos add type SERVICE TYPE printer PrintServerHelper id props superTypes Obtain and narrow the ServiceTypeRepository reference Create the array of structures that describes the properties of the service type Use a zero length array to indicate that the service type has no super types Add the service type The repository ID of the PrintServer interface is used as the interface type Exporting Offers The server uses a configuration file to describe the attributes of each printer org omg CosTrading Register reg trader register if fr new FileReader file BufferedReader in new BufferedReader fr String line while line in readLine null line line trim if line startsWith continue org omg CosTrading Property props parseProperties orb line reg export printServer SERVICE TYPE props Obtain the CosTrading Register interface Open the configuration file Read each line of the file skipping any lines that begin with Parse the line and produce an array of CosTrading Property structures containing the property val
224. nce using C In C I_imp1 must inherit from the skeleton class that was generated by the IDL to C translator If I inherits from other interfaces for example from the interfaces A and B then I impl must also inherit from the corresponding implementation classes A impl and B impl C class A impl virtual public POA A public virtual void op_a throw CORBA SystemException class B impl virtual public B public virtual void op_b throw CORBA SystemException class I impl virtual public I virtual public A impl virtual public B impl public 1 These naming rules are not mandatory they are just a recommendation ORBacus 77 CORBA Objects 19 20 Qo virtual void op i throw CORBA SystemException The servant class A impl is defined inheriting from the skeleton class A If a had any parameters these parameters would be mapped according to the standard IDL to C mapping rules 4 This is the servant class for B impl The servant class for I impl is not only derived from POA 1 but also from the servant classes A impland B impl Note that virtual public inheritance must be used The only situation in which the keyword virtual is not necessary is for an interface 1 which does not inherit from any other interface and from which no other interface inherits This means that the
225. nd the IDL to C mapping should be studied thoroughly For C users we also highly recommend 3 This book contains by far the best treat ment of CORBA programming with C to date What this manual does contain however is information on how ORBACUS implements the CORBA standard A shortcoming of the current CORBA specification is that it leaves a high degree of freedom to the CORBA implementation For example the precise seman tics of a oneway call are not specified by the standard To make it easier to get started with ORBACUS this manual contains a Getting Started chapter explaining some ORBACUS basics with a very simple example Getting Help Should you need any assistance with ORBACUS do not hesitate to contact us at support ooc com You might also consider joining our ORBACUS mailing list For more information on the mailing list please see http www ooc com ob mailing list html 16 ORBacus CHAPTER 2 Getting Started 2 1 The Hello World Application The example described in this chapter is founded on a well known application A Hello World program presented here in a special client server version Many books on programming start with this tiny demo program In introductory C books you ll probably find the following piece of code in the very first chapter C include iostream h int main int char cout Hello World endl return 0 Or in intro
226. ndows NT Event Viewer with the title Event Service To enable tracing information add the desired trace configuration property 1 one of the coc event trace properties or one of the ooc orb trace properties to the HKEY LOCAL MACHINE NT registry key with a REG SZ value of at least 1 Configuration Properties In addition to the standard configuration properties described in Chapter 4 ORBACUS Events also supports the following properties ooc event inactivity timeout sec Proxies that are inactive for the specified number of seconds will be reaped The default value is four hours ooc event max events The maximum number of events in each event queue If this limit is reached and another event is received the oldest event is discarded The default value is 10 ORBacus 183 ORBacus Events 13 1 4 The maximum number of times to retry before giving up and disconnecting the proxy The default value is 10 Specifies the port number on which the service should listen for new connections Note that this property is only considered if the ooc oa port property is not set This specifies the number of milliseconds between successive calls to pull on PullSupplier Default value is 0 This specifies the frequency in seconds in which inactive proxies will be reaped The default value is thirty minutes Setting this property to 0 disables the reaping of proxies Specifies the
227. ng is a brief description of the ORBACUS specific policies that are currently supported For a detailed description please refer to Appendix B For standard policies please refer to 4 OB ConnectionReusePolicy This policy determines whether the ORB is permitted to reuse a communications channel between peers If this policy is alse then each object will have a new communications channel to its peer The default for this policy is t rue OB ConnectTimeoutPolicy If an object has this policy and a connection cannot be established after value millisec onds CORBA NO RESPONSE exception is raised OB InterceptorPolicy This policy determines whether interceptors will be called This policy can be set on an ORB or object reference to control client side interceptors and can be set on a POA to control server side interceptors OB LocationTransparencyPolicy This policy determines how strictly the ORB will enforce location transparency The default behavior is strict enforcement but an application may wish to sacrifice strict CORBA compliance to improve performance for local invocations OB ProtocolPolicy This policy is used to force the selection of a particular protocol If this policy is set then the protocol with the identified tag will be used if possible If it is not possible to use this protocol a CORBA NO RESOURCES exception will be raised OB RequestTimeoutPolicy If an object has this
228. ns to be applied you can use the translator option a11 with 141 With this option the IDL to C translator treats code from included files as if the code appeared in your IDL file at the position where it is included This means that the compiler will not place include statements in the automatically generated header files regardless of whether the code comes directly from your IDL file or from files included by your IDL file Note that when generating code from an Interface Repository using irgen the translator behaves identically to 141 with the a11 option In other words the irgen command does not place include statements in the generated files but rather generates code for all IDL definitions in the Interface Repository Documenting IDL Files With the ORBACUS IDL to HTML and IDL to RTF translators hidl and ridl you can easily generate HTML and RTF files containing IDL interface descriptions The transla tors generate a nicely formatted file for each IDL module and interface Figure 3 1 shows an HTML example and Figure 3 2 an RTF example The formatting syntax supported by nidl and is similar to that used by javadoc The following keywords are recognized author author Denotes the author of the interface exception exception name description Adds an exception description to the exception list of an operation member member name description Adds a member description to the member list of a struct
229. nt to the ORBACUS CONF IG environment variable in C See Using a Configuration File on page 59 for more information on configuration files ooc orb client shutdown timeout Value timeout gt 0 If the client is not able to gracefully disconnect from the server in timeout seconds a con nection shutdown is forced If this property is set to zero then the client will not force a 1 Note that these properties have nothing to do with the Property Service as described in Chapter 11 ORBacus 49 ORB and Object Adapter Initialization connection shutdown If the property is not set a default timeout value of two seconds is used ooc orb client timeout Value timeout gt 0 The client actively closes a connection that has been idle for timeout seconds once that connection has no more outstanding replies Note that the application must use the threaded client side concurrency model if connection timeouts are desired If this property is set to zero or not set at all then the client does not close idle connections ooc orb conc model Value blocking reactive threaded Selects the client side concurrency model The reactive concurrency model is not cur rently available in ORBACUS for Java The default value is blocking for both C and Java applications See Chapter 18 for more information on concurrency models ooc orb default init ref Value URL Specifies a partial URL If an application calls the ORB oper
230. ntence ends at the first period that is followed by a blank tab or line terminator or at the first ORBacus 43 The ORBacus Code Generators ridl understands most basic HTML tags and produces an equivalent format in the gener ated RTF files The following HTML tags are supported EM HR P U UL B BR CODE 3 12 Using javadoc If not explicitly suppressed with the no comments option the ORBACUS IDL to Java translator 1141 adds IDL comments starting with to the generated Java files so that javadoc can be used to generate documentation as long as the comments are in a format compatible with javadoc Here is an example that shows how to include documentation in an IDL interface descrip tion file Let s assume we have an interface I in a module IDL module M version 1 0 interface I This is a comment related to interface I author Uwe Seimet This comment describes exception E exception E F X CH The description for operation 5 param arg A dummy argument 44 ORBacus Using javadoc return A dummy string exception E Raised under certain circumstances string S in long arg raises E When running on this file the comments are automatically added to the generated Java files M I java and M IPa
231. nterface 16 4 Interface Repository Utilities 16 4 1 irfeed IDL files can be loaded into the IFR at runtime using irfeed See the description of the irserv command for more information on the command line options irfeed h help v version e NAME cpp NAME d debug DNAME DNAME DEF UNAME IDIR E FILE 246 ORBacus Programming Example 16 4 2 irdel 16 5 MAN Oo Ci WH NH HB NN oy y ly ly NH N AND DH AND X Type definitions can be removed from IFR using irdel See the description of the irserv command for more information on the command line options irdel h help v version name The name argument represents the scoped name of the type to be removed A scoped name has the form X Y Z For example an interface I defined in a module M can be identi fied by the scoped name Programming Example Below is a simple example in Java that demonstrates how to obtain an InterfaceDef object and display its contents Java import org omg CORBA org omg CORBA ORB initialize the ORB org omg CORBA Object obj get object reference somehow org omg CORBA Object defObj obj get interface def if defObj null System err printin No Interface Repository available System exit 1 In
232. ntext from a file Save Context As Recursively saves the selected naming context to a file Save IOR to File Saves the stringified IOR of the currently selected item to a file Close Window Closes the current window Exit Quits ORBACUS NAMES 150 ORBacus The Menus After starting the application the current root context is the naming context corresponding to the IOR specified on the command line or the initial Naming Service as provided to the ORB with options like ORBservice or ORBconfigby You can make another naming context the root context using Switch Root Context The new root context s IOR is speci fied in the Enter IOR dialog window as shown in Figure 10 1 The IOR can be entered emo 1 loge OR Browes Cancil Figure 10 1 Entering an IOR directly or can be read from a file If an IOR is entered manually you usually either use the URL style notation as described in Chapter 6 or you copy a stringified object reference into the dialog box using Cut amp Paste After selecting Browse a file containing an IOR can be selected Sometimes it is not desirable to completely replace the currently visible root context by another root context For example you may need to copy bindings from one context to another If this is the case simply open an additional window for the new root context using New Window You can then switch the root context in only one window without affecting the information displ
233. nts and Servers on page 257 ORBACUS uses a so called Reactor for event dispatching 11 Simply speaking the Reactor is an instance in ORBACUS a singleton where special objects so called event handlers can register if they are interested in specific events These events can be network events such as an event signaling that data are ready to be read from a network connection Again this chapter only applies to ORBACUS when used with reactive concurrency mod els If you use ORBACUS with any other concurrency model for example any of the multi threaded models the following examples are not applicable Also since ORBACUS for Java currently doesn t support the reactive model at all the following only applies to ORBACUS for C Available Reactors Currently there are three Reactors supported by ORBACUS e The standard select Reactor which relies on the Berkeley Sockets select function ORBacus 263 Concurrency Models e A special Reactor for use with the X11 Window System This Reactor handles X11 events which for example can trigger X11 callbacks and CORBA network events simultaneously e A special Reactor for use with Microsoft Windows 95 98 NT 2000 This Reactor handles Windows messages and CORBA network events simultaneously The default Reactor is the select Reactor If one of the other Reactors is to be used it must be initialized explicitly The X11 Reactor on that wants to
234. o FALSE the operation returns a nil object reference if there is no new connection ready to be accepted Returns The new Transport object Raises COMM FAILURE In case of an error connect self Transport connect self Connect to this acceptor This operation can be used to unblock threads that are blocking in accept Returns The new Transport object Raises TRANSIENT If the server cannot be contacted COMM FAILURE In case of other errors add profiles void add profiles in ProfileInfo profile info 340 ORBacus Interface OCI Acceptor inout IOR ref Add new profiles that match this Acceptor to an IOR Parameters profile info The basic profile information to use for the new profiles ref The IOR get local profiles ProfileInfoSeq get local profiles in IOR ref From the given IOR get basic information about all profiles for which are local to this Accep tor Parameters ref The IOR from which the profiles are taken Returns The sequence of basic information about profiles If this sequence is empty there is no pro file in the IOR that is local to the Acceptor get info AcceptorInfo get info Returns the information object associated with the Acceptor Returns The Acceptor information object ORBacus 341 Open Communications Interface Reference E 10 Interface OCI AcceptorInfo interface AcceptorInfo Information on an OCI Acceptor
235. o overhead for thread cre ation or context switching Only an additional call to an operation like select is needed before operations such as send recv or accept can be used by the ORB The maximum nesting level for the reactive concurrency model is usually much higher than for threaded concurrency models The reason is that the maximum nesting level for 1 For more information on send deferred get response and poll response see the chapter The Dynamic Invocation Interface in 4 1 Instead of directly using operations like select ORBACUS uses a Reactor to provide for flex ible integration with existing event loops and to allow the installation of user supplied event han dlers See The Reactor on page 263 for more information 258 ORBacus Multi Threaded Concurrency Models 18 3 18 3 1 dispatch dispatch ly Client Server Client Server Figure 18 3 Reactive Client Server threaded models is determined by the maximum number of threads allowed per process whereas the reactive concurrency model is only limited by the maximum stack size per process Multi Threaded Concurrency Models Threaded Clients and Servers A threaded client uses two separate threads for each connection to a server one for send ing requests and another for receiving replies This model has the advantage that oneway requests can be sent in the background
236. o start the naming service select the ORBacus Interface Repository Service entry and press Start If the service is to be started automati cally when the machine is booted select the ORBacus Interface Repository Service entry then click Startup Next select Startup Type Automatic and press OK Alternatively the service could have been installed using the s option which configures the service for automatic start up ntirservice s If you want to remove the service run ntirservice u Note If the executable for the Interface Repository is moved it must be uninstalled and re installed Any trace information provided by the service is placed in the Windows NT Event Viewer with the title IRService To enable tracing information add the desired trace configura tion property i e one of ooc orb trace properties to the HKEY LOCAL MACHINI NT registry key with a REG SZ value of at least 1 IE Configuration Properties In addition to the standard configuration properties described in Chapter 4 the ORBACUS Interface Repository also supports the following properties ooc ifr options OPTS Allows command line options to be passed to the Win dows NT Native service at start up Note that absolute pathnames should be used when specifying include direc tives IDL files etc ooc ifr port PORT Specifies the port number on which the service should lis ten for new connections Note that this property is only considere
237. ode with the right mouse button a popup menu with a choice of operations is displayed as shown in Figure 10 4 This is F Change HD Charge Hiari Sana HOLT Fili _ Figure 10 4 A popup menu offers important operations another convenient alternative for executing frequently used operations 156 ORBacus ORBacus Properties The CORBA Property Service permits you to annotate an object with extra attributes called properties that were not defined by the object s IDL interface Properties can rep resent any value because they make use of the CORBA Any data type ORBACUS Properties is compliant with 10 This chapter does not provide a complete description of the service It only provides an overview suitable to get you started For more information please refer to the specification 1l 1 Synopsis 11 1 1 Usage ORBACUS includes functionally equivalent implementations of the Property Service in C and Java C propserv Ln help v version i ior 1 Note that the Property Service has nothing to do with the properties used for configuration pur poses Configuration properties are described in ORB Properties on page 49 ORBacus 157 ORBacus Properties 11 1 2 11 1 3 11 2 Java com ooc CosPropertyService Server help v version i iot Options h T Display the command line options supported by the server T D
238. omg CORBA Any boolAny orb create any boolAny insert boolean false org omg CORBA Policy policies new org omg CORBA Policy 1 policies 0 orb create policy com ooc OB CONNECTION REUSE POLICY value boolAny org omg CORBA Object newObj obj set policy override policies org omg CORBA SetOverrideType ADD OVERRIDE This is equivalent to the C version Timeout Policy This example shows how to configure timeouts at the object level As usual the C ver sion is presented first followed by the Java version C CORBA Any ULongAny ULongAny CORBA ULong 1000 CORBA PolicyList policies 1 policies length 1 policies 0 orb gt create policy OB TIMEOUT POLICY ID ULongAny CORBA Object_var newObj obj gt set policy overrides policies CORBA ADD_OVERRIDE We want to set the timeout to a value of 1000 milliseconds Set the policy on the object by using the set policy overrides method This method returns a new object that has the set of policies applied And now the same example in Java ORBacus 253 Using Policies Java org omg CORBA Any ULongAny orb create any ULongAny insert ulong 1000 org omg CORBA Policy policies new org omg CORBA Policy 1 policies 0 orb create policy com ooc OB TIMEOUT POLICY ID value ULongAny org omg CORBA Object newObj obj _set_policy_override policies org omg COR
239. on conn url openConnection BufferedReader in new BufferedReader new InputStreamReader conn getInputStream String ref in readLine in close ORBacus 103 Locating Objects 1 16 1 16 6 3 3 5 5 No hs org omg CORBA Object object orb string to object ref B b BHelper narrow object location is the URL of the file containing the stringified object reference Read the string from the URL connection Convert the string to an object reference Narrow the reference to a B object Using Applet Parameters In addition to using the URL method described in the previous section an applet can also use an applet parameter to obtain a stringified object reference The following HTML illustrates this concept lt APPLET CODE Client class ARCHIVE OB jar WIDTH 500 HEIGHT 300 gt lt PARAM NAME ref VALUE IOR 000012031 gt lt APPLET gt The stringified object reference is inserted directly into the HTML file and passed to the applet as a parameter The applet can retrieve this parameter and convert it to an object reference as shown below Java org omg CORBA ORB orb Get a reference to the ORB somehow String ref getParameter ref org omg CORBA Object object orb string_to_object ref B b BHelper narrow object Obtain the applet parameter ref Convert the string to an object reference Narrow
240. on on URLs and configuring initial services Using the Naming Service with the IMR The Naming Service may be used with the Implementation Repository IMR However if used with the IMR it is important to note that the corbaloc URL style object reference described in the previous section cannot be used If the IMR is used then the object refer ence for the Naming Service must be created using one of the following methods where NamingServer refers to the server name configured with the IMR e start the Naming Service with the options ior ORBserver name NamingServer causing the Naming Service to print its reference to standard output e use the mkref utility mkref NamingServer NameService RootContextPOA When using the Naming Service with the IMR the service must be started with the option ORBserver_name NamingServer where NamingServer refers to the server name configured with the IMR When the IMR is configured to start the Naming Service this option is automatically added to the service s arguments However when the Naming Ser vice is started manually the option must be present For further information on configur ing a service with the IMR refer to Getting Started with the Implementation Repository on page 124 ORBacus 139 ORBacus Names 9 4 9 4 1 Naming Service Concepts Bindings Object references registered with the Naming Service are maintained in a hierarchical structure similar to a
241. ools Withdraw Offers The Withdraw Offers dialog box appears as shown below withdraw Offers Service type Mortgage m Constraint OK Cancel 2 Select the service type from the drop down list Offers with this service type or a subtype of this service type are considered for withdrawal 3 Enter a constraint expression in the text box See Constraint on page 202 for more information on constraint expressions 4 Click OK to withdraw the offers Only offers that match the constraint expression are withdrawn An error message appears if no matching offers were found Note A simple way to remove all of the offers for a service type is to use TRUE for the constraint expression 228 ORBacus Managing Proxy Offers 15 8 Managing Proxy Offers 15 8 1 Adding a New Proxy Offer To add a new proxy offer do the following 1 Select Insert Proxy Offer The New Proxy Offer dialog box appears as shown below New Proxy Offer x Service type 4 Target Lookup IOR gt From file Browse Constraint recipe ff match all r Properties amic r Policies to pass on 2 Selecta service type from the drop down list Each time you select a service type the property table is updated to reflect the properties defined for that service type ORBacus 229 ORBacus Trader Console Select a method for speci
242. or a given IOR and a list of policies The sequence includes one or more Connectors for each IOR profile that matches this Connector factory and satisfies the list of policies Parameters ref The IOR for which Connectors are returned policies The policies that must be satisfied Returns The sequence of Connectors equivalent boolean equivalent IOR iorl ORBacus Interface OCT ConFactory in IOR ior2 Checks whether two IORs are equivalent taking only profiles into account matching this Con nector factory Parameters 1 The first IOR to check for equivalence ior2 The second IOR to check for equivalence Returns TRUE if the IORs are equivalent FALSE otherwise hash unsigned long hash in IOR ref in unsigned long maximum Calculates a hash value for an IOR Parameters ref The IOR to calculate a hash value for maximum The maximum value of the hash value Returns The hash value get info ConFactoryInfo get info Returns the information object associated with the Connector factory Returns The Connector factory information object ORBacus 351 Open Communications Interface Reference E 16 Interface OCI ConFactoryInfo interface ConFactoryInfo Information on an OCI ConFactory object See Also ConFactory Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute Profileld tag The profile id t
243. orForcedShutdown timeout 20 1 12INTF REPOS Minor Exception Code MinorNoIntfRepos Interface Repository is not available MinorLookupAmbiguous Search name for 1ookup is ambiguous MinorIllegalRecursion Illegal Recursion MinorNoEntry IFR is not populated with a required definition 20 1 130BJECT NOT EXIST Minor Exception Code Attempt to pass unactivated unregistered MinorUnregisteredValue value as an object reference 20 1 14INV POLICY Minor Exception Code No PolicyFactory for the PolicyType has been MinorNoPolicyFactory registered 20 2 Non Compliant Application Asserts If the ORBACUS library was compiled without the preprocessor definition DNDEBUG defined ORBACUS tries to detect common programming mistakes that lead to non com pliant CORBA applications If such a mistake is found an error messages like this will appear Non compliant application error detected ORBacus 293 Exceptions and Error Messages Application used wrong memory allocation function After detecting such an error the ORBACUS library dumps a core Unix only and prints the file and line number where the error was detected You can use the core dump in order to track down the problem with a debugger The following error messages can appear Application requested a feature that has not yet been implemented This is not an application error This error message a
244. ory idl Using the Event Service with the IMR The Event Service may be used with the Implementation Repository IMR However if used with the IMR it is important to note that the corbaloc URL style object reference described in the previous section cannot be used If the IMR is used then the object refer ence for the untyped Event Service must be created using one of the following methods where EventServer refers to the server name configured with the IMR e start the Event Service with the options ORBserver name EventServer ior causing the Event Service to print its reference to standard output e use the mkref utility mkref EventServer DefaultEventChannel EventServicePOA For the typed Event Service the object reference must be created using one of the fol lowing methods e start the Event Service with the options ORBserver name EventServer typed servic ior causing the Event Service to print its reference to standard output e use the mkref utility mkref EventServer DefaultTypedEventChannel EventServicePOA Object references for the ORBACUS proprietary factory objects can be created using the following commands mkref EventServer DefaultEventChannelFactory EventServicePOA mkref EventServer DefaultTypedEventChannelFactory EventServicePOA When using the Event Service with the IMR the service must be started with the option
245. ory pattern can be applied in a wide variety of situations including the following e Security A client is required to provide security information before the factory object will allow the client to have access to another object Load balancing The factory object manages a pool of objects often representing some limited resource and assigns them to clients based on some utilization algorithm e Polymorphism A factory object enables the use of polymorphism by returning object references to different implementations depending on the criteria specified by a client These are only a few examples of the potential applications of the Factory pattern The examples listed above can also be used in any combination depending on the require ments of the system being designed Note that the factory pattern applies equally to persis tent and transient objects 90 ORBacus Factory Objects AND GAA WHE AN O NH Rs A U NARO N A A simple application of the Factory pattern in which a new object is created for each cli ent is illustrated below The implementation uses the following interface definitions IDL interface Product void destroy interface Factory Product createProduct The Product interface is defined The dest roy operation allows a client to destroy the object when it is no longer needed The Factory interface
246. owed to a reference to a Hello object A simple Java cast is not allowed here because it is possible that the client will need to ask the server whether the object is really of type Hello The say hello operation is invoked causing the server to print Hello World on stan dard output Compiling Ensure that your CLASSPATH environment variable includes the current working directory as well as the ORBACUS for Java classes i e the OB jar file If you are using the Unix Bourne shell or a compatible shell you can do this with the following commands CLASSPATH your orbacus directory lib OB jar S CLASSPATH export CLASSPATH Replace your orbacus directory with the name of the directory where ORBACUS is installed If you are running ORBACUS on a Windows based system you can use the following command within the Windows command interpreter 28 ORBacus Summary 2 4 4 2 5 set CLASSPATH your_orbacus_directory lib OB jar CLASSPATH 66 99 66 99 Note that for Windows you must use and not as the delimiter To compile the implementation classes and the classes generated by the ORBACUS IDL to Java translator use javac or the Java compiler of your choice javac hello java Running the Application The Hello World Java server is started with java hello Server And the client with java hello Client Again make sure that your CLASSPATH environment variable includes the O
247. pe Note If a service type has subtypes you will not be able to remove the type until all of its subtypes have been removed Masking a Service Type To mask a service type do the following 1 Select View Service Types to display the service types in the item list 2 Select the service type you wish to mask 3 Select Tools Mask Type ORBacus 223 ORBacus Trader Console 15 6 4 Unmasking a Service Type To unmask a service type do the following 1 Select View Service Types to display the service types in the item list 2 Select the service type you wish to unmask 3 Select Tools Unmask Type 15 7 Managing Offers 15 7 1 Adding a New Offer To add a new offer do the following 1 Select Insert Offer The New Offer dialog box appears as shown below Service type xj IOR From file Browse r Properties Property Value Add Dynamic OK Cancel 2 Selecta service type from the drop down list Each time you select a service type the Properties table is updated to reflect the properties defined for that service type 3 Select a method for specifying the object reference for this offer Select the IOR toggle if you want to paste the stringified interoperable object reference into the text box If you want the application to read the reference from a file select From file and enter the filename in the text box or click the Browse button
248. pe for abstract interface MinorBadSchemeName Bad scheme name MinorBadAddress Bad address MinorBadSchemeSpecificPart Bad scheme specific part inorOther Other inorInvalidAbstractInterfaceInheritance Invalid abstract interface inheritance inorInvalidValueInheritance Invalid valuetype inheritance inorInvalidServiceContextId Invalid service context ID inorObjectIsNull Object parameter to object to ior is null inorInvalidComponentId Invalid component ID ORBacus CORBA System Exceptions MinorInvalidProfileId Invalid profile ID MinorDuplicateDeclarator Duplicate declarator MinorInvalidValueModifier Invalid valuetype modifier MinorDuplicateValueInit Duplicate valuetype initializer MinorAbstractValueInit Abstract valuetype cannot have initializer MinorDuplicateBaseType Base type appears more than once MinorSingleThreadedOnly ORB does not support multiple threads X MinorNameRedefinitionInImmediateScope Invalid name redefinition in an immediate scope 3 MinorInvalidValueBoxType Invalid type for valuebox ORBacus 287 Exceptions and Error Messages 20 1 4 NO MEMORY Minor Exception Code inorAllocationFailure Memory allocation failure 20 1 5 IMP LIMIT Minor Exception Code inorMessageSizeLimit Maximum messag
249. pera tion The specification defines a number of standard policies but implementations may support additional ones A policy is represented as a name value pair The Trading Ser vice administrator can establish default values for each policy to be used when an importer does not supply a value for a policy Maximum values for policies can also be established to constrain the importer s policy values Some of the standard policies are described below e search The upper bound cardinality on the total number of service offers to be searched e match card The upper bound on the total number of matching service offers e return card The upper bound on the total number of matching offers to be returned e exact type match If the value for this policy is TRUE the Trading Service will only consider service offers exported for the given service type If the value is FALSE or is not supplied the Trading Service will also consider service offers exported for subtypes of the given service type ORBACUS Trader supports all of the policies defined by the specification 204 ORBacus Trading Service Concepts 14 4 3 Offer Management The CosTrading Register interface provides operations for managing the service offers of the Trading Service including the ability to export modify and withdraw remove service offers Exporting a Service Offer Exporting a service offer is a relatively simple task The expo
250. perties 0 ph ih PropertyHolder h new PropertyHolder while ih value next one h ORBacus 163 ORBacus Properties 72 73 74 75 SLA 36 38 63 65 73 75 The next property is now stored in h value ih value destroy Get a Property Service reference and check for errors The PropertySetDefFactory object is used to create a PropertySetDef instance Note that PropertySetDef is a subclass of PropertySet Each property consists of a name and a value in the form of a CORBA Any Three properties are defined The first has the name LongProperty and stores a long value The second one is called StringProperty and stores a string The remaining property represents a short value If for some reason a property cannot be created an exception is thrown Now we try to get a list of all the properties that were previously defined With get all properties the PropertySetDef returns its properties As we have set the how many parameter to 0 we have to use the PropertiesIterator for each item An application would normally provide a positive integer for how many The iterator has fulfilled its duty and can now be destroyed 164 ORBacus CHAPTER 12 ORBacus Time 12 1 12 1 1 The CORBA Time Service provides the means to obtain the current time along with an error estimate The service also provides operations related to time and intervals This chapter does not
251. port 10002 ooc imr mode slave ooc imr dbdir usr local ORBacus db This files is placed in the usr local ORBacus etc directory on hosts slavel and slave2 3 Start the IMR in administrative mode On host master run imr ORBconfig usr local ORBacus etc imr conf administrative 4 Start the OADs On host slavel run imr ORBconfig usr local ORBacus etc oad conf On host slave2 run imr ORBconfig usr local ORBacus etc oad conf 124 ORBacus Getting Started with the Implementation Repository Each OAD automatically registers itself with the IMR Note that an OAD can also be registered manually using the imradmin utility For example to register the OAD on host slavel run imradmin ORBInitRef IMR corbaloc master 10000 IMR add oad slavel 5 Add each server to the IMR In our example we will run one server on each OAD The server names are Server1 and Server2 and are located in usr local bin on their respective hosts First we register the servers using the imradmin utility imradmin ORBInitRef IMR corbaloc master 10000 IMR add server Serverl usr local bin serverl slavel imradmin ORBInitRef IMR corbaloc master 10000 IMR add server Server2 usr local bin server2 slave2 Next we set the server arguments imradmin ORBInitRef IMR corbaloc master 10000 IMR set server Serverl args ORBInitRef IMR corbaloc master 10000 IMR imradmin ORBInitRef IMR corbaloc master 10000 IMR set
252. port PORT S PORT slave port PORT Display the command line options supported by the server Display the version of the server Run the server in master mode Run the server in slave mode Run the IMR in administrative mode The IMR will run in non administrative mode by default Specifies the directory in which the IMR maintains its database files If not specified the current working directory is used Specifies the IMR s administrative port This is the port that the and IMR enabled servers use to communicate with the IMR For security reasons access to this port can be restricted If not specified port 9999 is used Specifies the IMR s public port which is used by clients for server requests If not specified the port 9998 is used Specifies the port used by the OAD Note that all ofthe OADs in a domain must use the same port If not specified the port 9997 is used a Note that only one of the m or s options may be specified Also if neither the m or s option is specified then the server is started in dual mode Windows NT Native Service The imr server is also available as a native Windows NT service ntimrservice h help i u uninstall help install s start install d debug Display the command line options supported by the service 118 ORBacus Synopsis i Install the service The service must be started manually instal
253. ppears if an application attempts to use a feature that has not yet been implemented in ORBACUS In this case the only thing that can be done is to wait for the next ORBACUS version that has this particular feature implemented Application used wrong memory allocation function If this message appears an incorrect memory allocation function has been used A com mon mistake that leads to this error is to use malloc st rdup and free or the new and delete operator instead of CORBA string alloc and CORBA string dup and CORBA string free for string memory management Memory that was already deallocated was deallocated again This message indicates multiple memory deallocations For example if CORBA string_free is called twice on the same string this message will be displayed Object was deleted without an object reference count of zero This message appears if an object was deleted by calling delete on its object reference Never use the delete operator for that use CORBA release instead Object was already deleted object reference count was already zero This message appears if the number of release operations on an object reference is greater than the number of duplicate operations Sequence length was greater than maximum sequence length This message indicates that the application tried to set the length of a bounded sequence to a value greater than its maximum length 294 ORBacus Non Compliant Application
254. provide a complete description of the Time Service It only provides an overview suitable for getting started For detailed information please refer to the Time Service specification 9 Compliance Statement ORBACUS Time is compliant with 9 and conforms to the Basic Time Service The fol lowing presents the necessary documentation for conformance Criteria to Be Followed for Secure Time The Time Service specification states The following types of operations must be protected against unauthorized invocation They must also be mandatorily audited Operations that set or reset the current time e Operations that designate a time source as authoritative e Operations that modify the accuracy of the time service or the uncertainty interval of generated timestamps ORBacus 165 ORBacus Time 12 1 2 12 2 12 2 1 The UNIX and Windows NT 2000 operating systems do not provide mandatory auditing for the system time which is the source of time for ORBACUS Time Hence ORBACUS Time cannot provide secure time As required the TimeUnavailable exception is raised when the secure universal time operation of the TimeService interface is invoked Proxies and Time Uncertainty The specification states In a CORBA system the use of proxy objects can render time values unreliable by intro ducing unpredictable latency between the time the time server object generates a times tamp and the time the caller s time server proxy rec
255. py the stringified object refer ence i e the file He110 ref to the machine where the client program is to be run ORBacus 29 Getting Started 2 6 applications are complex the more you will learn to appreciate having a high level abstraction of your applications key interfaces captured in CORBA IDL Where to go from here To understand the remaining chapters of this manual you must have read the CORBA specifications in 4 5 and 6 You will not be able to understand the chapters that fol low without a good understanding of CORBA in general CORBA IDL and the IDL to C and IDL to Java mappings 30 ORBacus The ORBacus Code CHAPTER 3 3 1 Overview ORBACUS includes the following code generators idl The ORBACUS IDL to C Translator jidl The ORBACUS IDL to Java Translator hidl The ORBACUS IDL to HTML Translator ridl The ORBACUS IDL to RTF Translator irgen The ORBACUS Interface Repository C Code Generator 3 2 Synopsis options idl files jidl options idl files hidl options idl files ridl options idl files irgen name base ORBacus 31 The ORBacus Code Generators 3 3 3 4 Description idlis the ORBACUS IDL to C translator It translates IDL files into C files For each IDL file four C files are generated For example idl MyFile idl produces the following files yFile h Header file containing MyFile idl s translated data types
256. r C include lt Windows h gt include lt OB CORBA h gt include lt OB Logger h gt include lt OB Properties h gt include lt OB Windows h gt int main int argc char argv HINSTANCE hInstance GetModuleHandle 0 OB Reactor var reactor OB GetWindowsReactor hInstance CORBA ORB_var OBCORBA ORB init argc argv OB Properties _nil OB Logger _nil reactor POA initialization not shown orb gt run Cleanup not shown Include header files Use the Windows application instance to get a Windows Reactor Initialize the ORB using the ORBACUS specific OBCORBA ORB_init Enter the CORBA event loop which now also dispatches Windows events The standard Windows event loop may also be called which will then also dispatch CORBA events ORBacus 265 Concurrency Models 266 ORBacus CHAPTER 19 The Open Communications Interface 19 1 19 2 19 2 1 What is the Open Communications Interface The Open Communications Interface OCI defines common interfaces for pluggable pro tocols It supports connection oriented reliable byte stream protocols That is protocols which allow the transmission of a continuous stream of bytes octets from the sender to the receiver TCP IP is one possible candidate for an OCI plug in Since ORBACUS uses GIOP such a plug in then implements the IIOP protocol Other candidates are SCCP Signaling
257. r native code sets REBIND Thrown on a OBJECT_FORWARD or LOCATION_FORWARD status depending on the RebindPolicy TIMEOUT Time to live period was exceeded TRANSACTION_UNAVAILABLI GI Transaction service context could not be processed Table 20 1 Standard CORBA System Exceptions 284 ORBacus CORBA System Exceptions TRANSACTION MODE Mismatch between TransactionPolicy and current transaction mode BAD QOS Object cannot support the required QOS Table 20 1 Standard CORBA System Exceptions the following subsections the minor exception codes are presented Minor codes that are ORBACUS specific are presented as MinorCodeName that is are tagged with the super script ORBacus 285 Exceptions and Error Messages 20 1 1 INITIALIZE Minor Exception Code MinorORBDestroyed ORB already destroyed 20 1 2 UNKNOWN Minor Exception Code MinorUnknownUserException Unknown user exception 20 1 5 BAD PARAM Minor Exception Code MinorValueFactoryError Failure to register unregister or lookup value factory MinorRepositoryIdExists Repository ID already exists in Interface Repository MinorNameExists Name already used in Interface Repository MinorInvalidContainer Target is not a valid container MinorNameClashInInheritedContext Name clash in inherited context MinorBadAbstractInterfaceType Incorrect ty
258. r trace server status Value level gt 0 Defines the output level for IMR diagnostic messages related to the status of servers and POAs The default level is 0 which produces no output Connecting to the Service Servers that use the IMR must be configured with the IMR initial reference The object key of the IMR is IMR hence a URL style object reference of the IMR service running on host imrhost at port 10000 would be corbaloc imrhost 10000 IMR Using this object reference a server can configure the IMR initial reference with the prop erty ooc orb service IMR corbaloc imrhost 10000 IMR An alternative to using the above property is to use the ORBInitRef command line option Refer to Chapter 6 for more information on URLs and configuring initial services Utilities Implementation Repository Administration The imradmin utility provides complete control over the IMR OADs and servers in a domain Its command interface is shown below h help Display this information add oad host Register an OAD for the specified host ORBacus 121 The Implementation Repository add server server name exec host server name poa name remove oad host remove server server name remove poa server name poa name get oad status host get server info server name get poa status server name list oads list servers list poas server name tree tre
259. re 19 1 Connection Requirements Server OCI OCI Bi dir IIOP OCI IIOP Requests amp Requests Callbacks Callbacks OCI OCI IIOP IIOP OCI f Bi dir Client B Client A Any callback requests from the Server to Client A will travel down the existing connec tion already established by the client On the other hand any callback requests from the Server to Client B require a new IIOP connection to be established from the server to the client Peers The Bi directional plug in requires each peer in a bi directional connection to have a unique identifier called the peer ID Currently this identifier is just a simple ISO LATINI string In IIOP terms a unique endpoint is derived from the hostname port com bination However since the Bi directional OCI plug in has no knowledge of the underly ing protocol a separate identification scheme is currently required and must be provided by the application It is therefore the application s responsibility to ensure that each server and client has a unique peer ID In object references can be made persistent 1 valid across process restarts by ensuring that the process is restarted on the same host and port and that the object keys in the object references will continue to be valid The same is true of peer IDs If you want a bi directional IIOP object reference to remain valid across process restarts you must use 278 OR
260. ream out Hello ref 33 out lt lt s lt lt endl 34 out close 35 36 manager activate 37 orb run 38 128 ORBacus Programming Example 39 40 14 22 24 25 26 27 28 return 0 Create a new using PERSISTENT life span policy and the USER 1D object identifica tion policy Create the Hello servant Using the string hello create an object id Activate the servant with the new POA The remainder of the code is unchanged ORBacus 129 The Implementation Repository 130 ORBacus oare The Implementation Repository Console The ORBACUS Implementation Repository IMR includes a graphical client for adminis tering the service called the ORBACUS IMR Console The ORBACUS IMR Console pro vides complete control over the IMR OADs and servers in a domain ORBacus 131 The Implementation Repository Console 8 1 8 1 1 8 1 2 8 1 3 8 2 8 2 1 Synopsis Usage com ooc IMRConsole Main look CLASS windows motif mac h help look CLASS Use the specified Look amp Feel class windows Use the Windows Look amp Feel if available motif Use the Motif Look amp Feel if available mac Use the Macintosh Look amp Feel if available as Display the command line options supported by the program CLASSPATH Requirements The ORBACUS IMR Console requires the classes in OB jar OBIM
261. references published by the server This option can be especially helpful when used in conjunction with the Domain Name System DNS in which the OAhost option spec ifies a hostname alias that is mapped by DNS to the canonical hostname See Command line Options on page 58 for more information on the OAhost option Port Number Each time a server is executed the Root POA manager selects a new port number on which to listen for incoming requests Since the port number is included in published object references subsequent executions of the server could invalidate existing object ref erences To overcome this problem ORBACUS provides the OAport option that causes the Root POA manager to use the specified port number You will need to select an unused port number on your host and use that port number every time the server is started See Command line Options on page 58 for more information on the OAport option 100 ORBacus Stringified Object References 6 2 3 6 3 6 3 1 Object Key Each object created by a server is assigned a unique key that is included in object refer ences published for the object Furthermore the order in which your server creates its objects may affect the keys assigned to those objects To ensure that your objects always have the same keys activate your objects using POAs with the PERSISTENT life span policy and the USER ID object identification policy Stringifi
262. rings containing the current date and time After starting the Event Service server you can start these clients in any order The demo applications obtain the initial Event Service reference as already demonstrated i e by calling resolve initial references When started each supplier provides information about the current date and time and each client displays the event data in its console window This is the push supplier s main loop 1 Java 2 while consumer null 190 ORBacus Programming Example dc 19325 WH HB java util Date date new java util Date String s PushSupplier says date toString Any any orb create any any insert string s try consumer push any catch Disconnected ex Supplier was disconnected from event channel try Thread sleep 1000 catch InterruptedException ex The current date and time is inserted into the Any The event data in this example date and time are pushed to the event channel From the push supplier s view the event channel is just a consumer implementing the PushConsumer interface After sleeping for one second the steps above are repeated The example s pull supplier works similarly to the push supplier except that the event channel explicitly polls the supplier for new events This is done by either pull or try pull The pull supplier doesn t see anything from the e
263. roduces messages related to database operations a level of 2 or higher produces messages related to adding and removing listeners and a level of 3 or higher produces messages related to binding operations Persistence ORBACUS Names can optionally be used in a persistent mode in which all data managed by the service is saved in a file If you do not run the service in its persistent mode all of the data will be lost when the service terminates Itis also important to note that when using the service in its persistent mode you should always start the service on the same port see Chapter 4 for more information 138 ORBacus Connecting to the Service 9 1 5 9 2 9 3 CLASSPATH Requirements ORBACUS Names for Java requires the classes in OB jar and OBNaming jar Connecting to the Service The object key of the Naming Service is NameService which identifies an object of type CosNaming OBNamingContext The OBNamingContext interface is derived from the standard interface CosNaming NamingContextExt and provides additional ORBA CUS specific functionality For a description of the OBNamingContext interface please refer to the documented IDL file naming idl OBNaming idl The object key can be used when composing URL style object references For example the following URL identifies the naming service running on host nshost at port 10000 corbaloc nshost 10000 NameService Refer to Chapter 6 for more informati
264. rr println ex printStackTrace throw new SystemException 146 ORBacus Programming Example 24 25 26 27 28 29 30 31 32 33 34 35 36 3T 38 39 40 41 9 5 4 tQ NY Hh ex 9 10 2 190 catch CannotProceed ex System err printin Got a CannotProceed exception ex printStackTrace throw new SystemException catch InvalidName ex System err printin Got an InvalidName exception ex printStackTrace throw new SystemException catch AlreadyBound ex System err println Got an AlreadyBound exception ex printStackTrace throw new SystemException Catch exceptions Don t ever forget to do this It can be useful to call printStackTrace on the exception object in order to get detailed information about the program flow caus ing the exception The Event Loop Next we start listening for requests Java try manager activate catch org omg PortableServer POAManagerPackage AdapterInactive throw new RuntimeException orb run Everything is ready now so we can listen for requests by calling act iavate on POA Manager and run on the ORB ORBacus 147 ORBacus Names 9 5 5 Releasing Resources Some cleanup work should be done before exiting the program Every binding must be properly unbound and the ORB must be destroyed 1 Java 2 nc
265. rrent current org omg PortableServer CurrentHelper narrow obj if current null Got Current object OK 96 ORBacus CHAPTER 6 Locating Objects 6 1 ODN DOB Ql n Obtaining Object References Using CORBA an object can obtain a reference to another object in a multitude of ways One of the most common ways is by receiving an object reference as the result of an oper ation as demonstrated by the following example IDL interface A interface B A getA An interface A is defined An interface B is defined with an operation returning an object reference to an A On the server side A and can be implemented in C as follows C class A impl public POA A public PortableServer RefCountServantBase ORBacus 97 Locating Objects ONDA aA 10 11 12 13 14 15 16 17 18 Lg 20 21 22 23 24 25 26 27 28 7 28 14 17 RISB 24 27 Aa UNAK class B impl public POA B public PortableServer RefCountServantBase A impl a public B impl a_ new A_impl B impl a gt _remove_ref virtual A ptr getA throw CORBA SystemException return a gt this The servant class impl is defined which inherits from the skeleton class A and class Re CountServantBase which provides a reference counting implementation The servant class B impl inherits from the skeleton class
266. rs are created using the default settings For IIOP the default settings will cause an anonymous POA Manager to listen for new con nections on a port chosen by the operating system To override this behavior and allow an application to easily configure POA Managers ORBACUS provides a proprietary factory interface for creating named POA Managers IDL module OBPortableServer interface POAManagerFactory struct AcceptorConfig ORBacus 65 ORB and Object Adapter Initialization OCI ProtocolId id OCI ParamSeq params typedef sequence AcceptorConfig gt AcceptorConfigSeq exception POAManagerAlreadyExists POAManager create poa string raises POAManagerAlreadyExists OCI InvalidParam POAManager create poa manager with config in string name in AcceptorConfigSeq config raises POAManagerAlreadyExists OCI NoSuchFactory OCI InvalidParam POAManagerSeq get poa managers void destroy The example below illustrates how to create and configure a new Manager using the ORBACUS POA Manager Factory Here is an example in C C CORBA Object_var obj orb gt resolve initial references POAManagerFactory OBPortableServer POAManagerFactory var factory OBPortableServer POAManagerFactory narrow obj PortableServer POAManager var myPOAManager factory gt create poa manager MyPOAMana
267. rter must know the service type have a valid object reference and have values for all of the mandatory properties defined by the service type and any of its super types After the Trading Service has val idated the new offer a unique identifier is assigned to the offer and returned to the exporter Modifying a Service Offer The Trading Service allows service offers to be modified with a few restrictions First the object reference associated with an offer cannot be changed Second a client may add modify and delete the properties of an offer only within the limitations of the property modes established by the service type Each of the property mode combinations is described below along with the limitations if any in place when modifying a service offer e Normal Properties that are neither mandatory nor read only can be added modified and deleted without restriction e Read only Once a value has been defined for a read only property it cannot be modified A read only property that was not defined when the offer was exported can be added during a modification operation Read only properties cannot be deleted e Mandatory A mandatory property can be modified but cannot be deleted e Mandatory and read only A property that is both mandatory and read only cannot be modified or deleted Withdrawing Service Offers There are two distinct ways to withdraw service offers First a client application or the Trading
268. rties props System getProperties props put ooc orb conc model threaded props put ooc iiop port 10000 org omg CORBA ORB orb org omg CORBA ORB init args null Obtain the system properties Define ORBACUS properties Initialize the ORB Java virtual machines typically allow you to define system properties on the command line For example using Sun s JVM you can do the following java Dooc iiop port 5000 MyServer ORBacus 61 ORB and Object Adapter Initialization NOR You can also use the java util Properties object that is passed to the ORB init method to provide ORBACUS property definitions Java java util Properties props new java util Properties props put ooc iiop numeric true org omg CORBA ORB orb orb omg CORBA ORB init args props Create a java util Properties object to hold our properties Define ORBACUS properties Initialize the ORB using the java util Properties object Properties in C In C the ORBACUS specific class OB Properties can be used to define properties C class Properties public Properties Properties Properties_ptr p Properties static Properties ptr duplicate Properties ptr p static Properties ptr nil static Properties ptr getDefaultProperties void setProperty const char key const char value const char getProperty const char key const For examp
269. rties that are not defined in the service type The value of a property in a service offer can be modified if the mode of the property is not read only A property can be removed from a service offer if the property is not man datory New properties can also be added to an existing service offer Design Issues The Trading Service can be a tool for constructing efficient distributed applications The advantage of annotating a service offer with properties and allowing offers to be filtered ORBacus 201 ORBacus Trader 14 4 2 on the basis of those properties using a constraint is that importers can select offers with out having to incur the overhead of invoking operations on each object For example suppose ServiceTypeB did not have the cost property Instead let s pre tend that InterfaceB has an additional operation cost which returned a value of type float interface InterfaceB InterfaceA void do something else float cost In this situation if the importer needed to select only those objects whose cost is within a certain range the importer would need to iterate over each object returned by the Trading Service to invoke the cost operation In a distributed environment the overhead of this activity could be prohibitively expensive It is the developer s responsibility to anticipate the types of queries that importers will need to perform and design their service types accordingly Impo
270. rting Service Offers The primary responsibility of a Trading Service is satisfying an importer s request for matching service offers The CosTrading Lookup interface defines a single operation query for use by importers This operation takes a number of parameters the most important of which are explained below Service Type The service type informs the Trading Service about the kind of service in which the importer is interested The service type effectively narrows the total number of service offers the Trading Service must search to completely satisfy the importer s request Unless the importer requests otherwise the Trading Service will also consider the offers of ser vice types that are subtypes of the given service type Constraint The constraint is a boolean expression in a constraint language The Trading Service eval uates each potential service offer against the constraint if the expression evaluates to TRUE then the offer is considered a match One constraint language is defined by the Trading Service specification but proprietary query languages can also be accommodated 202 ORBacus Trading Service Concepts ORBACUS Trader supports the standard OMG constraint language which includes many of the features commonly found in query languages and is described in detail in the Trad ing Service specification The standard constraint language has constructs similar to common programming and database query lan
271. rty a request is made on the given object reference to obtain the property s value In essence the value of the property is delegated to another object which might look up the value in a database compute the value on the fly etc Dynamic properties introduce additional overhead during query processing therefore the importer can use a policy to exclude offers with dynamic properties Furthermore ORBA CUS Trader is careful to ensure that it does not needlessly evaluate a dynamic property Figure 14 1 illustrates the interactions of the objects involved 206 ORBacus Trading Service Concepts Figure 14 1 Dynamic Property Evaluation Importer Exporter 3 evalDP 2 T DynamicPropEval B Offer 1 An exporter advertises a service offer containing a dynamic property 2 Some time later an importer invokes the trader s query operation to search for service offers 3 If during the processing of the query the trader requires the value of the dynamic property the trader will invoke the eva1DP operation on the DynamicPropEval object whose reference was provided by the exporter This operation will determine the value of the property and return it to the trader 14 4 5 Trader Federation with Links A powerful feature of the Trading Service allows administrators to establish inks between traders for the propagation of query requests When an importer executes a query
272. rval in TimeBase TimeT lower 15 in TimeBase TimeT upper 172 ORBacus Time Service Extensions 16 17 6 7 Return a UTO with the current time 8 9 Since ORBACUS Time is not secure this operation will always raise a TimeUnavailable exception 10 13 Both new universal time and uto from utc return a UTO with the specified attributes 14 15 Return a TIO with the specified lower and upper bounds 12 4 Time Service Extensions ORBACUS provides additional operation for working with the structures defined in the TimeBase module In C these operations are provided by the TimeHelper class and global functions and are part of the OB module Declarations are as follows 1 2 module OB S 4 5 class TimeHelper 6 7 public 8 static const CORBA ULongLong MaxTimeT 9 OB ULONGLONG Oxffffffffffffffff 10 static const CORBA ULongLong MaxInaccuracyT 11 OB_ULONGLONG Oxffffffffffff 12 qu Static TimeBase UtcT utcNow TimeBase InaccuracyT 0 14 Static TimeBase UtcT utcMin 15 Static TimeBase UtcT utcMax 16 static timeval toTimeval const TimeBase UtcT amp 17 static timeval toTimeval TimeBase TimeT 18 Static TimeBase IntervalT toIntervalT TimeBase TimeT 19 TimeBase InaccuracyT 20 static TimeBase UtcT toUtcT TimeBase TimeT 21 TimeBase InaccuracyT TimeBase TdfT 0 22 static TimeBase UtcT toUtcT const TimeBase IntervalT amp
273. s Note that use of this option will generate proprietary stubs and skeletons which are not compatible with ORBs from other vendors Options for hidl h help v version e cpp NAMI d debug DNAME DNAME DEEF UNAME IDIR all case sensitiv These options are the same as for the 1 command no sort ORBacus 37 The ORBacus Code Generators 3 7 Don t sort symbols alphabetically ignore case Sort case insensitive output dir DIR Write HTML files to the directory DIR Options for ridl h help v version e cpp d debug DNAME DNAME DEEF UNAME IDIR ha all case sensitiv These options are the same as for the id1 command cho SOrt Don t sort symbols alphabetically ignore case Sort case insensitive output dir DIR Write RTF files to the directory DIR single file FILE Create a single rtf file called FILE with index Create index entries font NAME Use font NAME as the font for the text body 38 ORBacus Options for irgen 3 8 literal font NAME Use font NAME as the font for literals title font NAME Use font NAME as the font for the title heading font NAME font size SIZE Text body font size in points literal font size SIZE Literal font size in points
274. s Windows NT C only 7 HKEY_LOCAL_MACHINE Software 00C Properties Windows NT C only For example a property defined using a command line option overrides the same property defined in a configuration file Advanced Property Usage With the methods for ORB initialization discussed in the previous sections the command line arguments are not processed until a call to CORBA ORB init C OBCORBA ORB init or org omg CORBA ORB init Java Hence the set of properties that will be used by the ORB is not available until after the ORB is initialized This poses a problem if the properties need to be validated prior to ORB initialization If you need access to an ORB s property set before it is initialized then you may elect to use the ORBACUS specific operations OB ParseArgs C or com ooc CORBA ORB ParseArgs Java The following examples check the value of ORBacus 63 ORB and Object Adapter Initialization amp WHE Ea ka Ww A 11 DMN DoS WwW NH nm the ooc orb conc model property to ensure that it is set to reactive or threaded If not the code chooses the threaded concurrency model C OB Properties var dflt OB Properties getDefaultProperties OB Properties var props new OB Properties dflt OB ParseArgs argc argv props OB Logger _nil const char orbModel props gt getProperty ooc orb conc_model
275. s a new object with the Naming Service whereas a new context is registered with bind_context For each operation an object reference and a Name are expected as parameters New naming context objects are created with new_context or bind_new_context bind_context and bind_new_context throw an AlreadyBound exception if the name is already in use in the target context To create a new binding without being concerned if the specified binding already exists use the following operations IDL void rebind in Name n in Object obj raises NotFound CannotProceed InvalidName void rebind_context Name n in NamingContext nc raises NotFound CannotProceed InvalidName Use the unbind operation to delete a particular binding IDL void unbind in Name n raises NotFound CannotProceed InvalidName Name Resolution Besides registering objects an equally important task of the Naming Service is name reso lution A name is passed to the resolve or resolve_str operation and an object refer ence is returned if the name exists IDL Object resolve in Name n raises NotFound CannotProceed InvalidName Object resolve_str in StringName n raises NotFound CannotProceed InvalidName The resolve and resolve_str operations are only useful when a particular name is known in advance Sometimes it is necessary to ask for a list of all bindings registered with a particular naming context The 1ist operation returns a
276. s is created which is used by all clients and persistent the server process is started when the IMR starts and is used by all clients activate poas If this attribute is set to t rue default then all persistent POAs will be registered automatically If set to false then persistent POAs are not registered automatically update timeout The amount of time in milliseconds to wait for server status updates failure timeout The amount of time in seconds to wait for the server to start max spawns The maximum number of tries to start the server The IMR also maintains various state information for each server The internal ID of the server e The status of the server process The valid values are forked starting running stopping and stopped e Whether or not the server was started manually e The number of times that the server process has been spawned Server processes inherit environment settings from the environment in which the OAD was started Hence path library path and class path environment variables can be used by the server application This is especially useful in the case of shared library and class path settings Note that the class path may also be set in the args attribute On Windows platforms the exec attribute may refer to an executable or batch file On UNIX platforms the exec attribute may refer to an executable or a shell script with interpreter as its first line However if a batch file or
277. s property is use ful in situations where a host has several network interfaces but the server should only listen for connections on a particular interface ORBacus 55 ORB and Object Adapter Initialization ooc iiop host Value host host Explicitly defines the hostname s and or IP address es to be used in generated object ref erences The default value is the canonical hostname of the machine If multiple host names are specified the value of ooc iiop multi profile determines how those hostnames are represented in object references ooc iiop multi profile Value true false Specifies how multiple addresses should be represented in an object reference If true each address is represented as a separate tagged profile in the object reference If false there will be only one tagged profile with the first address used as the primary address of the profile and all other addresses represented as alternate addresses in that profile The default representation depends on the protocol version in use If the protocol version is 1 0 the default value is t rue otherwise the default value is false As far as ORBACUS is concerned the ORB behavior is identical for both representations but other ORBs may require a particular representation ooc iiop numeric Value true false If true object references are generated using the internet IP address in dotted decimal notation instead of the canonical hostname The default
278. se it had a number of seri ous deficiencies and was under specified The POA is a far more flexible and powerful object adapter than the BOA The POA not only allows you to write code that is portable among ORBs from different vendors it also provides a number of features that are essen tial for building high performance and scalable servers Implementing Servants In this section we will implement servant classes or implementation classes for the IDL interfaces defined below IDL interface A void op a interface B void op_b interface I A B void op i 0 76 ORBacus Implementing Servants 25 FALO 12 15 5 2 1 AN DoS WN RRR An interface A is defined with the operation op a An interface B is defined with the operation Interface 1 is defined which is derived from A and B It also defines a new operation Opa Implementing Servants using Inheritance ORBACUS for C and ORBACUS for Java both support the use of inheritance for inter face implementation To implement an interface using inheritance you write a servant class that inherits from a skeleton class generated by the IDL translator By convention the name of the servant class should be the name of the interface with the suffix impl e g for an interface I the implementation class is named I impl Inherita
279. servant is activated implicitly by calling this Note that implicit activation as shown requires the RETAIN IMPLICIT ACTIVATION and SYSTEM ID policies on the servant s POA The servant is activated with the POA that is returned by the servant S default member function The default implementa 86 ORBacus Activating Servants 5 4 2 5 4 3 Aa NOR tion of _default_POA returns the Root POA if you want servants activated on a differ ent POA you must override default POA in the implementation class to return the POA you want to use Implicit Activation of Servants using Java This is how Java servants are implicitly activated Java org omg CORBA ORB orb Get a reference to the ORB somehow I impl impl new I impl I Iref impl this orb To activate a servant we need the ORB A new servant impl is created The new servant is activated using the POA returned by the servant Ss default operation As shown above a servant in Java must be associated with an ORB and cannot be associ ated with multiple ORBs The first call to tnis must supply the ORB reference sub sequent calls to this for the same servant can omit the ORB reference An alternative way to associate a servant with an ORB is to call the set delegate method defined in org omg CORBA 2 3 ORB Java org omg CORBA ORB orb Get a reference to the ORB somehow org omg CORBA 2 3 O
280. server Server2 args ORBInitRef IMR corbaloc master 10000 IMR A C server can automatically register itself with the IMR using the ORBregister command line option For example to registered Server1 run the following on slavel usr local bin serverl ORBregister Serverl ORBInitRef IMR corbaloc master 10000 IMR If the server requires command line options then these options must be added using the imradmin utility 6 Add each POA to the IMR In this example the servers are registered without setting the activate poas attribute so the attribute defaults to true Hence all persistent POAs will be regis tered automatically If this were not the case the POAs would have to be registered manually 7 Configure your servers to use the IMR There are three ways to configure a server to use the IMR ORBacus 125 The Implementation Repository 7 6 a Use the ORBregister command line option only available for C servers This option is used for server registration and can only be used when starting the server for the first time b Use the ORBserver_name command line option c Use the ooc orb server name configuration property This configuration property is equivalent to the ORBserver name command line option and may be set in a configuration file or programmatically prior to initializing the ORB in a server In this example the IMR is responsible for starting the servers Hence when the
281. shell script is used then it should accept the ORBserver name option since it is automatically appended to the args attribute by the IMR ORBacus 115 The Implementation Repository 7 1 3 In the case of Java servers a batch file or shell script should be created to start the server An alternative is to set the exec attribute to the Java interpreter and to use the args attribute to specify the class implementing the server POAs The IMR allows implicit registration of POAs when the server is started This can be enabled or disabled for each server using the activate poas server attribute If implicit registration is enabled then the user does not have to register any of the POAs instead the server transparently notifies the IMR whenever a call to create POA is made by the application code If the user disables implicit registration then the user must register all persistent POAs 1 POAs with the PERSISTENT life span policy POAs are registered using the name of its server and the name of the POA Note that any transient POAs POAs with the TRANSIENT life span policy created by the server are not registered with the IMR The IMR also maintains the status for each POA which indicates the state of its POA Manager The valid values are inactive active holding and discarding IMR Security Itis very important that only the IMR s public port also referred to as its forward port be accessible outsi
282. sole main window E Trader Console Console Edit View Pile Es Insert Tools D amp x oa 9 Service Types 2 escription of Mortgage terface IDL LenderDemo Lender 1 0 mandatory float pct down mandatory string product id mandatory float rate mandatory short years carnation 1 0 10 IDL omg org CosTrading L ookup 1 0 Host 1 1 1 1 Port 1063 The main window includes the following elements Menu bar Toolbar Item type selector Item list Item description Status bar 15 3 Terminology Provides access to all of the application s features Shortcuts for the most common menu commands Selects which type of item is shown in the item list Displays the names or identifiers of all items contained in the trader Provides a textual summary of the selected item Displays information about the trader to which the console is currently connected including the host port and IDL interface The ORBACus Trader Console application uses the term item to generically refer to the four types of data managed by a trading service e Service types ORBacus 217 ORBacus Trader Console 15 4 15 4 1 15 4 2 e Offers e Proxy offers Links The console window is used to browse these items The window only shows one type of item at a time which you can change with the item type selector drop down list or by selecting a type from the View menu When a new item type is selected
283. t 65535 Specifies the port number on which the POA Manager with name manager should listen for new connections If no port is specified one will be selected automatically by the server 4 3 4 Command line Options There are equivalent command line options for many of the ORBACUS properties The options and their equivalent property settings are shown in Table 4 1 Refer to ORB Properties on page 49 for a description of the properties Option Property OAbacklog backlog ooc iiop backlog backlog OAbind host ooc iiop bind host OAhost host host ooc iiop host host host OAnumeric ooc iiop numeric true OAport port ooc iiop port port OAreactive ooc orb oa conc_model reactive OAthreaded ooc orb oa conc model threaded OAthread per client ooc orb oa conc model thread per client OAthread per request ooc orb oa conc model thread per request OAthread pooln ooc orb oa conc model thread pool ooc orb oa thread_pool n OAversion version ooc orb oa version version ORBblocking ooc orb conc model blocking ORBDefaultInitRef URL ooc orb default init ref URL ORBid id ooc orb id id ORBInitRef name ior ooc orb service name ior ORBnative cs name ooc orb native cs name Table 4 1 Command line Options 58 ORBacus Configuring the ORB and Object Adapter Option Property ORBnative wcs name ooc orb native wcs
284. t 5002 TradingService Note that trailing blanks are not ignored but are a part of the property You can define the name of the configuration file using a command line option an envi ronment variable C or a system property Java e Command line option ORBconfig filename e Environment variable ORBACUS CONFIG filename e Java system property ooc config filename When an ORB is initialized it first checks for the presence of the environment variable or system property If present the ORB loads the configuration file Next the ORB loads the configuration file specified by the ORBconfig option Therefore the properties loaded from the file specified by ORBconfig will override any existing properties including those loaded by a configuration file specified in the environment variable or system prop erty See Precedence of Properties on page 63 for more information Configuration files are only loaded during ORB initialization Changes made to a configu ration file after an ORB has been initialized have no effect on that ORB Using the Windows NT Registry Another convenient mechanism for use with C applications under Windows NT is to use the system registry Properties can be stored in the registry under the following regis try keys HKEY LOCAL MACHINENSoftwareNOOCMProperties HKEY CURRENT USERNSoftwareNOOCNProperties Individual properties are defined as sub keys of the base For example
285. t B Server Figure 18 5 Thread per Client Server The thread per client model is still efficient Like with the threaded concurrency model no threads need to be created except when new connections are accepted 18 3 3 Thread per Request Server If the thread per request server concurrency model is chosen the ORB creates a new thread for each request This is shown in Figure 18 6 For simplicity there are no separate f 90 h gt Client A Thread per Request Client B Server Figure 18 6 Thread per Request Server ORBacus 261 Concurrency Models 18 3 4 arrows for dispatch and thread creation in the diagram With the thread per request model requests are never delayed When they arrive a new thread is created and the request is executed in the user code using this thread On return the thread is destroyed Besides using a reactive client together with a reactive server the thread per request server in combination with a threaded client is the only other model that allows nested method calls with an unlimited nesting level The thread pool model also allows nested method calls but the nesting level is limited by the number of threads in the pool The thread per request concurrency model is inefficient The main problem results from the overhead involved in creating new threads namely one for each request Thread Pool S
286. t is the Open Communications Interface 267 Interface Summary 267 Buffer 267 Transport 268 Acceptor and Connector 268 Acceptor and Connector Factories 268 The Registries 268 The Info Objects 268 Class Diagram 269 ORBacus 11 CHAPTER 20 APPENDIX A OCI Reference 270 OCI for the Application Programmer 270 A Converter Class for Java 270 Getting Hostnames and Port Numbers 271 Determining a Client s IP Address 272 Determining a Server s IP Address 274 The IIOP OCI Plug in 275 IIOP Acceptor Configuration 275 The Bi directional OCI Plug in 277 How does it work 277 Peers 278 POA Managers 279 Initialization and Configuration 279 Bi directional Acceptor Configuration 281 Exceptions and Error Messages 283 CORBA System Exceptions 283 INITIALIZE Minor Exception Code 286 UNKNOWN Minor Exception Code 286 BAD_PARAM Minor Exception Code 286 NO MEMORY Minor Exception Code 288 IMP LIMIT Minor Exception Code 288 COMM FAILURE Minor Exception Code 288 MARSHAL Minor Exception Code 290 NO IMPLEMENT Minor Exception Code 292 NO RESOURCES Minor Exception Code 292 BAD INV ORDER Minor Exception Code 292 TRANSIENT Minor Exception Code 293 INTF REPOS Minor Exception Code 293 OBJECT NOT EXIST Minor Exception Code 293 POLICY Minor Exception Code 293 Non Compliant Application Asserts 293 Boot Manager Reference 297 Interface OB BootManager 297 Interface OB BootLocator 299 12 ORBacus APPENDIX B APPEN
287. t provided This option is passed DNAME DEF directly to the preprocessor ANANE Removes any definition for NAME This option is passed directly to the E preprocessor LODS Adds DIR to the include file search path This option is passed directly to the preprocessor Run only the preprocessor Er The semantics of OMG IDL forbid identifiers in the same scope to differ only in case This option relaxes these semantics but is only provided for backward compatibility with non compliant IDL case sensitiv FILE IDL files to be loaded into the repository Windows NT Native Service ntirservice h help i install s start install u uninstall d debug h heip Display the command line options supported by the server ES Install the service The service must be started manually install s Install the service and start it start install u Uninstall the service uninstall d gt debug Run the service in debug mode 244 ORBacus Synopsis 16 1 3 In order to use the IFR as a native Windows NT service it is first necessary to add the ooc ifr port configuration property to the HKEY LOCAL MACHINE NT registry key see Using the Windows NT Registry on page 60 for more details Next the service should be installed with ntirservice i This adds the ORBacus Interface Repository Service entry to the Services dia log in the Control Panel T
288. talled A value of none will typically be used when a different protocol plug in is being used and the IIOP plug in is unnecessary ooc orb native cs Value string Specifies the native character code set for the ORB The default is ISO 8859 1 ooc orb native wcs Value string Specifies the native wide character code set for the ORB The default is UTF 16 ooc orb raise dii exceptions Value true false Determines whether system exceptions that occur during Dynamic Invocation Interface DII operations are raised immediately or are stored only in the CORBA Environment object This property is only available for Java applications The default value is false for JDK 1 1 x and true for later JDK versions Note that specifying a value of false when using JDK 1 2 or later may result in unexpected behavior ORBacus 5 ORB and Object Adapter Initialization ooc orb server name Value string Specifies the name of the server as registered with the Implementation Repository IMR Note that you should not put this property in a configuration file that is shared by several IMR enabled servers Furthermore this property should not be specified for servers that are not registered with the IMR ooc orb server shutdown timeout Value timeout gt 0 If the server is not able to gracefully disconnect from the client in timeout seconds a con nection shutdown is forced If this property is set to zero then the server will
289. tarts to dispatch a request on the servant the reference count is increased by 1 After request dispatching is finished the count is decremented by 1 This ensures that a reference counted servant cannot be deleted while a request is exe cuting Factory Objects using Java Here is our Java implementation of the Product interface Java public class Product impl extends ProductPOA public void destroy byte id default POA servant to id this default POA deactivate object id Servant class Product impl is defined as an implementation of the Product interface The dest roy operation deactivates the servant with the POA As long as no other refer ences to the servant are held in the server the object will be eligible for garbage collec tion Here s our implementation of the factory Java public class Factory impl extends FactoryPOA public Product createProduct Product impl result new Product impl orb org omg PortableServer POA poa Get servant s POA byte id Assign an ID poa activate object with id id result return result this Servant class Factory impl is defined as an implementation of the Factory interface The createProduct operation instantiates a new Product servant activates it with the POA and returns an object reference to the client ORBacus 93 CORBA Objects 5 6 3 5 6 4 AN O Ci WH NH Rs RRR
290. tered acceptors is requested from the POA Manager The for loop iterates over all acceptors The info object for the acceptor is requested and narrowed to an IIOP acceptor info object ORBacus 271 The Open Communications Interface 10 12 16 AN Dos WH Ns E sk ka OS 18 13 15 16 19 4 3 AN WwW NH The i block is only entered in case the info object really belongs to plug in The hostname and port number are requested from the IIOP acceptor info object and printed on standard output The Java version is basically equivalent to the C code and looks as follows Java com ooc OCI Acceptor acceptors poaManager get acceptors for int i 0 i lt acceptors length i com ooc OCI AcceptorInfo info acceptors il get info com ooc OCI IIOP AcceptorInfo iiopInfo com ooc OCI IIOP AcceptorInfoHelper narrow info if iiopInfo null String hosts iiopInfo hosts short port Converter port iiopInfo port System out println host host 0 System out println port port This is equivalent to the C version The converter class is used to get a port number in int format Like in the C version the hostname and port number are printed on standard output Determining a Client s IP Address To determine the IP address of a client within a server method the following code can
291. terfaceDef def InterfaceDefHelper narrow defObj org omg CORBA InterfaceDefPackage FullInterfaceDescription desc def describe_interface jnt ay System out println name desc name System out println id desc id System out println defined in desc defined in System out println version desc version System out println operations for i 0 i lt desc operations length i System out println i desc operations i name ORBacus 247 The Interface Repository 29 30 31 39 34 35 36 37 38 39 16 17 19 329 System out println attributes for i 0 i lt desc attributes length i System out println i desc attributes i name System out printin base_interfaces for i 0 i lt desc base interfaces length i System out println i desc base interfaces il After initializing the ORB and obtaining an object reference we invoke get interface deflonthe object If no interface definition could be found get interface def returns nil Narrow the object reference to InterfaceDef We now have a reference to an object in the IFR that describes the most derived type of our object reference Request a complete description of the interface Print information about the interface including the names of its operations and attributes A complete example of how to use the IFR can be fo
292. th any other property If you later decide that you do not want to include the property with the offer simply uncheck the property s checkbox 6 If you wish to make a property dynamic select the property and click the Dynamic button The Dynamic Property dialog box appears as shown below Select a method for specifying an object reference as outlined in step 3 above If you wish to include additional data select a type from the drop down list and enter a value in the text box ORBacus 225 ORBacus Trader Console Click OK to save the dynamic property The property table displays dynamic as the value of a dynamic property Dynamic Property rate x IOR Fromfile Browse Extra information None m Value OK Cancel 7 clear the value of a property select the property and click Reset You can use this command to convert a property from a dynamic property to a regular property 8 Click OK to add the new offer The application validates the information and reports any errors in a dialog box Note For properties of type string an empty value is accepted as a valid value even for mandatory properties 15 7 2 Modifying an Offer To modify an offer do the following 1 Select View Offers to display the offers in the item list 2 Select the offer you wish to modify 226 ORBacus Managing Offers 15 7 3 3 Select Edit Modify The Edit O
293. the current list of items is retrieved from the trading service and displayed in the item list The Trader Console Menus This section describes the ORBACUS Trader Console menu commands The Console menu You use the commands in the Console menu to manage the console windows New Window Creates a new console window connected to the current trader Connect Opens the Connect dialog box allowing you to connect to a different trading service Close Closes the current console window If this window is the last console window present the application exits Exit Quits the application The Edit menu The console supports the typical notion of a clipboard which can be manipulated with cut copy and paste commands However the console does not use the system clipboard and therefore the application clipboard can only be accessed by windows from the same exe cution of the application In other words if you start two instances of the application you cannot cut and paste between them You can cut and paste if you start a single instance of the application and create multiple windows with the Console New Window command Cut Copies the selected items to the clipboard and then permanently removes the selected items Copy Copies the selected items to the clipboard Paste Pastes the items from the clipboard into the current trader 1 Also known as a combo box 218 ORBacus The Trader Console Menus 15 4 3 Select All
294. the object reference to a B object The presence of the stringified object reference in the HTML file could present a mainte nance problem One solution is for the server to write the entire HTML file thereby ensur ing that the object reference is always up to date You can find an example of this approach in the demo he110 subdirectory See Applets on page 72 for more information on using ORBACUS in applets 104 ORBacus Object Reference URLs 6 4 6 4 1 Object Reference URLs Prior to the adoption of the Interoperable Naming Service INS 10 the only standard format for stringified object references was the cumbersome IOR format The INS intro duced two new more readable formats for object references that use a URL like syntax Object reference URLs can be passed to string to object just like IOR references The two new URL formats are described in detail in the specification but will be briefly discussed here The optional ile URL format is also discussed as well as the propri etary relfile URL format corbaloc URLs The corbaloc URL supports any number of protocols the format of the URL depends on the protocol in use The general format of a corbaloc URL is shown below corbaloc protocol protocol specific ORBACUS supports two standard protocols iiop and rir The corbaloc URL for the iiop protocol has the following structure corbaloc iiop versionG host port object key The compon
295. the selected items Cut Moves the selected items to the clipboard Copy Copies the selected items to the clipboard Paste Inserts the clipboard contents Change ID Edits the ID field of the selected item Change Kind Edits the Kind field of the selected item Change IOR Edits the IOR of the selected item Select all Selects all items in the object table Invert Selection Inverts the current selection New contexts and bindings are created with the operations New Context and New Binding respectively If one of these functions is selected a new context or object binding with a unique name is added to the current context For new object bindings an IOR can be spec ified Use Delete to remove the selected items from a naming context Deleting Naming Service entries removes all selected bindings from their parent context The objects belonging to these bindings are not affected Destroying Naming Service information only affects the actual Naming Service data not the objects themselves Use Link to create a new binding for an existing naming context where the naming con text is specified by an IOR The operation Unlink unbinds the selected items For objects Unlink is equivalent to Delete but for contexts Unlink differs in that the context is not destroyed Since a context is not destroyed using Unlink it should only be used when there are multiple bindings to a context in order to avoid orphaned contexts The console supports a clipboard
296. there is overlap The overlap interval is the intersection of the two intervals e OTNoOverlap indicates that the two intervals do not intersect The overlap interval is the gap between the two intervals Exceptions In addition to the standard CORBA exceptions the Time Service may raise the TimeUnavailable exception that is declared in the CosTime module ORBACUS Time will always raise the TimeUnavailable exception when the secure universal time operation of the TimeService interface is invoked This is because ORBACUS Time does not provide secure time The Universal Time Object The Universal Time Object UTO represents an absolute or relative time along with its associated inaccuracy and time displacement factor The UTO also provides various oper ations related to time The UTO is declared in the CosTime module as follows IDL module CosTime interface TIO forward declaration 170 ORBacus Time Service Concepts MOND 12 T2 13 14 IS 16 T7 10 11 12 13 14 15 12 3 6 ND GO Ww NY HB interface UTO readonly attribute TimeBase TimeT time readonly attribute TimeBase InaccuracyT inaccuracy readonly attribute TimeBase TdfT tdf readonly attribute TimeBase UtcT utc_time UTO absolute_time TimeComparison compare_time in ComparisonType comparison_type in UTO uto TIO time to interval in UTO uto TIO interval
297. tialize the ORB e Create a POA Manager with one or more Bi directional acceptors e Create POAs activate servants etc e Activate POAManager The createPOAManager method initializes the Bi directional OCI plug in for IIOP and returns a new POA Manager Java package com ooc BiDir public class IIOP public static org omg PortableServer POAManager createPOAManager ORBacus 279 The Open Communications Interface String name org omg CORBA ORB orb String args java util Properties properties C include OB BiDirIIOPInit h namespace OBBiDir namespace IIOP PortableServer POAManager ptr createPOAManager const char name CORBA ORB_ptr orb int amp argc char argv OB Properties ptr properties The createPOAManager method supports the following properties ooc bidir peer id Specifies the peer identifier for this ORB This property is required ooc bidir mode client server both Specifies the bi directional mode If the value is client then only callback connections will be accepted If the value is server then bi directional connections will only be accepted on a port The default value is both in which both kinds of connections are accepted The following command line option is also supported BIDIRpeer ID Equivalent to ooc bidir peer If the command line option and the ooc bidir peer property are both defined the command line option has preceden
298. ting of RETRY ST behavior can be relaxed using RETRY_ALWAYS RICT most communication failures will not cause a retry This 310 ORBacus Interface OB TimeoutPolicy B 9 Interface OB TimeoutPolicy interface TimeoutPolicy inherits from CORBA Policy The timeout policy This policy can be used to specify the default timeout for connection establish ment and requests If an object also has Connect ionTimeoutPolicy or Request TimeoutPol icy Set those values have precedence See Also ConnectionTimeoutPolicy RequestTimeoutPolicy Attributes value readonly attribute unsigned long value If an object has a TimeoutPolicy set and a connection cannot be established or no response to a request is available after value milliseconds a CORBA NO_RESPONSE exception is raised The default value is 1 which means no timeout ORBacus 311 ORBacus Policy Reference 312 ORBacus weenoxe Reactor Reference C l Interface OB Reactor interface Reactor A generic Reactor interface Operations register handler void register handler in EventHandler handler in Mask handler mask in TypeMask type mask in Handle nh Register an event handler with the Reactor or change the registration of an already registered event handler Parameters handler The event handler to register mask The type of events the event handler is interested in type mask The category the event
299. tion informs the ORB run time which particular servant represents or incarnates a particular CORBA object Activation of a servant assigns an object identifier to the servant That object identifier is also embedded in every object reference that is created for an object and serves to link the object reference with its servant The POA s IdAssignmentPolicy value controls whether object IDs are assigned by the POA or the server application code The SYSTEM ID policy value directs the ORB to assign a unique object identifier to the CORBA object represented by the servant the USER ID policy value requires the server application code to supply an ID that must be unique within the servant s POA Servants can be activated implicitly or explicitly Implicit activation takes place when you create the first object reference for a servant Explicit activation requires a separate API call Typically you will use implicit activation for transient objects and explicit activation for persistent objects The ImplicitActivationPolicy controls whether explicit or implicit is in effect Explicit activation requires the NO IMPLICIT ACTIVATION policy value on the servant s POA whereas implicit activation requires the IMPLICIT ACTIVATION policy value Implicit Activation of Servants using C The following code shows how to implicitly activate a servant C I impl impl I var iv impl gt this A new servant impl is created The new
300. tions participating in generating and accepting events are called suppliers and con sumers respectively Suppliers and consumers each come in two different versions namely push suppliers and pull suppliers and push consumers and pull consumers What s the difference between pushing events and pulling events Let s have a look at the consumer side first Some consumers must be immediately informed when new events become available on an event channel Such consumers usually act as push consumers They implement the PushConsumer interface which ensures that the event channel actively forwards events to them using the push operation IDL interface PushConsumer void push in any data raises Disconnected void disconnect push consumer Push consumers are passive that is are servers Conversely pull consumers are active that is are clients Pull consumers poll an event channel for new events As events may arrive at a greater rate than they are polled for by a pull consumer or accepted and pro cessed by a push consumer some events might get lost A buffering policy implemented by the event channel determines whether events are buffered and what happens in case of an event queue overflow ORBacus 187 ORBacus Events 13 4 3 13 4 4 Like consumers suppliers can also use push or pull behavior Push suppliers are the more common type in which the supplier directly forwards data to the event channel and
301. to create Acceptors and Connectors Acceptors are created infrequently usually only when POA Managers are created Con nectors however need to be created by clients whenever a new connection to a server has to be established The only component of the OCI that is configurable by applications is the Acceptor When creating a new Acceptor an Acceptor Factory takes a sequence of protocol specific parameters which are used to configure the Acceptor Each plug in implementation should document these configuration parameters The configuration parameters for the plug ins included with ORBACUS are described later in this chapter The Registries The ORB provides Acceptor and Connector Factory Registries These registries allow the plugging in of new protocols Transport Connector Connector Factory Acceptor Factory and Acceptor must be written by the plug in implementors The Connector Factory must then be registered with the ORB s Connector Factory Registry and the Acceptor Factory must be registered with the ORB s Acceptor Factory Registry The Info Objects Info objects provide information on Transports Acceptors and Connectors A Transport Info provides information on a Transport an Acceptor Info on an Acceptor and a Connec tor Info on a Connector To get information for a concrete protocol these info objects 268 ORBacus Interface Summary must be narrow d to an info object for this protocol for example in the case of an
302. tory bidir demo hello Bi directional Acceptor Configuration The configuration parameters for the Bi directional Acceptor are described in Table 19 1 ORBacus 281 The Open Communications Interface Table 19 1 Bi directional Acceptor Configuration Parameters Name Type Description callback boolean Specifies whether the factory should create a callback acceptor i e one that can only receive callback connections Note that only one callback acceptor can be created per ORB If not specified the default value is false params OCI ParamSeq Provides a sequence of parameters for use in creating a protocol specific acceptor For example when creating a bi directional IIOP acceptor these parameters are used by the Bi directional plug in to create an acceptor This parameter can only be specified when the callback parameter is false 282 ORBacus oarra Exceptions and Error Messages 20 1 CORBA System Exceptions The CORBA specification defines the standard system exceptions shown in Table 20 1 In UNKNOWN Unknown exception type BAD PARAM An invalid parameter was passed NO MEMORY Failure to allocate dynamic memory IMP LIMIT Implementation limit was violated COMM FAILURE Communication failure INV OBJREF Invalid object reference O PERMISSION The attempted operation was not p
303. ts See Also TimeoutPolicy Attributes value readonly attribute unsigned long value If an object has a Request TimeoutPolicy set and no response to a request is available after value milliseconds a CORBA NO_RESPONSE exception is raised The default value is 1 which means no timeout ORBacus 309 ORBacus Policy Reference B 8 Interface OB RetryPolicy interface RetryPolicy inherits from CORBA Policy The retry policy This policy is used to specify whether requests are retried after communication failures 1 CORBA TRANSIENT and CORBA COMM_FAILURI Attributes value readonly attribute short value E exceptions RETRY NEVER indicates that requests should never be retried and the exception is re thrown to the application RETRY STRICT will retry once if the exception completion status is COMPLETED NO in order to guarantee at most once semantics RETRY_ALWAYS will retry once regardless of the exception completion status The default value 15 RETRY STRICT Note Many TCP IP stacks do not provide a reliable indication of communication failure when send ing smaller requests therefore the failure may not be detected until the ORB attempts to read the reply In this case the ORB must assume that the remote end has received the request in order to guarantee at most once semantics for the request The implication is that when using the default set
304. type must conform to the interface type of all super types ORBACUS Trader may use the interface repository to verify that this is true For example consider two IDL interfaces InterfaceA and InterfaceB defined below interface InterfaceA void do something interface InterfaceB InterfaceA void do something else InterfaceB 15 defined as a subclass of InterfaceA Now let s define two service types service ServiceTypeA interface InterfaceA property string name service ServiceTypeB ServiceTypeA interface InterfaceB mandatory property string name readonly property float cost In the example above ServiceTypeB inherits from ServiceTypeA As such it inherits all of the property types from ServiceTypeA and declares an interface type of InterfaceB which conforms to the interface type of its super type because InterfaceB is a subclass of InterfaceA Notice that ServiceTypeB redefines the mode of the name property Whereas the defi nition in ServiceTypeA does not specify a mode making the property optional the def inition in ServiceTypeB makes this property mandatory therefore a value for the 200 ORBacus Trading Service Concepts property must be supplied when the offer is exported Note that the reverse is not allowed a subtype cannot redefine a mandatory property to be optional ServiceTypeB also adds a new property
305. ues Export the service offer supplying the object reference of the PrintServer the service type and the properties 212 ORBacus Programming Example 14 5 2 AN CQ RRR 90 DO 18 19 The Client Most of the code in the example client located in demo printer Client java involves creating and managing the graphical user interface The code that executes the trader query is shown below org omg CosTrading Policy policies new org omg CosTrading Policy 0 org omg CosTrading LookupPackage SpecifiedProps desiredProps new org omg CosTrading LookupPackage SpecifiedProps desiredProps default org omg CosTrading LookupPackage HowManyProps all org omg CosTrading OfferSeqHolder offers new org omg CosTrading OfferSegHolder org omg CosTrading OfferIteratorHolder iter new org omg CosTrading OfferIteratorHolder org omg CosTrading PolicyNameSeqHolder limits new org omg CosTrading PolicyNameSeqHolder trader_ query Printer constraint preference policies desiredProps 100 offers iter limits if iter value null iter value destroy Allocate an empty array of policies See the example client in demo loan client fora demonstration of how to use policies in a query The client wants the server to return all of the properties for each matching offer Allocate holders for the out parameters
306. umes that the ORB has already been initialized as usual First the Java version Java org omg CORBA Object obj null org omg CosNaming NamingContext ctx null 108 ORBacus Initial Services ONDA OA 11 12 13 14 15 16 L7 18 19 20 21 22 23 24 29 26 19 26 AND GOA t RW C N O try obj orb resolve_initial_references NameService catch org omg CORBA ORBPackage InvalidName ex An error occured service is not available if obj null The object reference is invalid try ctx org omg CosNaming NamingContextHelper narrow obj catch org omg CORBA BAD_PARAM ex This object does not implement a NamingContext Try to resolve the name of a particular service If a service of the specified name is not known to the ORB an InvalidName exception is thrown The service type was known Now the object reference has to be narrowed to the particular service type If this fails the service is not available And here s the C version C CORBA Object_var obj CosNaming NamingContext var ctx try obj orb gt resolve initial references NameService catch CORBA ORB InvalidName amp An error occured service is not available ORBacus 109 Locating Objects 14 15 16 17 L8 Lg 20 21 22 23 1 23 6 5 2 if CORBA is nil obj The object re
307. und in the ob demo repository subdirectory 1 Recent versions of the IDL to Java mapping introduced the get interface def operation which returns org omg CORBA Object instead of org omg CORBA InterfaceDef Portable Java applications should use get interface def In the operation is get interface 248 ORBacus CHAPTER 17 Using Policies 17 1 Overview The ORB and its services may allow the application developer to configure the semantics of its operations This configuration is accomplished in a structured manner through inter faces derived from the interface CORBA Policy There are two basic types of policies those used to configure the ORB and those used to create a new POA Furthermore the configuration of ORB policy objects is accomplished at two levels e ORB Level These policies override the system defaults The ORB has an initial reference ORBPolicyManager A PolicyManager has a set of operations through which the current set of overriding policies can be obtained and new policies can be applied e Object Level The object interface contains operations to retrieve and set policies for itself Policies applied at the object level override those applied at the thread level or the ORB level For more information on Policies the PolicyManager interface and the CORBA Object policy operations see 8 and 4 ORBacus 249 Using Policies 17 2 Supported Policies The followi
308. union enum or exception type param parameter name description Adds a parameter description to the parameter list of an operation return description 1 Preprocessor statements like define or ifdef may be placed before your include statements ORBacus 41 The ORBacus Code Generators PER GUERRE 3943226451 zu Module OCI The Open Communi merie OCT The deBnitiens im this module gravide a uniform mrierface to neturock This alaws Bor easy plug c new probarols of other commounicabon obo ORE that amglereeni the OCD Fordserssore protocol enpletestatiuriz ated andy to be written abs and cas then be reused with al OC CERE Far mare nfermabon please ree the OC documeniaion hloadule Index Tic made cente interfaces to gather formato en the OF OCT pegan Interface Index i A masiy for Acceptars Actegl c B An fe an accept callback obari crepjor mirisa for an Acceptor obpect wi i used by CORBA sereens to accept clent roenertar quests lefarmatexs on an CIC oieri Buffer n nierien for briffer mier nca for a cloro callback abect ConFachory A Ix for Cannector ohyects CpaFarte vista i PUER rire LE Figure 3 1 Documentation generated with the IDL to HTML translator Adds descriptive text for the return value of an operation
309. unsigned long delta Increment the position counter Parameters delta The value to add to the position counter rest length unsigned long rest length 324 ORBacus Interface OCI Buffer Returns the rest length of the buffer The rest length is the length minus the position counter s value If the value of the position counter exceeds the buffer s length the return value is unde fined Returns The rest length is full boolean is full Checks if the buffer is full The buffer is considered full if its length is equal to the position counter s value Returns TRUE if the buffer is full FALSE otherwise ORBacus 325 Open Communications Interface Reference E 3 Interface OCI Transport interface Transport The interface for a Transport object which provides operations for sending and receiving octet streams In addition it is possible to register callbacks with the Transport object which are invoked whenever data can be sent or received without blocking See Also Connector Acceptor Attributes id readonly attribute ProtocolId id The protocol id tag readonly attribute ProfileId tag The profile id tag handle readonly attribute Handle handle The handle for this Transport The handle may only be used to determine whether the Trans port object is ready to send or to receive data e g with select on Unix based operating systems All other uses e g
310. use the X11 Reactor can obtain a special X11 Reactor using lReactor which it must pass to OBCORBA ORB init An applicati OB GetX1 i A CE 2 include 3 4 include 5 include 6 include 7 include 8 9 int main 10 11 1 13 14 15 16 SA CORBA 18 OB 19 20 21 22 23 24 25 X11 Intrinsic h lt OB CORBA h gt lt OB Logger h gt lt OB Properties h gt lt OB X11 h gt int argc char argv XtAppContext appContext Widget topLevel XtAppInitialize amp appContext MyApplication 0 0 amp argc argv 0 0 0 OB Reactor var reactor OB GetXllReactor appContext ORB var OBCORBA ORB init argc argv Properties nil OB Logger nil reactor POA initialization not shown orb run Cleanup not shown 1 7 Include header files 11 13 Initialize the X11 application 264 ORBacus The Reactor 15 17 22 AN CQ No NON ON ks ka ka ka ka ka ka C lo 2 DH AN DA GAB DOD 13 15 16 20 Use the X11 application context to obtain a X11 Reactor Initialize the ORB using the ORBACUS specific OBCORBA ORB_init Enter the CORBA event loop This loop will also dispatch X11 events Alternatively the standard X11 event loop may be called which will also dispatch CORBA events The Windows Reactor Using a Windows Reactor is very similar to using a X11 Reacto
311. ut s endl out close A servant for the interface B is created and is used to incarnate a CORBA object The object reference of the servant is stringified The stringified object reference is written to a file In Java the server code looks like this Java org omg CORBA ORB orb Get a reference to the ORB somehow B impl bImpl new B impl B b bImpl this orb String ref orb object to string b java io PrintWriter out new java io PrintWriter new java io FileOutputStream object ref out println ref out close A servant for the interface B is created and is used to incarnate a CORBA object The object reference of the servant is stringified The stringified object reference is written to a file Now that the stringified object reference resides in a file our clients can read the file and convert the string to an object reference C CORBA ORB var orb Get a reference to the ORB somehow ifstream in object ref string S gt gt s CORBA Object_var obj orb gt string to object s c str B var b B narrow obj The stringified object reference is read string to object creates an object reference from the string 102 ORBacus Stringified Object References 6 3 2 Qo Wow NARO Since the return value of string to object is of type CORBA Object ptr
312. validates the information and reports any errors in a dialog box Note For properties of type string an empty value is accepted as a valid value even for mandatory properties 15 8 2 Withdrawing Proxy Offers To withdraw a proxy offer do the following Select View Proxy Offers to display the proxy offers in the item list Select the proxy offer you wish to withdraw Select Edit Delete A confirmation dialog appears Pe Ny Click Yes to withdraw the proxy offer ORBacus 231 ORBacus Trader Console 15 9 Managing Links 15 9 1 Adding a New Link To add a new link do the following 1 Select Insert Link The New Link dialog box appears as shown below E New Link x Name Target Lookup IOR From file Browse Default follow rule Always Limiting follow rule Always OK Cancel 2 Enter a name for this link in the text box 3 Select a method for specifying the target trader s object reference for this link Select the IOR toggle if you want to paste the stringified interoperable object reference into the text box If you want the application to read the reference from a file select From file and enter the filename in the text box or click the Browse button to display a file selection dialog box 4 Select the appropriate link follow rules from the drop down lists 5 Click OK to add the new link 15 9 2 Modifying a Link To modify a link
313. value 0 The LOCATION_TRANSPARENCY_STRICT LocationTransparencyPolicy value PROTOCOL_POLICY_ID const CORBA PolicyType PROTOCOL POLICY ID 1330577410 This policy type identifies the protocol policy REQUEST TIMEOUT POLICY ID const CORBA PolicyType R This policy type identifies the request timeout policy RETRY ALWAYS EQUEST TIMEOUT POLICY ID 1330577417 const short RETRY ALWAYS 2 The RETRY ALWAYS RetryPolicy value RETRY NEVER const short RETRY NEVER 0 The RETRY NEVER RetryPolicy value RETRY POLICY ID const CORBA PolicyType R ETRY POLICY ID This policy type identifies the retry policy RETRY STRICT const short RETRY STRICT 1 The RETRY STRICT RetryPolicy value 1330577412 302 ORBacus Module OB TIMEOUT POLICY ID const CORBA PolicyType TIMEOUT POLICY ID 1330577413 This policy type identifies the timeout policy ORBacus 303 ORBacus Policy Reference B 2 Interface OB ConnectTimeoutPolicy interface ConnectTimeoutPolicy inherits from CORBA Policy The connect timeout policy This policy can be used to specify a maximum time limit for connec tion establishment See Also TimeoutPolicy Attributes value readonly attribute unsigned long value If an object has a Connect Timeout Policy set and a connection cannot be established after value milliseconds a CORBA NO
314. value is a1se This property is ignored if ooc iiop host is specified ooc iiop port Value 0 lt port lt 65535 Specifies the port number on which the Root POA Manager should listen for new connec tions If no port is specified one will be selected automatically by the server Use this property if you plan to publish an IOR e g in a file a naming service etc and you want that IOR to remain valid across executions of your server Without this property your server is likely to use a different port number each time the server is executed See Chapter 6 for more information ooc iiop acceptor manager backlog Value 0 lt backlog lt 65535 56 ORBacus Configuring the ORB and Object Adapter Specifies the length of the queue for incoming connection requests on the POA Manager with name manager Note that the operating system may override this setting if the value exceeds the maximum allowed by the operating system ooc iiop acceptor manager bind Value hostname or IP address Specifies that the POA Manager with name manager should bind its socket to a specific network interface If not specified the POA Manager will bind its socket to all available network interfaces This property is useful in situations where a host has several network interfaces but the POA Manager should only listen for connections on a particular inter face 00c iiop acceptor manager host Value hostname s and or IP address es E
315. vant unless some assumptions are made e g a default POA name To solve this problem ORBACUS defines the interfaces BootManager and Boot Locator See Appendix A for a detailed description The BootManager add binding operation binds an object id to an object reference The BootManager remove binding operation is used to remove a binding A BootLocator object can be registered with the BootManager using the set locator operation and is used to dynamically locate a reference for a given object id The follow ing example illustrates how a server can add a binding for the object id MyOb ject 1a First in C C CORBA Object_var obj A reference to a persistent object CORBA Object_var bmgrObj orb gt resolve_initial_references BootManager OB BootManager var bootManager OB BootManager narrow bmgrObj PortableServer ObjectId var objId PortableServer string to ObjectId MyObjectId bootManager add binding objId obj Get a reference to the Boot Manager object by invoking resolve initial references see 6 5 1 on page 108 on the ORB Create the object id Create the new binding Or in Java Java org omg CORBA Object obj A reference to a persistent object org omg CORBA Object bmgrObj 106 ORBacus Object Reference URLs ON aA 6 4 2 6 4 3 orb resolve_initial_references BootManager com ooc OB BootManager bootManager com ooc
316. vantBase PortableServer POA var poa public void Product impl PortableServer POA ptr poa poa PortableServer POA duplicate poa virtual PortableServer POA ptr default POA return PortableServer POA duplicate poa 1 Two possible strategies for handling this issue include time outs in which a servant that has not been used for some length of time is automatically released and expiration in which an object reference is only valid for a certain length of time after which a client must obtain a new refer ence The implementation of these solutions is beyond the scope of this manual 94 ORBacus Factory Objects I 18 The constructor accepts reference and remembers that reference in a private mem ber variable 14 17 The default POA function returns the servant s POA 5 6 5 In Java the approach is very similar Java public class Product impl extends ProductPOA org omg PortableServer POA poa_ public Product impl org omg PortableServer POA poa poa_ poa public org omg PortableServer POA default POA return poa_ Getting the POA for a Currently Executing Request The ORB provides access to an object of type PortableServer Current IDL module PortableServer interface Current CORBA Current exception NoContext get POA raises NoContext ObjectId get object id raises NoContext This
317. ve initial reference is invoked to obtain a refer ence to the Time Service The reference is then narrowed to a reference of type CosTime TimeServic stopwatch uses the Time Service to implement a stop watch C int stopwatch CosTime TimeService ptr ts CosTime UTO_var start CosTime UTO_var stop try cout lt lt Press Enter to start lt lt flush cin get start ts universal time cout Press Enter to stop flush cin get stop ts universal time 178 ORBacus Programming Example 16 catch const CosTime TimeUnavailable amp 17 18 cout Time not available endl 19 return EXIT FAILURE 20 21 22 CORBA String_var str 23 OB TimeHelper toTimeString start gt time 24 cout Start time str endl 25 26 str OB TimeHelper toTimeString stop time 27 cout Stop time str endl 28 29 TimeBase TimeT elapsed stop time start time 30 cout lt lt Elapsed time lt lt total 10000 lt lt ms lt lt endl 31 32 return EXIT SUCCESS 33 7 20 Get the start and stop times 22 27 Output the start and stop times 29 30 Compute elapsed time and output result ORBacus 179 ORBacus Time 180 ORBacus CHAPTER 13 ORBacus Events 13 1 13 1 1 Some applications need to exchange
318. vent channel but an object implementing the PullConsumer interface The following example shows the basic lay out of a pull supplier Java public Any pull java util Date date new java util Date String s PullSupplier says date toString ORBacus 191 ORBacus Events v 8 10 T 12 T3 14 15 16 17 18 L9 N i 13 Any any orb create any any insert string s return any public Any try pull BooleanHolder has event has event value true return pull Date and time are inserted into the Any In this example new event data can be provided at any time so try pull always sets has_event to true in order to signal that an event is available It then returns the actual event data After examining the most important aspects of the event suppliers code we are now going to analyze the consumers code The push consumer with its push operation is shown first Java public void push Any any try String s any extract_string System out println s catch MARSHAL ex Ignore unknown event data The push consumer s push operation is called with the event wrapped in a CORBA Any In this code fragment it is assumed that the Any contains a string with date and time information In case the Any contains another data type a MARSHAL exception is thrown This exceptio
319. very useful for oneway operations or the Dynamic Invocation Interface DII operation send_deferred in combination with get_response or poll_response ORBacus 257 Concurrency Models However the main advantage of a reactive client becomes apparent if it is used together with a reactive server in mixed client server applications A mixed client server applica tion is a program that is both a client and server at the same time Without the reactive concurrency model it is not possible to use nested method calls in single threaded applica tions which are absolutely necessary for most kinds of callbacks Consider two programs A and B both mixed client server applications First A tries to call a method f on B Before this method returns B calls back A by invoking method g This scenario is quite common and for example is used in the popular Model View Controller pattern 1 For blocking clients this scenario is shown in Figure 18 2 As you can see the callback g dispatch Client Server Client Server B Figure 18 2 Blocking Client from B to A does not succeed because A blocks while waiting for a reply for from B In contrast if the reactive concurrency model for the client is used A can dispatch incoming requests while waiting for B s reply for This is shown in Figure 18 3 The reactive concurrency models are also very fast There is n
320. vides importers and administrators with a great deal of control over the trader s linked behavior during a query operation In particular each link has a rule that dictates under what circumstances the trader should propagate a query to the target trader Three possibilities exist as defined in the Fol lowOption enu merated type 1ocal only Never propagate a query request effectively disabling the link 2 if no local Only propagate a query request if no matching offers were found among the trader s local offers 3 always Always propagate a query request In addition an importer may supply a value for the 1ink follow rule policy contain ing one of the above settings When the trader executes a query operation it uses the fol lowing algorithm to decide how it should behave for each of its links e importer has not supplied a value for the 1ink follow rule policy the trader s default value will be used instead Otherwise the importer s value is checked to ensure that it does not exceed the trader s maximum value for this policy e Ifthe policy is more restrictive than the rule established for the link the importer s policy or the default value will be used e If the link s rule is more restrictive then the link s rule takes precedence Importers may use the hop count policy to limit the total number of hops that occur for each link of a query For example using a value of five means that the query ca
321. while reading wchar MinorReadOctetOverflow Overflow while reading octet MinorReadShortOverflow Overflow while reading short MinorReadUShortOverflow Overflow while reading ushort MinorReadLongOverflow Overflow while reading long MinorReadULongOverflow Overflow while reading ulong MinorReadLongLongOverflow Overflow while reading longlong MinorReadULongLongOverflow Overflow while reading ulonglong E MinorReadFloatOverflow Overflow while reading float MinorReadDoubleOverflow Overflow while reading double MinorReadLongDoubleOverflow Overflow while reading longdouble gt MinorReadStringOverflow Overflow while reading string MinorReadStringZeroLength Encountered zero length string MinorReadStringNullChar Encountered null char in string MinorReadStringNoTerminator Terminating null char missing in string MinorReadWStringOverflow Overflow while reading wstring MinorReadWStringZeroLength Encountered zero length wstring MinorReadWStringNullWChar Encountered null char in wstring MinorReadWStringNoTerminator Terminating null char missing in wstring MinorReadFixedOverflow Overflow while reading fixed 290 ORBacus CORBA System Exceptions MinorReadFixedInvalid Invalid encoding for fixed value MinorReadBooleanArrayOverflow Over
322. xplicitly defines the hostname s to be used in object references generated by the POA Manager with name manager The default value is determined by the value of ooc iiop host ooc iiop acceptor manager multi profile Value true false Specifies how multiple addresses should be represented in an object reference generated by the POA Manager with name manager If true each address is represented as a sepa rate tagged profile in the object reference If false there will be only one tagged profile with the first address used as the primary address of the profile and all other addresses represented as alternate addresses in that profile The default representation depends on the protocol version in use If the protocol version is 1 0 the default value is t rue other wise the default value is false As far as ORBACUS is concerned the ORB behavior is identical for both representations but other ORBs may require a particular representation ooc iiop acceptor manager numeric Value true false If true the POA Manager with name manager will generate object references that contain an internet IP address in dotted decimal notation instead of the canonical hostname The default value is determined by the value of ooc iiop numeric This property is ignored if either coc iiop host or ooc iiop acceptor manager host is specified ORBacus 57 ORB and Object Adapter Initialization ooc iiop acceptor manager port Value 0 lt port l
323. y its own value caused a dangling pointer This message appears if there is an attempt to replace the content of an Any by its own value For example char s CORBA string dup Hello world CORBA Any any ORBacus 295 Exceptions and Error Messages 3 any lt lt 5 4 any lt lt s 3 4 Inserting s into any twice will result in a dangling pointer because any will free its own value which is s on assignment Invalid union discriminator type used This message appears if the discriminator type argument to CORBA ORB create union tc denotes a type invalid for union discriminators Valid types have a CORBA TCKind that is one of CORBA tk short CORBA tk ushort CORBA tk_long ORBA tk ulong CORBA tk char ORBA tk boolean or CORBA tk enum Union discriminator mismatch This message either indicates an attempt to set a union discriminator to an invalid value with the _d modifier function or the use of a wrong accessor function i e an accessor function that does not correspond to the type of the union s actual value Uninitialized union used If this message appears an uninitialized union 1 a union that was created with the default constructor and that was not set to any legal value was used Dynamic implementation object cannot be used as static implementation object This message appears if an attempt is made to use a DSI object implementation as a regu lar i e static implem
324. yData can be located on the host myhost at port 2098 using the following URL corbaloc myhost 2098 TelemetryData To obtain the object reference of a channel factory use a corbaloc URL with the object key as shown in Table 13 1 on page 185 For example assuming the untyped Event Ser vice is running on host myhost at port 2098 here is how a C application can obtain the object reference of the channel factory and create a channel with the identifier TelemetryData C CORBA Object_var obj orb gt string to object corbaloc myhost 2098 DefaultEventChannelFactory OBEventChannelFactory EventChannelFactory var factory OBEventChannelFactory EventChannelFactory narrow obj CosEventChannelAdmin EventChannel var channel factory gt create channel TelemetryData Here is the same example in Java Java org omg CORBA Object obj orb string to object corbaloc myhost 2098 DefaultEventChannelFactory com ooc OBEventChannelFactory EventChannelFactory factory com ooc OBEventChannelFactory EventChannelFactoryHelper narrow obj org omg CosEventChannelAdmin EventChannel channel factory create channel TelemetryData 13 5 Programming Example In the Event Service example that comes with ORBACUS two supplier and two consumer clients demonstrate how to use an untyped event channel to propagate information The pieces of information transferred by this example are st
Download Pdf Manuals
Related Search
Related Contents
Just Speak Bedienungsanleitung Caberg Sintesi XPS 13 Manual de servicio Benutzerhandbuch 4 - GE Healthcare Life Sciences JEWELS DOT CONNECTION INSTALLATION français español important safety instructions save these Sony DCR-SX65ES Extensión de McAfee Security-as-a-Service versión Guía del usuario Copyright © All rights reserved.
Failed to retrieve file