Java Doc for Bootstrapper.java in  » Science » Cougaar12_4 » org » cougaar » bootstrap » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » Cougaar12_4 » org.cougaar.bootstrap 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.cougaar.bootstrap.Bootstrapper

All known Subclasses:   org.cougaar.bootstrap.BaseBootstrapper,  org.cougaar.bootstrap.CheckingBootstrapper,
Bootstrapper
public class Bootstrapper (Code)
A main(String[] args) class that searches for classes and jar files in a path, creates an XURLClassLoader that uses the found jars, and launches an application class (typically a Cougaar Node).

The Bootstrapper simplifies the $COUGAAR_INSTALL_PATH/bin/cougaar script and similar run scripts, which use the bootstrapper's jar for their Java classpath, instead of listing many individual jar files. For example, instead of:

 java 
 -classpath /tmp/classes:/jars/lib/a.jar:/jars/lib/b.jar:/jars/lib/c.jar
 MyClass
 
one can write:
 java 
 -Dorg.cougaar.class.path=/tmp/classes
 -Dorg.cougaar.install.path=/jars
 -jar bootstrap.jar 
 MyClass
 
or the equivalent:
 java 
 -classpath bootstrap.jar 
 -Dorg.cougaar.class.path=/tmp/classes
 -Dorg.cougaar.install.path=/jars
 org.cougaar.bootstrap.Bootstrapper
 MyClass
 

Note that the "-classpath" should only specify the Bootstrapper's jar. See the "Important Notes" below for further details.

The application classname can be specified by either the:

 -Dorg.cougaar.bootstrap.application=CLASSNAME
 
system property or as the first command-line argument to this Bootstrapper class's Bootstrapper.main method. The class must provide a public static launch(String[]) or main(String[]) method (searched for in that order). If additional command-line arguments are specified, they are passed along to the application class's method.

The default jar search path is specified by the:

 -Dorg.cougaar.jar.path=
Bootstrapper.DEFAULT_JAR_PATH 
 
system property. In standard configurations this path is expanded to (approximately) the following jars:
 $COUGAAR_INSTALL_PATH/lib/*.jar
 $COUGAAR_INSTALL_PATH/sys/*.jar
 

The exact list of jars is controlled by "-Dorg.cougaar.jar.path". The separator character is ":" on Linux, ";" on Windows, and "," on both. The jar path defaults to the Bootstrapper.DEFAULT_JAR_PATH value of:

 -Dorg.cougaar.jar.path=\
 classpath($CLASSPATH):\
 $RUNTIME/lib:\
 $RUNTIME/sys:\
 $SOCIETY/lib:\
 $SOCIETY/sys:\
 $INSTALL/lib:\
 $INSTALL/plugins:\
 $SYS:\
 $INSTALL/sys
 
where:
 $CLASSPATH    is the optional -Dorg.cougaar.class.path
 $RUNTIME      is the optional -Dorg.cougaar.runtime.path
 $SOCIETY      is the optional -Dorg.cougaar.society.path
 $INSTALL      is the optional -Dorg.cougaar.install.path
 $SYS          is the optional -Dorg.cougaar.system.path
 
If any of the above "$VARIABLE" system properties is not set, then the corresponding paths in the default jar path will be excluded. For example, if only the "-Dorg.cougaar.install.path" is set, then the default jar path will be:
 -Dorg.cougaar.jar.path=$INSTALL/lib:$INSTALL/plugins:$INSTALL/sys
 

The "classpath(..)" path wrapper is used to list jars and directories containing classes, similar to Java's CLASSPATH. For example:

 -Dorg.cougaar.class.path=/tmp/classes:/tmp/foo.jar
 
The default path wrapper, "directory(..)", is used to find jars in a directory by listing "*.jar", "*.zip", and "*.plugin". For example:
 -Dorg.cougaar.system.path=/jars 
 
where "/jars" contains jar files, for example:
 /jars/a.jar 
 /jars/b.jar 
 /jars/c.jar 
 
If the "-Dorg.cougaar.jar.path" value ends in the separator character, then the Bootstrapper.DEFAULT_JAR_PATH is appended to the end of the specified value. This can be used to easily prefix the jar path.

Note that the above "$" strings must be escaped to avoid Unix shell expansion, for example:

 -Dorg.cougaar.jar.path=\\\$INSTALL/lib:\\\$INSTALL/sys 
 
In practice the "$" strings are rarely used, since explicit paths are often specified, for example:
 -Dorg.cougaar.jar.path=/tmp/lib:classpath(/tmp/classes):/tmp/sys
 

The $CLASSPATH "-Dorg.cougaar.class.path" is primarily a developer mechanism to override the infrastructure and application jars with development code. Most packaged Cougaar applications do not use these optional system properties, and instead create jar files for $INSTALL/lib.

A couple jars are typically excluded by the jar finder, and instead are loaded by the Java system ClassLoader:

 
 bootstrap.jar   (contains this Bootstrapper class)
 javaiopatch.jar (contains the persistence I/O overrides)
 
These excluded jars are set by:
 
 -Dorg.cougaar.bootstrap.excludeJars=javaiopatch.jar:bootstrap.jar
 

Important Notes: If you use the Bootstrapper, do not put Cougaar classes on your Java classpath -- only specify:

 java -classpath bootstrapper.jar ..
 
If the Java SystemClassloader loads a Cougaar class, it will refer to SystemClassloader-loaded core classes which exist in a different namespace than Bootstrapper-loaded classes. This problem will cause all sorts of loading errors.

A common problem is the attempt to use "patch" jar files to repair a few classes of some much larger archive. There are two problems with this use pattern:

  1. The order that Bootstrapper will find jar files in a directory is undefined - there is no guarantee that the patch will take precedence over the original.
  2. Classloaders will refuse to load classes of a given package from multiple jar files - if the patch jar does not contain the whole package, the classloader will likely be unable to load the rest of the classes.
Both problems tend to crop up when you can least afford this confusion.

Bootstrapper.DEFAULT_JAR_PATH



Field Summary
final public static  StringDEFAULT_JAR_PATH
     The default value for the "org.cougaar.jar.path" system property.

See the above class-level javadoc for details.

protected  Object[]applicationArguments
    
protected  ClassLoaderapplicationClassLoader
    
protected  StringapplicationClassname
    
final protected static  intloudness
    


Method Summary
final protected  StringcanonicalPath(String filename)
    
protected  booleancheckURL(URL url)
     Check to see if a specific URL should be included in the bootstrap classloader's URLlist.
protected  ListcomputeURLs()
     Entry point for computing the list of URLs to pass to our classloader.
protected  ClassLoadercreateClassLoader(List l)
     construct the right classloader, given a list of URLs. The default method uses the value of the system property "org.cougaar.bootstrap.classloader.class" as a class to find, then calls the constructor with a URL[] as the single argument (e.g.
protected  ListfilterURLs(List l)
     Filter a set of URLs with whatever checks are required.
protected  ListfindJarsIn(String s)
    
protected  ListfindJarsInClasspath(String path)
    
protected  ListfindJarsInDirectory(String s)
    
protected  ListfindJarsInDirectory(File f)
    
protected  ListfindJarsInDirectoryURL(String s)
    
protected  ListfindURLPaths()
    
protected  ListfindURLs()
     Find jars, etc in the documented places.
protected  ListgetExcludedJars()
     Get the list of jar files to be ignored by bootstrapper, which typically includes javaiopatch and boostrap itself.
final public static  intgetLoudness()
     return the loudness value of the bootstrapper.
protected  PropertiesgetProperties()
    
protected  StringgetProperty(String key)
    
protected  StringgetProperty(String key, String def)
    
final public static  booleanisBootstrapped()
    
protected  booleanisJar(String n)
    
public static  voidlaunch(Object[] args)
    
public static  voidlaunch(String classname, Object[] args)
     Make a note that the application is being bootstrapped, construct a Bootstrapper instance, and pass control to the instance.
protected  voidlaunchApplication(String classname, Object[] args)
     Primary instance entry point for bootstrapper.
protected  voidlaunchMain(ClassLoader cl, String classname, Object[] args)
     Find the primary application entry point for the application class and call it.
public static  voidmain(String[] args)
     Launch an application inside the context of a bootstrapper instance.
protected  URLnewURL(String p)
    
protected  ClassLoaderprepareVM(String classname, Object[] args)
     Called to prepare the VM environment for running the application.
public static  voidreadProperties(String propertiesURL)
    
protected  voidreadPropertiesFromURL(String propertiesURL)
    
final protected static synchronized  voidsetIsBootstrapped()
     If no bootstrapper has run in the current vm, sets a flag and returns, otherwise throws an error.

Field Detail
DEFAULT_JAR_PATH
final public static String DEFAULT_JAR_PATH(Code)
The default value for the "org.cougaar.jar.path" system property.

See the above class-level javadoc for details.




applicationArguments
protected Object[] applicationArguments(Code)



applicationClassLoader
protected ClassLoader applicationClassLoader(Code)



applicationClassname
protected String applicationClassname(Code)



loudness
final protected static int loudness(Code)





Method Detail
canonicalPath
final protected String canonicalPath(String filename)(Code)
convert a directory name to a canonical path *



checkURL
protected boolean checkURL(URL url)(Code)
Check to see if a specific URL should be included in the bootstrap classloader's URLlist. The default implementation checks each url against the list of excluded jars.



computeURLs
protected List computeURLs()(Code)
Entry point for computing the list of URLs to pass to our classloader.



createClassLoader
protected ClassLoader createClassLoader(List l)(Code)
construct the right classloader, given a list of URLs. The default method uses the value of the system property "org.cougaar.bootstrap.classloader.class" as a class to find, then calls the constructor with a URL[] as the single argument (e.g. like a URLClassLoader).

The default is to create an XURLClassLoader , but another good option is a BootstrapClassLoader .




filterURLs
protected List filterURLs(List l)(Code)
Filter a set of URLs with whatever checks are required. a list of URLs suitable for passing to the classloader.



findJarsIn
protected List findJarsIn(String s)(Code)



findJarsInClasspath
protected List findJarsInClasspath(String path)(Code)
gather jar files listed in the classpath-like specification *



findJarsInDirectory
protected List findJarsInDirectory(String s)(Code)



findJarsInDirectory
protected List findJarsInDirectory(File f)(Code)
Gather jar files found in the directory specified by the argument *



findJarsInDirectoryURL
protected List findJarsInDirectoryURL(String s)(Code)



findURLPaths
protected List findURLPaths()(Code)



findURLs
protected List findURLs()(Code)
Find jars, etc in the documented places. Shouldn't actually load or check the jars for correctness at this point.



getExcludedJars
protected List getExcludedJars()(Code)
Get the list of jar files to be ignored by bootstrapper, which typically includes javaiopatch and boostrap itself.



getLoudness
final public static int getLoudness()(Code)
return the loudness value of the bootstrapper. 0 is quiet (normal), 1 is verbose, 2 is insanely verbose.



getProperties
protected Properties getProperties()(Code)



getProperty
protected String getProperty(String key)(Code)



getProperty
protected String getProperty(String key, String def)(Code)



isBootstrapped
final public static boolean isBootstrapped()(Code)
true iff a bootstrapper has run in the current VM *



isJar
protected boolean isJar(String n)(Code)
true iff the argument appears to name a jar file *



launch
public static void launch(Object[] args)(Code)



launch
public static void launch(String classname, Object[] args)(Code)
Make a note that the application is being bootstrapped, construct a Bootstrapper instance, and pass control to the instance.
Parameters:
  args - the args are typically a String[], but an Object[] issupported to pass more complex data structures from a container intothe application
See Also:   Bootstrapper.launchApplication(String,Object[])



launchApplication
protected void launchApplication(String classname, Object[] args)(Code)
Primary instance entry point for bootstrapper. Essentially finds the right list of URLs to use, creates a Classloader, and then calls launchMain.



launchMain
protected void launchMain(ClassLoader cl, String classname, Object[] args)(Code)
Find the primary application entry point for the application class and call it. The default implementation will look for static void launch(String[]) and then static void main(String[]). This method contains all the reflection code for invoking the application.



main
public static void main(String[] args)(Code)
Launch an application inside the context of a bootstrapper instance. Gets the application class to use from the org.cougaar.bootstrap.application system property or from the first argument and then calls launch(String, String[]).



newURL
protected URL newURL(String p) throws MalformedURLException(Code)
Convert the argument into a URL *



prepareVM
protected ClassLoader prepareVM(String classname, Object[] args)(Code)
Called to prepare the VM environment for running the application. A ClassLoader instance to be used to load the application.



readProperties
public static void readProperties(String propertiesURL)(Code)
Reads the properties from specified url



readPropertiesFromURL
protected void readPropertiesFromURL(String propertiesURL)(Code)



setIsBootstrapped
final protected static synchronized void setIsBootstrapped()(Code)
If no bootstrapper has run in the current vm, sets a flag and returns, otherwise throws an error.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.