Before you can use any ORB classes, you must call the ORB_init method, which:
Returns an object reference to the ORB.
Allows you to pass initialization parameters to the driver class in the form of a string array. You can also set an environment variable (in the System Properties for your machine) for each initialization parameter. If the environment variable and initialization parameter are set, the value of the initialization parameter is used. You can set any initialization parameter to a value of none, which overrides the value of the environment variable and sets the value to the default, if any.
You can pass the following initialization parameters to the driver class:
ORBHttp – this specifies whether the ORB should use HTTP-tunnelling to connect to the server. A setting of of "true" specifies HTTP tunnelling. The default is "false". This parameter can also be set in an environment variable, JAG_HTTP. Some firewalls may not allow IIOP packets through, but most all allow HTTP packets through. When connecting through such firewalls, set this property to "true".
ORBHttpExtraHeader – An optional setting to specify what extra information is appended to the header of each HTTP packet when connecting through a Web proxy. See Chapter 12, “Deploying Applications Around Proxies and Firewalls,” in the EAServer Security Administration and Programming Guide for more information.
ORBHttpUsePost – when using HTTP tunnelling, specifies the HTTP request type used. A value of true indicates that POST requests are to be used. A value of false (the default) specifies that GET requests are to be used. This parameter can also be set in an environment variable, JAG_HTTPUSEPOST.
ORBLogIIOP – this specifies whether the ORB should log IIOP protocol trace information. A setting of "true" enables logging. The default is "false". This parameter can also be set in an environment variable, JAG_LOGIIOP. When this parameter is enabled, you must set the ORBLogFile option (or the corresponding environment variable) to specify the file where protocol log information is written.
ORBLogFile – this sets the path and name of the file to which to log client execution status and error messages. This parameter can also be set in an environment variable, JAG_LOGFILE. The default setting is no log.
ORBCodeSet – this sets the code set that the client uses. This parameter can also be set in an environment variable, JAG_CODESET. The default setting is iso_1.
ORBRetryCount – specify the number of times to retry when the initial attempt to connect to the server fails. This parameter can also be set in an environment variable, JAG_RETRYCOUNT. The default is 5.
ORBRetryDelay – specify the delay, in milliseconds, between retry attempts when the initial attempt to connect to the server fails.This parameter can also be set in an environment variable, JAG_RETRYDELAY. The default is 2000.
ORBProxyHost – specifies the machine name or the IP address of an reverse proxy server. See Chapter 12, “Deploying Applications Around Proxies and Firewalls,” in the EAServer Security Administration and Programming Guide for more information.
ORBProxyPort – specifies the port number of a reverse proxy server.
ORBforceSSL – force an SSL connection to a reverse proxy server (indicated by the ORBProxyHost and ORBProxyPort properties). Set this property to true if the connection to the reverse proxy must use SSL (HTTPS) tunnelling, but the connection from the proxy to the server does not use SSL tunnelling.
ORBsocketReuseLimit – specifies the number of times that a network connection may be reused to call methods from one server. The default is 0, which indicates no limit. The default is ideal for short-lived clients. The default may not be appropriate for a long-running client program that calls many methods from servers in a cluster. If sockets are reused indefinitely, the client may build an affinity for servers that it has already connected to rather than randomly distributing its server-side processing load among all the servers in the cluster. In these cases, the property should be tuned to best balance client performance against cluster load distribution. In Sybase testing, a setting of 10 to 30 proved to be a good starting point. If the reuse limit is too low, client performance degrades.
ORBIdleConnectionTimeout – specifies the time, in seconds, that a connection is allowed to sit idle. When the timeout expires, the ORB closes the connection. The default is 0, which specifies that connections can never timeout. The connection timeout does not affect the life of proxy instance references; the ORB may close and reopen connections transparently between proxy method calls. Specifying a finite timeout for your client applications can improve server performance. If many instances of the client run simultaneously, a finite client connection timeout limits the number of server connections that are devoted to idle clients. A finite timeout also allows rebalancing of server load in an application that uses a cluster of servers.
ORBWebProxyHost – the host name or IP address of an HTTP proxy server that supports generic Web tunnelling, sometimes called connect-based tunnelling. There is no default for this property, and you must specify both the host name and port number properties. See Chapter 12, “Deploying Applications Around Proxies and Firewalls,” in the EAServer Security Administration and Programming Guide for more information. You can also specify the property by setting the environment variable JAG_WEBPROXYHOST.
ORBWebProxyPort – when
generic Web tunnelling is enabled by setting ORBWebProxyHost
,
this property specifies the port number at which the HTTP proxy
server accepts connections. There is no default for this property,
and you must specify both a host name and port. See Chapter
12, “Deploying Applications Around Proxies and Firewalls,” in
the EAServer Security Administration and Programming Guide for
more information. You can also specify the property by setting the
environment variable JAG_WEBPROXYPORT.
ORBHttpExtraHeader – an
optional setting to specify what extra information is appended to
the header of each HTTP packet sent to a proxy server (specified
with the ORBWebProxyHost
parameter).
You can also specify the property by setting the property JAG_HTTPEXTRAHEADER. See Chapter
12, “Deploying Applications Around Proxies and Firewalls,” in
the EAServer Security Administration and Programming Guide for
more information.
You can pass additional properties to configure secure (IIOPS) connections. See Chapter 6, “Using SSL in C++ Clients,” in the EAServer Security Administration and Programming guide for more information.
ORB initialization is demonstrated in this example. You can specify the ORB options as a command line parameters to be passed to the ORB_init method.
#include <stdio.h> #include <iostream.h> #include <string.h> #include <SessionManager.hpp> #include <CosNaming.hpp> #include <Jaguar.hpp> #include <Tutorial.hpp> // Stubs for interfaces in Tutorial IDL // module. int main(int argc, char** argv) { const char *usage = "Usage:\n\tarith -ORBNameServiceURL iiop:// <host>:<iiop-port>/<initial-context>\n"; const char *tutorial_help = "Check EAServer Manager and verify that the" "Tutorial/CPPArithmetic component exists " "and that it implements the " "Tutorial::CPPArithmetic IDL interface."; const char *ior_prefix = "iiop://"; const char *component_name = "Tutorial/CPPArithmetic"; char *ior = NULL; try { cout << "Creating Jaguar session\n\n"; // Initialize the ORB CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, 0);
Copyright © 2005. Sybase Inc. All rights reserved. |