org.openorb.util
Class ORBUtils

java.lang.Object
  |
  +--org.openorb.util.ORBUtils

public abstract class ORBUtils
extends Object

Contains common methods used by OpenORB modules.

Author:
Michael Rumpf, Shawn Boyce

Field Summary
static int BUGFIX
           
static String COPYRIGHT
           
static String IOR_FILE_EXT
          File extension of IOR files.
static int MAJOR
           
static int MINOR
           
static String NAME
           
static String OPENORB_ORB_CLASS
          OpenORB ORBClass value
static String OPENORB_ORB_SINGLETON_CLASS
          OpenORB ORBSingleton value
static String OPENORB_PKG_PREFIX
          OpenORB package prefix
static String ORB_ARG_PREFIX
          ORB Initialization options.
static String ORB_CLASS_KEY
          CORBA ORBClass property key
static String[] ORB_FLAG_ARGS
          CORBA 3.0 init flag options (without a value).
static String ORB_SINGLETON_CLASS_KEY
          CORBA ORBSingletonClass property key
static String[] ORB_VALUE_ARGS
          CORBA 3.0 init options with an additional value.
static String URL_FILE_EXT
          File extension of URL files.
static String VERSION
           
static String YEAR
           
 
Method Summary
static boolean checkAddress(String addr)
          This function checks an address for the correct format.
static ORB createORB(String[] args, Properties props)
          Create the ORB instance.
static String[] extractNonORBArgs(String[] args)
          Extract non ORB arguments from the command line option array.
static String[] extractORBArgs(String[] args)
          Extract ORB arguments from the command line option array.
static String getIORFileName(String arg, String name)
          Given the --writeIORFile argument, figure out what the IOR filename should be.
static String getLongFromShortName(String short_name)
          Provides a mapping between service short and their long names.
static String getShortNameFromClass(Class clz)
          Extract the short name from the class name.
static File getTemporaryDir(String firstDirName, String subdirName)
          Returns a temporary Directory.
static String getVersionFromShortName(String short_name)
          Provides a mapping between service short and the version number.
static boolean isFlagArg(String arg)
          Check whether the ORB init option is a single flag argument.
static boolean isValueArg(String arg)
          Check whether the ORB init option has an additional value argument.
static void writeIORToFile(ORB orb, String name, Object obj)
          Write the IOR to a file.
static void writeIORToFileName(ORB orb, String fileName, Object obj)
          Write the IOR to a given fileName.
static void writeURLToFile(String name, String url)
          Write the URL to a file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORB_CLASS_KEY

public static final String ORB_CLASS_KEY
CORBA ORBClass property key

ORB_SINGLETON_CLASS_KEY

public static final String ORB_SINGLETON_CLASS_KEY
CORBA ORBSingletonClass property key

OPENORB_ORB_CLASS

public static final String OPENORB_ORB_CLASS
OpenORB ORBClass value

OPENORB_ORB_SINGLETON_CLASS

public static final String OPENORB_ORB_SINGLETON_CLASS
OpenORB ORBSingleton value

ORB_ARG_PREFIX

public static final String ORB_ARG_PREFIX
ORB Initialization options.

ORB_FLAG_ARGS

public static final String[] ORB_FLAG_ARGS
CORBA 3.0 init flag options (without a value).

ORB_VALUE_ARGS

public static final String[] ORB_VALUE_ARGS
CORBA 3.0 init options with an additional value. Syntax: General: "-ORB<suffix><optional white space><value>

IOR_FILE_EXT

public static final String IOR_FILE_EXT
File extension of IOR files.

URL_FILE_EXT

public static final String URL_FILE_EXT
File extension of URL files.

MAJOR

public static final int MAJOR

MINOR

public static final int MINOR

BUGFIX

public static final int BUGFIX

VERSION

public static final String VERSION

NAME

public static final String NAME

YEAR

public static final String YEAR

COPYRIGHT

public static final String COPYRIGHT

OPENORB_PKG_PREFIX

public static final String OPENORB_PKG_PREFIX
OpenORB package prefix
Method Detail

isFlagArg

public static boolean isFlagArg(String arg)
Check whether the ORB init option is a single flag argument.
Parameters:
arg - The argument to check.
Returns:
True when the arg is a single flag argument, false otherwise.

isValueArg

public static boolean isValueArg(String arg)
Check whether the ORB init option has an additional value argument.
Parameters:
arg - The argument to check.
Returns:
True when the arg has an additional value, false otherwise.

extractORBArgs

public static String[] extractORBArgs(String[] args)
Extract ORB arguments from the command line option array.
Parameters:
args - The original argument array.
Returns:
An array with options that all start with the "-ORB" prefix.

extractNonORBArgs

public static String[] extractNonORBArgs(String[] args)
Extract non ORB arguments from the command line option array.
Parameters:
args - The original argument array.
Returns:
An array without options that start with the "-ORB" prefix.

getShortNameFromClass

public static String getShortNameFromClass(Class clz)
Extract the short name from the class name.
Parameters:
clz - The OpenORB class from which to extract the short name.
Returns:
The short name when the class was an OpenORB class, null otherwise.

getLongFromShortName

public static String getLongFromShortName(String short_name)
Provides a mapping between service short and their long names.
Parameters:
short_name - The short name of the service.
Returns:
The long name of the service.

getVersionFromShortName

public static String getVersionFromShortName(String short_name)
Provides a mapping between service short and the version number.
Parameters:
short_name - The short name of the service.
Returns:
The version number of the service.

checkAddress

public static boolean checkAddress(String addr)
This function checks an address for the correct format.
Parameters:
addr - The address to check.
Returns:
True if the format is correct, false otherwise.

writeURLToFile

public static void writeURLToFile(String name,
                                  String url)
Write the URL to a file. File name will be object.url.
Parameters:
name - name of the object
url - url of the object

writeIORToFile

public static void writeIORToFile(ORB orb,
                                  String name,
                                  Object obj)
Write the IOR to a file. File name will be name + ".ior"
Parameters:
orb - ORB
name - name of the object
obj - object whose IOR to write

getIORFileName

public static String getIORFileName(String arg,
                                    String name)
Given the --writeIORFile argument, figure out what the IOR filename should be.
Parameters:
arg - can be either a directory or a full filename
name - object name used to create default IOR filename
Returns:
the end-result IOR filename. If 'arg' is a directory, then we'll return: arg + '/' + name + IOR_FILE_EXT

writeIORToFileName

public static void writeIORToFileName(ORB orb,
                                      String fileName,
                                      Object obj)
Write the IOR to a given fileName.
Parameters:
orb - ORB
fileName - file name
obj - object whose IOR to write

getTemporaryDir

public static File getTemporaryDir(String firstDirName,
                                   String subdirName)
                            throws IOException
Returns a temporary Directory. The directory is created if it does not exist.

Tries the following locations in order:

  1. System Property: OpenORB home directory
  2. System Property: User home directory
  3. Current Directory
Returns:
File directory
Throws:
IOException - occurs if unable to create temporary directory

createORB

public static ORB createORB(String[] args,
                            Properties props)
Create the ORB instance. Unless already set in the properties, it will set the org.omg.CORBA.ORBClass and org.omg.CORBA.ORBSingletonClass properties to use OpenORB.
Parameters:
args - The ORB specific arguments.
props - ORB properties. May be null.
Returns:
ORB instance created