FileDocCategorySizeDatePackage
Configuration.javaAPI DocGlassfish v2 API23027Fri May 04 22:36:36 BST 2007com.sun.jts.CosTransactions

Configuration

public class Configuration extends Object
Provides interaction with the execution environment.
version
0.01
author
Simon Holdsworth, IBM Corporation
see

Fields Summary
private static String
serverName
private static byte[]
serverNameByteArray
private static org.omg.CORBA.ORB
orb
private static Properties
prop
private static TransactionFactory
factory
private static boolean
localFactory
private static boolean
recoverable
private static ProxyChecker
checker
private static LogFile
logFile
private static Hashtable
poas
private static String
dbLogResource
private static boolean
disableFileLogging
private static Hashtable
logPathToServernametable
private static Hashtable
logPathToFiletable
private static int
retries
public static final int
LAO_PREPARE_OK
public static final long
COMMIT_RETRY_WAIT
private static boolean
isAppClient
static Logger
_logger
The traceOn would enable/disable JTS wide tracing; (Related class: com.sun.jts.trace.TraceUtil) - kannan.srinivasan@Sun.COM 27Nov2001
public static boolean
traceOn
public static final String
TRACE_DIRECTORY
The property key used to specify the directory to which trace files and the error log should be written.

The value is com.sun.jts.traceDirectory.

The default value used for this property is the current directory.

public static final String
LOG_DIRECTORY
The property key used to specify the directory to which transaction log files should be written.

The value is com.sun.jts.logDirectory.

The default value used for this property is the "jts" subdirectory from the current directory, if that exists, otherwise the current directory.

public static final String
DB_LOG_RESOURCE
The property key used to specify the resource which will be used to wirte transaction logs.

The value is com.sun.jts.logResource.

public static final String
ERR_LOGGING
Whether to write warnings and errors to jts.log file if this property has any value, it is active, otherwise it is inactive
public static final String
MANUAL_RECOVERY
This property indicates that XA Resources would be passed in via the TM.recover() method, and that the recovery thread would have to wait until the resources are passed in. If not set, the recovery thread would not wait for the XA Resources to be passed in.
public static final String
COMMIT_RETRY
The property key used to specify the number of times the JTS should retry a commit or resync operation before giving up.

The value is com.sun.jts.commitRetry.

If this property has no value, retries continue indefinitely. A value of zero indicates that no retries should be made.

public static final String
HEURISTIC_DIRECTION
The property key used to specify whether the JTS should assume a transaction is to be committed or rolled back if an outcome cannot be obtained during recovery. It should also be used by Resource objects if they cannot obtain an outcome during recovery and cannot make a decision.

The value is com.sun.jts.heuristicDirection.

The default is to assume that the transaction should be rolled back. If the value is '1', the transaction should be committed.

public static final String
KEYPOINT_COUNT
The property key used to specify the number of transactions between keypoint operations on the log. Keypoint operations reduce the size of the transaction log files. A larger value for this property (for example, 1000) will result in larger transaction log files, but less keypoint operations, and hence better performance. a smaller value (e.g. 20) results in smaller log files but slightly reduced performance due to the greater frequency of keypoint operations.

The value is com.sun.jts.keypointCount.

The default value for this property is 100. If the value is specified as zero, then no keypoints are taken.

public static final String
INSTANCE_NAME
public static final String
TIMEOUT_INTERVAL
The property is used to specify the time interval in seconds for which the timeout manager would scan for timedout transactions. A higher value would mean better performance, but at the cost of closeness to which coordinator timeout is effected.

The value is com.sun.jts.timeoutInterval"

This needs to be a positive integer value greater than 10. If the value is less than 10, illegal or unspecified a default value of 10 seconds is assumed.

public static final String
JTS_SUBDIRECTORY
The default subdirectory in which log and repository files are stored.
public static final int
DIRECTORY_OK
getDirectory return value which indicates that the required directory was specified and is OK.
public static final int
DEFAULT_USED
getDirectory return value which indicates that the required directory was either not specified or was specified and invalid, and that the default subdirectory exists. In this case the default subdirectory should be used.
public static final int
DEFAULT_INVALID
getDirectory return value which indicates that the required directory was either not specified or was specified and invalid, and that the default subdirectory does not exist. In this case the current directory should be used.
public static final int
EXPECTED_CONCURRENT_TRANSACTIONS
The approximate concurrent transactions expected. This is used to set the capacity of Vectors etc.
public static final int
EXPECTED_CONCURRENT_THREADS
The approximate concurrent transactions expected. This is used to set the capacity of Vectors etc.
Constructors Summary
Methods Summary
public static voiddisableFileLogging()

       disableFileLogging = true;
   
public static final voiddisableTrace()


	traceOn = false;

    
public static final voidenableTrace()


	traceOn = true;

    
public static java.lang.StringgetDirectory(java.lang.String envDir, java.lang.String defaultSubdirectory, int[] result)
Returns a valid directory for a particular purpose. If the required directory is not valid, then a default subdirectory of the current directory is tried. If that is not valid either, then the current directory is used.

param
envDir The environment variable containing the directory.
param
defaultSubdirectory The default subdirectory to use.
param
result A single-element array which will hold a value indicating whether the requested directory, default subdirectory, or current directory had to be used.
return
The directory name.
see


                                                                                                                                                                                                             
         
                                        
                                       /*1*/   

        // Get the environment variable value.

        String envValue = null;
        if( prop != null )
            envValue = prop.getProperty(envDir);

        // If the environment variable is not set, or does not refer to a valid
        // directory, then try to use a default.

        result[0] = DIRECTORY_OK;

        if( envValue == null || envValue.length() == 0 ||
            !new File(envValue).isDirectory() ) {
            result[0] = DEFAULT_USED;

            // If the default subdirectory is not valid, then use the current directory.

            envValue = new String("."+File.separator+defaultSubdirectory/*#Frozen*/);
            if( !new File(envValue).isDirectory() ) {
                result[0] = DEFAULT_INVALID;
            }
        }
	if(_logger.isLoggable(Level.FINE))
	{
		String dirType="";
		switch(result[0]){
		case DEFAULT_INVALID:
			dirType="used default, but is invalid";
			break;
		case DEFAULT_USED :
			dirType="used default";
			break;
		case DIRECTORY_OK:
			dirType="provided in configuration";
			break;
		default:
			dirType="invalid type";
			break;
		}
		_logger.logp(Level.FINE,"Configuration","getDirectory()",
				"Using directory = " + envValue + " : "+dirType);
	}

        return envValue;
    
public static final TransactionFactorygetFactory()
Returns the identity of the TransactionFactory.

param
return
The TransactionFactory.
see


        // Return the TransactionFactory identity.

        return factory;
    
public static final LogFilegetLogFile()
Returns the identity of the LogFile for the process.

param
return
The LogFile.
see

        return logFile;
    
public static final LogFilegetLogFile(java.lang.String logPath)
Returns the LogFile for the given log path. For delegated recovery support.

param
logPath log location.
return
The LogFile.
see

        if (logPath == null) return null;
        return (LogFile)logPathToFiletable.get(logPath);
    
public static final org.omg.CORBA.ORBgetORB()
Returns the identity of the ORB.

param
return
The ORB.
see



        // Return the ORB identity.


        return orb;
    
public static final POAgetPOA(java.lang.String type)
Returns the identity of the POA to be used for the given type of objects.

param
type The type of objects
return
The POA.
see


        POA result = (POA)poas.get(type);

        return result;
    
public static final java.lang.StringgetPropertyValue(java.lang.String envValue)
Returns the value of the given variable.

param
envValue The environment variable required.
return
The value.
see


        // Get the environment variable value.

        String result = null;
        if( prop != null )
		{
            result = prop.getProperty(envValue);
		    if(_logger.isLoggable(Level.FINE))
            {
				_logger.log(Level.FINE,"Property :"+ envValue +
						" has the value : " + result);

            }
		}

        return result;
    
public static final ProxyCheckergetProxyChecker()
Returns the identity of the ProxyChecker.

param
return
The ProxyChecker.
see

        return checker;
    
public static intgetRetries()

       return retries;
    
public static final java.lang.StringgetServerName()
Returns the name of the server.

Non-recoverable servers may not have a name, in which case the method returns null.

param
return
The server name.
see


        // Determine the server name.

        String result = serverName;

        return result;
    
public static final java.lang.StringgetServerName(java.lang.String logPath)
Returns the name of the server for the given log path. Added for delegated recovery support.

param
logPath location of the log files.
return
The server name.
see

        return (String)logPathToServernametable.get(logPath);
    
public static final byte[]getServerNameByteArray()
Returns a byte array with the name of the server.

Non-recoverable servers may not have a name, in which case the method returns null.

param
return
The server name (byte array).
see


        // Determine the server name.

        byte [] result = serverNameByteArray;

        return result;
    
public static booleanisAppClientContainer()

        return isAppClient;
    
static booleanisDBLoggingEnabled()

       if (dbLogResource == null)
           return false;
       else
           return true;
   
static booleanisFileLoggingDisabled()

       return disableFileLogging;
   
public static final booleanisLocalFactory()
Determines whether we hava a local factory or a remote factory.

param
return
Indicates whether we have a local factory.
see


        // This is a local factory if localFactory is TRUE

        boolean result = localFactory;

        return result;
    
public static final booleanisRecoverable()
Determines whether the JTS instance is recoverable.

param
return
Indicates whether the JTS is recoverable.
see


        // This JTS is recoverable if recoverable is set to TRUE.

        boolean result = recoverable;

        return result;
    
public static final booleanisTraceEnabled()


        return traceOn;

    
public static voidsetAsAppClientConatiner(boolean value)

        isAppClient = value;
    
public static voidsetCommitRetryVar(java.lang.String commitRetryString)

        // RegisteredResources.setCommitRetryVar(commitRetryString);
        if (commitRetryString != null) {
            int retriesInMinutes = Integer.parseInt(commitRetryString,10);
            if ((retriesInMinutes % (COMMIT_RETRY_WAIT / 1000)) == 0)
                   retries = (int)(retriesInMinutes / (COMMIT_RETRY_WAIT / 1000));
            else
                retries = ((int)(retriesInMinutes / (COMMIT_RETRY_WAIT / 1000))) + 1;

        }
    
public static final voidsetFactory(TransactionFactory newFactory, boolean localTxFactory)
Sets the identity of the TransactionFactory and indicates if it is local or remote.

param
newFactory The TransactionFactory.
param
localFactory Indicates if the factory is local or remote.
return
see


        // Store the factory identity and if it is local or not.

        factory = newFactory;
        localFactory = localTxFactory;
    
public static voidsetKeypointTrigger(int keypoint)

        CoordinatorLogPool.getCoordinatorLog().setKeypointTrigger(keypoint);
    
public static final voidsetLogFile(LogFile newLogFile)
Sets the identity of the log file for the process.

param
logFile The new LogFile object.
return
see



        // Store the logFile identity.

        logFile = newLogFile;

    
public static final voidsetLogFile(java.lang.String logPath, LogFile newLogFile)
Sets the log file for the given log path. For delegated recovery support.

param
logPath The new LogFile object.
param
newLogFile The new LogFile object.
return
see

        logPathToFiletable.put(logPath, newLogFile);
    
public static final voidsetORB(org.omg.CORBA.ORB newORB)
Sets the identity of the ORB.

param
newORB The ORB.
return
see


        // Store the ORB identity.

        orb = newORB;

    
public static final voidsetPOA(java.lang.String type, POA poa)
Sets the identity of the POA to be used for the given types of object.

param
type The type of objects to use the POA.
param
POA The POA object.
return
see

        // Store the mapping.

        poas.put(type,poa);

    
public static final voidsetProperties(java.util.Properties newProp)
Sets the Properties object to be used for this JTS instance.

param
prop The Properties.
return
see


        // Store the Properties object.
        if (prop == null)
            prop = newProp;
        else if (newProp != null)
            prop.putAll(newProp);

		if(_logger.isLoggable(Level.FINE))
        {
	      String propertiesList = LogFormatter.convertPropsToString(prop);			   
         _logger.logp(Level.FINE,"Configuration","setProperties()",
		 		" Properties set are :"+ propertiesList);
        }
        if (prop != null) {
            dbLogResource = prop.getProperty(DB_LOG_RESOURCE);
            String retryLimit = prop.getProperty(COMMIT_RETRY);
            int retriesInMinutes;
            if (retryLimit != null) {
               retriesInMinutes = Integer.parseInt(retryLimit,10);
               if ((retriesInMinutes % (COMMIT_RETRY_WAIT / 1000)) == 0)
                   retries = (int)(retriesInMinutes / (COMMIT_RETRY_WAIT / 1000));
               else
                   retries = ((int)((retriesInMinutes / (COMMIT_RETRY_WAIT / 1000)))) + 1;
            }
        }

    
public static final voidsetProxyChecker(ProxyChecker newChecker)
Sets the identity of the ProxyChecker.

param
newChecker The new ProxyChecker.
return
see



        // Store the checker identity.

        checker = newChecker;

    
public static final voidsetServerName(java.lang.String name, boolean recoverableServer)
Sets the name of the server.

param
name The server name. Non-recoverable servers have null.
return
see


        // Store the server name.

        serverName = name;
	      serverNameByteArray = (name == null) ? null : serverName.getBytes();
        recoverable = recoverableServer;
        if(recoverable)
            RecoveryManager.createRecoveryFile(serverName);
		if(_logger.isLoggable(Level.FINE))
        {
			_logger.logp(Level.FINE,"Configuration" ,"setServerName()",
					" serverName = " +
					 serverName + "; isRecoverable = " + recoverable);
        }
    
public static final voidsetServerName(java.lang.String logPath, java.lang.String name)
Sets the name of the server for the given log path. Added for delegated recovery support.

param
logPath Location, where the logs are stored.
param
name The server name.
return
see

        logPathToServernametable.put(logPath, name);