org.jacorb.util
Class Environment

java.lang.Object
  extended byorg.jacorb.util.Environment

public class Environment
extends java.lang.Object

JacORB configuration options are accessed through this class.

On initialization, this class loads ORB configuration properties from different sources. The default configuration files are called ".jacorb_properties" or "jacorb.properties". Properties areloaded in the following order, with properties loaded later overriding earlier settings:

  1. default file in JRE/lib
  2. default file in user.home
  3. default file on classpath
  4. additional custom properties files (custom.props)
  5. command line properties
ORB.init() parameters are set using the addProperties() method and override any settings from configuration files, so hard-coded properties will always we honored.

Version:
$Id: Environment.java,v 1.80 2004/02/03 20:57:01 francisco Exp $
Author:
Gerald Brose

Field Summary
static java.net.URL URL
           
 
Constructor Summary
Environment()
           
 
Method Summary
static void addProperties(java.util.Properties otherProperties)
          Adds more properties, overriding any existing settings.
static boolean cacheReferences()
           
static java.lang.Class classForName(java.lang.String name)
          Returns the Class object for the class or interface with the given string name.
static int clientPendingReplyTimeout()
           
static java.util.Map createIdentityHashMap()
          Creates an IdentityHashMap, using either the JDK 1.4 class or JacORB's drop-in replacement class if the former is not available.
static long currentLogSize()
           
static int getCompactTypecodes()
           
static int getIntProperty(java.lang.String key, int base)
           
static int getIntPropertyWithDefault(java.lang.String key, int def)
           
static java.util.List getListProperty(java.lang.String key)
          For a property that has a list of comma-separated values, this method returns these values as a list of Strings.
static org.apache.avalon.framework.logger.Logger getLogger()
           
static LoggerFactory getLoggerFactory()
           
static long getLongProperty(java.lang.String key, int base)
           
static long getLongProperty(java.lang.String key, int base, long def)
           
static int getMaxManagedBufSize()
           
static java.lang.Object getObjectProperty(java.lang.String key)
          Create an object from the given property.
static java.util.Vector getORBInitializers()
          Collects all properties with prefix "org.omg.PortableInterceptor.ORBInitializerClass."
static java.util.Hashtable getProperties(java.lang.String prefix)
          Collects all properties with a given prefix
static java.util.Hashtable getProperties(java.lang.String prefix, boolean trim)
          Collects all properties with a given prefix.
static java.lang.String getProperty(java.lang.String key)
          generic
static java.lang.String getProperty(java.lang.String key, java.lang.String def)
           
static java.lang.String[] getPropertyValueList(java.lang.String key)
           
static boolean getStrictCheckOnTypecodeCreation()
           
static boolean getUseIndirection()
           
static boolean giopAdd_1_0_Profiles()
           
static int giopMinorVersion()
           
static boolean hasProperty(java.lang.String key)
           
static byte[] implName()
           
static java.lang.String imrProxyHost()
           
static int imrProxyPort()
           
static void init()
          Starting point for initialization of the ORB's environment.
static java.lang.String iorProxyHost()
           
static int iorProxyPort()
           
static boolean isMonitoringOn()
           
static boolean isPropertyOn(java.lang.String key)
          This will return true if the property's value is "on".
static boolean isPropertyOn(java.lang.String key, java.lang.String def)
           
static boolean locateOnBind()
           
static long maxLogSize()
           
static int noOfRetries()
           
static int queueMax()
           
static int queueMin()
           
static boolean queueWait()
           
static void readFromURL(java.net.URL _url)
           
static long retryInterval()
           
static boolean retryOnFailure()
           
static byte[] serverId()
           
static void setProperty(java.lang.String key, java.lang.String value)
           
static int threadPoolMax()
           
static int threadPoolMin()
           
static boolean useAppligator(boolean amIanApplet)
           
static boolean useImR()
           
static boolean useImREndpoint()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL

public static java.net.URL URL
Constructor Detail

Environment

public Environment()
Method Detail

init

public static void init()
Starting point for initialization of the ORB's environment. Locates configuration files and reads properties from these, then initializes logging. (This needs to be public because we also call it from the regression suite.)


addProperties

public static void addProperties(java.util.Properties otherProperties)
Adds more properties, overriding any existing settings. (Called from ORB.init()).

Parameters:
otherProperties - a Properties object with properties to be added

getStrictCheckOnTypecodeCreation

public static final boolean getStrictCheckOnTypecodeCreation()

isMonitoringOn

public static final boolean isMonitoringOn()

getLogger

public static final org.apache.avalon.framework.logger.Logger getLogger()
Returns:
the root logger object for JacORB

maxLogSize

public static final long maxLogSize()
Returns:
the max size of the log file in kilo bytes. A size of 0 means no limit, any other size requires log file rotation.

currentLogSize

public static final long currentLogSize()

clientPendingReplyTimeout

public static final int clientPendingReplyTimeout()

noOfRetries

public static final int noOfRetries()

locateOnBind

public static final boolean locateOnBind()

cacheReferences

public static final boolean cacheReferences()

queueWait

public static final boolean queueWait()

queueMin

public static final int queueMin()

queueMax

public static final int queueMax()

retryInterval

public static final long retryInterval()

useImR

public static final boolean useImR()

useImREndpoint

public static final boolean useImREndpoint()

threadPoolMax

public static final int threadPoolMax()

threadPoolMin

public static final int threadPoolMin()

implName

public static final byte[] implName()

useAppligator

public static final boolean useAppligator(boolean amIanApplet)

getMaxManagedBufSize

public static int getMaxManagedBufSize()

getCompactTypecodes

public static int getCompactTypecodes()

getUseIndirection

public static boolean getUseIndirection()

imrProxyHost

public static java.lang.String imrProxyHost()

imrProxyPort

public static int imrProxyPort()

iorProxyHost

public static java.lang.String iorProxyHost()

iorProxyPort

public static int iorProxyPort()

giopMinorVersion

public static int giopMinorVersion()

giopAdd_1_0_Profiles

public static boolean giopAdd_1_0_Profiles()

retryOnFailure

public static final boolean retryOnFailure()

getProperty

public static java.lang.String getProperty(java.lang.String key)
generic


getProperty

public static java.lang.String getProperty(java.lang.String key,
                                           java.lang.String def)

isPropertyOn

public static boolean isPropertyOn(java.lang.String key)
This will return true if the property's value is "on". Otherwise (i.e. value "off", or property not set), false is returned.


isPropertyOn

public static boolean isPropertyOn(java.lang.String key,
                                   java.lang.String def)

getLongProperty

public static long getLongProperty(java.lang.String key,
                                   int base,
                                   long def)

getLongProperty

public static long getLongProperty(java.lang.String key,
                                   int base)

getIntProperty

public static int getIntProperty(java.lang.String key,
                                 int base)

getIntPropertyWithDefault

public static int getIntPropertyWithDefault(java.lang.String key,
                                            int def)

getObjectProperty

public static java.lang.Object getObjectProperty(java.lang.String key)
Create an object from the given property. The class's default constructor will be used.

Returns:
null or an object of the class of the keys value
Throws:
java.lang.Error - if reflection fails.

getListProperty

public static java.util.List getListProperty(java.lang.String key)
For a property that has a list of comma-separated values, this method returns these values as a list of Strings. If the property is not set, an empty list is returned.


hasProperty

public static boolean hasProperty(java.lang.String key)

setProperty

public static void setProperty(java.lang.String key,
                               java.lang.String value)

getPropertyValueList

public static java.lang.String[] getPropertyValueList(java.lang.String key)

readFromURL

public static final void readFromURL(java.net.URL _url)

serverId

public static final byte[] serverId()

getORBInitializers

public static java.util.Vector getORBInitializers()
Collects all properties with prefix "org.omg.PortableInterceptor.ORBInitializerClass." and try to instantiate their values as ORBInitializer-Classes.

Returns:
a Vector containing ORBInitializer instances

getProperties

public static java.util.Hashtable getProperties(java.lang.String prefix)
Collects all properties with a given prefix

Returns:
a hash table with key/value pairs where key has the given prefix

getProperties

public static java.util.Hashtable getProperties(java.lang.String prefix,
                                                boolean trim)
Collects all properties with a given prefix. The prefix will be removed from the hash key if trim is true

Returns:
a hash table with key/value pairs

classForName

public static java.lang.Class classForName(java.lang.String name)
                                    throws java.lang.ClassNotFoundException,
                                           java.lang.IllegalArgumentException
Returns the Class object for the class or interface with the given string name. This method is a replacement for Class.forName(String name). Unlike Class.forName(String name) (which always uses the caller's loader or one of its ancestors), classForName uses a thread-specific loader that has no delegation relationship with the caller's loader. It attempts the load the desired class with the thread-specific context class loader and falls back to Class.forName(String name) only if the context class loader cannot load the class.

Loading a class with a loader that is not necessarily an ancestor of the caller's loader is a crucial thing in many scenarios. As an example, assume that JacORB was loaded by the boot class loader, and suppose that some code in JacORB contains a call Class.forName(someUserClass). Such usage of Class.forName effectively forces the user to place someUserClass in the boot class path. If classForName(someUserClass) were used instead, the user class would be loaded by the context class loader, which by default is set to the system (CLASSPATH) classloader.

In this simple example above, the default setting of the context class loader allows classes in the boot classpath to reach classes in the system classpath. In other scenarios, the context class loader might be different from the system classloader. Middleware systems like servlet containers or EJB containers set the context class loader so that a given thread can reach user-provided classes that are not in the system classpath.

For maximum flexibility, classForName should replace Class.forName(String name) in nearly all cases.

Parameters:
name - the fully qualified name of a class
Returns:
the Class object for that class
Throws:
java.lang.IllegalArgumentException - if name is null
java.lang.ClassNotFoundException - if the named class cannot be found
java.lang.LinkageError - if the linkage fails
java.lang.ExceptionInInitializerError - if the class initialization fails

getLoggerFactory

public static LoggerFactory getLoggerFactory()
Returns:
the default logger factory
Since:
JacORB 2.0 beta 3

createIdentityHashMap

public static java.util.Map createIdentityHashMap()
Creates an IdentityHashMap, using either the JDK 1.4 class or JacORB's drop-in replacement class if the former is not available.

Returns:
a newly created IdentityHashMap instance