Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   * 
   * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
   * 
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License. You can obtain
  * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
  * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  * 
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
  * Sun designates this particular file as subject to the "Classpath" exception
  * as provided by Sun in the GPL Version 2 section of the License file that
  * accompanied this code.  If applicable, add the following below the License
  * Header, with the fields enclosed by brackets [] replaced by your own
  * identifying information: "Portions Copyrighted [year]
  * [name of copyright owner]"
  * 
  * Contributor(s):
  * 
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 /*
  * Copyright 2004-2005 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 //----------------------------------------------------------------------------
 //
 // Module:      Configuration.java
 //
 // Description: JTS configuration management.
 //
 // Product:     com.sun.jts.CosTransactions
 //
 // Author: Simon Holdsworth 
 //
 // Date:        March, 1997 
 //
 // Copyright (c): 1995-1997 IBM Corp.
 //
 //   The source code for this program is not published or otherwise divested 
 //   of its trade secrets, irrespective of what has been deposited with the 
 //   U.S. Copyright Office. 
 //
 //   This software contains confidential and proprietary information of 
 //   IBM Corp.
 //----------------------------------------------------------------------------
 
 package com.sun.jts.CosTransactions;
 
 // Import required classes.
 
 import java.io.*;
 import java.util.*;
 
 import  org.omg.CosTransactions.*;
 
 import  com.sun.jts.trace.*;
 
Provides interaction with the execution environment.

Author(s):
Simon Holdsworth, IBM Corporation
Version:
0.01
See also:
 
 // CHANGE HISTORY
 //
 // Version By     Change Description
 //   0.01  SAJH   Initial implementation.
 //------------------------------------------------------------------------------
 
 public class Configuration extends Object {
     private static String serverName = null;
     private static byte[] serverNameByteArray = null;
     private static org.omg.CORBA.ORB orb = null;
     private static Properties prop = null;
    private static TransactionFactory factory = null;
    private static boolean localFactory = false;
    private static boolean recoverable = false;
    private static ProxyChecker checker = null;
    private static LogFile logFile = null;
    private static Hashtable poas = new Hashtable();
    private static String dbLogResource = null;
    private static boolean disableFileLogging = false;
    // for delegated recovery support
    private static Hashtable logPathToServernametable = new Hashtable();
    private static Hashtable logPathToFiletable = new Hashtable();
    private static int retries = -1;
    public static final int LAO_PREPARE_OK = .;
    public final static long COMMIT_RETRY_WAIT = 60000;
    private static boolean isAppClient = true;

The traceOn would enable/disable JTS wide tracing; (Related class: com.sun.jts.trace.TraceUtil) - kannan.srinivasan@Sun.COM 27Nov2001
	/*
		Logger to log transaction messages
	*/
   public static boolean traceOn = false;

   
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 final static String TRACE_DIRECTORY = "com.sun.jts.traceDirectory"/*#Frozen*/;

    
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 final static String LOG_DIRECTORY = "com.sun.jts.logDirectory"/*#Frozen*/;

    
The property key used to specify the resource which will be used to wirte transaction logs.

The value is com.sun.jts.logResource.

    public final static String DB_LOG_RESOURCE = "com.sun.jts.logResource"/*#Frozen*/;

    
Whether to write warnings and errors to jts.log file if this property has any value, it is active, otherwise it is inactive
    public final static String ERR_LOGGING = "com.sun.jts.errorLogging"/*#Frozen*/;

    
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 final static String MANUAL_RECOVERY = "com.sun.jts.ManualRecovery"/*#Frozen*/;

    
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 final static String COMMIT_RETRY = "com.sun.jts.commitRetry"/*#Frozen*/;

    
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 final static String HEURISTIC_DIRECTION = "com.sun.jts.heuristicDirection"/*#Frozen*/;

    
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 final static String KEYPOINT_COUNT = "com.sun.jts.keypointCount"/*#Frozen*/;
    // Property to specify the instance name
    public final static String INSTANCE_NAME = "com.sun.jts.instancename"/*#Frozen*/;

    
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 final static String TIMEOUT_INTERVAL = "com.sun.jts.timeoutInterval" ;

    
The default subdirectory in which log and repository files are stored.
    public final static String JTS_SUBDIRECTORY = "jts"/*#Frozen*/;

    
getDirectory return value which indicates that the required directory was specified and is OK.
    public final static int DIRECTORY_OK    = 0;

    
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 final static int DEFAULT_USED    = 1;

    
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 final static int DEFAULT_INVALID = 2;

    
The approximate concurrent transactions expected. This is used to set the capacity of Vectors etc.
    public final static int EXPECTED_CONCURRENT_TRANSACTIONS = 10000;

    
The approximate concurrent transactions expected. This is used to set the capacity of Vectors etc.
    public final static int EXPECTED_CONCURRENT_THREADS = 100;

    
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.

Parameters:
envDir The environment variable containing the directory.
defaultSubdirectory The default subdirectory to use.
result A single-element array which will hold a value indicating whether the requested directory, default subdirectory, or current directory had to be used.
Returns:
The directory name.
See also:
    public static String getDirectoryString envDir,
                                       String defaultSubdirectory,
                                       int[/*1*/result ) {
        // Get the environment variable value.
        String envValue = null;
        if != null )
            envValue = .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] = ;
        ifenvValue == null || envValue.length() == 0 ||
            !new File(envValue).isDirectory() ) {
            result[0] = ;
            // If the default subdirectory is not valid, then use the current directory.
            envValue = new String("."+.+defaultSubdirectory/*#Frozen*/);
            if( !new File(envValue).isDirectory() ) {
                result[0] = ;
            }
        }
	{
		String dirType="";
		switch(result[0]){
			dirType="used default, but is invalid";
			break;
		case  :
			dirType="used default";
			break;
			dirType="provided in configuration";
			break;
		default:
			dirType="invalid type";
			break;
		}
		.logp(.,"Configuration","getDirectory()",
				"Using directory = " + envValue + " : "+dirType);
	}
        return envValue;
    }

    
Sets the name of the server.

Parameters:
name The server name. Non-recoverable servers have null.
Returns:
See also:
    public static final void setServerNameString nameboolean recoverableServer ) {
        // Store the server name.
         = name;
	       = (name == null) ? null : .getBytes();
         = recoverableServer;
        if()
            RecoveryManager.createRecoveryFile();
        {
			.logp(.,"Configuration" ,"setServerName()",
					" serverName = " +
					  + "; isRecoverable = " + );
        }
    }

    
Returns the name of the server.

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

Parameters:
Returns:
The server name.
See also:
    public static final String getServerName() {
        // Determine the server name.
        String result = ;
        return result;
    }

    
Sets the name of the server for the given log path. Added for delegated recovery support.

Parameters:
logPath Location, where the logs are stored.
name The server name.
Returns:
See also:
    public static final void setServerName(String logPathString name) {
        .put(logPathname);
    }

    
Returns the name of the server for the given log path. Added for delegated recovery support.

Parameters:
logPath location of the log files.
Returns:
The server name.
See also:
    public static final String getServerName(String logPath) {
        return (String).get(logPath);
    }

    
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.

Parameters:
Returns:
The server name (byte array).
See also:
    public static final byte [] getServerNameByteArray() {
        // Determine the server name.
        byte [] result = ;
        return result;
    }

    
Sets the Properties object to be used for this JTS instance.

Parameters:
prop The Properties.
Returns:
See also:
    public static final void setPropertiesProperties newProp ) {
        // Store the Properties object.
        if ( == null)
             = newProp;
        else if (newProp != null)
            .putAll(newProp);
        {
	      String propertiesList = LogFormatter.convertPropsToString();			   
         .logp(.,"Configuration","setProperties()",
		 		" Properties set are :"propertiesList);
        }
        if ( != null) {
             = .getProperty();
            String retryLimit = .getProperty();
            int retriesInMinutes;
            if (retryLimit != null) {
               retriesInMinutes = Integer.parseInt(retryLimit,10);
               if ((retriesInMinutes % ( / 1000)) == 0)
                    = (int)(retriesInMinutes / ( / 1000));
               else
                    = ((int)((retriesInMinutes / ( / 1000)))) + 1;
            }
        }
    }

    
Returns the value of the given variable.

Parameters:
envValue The environment variable required.
Returns:
The value.
See also:
    public static final String getPropertyValueString envValue ) {
        // Get the environment variable value.
        String result = null;
        if != null )
		{
            result = .getProperty(envValue);
            {
				.log(.,"Property :"envValue +
						" has the value : " + result);
            }
		}
        return result;
    }


    
Sets the identity of the ORB.

Parameters:
newORB The ORB.
Returns:
See also:
    public static final void setORBorg.omg.CORBA.ORB newORB ) {
        // Store the ORB identity.
         = newORB;
    }


    
Returns the identity of the ORB.

Parameters:
Returns:
The ORB.
See also:
    public static final org.omg.CORBA.ORB getORB() {
        // Return the ORB identity.
        return ;
    }


    
Sets the identity of the TransactionFactory and indicates if it is local or remote.

Parameters:
newFactory The TransactionFactory.
localFactory Indicates if the factory is local or remote.
Returns:
See also:
    public static final void setFactory( TransactionFactory newFactory,
                                              boolean localTxFactory ) {
        // Store the factory identity and if it is local or not.
         = newFactory;
         = localTxFactory;
    }


    
Returns the identity of the TransactionFactory.

Parameters:
Returns:
The TransactionFactory.
See also:
    public static final TransactionFactory getFactory() {
        // Return the TransactionFactory identity.
        return ;
    }

    
Determines whether we hava a local factory or a remote factory.

Parameters:
Returns:
Indicates whether we have a local factory.
See also:
    public static final boolean isLocalFactory() {
        // This is a local factory if localFactory is TRUE
        boolean result = ;
        return result;
    }

     
Determines whether the JTS instance is recoverable.

Parameters:
Returns:
Indicates whether the JTS is recoverable.
See also:
    public static final boolean isRecoverable() {
        // This JTS is recoverable if recoverable is set to TRUE.
        boolean result = ;
        return result;
    }
    
Sets the identity of the ProxyChecker.

Parameters:
newChecker The new ProxyChecker.
Returns:
See also:
    public static final void setProxyCheckerProxyChecker newChecker ) {
        // Store the checker identity.
         = newChecker;
    }

    
Returns the identity of the ProxyChecker.

Parameters:
Returns:
The ProxyChecker.
See also:
    public static final ProxyChecker getProxyChecker() {
        return ;
    }


    
Sets the identity of the log file for the process.

Parameters:
logFile The new LogFile object.
Returns:
See also:
    public static final void setLogFileLogFile newLogFile ) {
        // Store the logFile identity.
         = newLogFile;
    }


    
Returns the identity of the LogFile for the process.

Parameters:
Returns:
The LogFile.
See also:
    public static final LogFile getLogFile() {
        return ;
    }

    
Sets the log file for the given log path. For delegated recovery support.

Parameters:
logPath The new LogFile object.
newLogFile The new LogFile object.
Returns:
See also:
    public static final void setLogFile(String logPathLogFile newLogFile) {
        .put(logPathnewLogFile);
    }
    
Returns the LogFile for the given log path. For delegated recovery support.

Parameters:
logPath log location.
Returns:
The LogFile.
See also:
    public static final LogFile getLogFile(String logPath) {
        if (logPath == nullreturn null;
        return (LogFile).get(logPath);
    }


    
Sets the identity of the POA to be used for the given types of object.

Parameters:
type The type of objects to use the POA.
POA The POA object.
Returns:
See also:
    public static final void setPOAString typePOA poa ) {
        // Store the mapping.
        .put(type,poa);
    }


    
Returns the identity of the POA to be used for the given type of objects.

Parameters:
type The type of objects
Returns:
The POA.
See also:
    public static final POA getPOAString type ) {
        POA result = (POA).get(type);
        return result;
    }
    public static final boolean isTraceEnabled() {
        return ;
    }
    public static final void enableTrace() {
	 = true;
    }
    public static final void disableTrace() {
	 = false;
    }
    // START IASRI 4662745
    public static void setKeypointTrigger(int keypoint)
    {
        CoordinatorLogPool.getCoordinatorLog().setKeypointTrigger(keypoint);
    }
    public static void setCommitRetryVar(String commitRetryString)
    {
        // RegisteredResources.setCommitRetryVar(commitRetryString);
        if (commitRetryString != null) {
            int retriesInMinutes = Integer.parseInt(commitRetryString,10);
            if ((retriesInMinutes % ( / 1000)) == 0)
                    = (int)(retriesInMinutes / ( / 1000));
            else
                 = ((int)(retriesInMinutes / ( / 1000))) + 1;
        }
    }
    // END IASRI 4662745
    public static int getRetries() {
       return ;
    }
    public static void setAsAppClientConatiner(boolean value) {
         = value;
    }
    public static boolean isAppClientContainer() {
        return ;
    }
   static boolean isDBLoggingEnabled() {
       if ( == null)
           return false;
       else
           return true;
   }
   
   public static void disableFileLogging() {
        = true;
   }
 
   static boolean isFileLoggingDisabled() {
       return ;
   }
New to GrepCode? Check out our FAQ X