Bug 3715

Summary: Allow classpath override in org.globus.bootstrap.Bootstrap
Product: Java WS Core Reporter: Brian Watt <bwatt@us.ibm.com>
Component: globus_wsrf_coreAssignee: Rachana Ananthakrishnan <ranantha@mcs.anl.gov>
Status: NEW    
Severity: enhancement CC: meder@mcs.anl.gov
Priority: P3    
Version: 4.0.0   
Target Milestone: ---   
Hardware: PC   
OS: Linux   

Description From 2005-09-01 12:38:04
The current org.globus.bootstrap.Bootstrap is hardcoded to only allow the 
$GLOBUS_LOCATION directory and JAR files in the GLOBUS_LOCATION/lib directory 
into the class loader's URL list. This enhancement is to request that multiple 
directories locations in various orderings may be specified as a override of 
the current capability. This would allow the following uses (1) developers 
could provide JAR files that override existing Globus classes to test out 
extensions to the system without modifying the existing Globus JAR files 
themselves [Note: even if developers place additional JAR files within the 
current $GLOBUS_LOCATION/lib directory containing overrides for existing 
Globus classes, they are unable to force them to be first in the URL list 
because the files are not read in any defined order.], and (2) the 
AntBootstrap could be replaced (eliminated) by this enhanced and more general 
Bootstrap.  

As a possible proposal, a new environment variable, GLOBUS_CLASSPATH is 
proposed along with its Java System property. If the GLOBUS_CLASSPATH is not 
set, the $GLOBUS_LOCATION is used and the bootstrap performs the same as 
today. However if set, the $GLOBUS_LOCATION is not used, and this property 
contains a list of JAR files and directories separated by the 
Java "path.separator" character. The Bootstrap tokenizes the list and 
processes each list item. For each item that is a JAR file, it adds it to the 
URL list for the class loader as is (this enables a single JAR file to be 
specified). For each item that is a directory, it adds the directory itself 
followed by all JAR files within that directory to the URL list. The remaining 
launch processing is then the same as it is today.

Example: place local mods before GT
GLOBUS_CLASSPATH=/home/user/mods.jar:$GLOBUS_LOCATION:$GLOBUS_LOCATION/lib
globus-start-container

Example: enhanced Ant bootstrap
GLOBUS_CLASSPATH=$GLOBUS_LOCATION:$GLOBUS_LOCATION/lib:$ANT_HOME/lib
globus-start-container
------- Comment #1 From 2005-11-01 15:47:26 -------
More step-by-step detail: 

The class org.globus.bootstrap.Bootstrap.java has the following changes.

1. Define a constant (static final String) named GLOBUS_CLASSPATH with the value
"GLOBUS_CLASSPATH" (new).
2. Query the System property GLOBUS_LOCATION and set a local String variable
base. (Existing)
3. In the main method after constructing a Bootstrap object named boot
(Existing), query the System property GLOBUS_CLASSPATH and set the local String
variable classPath (new).
4. If the classPath is not set, that is, it is null (new check), then print out
"GLOBUS_CLASSPATH not set, default Classpath will be used." (new), add the
directory specified by base to the bootstrap object (Existing), and add the lib
directory specified by base to the boostrap object (Existing).
5. If the classPath is set, that is, it is not-null (new), then get the
"path.separator" and set the local variable pathSeparator, construct a String
Tokenizer to process the classPath using the pathSeparator, loop while the
tokenizer has more tokens: get the next token as a local variable entry,
construct a new File object given this entry named file, add the directory
specified by file to the bootstrap object, if the file is a directory invoke a
new method named addJarsInDirectory given the file and a null filter [note:this
method is in the BootstrapBase class which is described below], and end the
tokenization loop. So for a directory this adds both the directory and the jars
in the directory to the classpath which enables system resources to be found. 
6. Continue processing (Existing).

The class org.globus.boostrap.BoostrapBase has the following changes.

1. In the getDirectory method remove the condition: if the baseDir is not a
directory. IOW, allow files and directories now. Optionally rename method
getFileOrDirectory. Change bootstrap exception message to remove the phase "is
not a directory,".
2. Remove the first addLibDirectory method which accepts a single string as the
directory and then invokes the addLibDirectory which accepts two arguments, the
directory and a null filter. It will no longer be called since we're going to
refactor the method next.
3. Refactor the second addLibDirectory into two methods: addLibDirectory and
addJarsInDirectory. Remove the filter argument from the remaining
addLibDirectory, and after checking the lib file exists, is a directory and can
be read invoke the new method addJarsInDirectory passing it the libDir
(converted to a string), and a null filter. Then end the addLibDirectory method.
IOW, don't do the code in the old try statement it'll be refactored into the
next method, addJarsInDirectory.
4. Create a new addJarsInDirectory method contain the remainder of the old
addLibDirectory statements beginning at the try statement. Have it take two
arguments, the directory and a filter. Before the old try statement have it
invoke the getDirectory method passing it the directory argument and setting the
local variable libDir (although this is a misnomer and should probably be called
baseDir now since it doesn't have to be a lib directory anymore). 
5. Continue processing (Existing)
------- Comment #2 From 2007-09-12 16:42:47 -------
Reassigning to current wsrf developer to close/fix as appropriate