com.isti.openorbutil
Class OrbManager

java.lang.Object
  extended by com.isti.openorbutil.OrbManager

public class OrbManager
extends java.lang.Object

Class OrbManager contains methods for managing a CORBA ORB and POA. This implementation uses OpenORB.


Field Summary
protected static boolean BIDIRECTIONAL_BOTH_FLAG
          Flag for the 'BiDirectionalPolicy' value.
protected  boolean biDirectionalFlag
          Flag for BiDirectional IIOP, true = enabled.
protected  boolean closeImplFlag
           
protected  org.openorb.orb.corbaloc.CorbalocService corbalocServiceObj
           
protected  boolean deactivatePoaMgrFlag
           
protected  java.lang.String errorMessage
           
protected  boolean forceOrbDestroyFlag
           
protected  boolean forcePoaDestroyFlag
           
 java.lang.String orbCfgFileName
          Path and file name for ORB configuration file.
protected  java.lang.String orbHostAddressStr
          Host address string passed in to the ORB.
protected  boolean orbInitFlag
           
 org.omg.CORBA.ORB orbObj
          Handle for CORBA ORB.
protected  int orbPortNumber
          Port number passed in to the ORB.
 org.omg.PortableServer.POAManager poaManager
          Handle for POA manager for the root POA.
 org.omg.PortableServer.POA poaObj
          Handle for the root portable object adapter.
 java.lang.String[] programArgs
          Command-line arguments passed in to the ORB.
protected  boolean publishNumericIPFlag
          Flag for using numeric IPs instead of host names, true = enabled.
protected static int ROUNDTRIP_TIMEOUT_SECS
          Value for the 'RelativeRoundtripTimeoutPolicy'.
protected  boolean runningImplFlag
           
protected  int runningOrbIdValue
           
 
Constructor Summary
OrbManager()
          Creates an ORB/POA management object.
OrbManager(java.lang.String[] programArgs)
          Creates an ORB/POA management object.
OrbManager(java.lang.String[] programArgs, java.lang.String orbCfgFileName)
          Creates an ORB/POA management object.
OrbManager(java.lang.String[] programArgs, java.lang.String hostAddrStr, int orbPortNum)
          Creates an ORB/POA management object.
OrbManager(java.lang.String[] programArgs, java.lang.String hostAddrStr, int orbPortNum, java.lang.String orbCfgFileName)
          Creates an ORB/POA management object.
 
Method Summary
static java.lang.String buildCorbalocString(java.lang.String hostAddress, int portNumber, java.lang.String refNameStr)
          Builds a "Corbaloc" locator string.
 void clearErrorMessage()
          Clears the error message string.
 boolean closeImplementation(boolean waitFlag)
          Shuts downs the implementation.
static org.omg.CORBA.Policy createBiDirectionalPolicyObj(org.omg.CORBA.ORB orbObj, boolean bothFlag)
          Creates a 'Policy' object that may be used to set a 'BiDirectionalPolicy' value (for BiDirectional IIOP).
static org.omg.CORBA.Policy createRoundtripTimeoutPolicyObj(org.omg.CORBA.ORB orbObj, int timeoutSecs)
          Creates a 'Policy' object that may be used to set the given 'RelativeRoundtripTimeoutPolicy' value.
 boolean deactivatePoaMgr()
          Deactives the POA manager.
 boolean enterBiDirectionalFlag(boolean flgVal)
          Enters the BiDirectional IIOP flag for the ORB.
 boolean enterConnectParams(java.lang.String hostAddrStr, int orbPortNum)
          Enters connection parameters for the ORB.
static void enterPoliciesArray(org.omg.CORBA.ORB orbObj, org.omg.CORBA.Policy[] policyArr)
          Enters the given array of 'Policy' objects.
 boolean enterPublishNumericIPFlag(boolean flgVal)
          Enters the "publishIP" IIOP flag for the ORB, which determines if numeric IPs will be used instead of host names.
 boolean forcePoaDestroy()
          Forcibly destroys the POA and its resources.
 java.lang.String getEnteredHostAddrStr()
          Returns the host string entered into the ORB.
 boolean getErrorFlag()
          Returns true if an error was detected.
 java.lang.String getErrorMessage()
          Returns message string for last error (or 'No error' if none) and clears the error.
static java.lang.String getOpenOrbVersionStr()
          Returns the OpenORB version string.
 int getOrbPortNum()
          Returns the port number entered into the ORB.
 boolean initImplementation()
          Initializes the implementation.
 boolean initImplementation(boolean corbalocServiceFlag)
          Initializes the implementation.
 boolean isImplementationRunning()
          Returns the status of the running implementation.
 boolean isInitialized()
          Returns state of ORB implementation.
 boolean registerCorbalocObject(java.lang.String refNameStr, org.omg.CORBA.Object cObj)
          Registers a 'Corbaloc' service reference for a CORBA object.
 boolean registerCorbalocObject(java.lang.String refNameStr, org.omg.PortableServer.Servant servantObj)
          Registers a 'Corbaloc' service reference for a CORBA Servant object.
 org.omg.CORBA.Object resolveCorbalocObject(java.lang.String hostAddress, int portNumber, java.lang.String refNameStr)
          Resolves a CORBA object via the "Corbaloc" service.
 boolean runImplementation()
          Runs the implementation.
protected  void setErrorMessage(java.lang.String str)
          Enter error message (if none previously entered).
static void setRoundtripBiDirPolicies(org.omg.CORBA.ORB orbObj, int timeoutSecs, boolean biDirBothFlag)
          Sets the 'RelativeRoundtripTimeoutPolicy' and 'BiDirectionalPolicy' values for the given ORB.
 boolean waitForImplFinished(int timeOutMS)
          Waits for the implementation to stop running, up to the given timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

orbObj

public org.omg.CORBA.ORB orbObj
Handle for CORBA ORB.


poaObj

public org.omg.PortableServer.POA poaObj
Handle for the root portable object adapter.


poaManager

public org.omg.PortableServer.POAManager poaManager
Handle for POA manager for the root POA.


programArgs

public final java.lang.String[] programArgs
Command-line arguments passed in to the ORB.


orbCfgFileName

public final java.lang.String orbCfgFileName
Path and file name for ORB configuration file.


orbHostAddressStr

protected java.lang.String orbHostAddressStr
Host address string passed in to the ORB.


orbPortNumber

protected int orbPortNumber
Port number passed in to the ORB.


publishNumericIPFlag

protected boolean publishNumericIPFlag
Flag for using numeric IPs instead of host names, true = enabled.


biDirectionalFlag

protected boolean biDirectionalFlag
Flag for BiDirectional IIOP, true = enabled.


ROUNDTRIP_TIMEOUT_SECS

protected static final int ROUNDTRIP_TIMEOUT_SECS
Value for the 'RelativeRoundtripTimeoutPolicy'.

See Also:
Constant Field Values

BIDIRECTIONAL_BOTH_FLAG

protected static final boolean BIDIRECTIONAL_BOTH_FLAG
Flag for the 'BiDirectionalPolicy' value.

See Also:
Constant Field Values

orbInitFlag

protected boolean orbInitFlag

closeImplFlag

protected boolean closeImplFlag

runningImplFlag

protected boolean runningImplFlag

errorMessage

protected java.lang.String errorMessage

runningOrbIdValue

protected int runningOrbIdValue

forceOrbDestroyFlag

protected boolean forceOrbDestroyFlag

forcePoaDestroyFlag

protected boolean forcePoaDestroyFlag

deactivatePoaMgrFlag

protected boolean deactivatePoaMgrFlag

corbalocServiceObj

protected org.openorb.orb.corbaloc.CorbalocService corbalocServiceObj
Constructor Detail

OrbManager

public OrbManager(java.lang.String[] programArgs,
                  java.lang.String hostAddrStr,
                  int orbPortNum,
                  java.lang.String orbCfgFileName)
Creates an ORB/POA management object.

Parameters:
programArgs - the array of command-line arguments to be passed on to the CORBA ORB.
hostAddrStr - a host name or IP address to be associated with this ORB, or null to have the address auto-determined.
orbPortNum - a port address value to be associated with this ORB, or 0 to have the ORB choose the port address.
orbCfgFileName - path and file name for ORB configuration file, or null for none.

OrbManager

public OrbManager(java.lang.String[] programArgs,
                  java.lang.String hostAddrStr,
                  int orbPortNum)
Creates an ORB/POA management object.

Parameters:
programArgs - the array of command-line arguments to be passed on to the CORBA ORB.
hostAddrStr - a host name or IP address to be associated with this ORB, or null to have the address auto-determined.
orbPortNum - a port address value to be associated with this ORB, or 0 to have the ORB choose the port address.

OrbManager

public OrbManager(java.lang.String[] programArgs,
                  java.lang.String orbCfgFileName)
Creates an ORB/POA management object.

Parameters:
programArgs - the array of command-line arguments to be passed on to the CORBA ORB.
orbCfgFileName - path and file name for ORB configuration file, or null for none.

OrbManager

public OrbManager(java.lang.String[] programArgs)
Creates an ORB/POA management object.

Parameters:
programArgs - the array of command-line arguments to be passed on to the CORBA ORB.

OrbManager

public OrbManager()
Creates an ORB/POA management object.

Method Detail

enterConnectParams

public boolean enterConnectParams(java.lang.String hostAddrStr,
                                  int orbPortNum)
Enters connection parameters for the ORB. The parameters cannot be entered after the ORB is initialized (unless it has been closed).

Parameters:
hostAddrStr - a host name or IP address to be associated with this ORB, or null to have the address auto-determined.
orbPortNum - a port address value to be associated with this ORB, or 0 to have the ORB choose the port address.
Returns:
true if successful, false if error (in which case the 'getErrorMessage()' method may be used to fetch the error message).

enterPublishNumericIPFlag

public boolean enterPublishNumericIPFlag(boolean flgVal)
Enters the "publishIP" IIOP flag for the ORB, which determines if numeric IPs will be used instead of host names. If this method is not called then host names will be used (default=='false'). This method must be called before the ORB is initialized.

Parameters:
flgVal - true for numeric IPs, false for host names.
Returns:
true if successful, false if error (in which case the 'getErrorMessage()' method may be used to fetch the error message).

enterBiDirectionalFlag

public boolean enterBiDirectionalFlag(boolean flgVal)
Enters the BiDirectional IIOP flag for the ORB. If this method is not called then the default of BiDirectional IIOP enabled is used. This method must be called before the ORB is initialized.

Parameters:
flgVal - true for BiDirectional IIOP enabled, false for BiDirectional IIOP disabled.
Returns:
true if successful, false if error (in which case the 'getErrorMessage()' method may be used to fetch the error message).

initImplementation

public boolean initImplementation(boolean corbalocServiceFlag)
Initializes the implementation. A relative-roundtrip-timeout policy value of 10 seconds is setup and the bidirectional-IIOP policy is enabled for consumers/clients.

Parameters:
corbalocServiceFlag - if true then the "CorlocService" module will be imported.
Returns:
true if successful, false if error (in which case the 'getErrorMessage()' method may be used to fetch the error message).

initImplementation

public boolean initImplementation()
Initializes the implementation.

Returns:
true if successful, false if error (in which case the 'getErrorMessage()' method may be used to fetch the error message).

runImplementation

public boolean runImplementation()
Runs the implementation. If 'initImplementation()' has not yet been called then this method will call it. This method blocks until the implementation is shut down.

Returns:
false if an error occurred while trying to run the implementation (in which case the 'getErrorMessage()' method may be used to fetch the error message).

closeImplementation

public boolean closeImplementation(boolean waitFlag)
Shuts downs the implementation.

Parameters:
waitFlag - true to wait for CORBA operations to complete, false to return immediately.
Returns:
true if method successfully completed; false if not.

isInitialized

public boolean isInitialized()
Returns state of ORB implementation.

Returns:
true if initialized, false if not.

isImplementationRunning

public boolean isImplementationRunning()
Returns the status of the running implementation.

Returns:
true if the implementation is running; false if not.

waitForImplFinished

public boolean waitForImplFinished(int timeOutMS)
Waits for the implementation to stop running, up to the given timeout.

Parameters:
timeOutMS - the timeout to use.
Returns:
true if the implementation stopped; false if the timeout was reached (or if the thread was interrupted).

forcePoaDestroy

public boolean forcePoaDestroy()
Forcibly destroys the POA and its resources. This method should only be used after 'closeImplementation()' has failed to make the 'runImplementation()' method return. A new thread is launched to perform the work to keep things from getting blocked if the POA 'destroy()' method gets "stuck".

Returns:
true if the POA 'destroy()' method returned, false if a timeout occurred.

deactivatePoaMgr

public boolean deactivatePoaMgr()
Deactives the POA manager. A new thread is launched to perform the work to keep things from getting blocked if the 'deactivate()' method gets "stuck".

Returns:
true if the POA 'deactivate()' method returned, false if a timeout occurred.

setRoundtripBiDirPolicies

public static void setRoundtripBiDirPolicies(org.omg.CORBA.ORB orbObj,
                                             int timeoutSecs,
                                             boolean biDirBothFlag)
                                      throws org.omg.CORBA.ORBPackage.InvalidName,
                                             org.omg.CORBA.PolicyError,
                                             org.omg.CORBA.InvalidPolicies
Sets the 'RelativeRoundtripTimeoutPolicy' and 'BiDirectionalPolicy' values for the given ORB. Note that for the 'RelativeRoundtripTimeoutPolicy' to work the 'messaging.MessagingInitializer' class must be entered as an OpenORB "FeatureInitializer".

Parameters:
orbObj - the ORB object to use.
timeoutSecs - the timeout value to use, in seconds.
biDirBothFlag - if true then a BiDirectional Policy value of "BOTH" is entered (BiDirectional IIOP enabled), otherwise a BiDirectional Policy value of "NORMAL" is entered (BiDirectional IIOP disabled).
Throws:
org.omg.CORBA.ORBPackage.InvalidName - if the ORBPolicyManager cannot be found.
org.omg.CORBA.PolicyError - if a policy error occurs.
org.omg.CORBA.InvalidPolicies - if the policy is invalid.

createRoundtripTimeoutPolicyObj

public static org.omg.CORBA.Policy createRoundtripTimeoutPolicyObj(org.omg.CORBA.ORB orbObj,
                                                                   int timeoutSecs)
                                                            throws org.omg.CORBA.PolicyError
Creates a 'Policy' object that may be used to set the given 'RelativeRoundtripTimeoutPolicy' value. Note that for this to work the 'messaging.MessagingInitializer' class must be entered as an OpenORB "FeatureInitializer".

Parameters:
orbObj - the ORB object to use.
timeoutSecs - the timeout value to use, in seconds.
Returns:
A 'Policy' object containing the given 'RelativeRoundtripTimeoutPolicy' value.
Throws:
org.omg.CORBA.PolicyError - if a policy error occurs.

createBiDirectionalPolicyObj

public static org.omg.CORBA.Policy createBiDirectionalPolicyObj(org.omg.CORBA.ORB orbObj,
                                                                boolean bothFlag)
                                                         throws org.omg.CORBA.PolicyError
Creates a 'Policy' object that may be used to set a 'BiDirectionalPolicy' value (for BiDirectional IIOP).

Parameters:
orbObj - the ORB object to use.
bothFlag - if true then a BiDirectional Policy value of "BOTH" is entered (BiDirectional IIOP enabled), otherwise a BiDirectional Policy value of "NORMAL" is entered (BiDirectional IIOP disabled).
Returns:
A 'Policy' object containing the given 'BiDirectionalPolicy' value.
Throws:
org.omg.CORBA.PolicyError - if a policy error occurs.

enterPoliciesArray

public static void enterPoliciesArray(org.omg.CORBA.ORB orbObj,
                                      org.omg.CORBA.Policy[] policyArr)
                               throws org.omg.CORBA.ORBPackage.InvalidName,
                                      org.omg.CORBA.InvalidPolicies
Enters the given array of 'Policy' objects.

Parameters:
orbObj - the ORB object to use.
policyArr - the array of 'Policy' objects to use.
Throws:
org.omg.CORBA.ORBPackage.InvalidName - if the ORBPolicyManager cannot be found.
org.omg.CORBA.InvalidPolicies - if a policy is invalid.

registerCorbalocObject

public boolean registerCorbalocObject(java.lang.String refNameStr,
                                      org.omg.CORBA.Object cObj)
Registers a 'Corbaloc' service reference for a CORBA object. This manager object should be initialized with its 'corbalocServiceFlag' set 'true' to make the Corbaloc' service available.

Parameters:
refNameStr - the reference name to be associated with the object.
cObj - the CORBA object handle to be entered.
Returns:
true if successful, false if error (in which case the 'getErrorMessage()' method may be used to fetch the error message).

registerCorbalocObject

public boolean registerCorbalocObject(java.lang.String refNameStr,
                                      org.omg.PortableServer.Servant servantObj)
Registers a 'Corbaloc' service reference for a CORBA Servant object. This manager object should be initialized with its 'corbalocServiceFlag' set 'true' to make the Corbaloc' service available.

Parameters:
refNameStr - the reference name to be associated with the object.
servantObj - the CORBA servant object handle to be entered.
Returns:
true if successful, false if error (in which case the 'getErrorMessage()' method may be used to fetch the error message).

buildCorbalocString

public static java.lang.String buildCorbalocString(java.lang.String hostAddress,
                                                   int portNumber,
                                                   java.lang.String refNameStr)
Builds a "Corbaloc" locator string.

Parameters:
hostAddress - the host address to use.
portNumber - the port number to use.
refNameStr - the object reference name to use.
Returns:
A "Corbaloc" string in the form "corbaloc:iiop:1.2@hostAddress:portNumber/refNameStr".

resolveCorbalocObject

public org.omg.CORBA.Object resolveCorbalocObject(java.lang.String hostAddress,
                                                  int portNumber,
                                                  java.lang.String refNameStr)
Resolves a CORBA object via the "Corbaloc" service.

Parameters:
hostAddress - the host address to use.
portNumber - the port number to use.
refNameStr - the object reference name to use.
Returns:
The resolved CORBA object, or null if an error occurred (in which case the 'getErrorMessage()' method may be used to fetch the error message).

getEnteredHostAddrStr

public java.lang.String getEnteredHostAddrStr()
Returns the host string entered into the ORB.

Returns:
the host string entered into the ORB, or null if none entered.

getOrbPortNum

public int getOrbPortNum()
Returns the port number entered into the ORB.

Returns:
the port number entered into the ORB, or 0 if none entered.

setErrorMessage

protected void setErrorMessage(java.lang.String str)
Enter error message (if none previously entered).

Parameters:
str - the error message text.

getErrorFlag

public boolean getErrorFlag()
Returns true if an error was detected. The error message may be fetched via the 'getErrorMessage()' method.

Returns:
true if error; false if not.

getErrorMessage

public java.lang.String getErrorMessage()
Returns message string for last error (or 'No error' if none) and clears the error.

Returns:
The error message text (or 'No error' if none).

clearErrorMessage

public void clearErrorMessage()
Clears the error message string.


getOpenOrbVersionStr

public static java.lang.String getOpenOrbVersionStr()
Returns the OpenORB version string.

Returns:
The OpenORB version string.