Java Doc for JarConfigFinder.java in  » Science » Cougaar12_4 » org » cougaar » util » jar » 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.util.jar 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.cougaar.util.ConfigFinder
      org.cougaar.util.jar.JarConfigFinder

JarConfigFinder
public class JarConfigFinder extends ConfigFinder (Code)
JarConfigFinder provides utilities to search for a named file in several specified locations, returning the first location where a file by that name is found. Files are found and opened by the open() method. JarConfigFinder searches an ordered list of configuration paths to locate files. Each element in the list is a URL pointing to a file or a directory, and may reference one of the following elements:
  • A simple file
  • A signed or unsigned jar file in a file system or available through an HTTP connection
  • A local directory
The configuration path is a semi-colon ordered list of these URL elements. The search is performed by looking at the URL elements from left to right.
  • If the element is a simple file and the name matches the requested file, the file is returned.
  • If the element is a jar file, the JarConfigFinder attempts to locate a file in the jar file that matches the name of the requested file. The jar file can be opened in a file system or through an HTTP connection.
  • If the element is a directory in a file system, the JarConfigFinder attempts to locate a matching (unsigned) file in that directory. The JarConfigFinder also looks up all jar files contained in that directory and tries to find a matching file in one of those jar files.
Properties:
  • If the org.cougaar.util.jar.jarFilesOnly is set to true, JarConfigFinder returns files contained in JAR files only
  • If the org.cougaar.config.signedOnly property is set to true, the SecureConfigFinder returns only files that have been signed.


Field Summary
protected  File_jarFileCacheDirectory
     A directory to store files extracted from JAR files, so that we can return a File reference to the client.
protected  File_tmpBaseDirectory
     Parent directory to _tmpDirectory and _jarFileCacheDirectory, specified by getTmpBaseDirectoryName().
protected  File_tmpDirectory
     A directory to extract files from JAR files, before they are moved to the _jarFileCacheDirectory.

Constructor Summary
public  JarConfigFinder()
    
public  JarConfigFinder(String path)
    
public  JarConfigFinder(String path, Map props)
    
public  JarConfigFinder(String module, String path)
    
public  JarConfigFinder(String module, String path, Map props)
     Constructs a JarConfigFinder that will first search within the specified module, and then in the directories on the given search path, using the given Property substitutions. When searching the given module, we search the following 4 directories (if defined) before any other directories:
  • $INSTALL/$module/configs/$CONFIG
  • $INSTALL/$module/configs
  • $INSTALL/$module/data/$CONFIG
  • $INSTALL/$module/data

Parameters:
  module - Name of the module to use for module-specific configs.

Method Summary
protected  booleanacceptAbsoluteFileNames()
     Determines if ConfigFinder client may specify absolute file names.
protected  JarFileInfoappendJarFile(URL jarFile)
    
protected  voidappendJarFiles(URL[] jarFiles)
    
protected  FilecopyFileToTempDirectory(URL aUrl, String aFilename)
     Copy a file contained in a Jar file so that it can be opened using a File handle.
protected  voidcreateJarFileCacheDirectory()
     create a set of uniquely-named temporary directories for our use.
public  URLfind(String aURL)
     Attempt to find the URL which would be opened by the open method. Note that this must actually attempt to open the various URLs under consideration, so this is not an inexpensive operation. The file being searched should be specified as one of:
  • The name of the file being searched, e.g.
protected  JarFilegetJarFile(File aFile)
     Return a JarFile if the file is really a Jar file.
protected  StringgetTmpBaseDirectoryName()
     Return a pathname to use as the directory argument for File.createTempFile.
protected  booleanisValidUrl(URL aUrl)
     Determines if a simple configuration file can be loaded. When signed jar files are used, files that are not in signed jar files are not loaded.
protected  booleanjarFilesOnly()
     Determines if configuration files must be stored in signed jar files.
protected  voidlaunchJarInfoCleanupThread()
    
public  FilelocateFile(String aFilename)
     Locate an actual file in the config path.
protected  URLlocateFileInFileElement(URL base, String aFileName)
    
protected  URLlocateFileInHttpElement(URL base, String aFileName)
    
protected  URLlocateFileInJarFile(String aFileName, JarFileInfo entry)
     Attempts to locate a file in a JAR file.
protected  URLlocateFileInPathElement(URL base, String aFileName)
    
Parameters:
  base - - The path element where to search files.
Parameters:
  aFileName - - The name of a file to search.If aFileName is null, then no search is performed.
public  InputStreamopen(String aURL)
     Opens an InputStream to access the named file.
protected  voidrefreshJarFileCache()
     Add Jar files back to the cache of Jar files.
protected  URLresolveUrl(String aFileName)
    
protected  voidverifyInputStream(URL aURL)
     Verify the integrity of the data contained at a URL. Some integrity issues might be discovered late when reading an input stream.
protected  voidverifyJarFile(JarFile aJarFile)
     Check the integrity of a jar file.

Field Detail
_jarFileCacheDirectory
protected File _jarFileCacheDirectory(Code)
A directory to store files extracted from JAR files, so that we can return a File reference to the client.



_tmpBaseDirectory
protected File _tmpBaseDirectory(Code)
Parent directory to _tmpDirectory and _jarFileCacheDirectory, specified by getTmpBaseDirectoryName(). If null, we will use the system-defined tmp directory (see File.createTempFile).



_tmpDirectory
protected File _tmpDirectory(Code)
A directory to extract files from JAR files, before they are moved to the _jarFileCacheDirectory.




Constructor Detail
JarConfigFinder
public JarConfigFinder()(Code)
Alias for JarConfigFinder( Configuration.getConfigPath , Configuration.getDefaultProperties )



JarConfigFinder
public JarConfigFinder(String path)(Code)
Alias for JarConfigFinder(path, Configuration.getDefaultProperties )



JarConfigFinder
public JarConfigFinder(String path, Map props)(Code)
Alias for JarConfigFinder(null, path, props)



JarConfigFinder
public JarConfigFinder(String module, String path)(Code)
Alias for JarConfigFinder(module, path, Configuration.getDefaultProperties())



JarConfigFinder
public JarConfigFinder(String module, String path, Map props)(Code)
Constructs a JarConfigFinder that will first search within the specified module, and then in the directories on the given search path, using the given Property substitutions. When searching the given module, we search the following 4 directories (if defined) before any other directories:
  • $INSTALL/$module/configs/$CONFIG
  • $INSTALL/$module/configs
  • $INSTALL/$module/data/$CONFIG
  • $INSTALL/$module/data

Parameters:
  module - Name of the module to use for module-specific configs. If null, no module-specific paths are added.
Parameters:
  path - Configuration path string. If null, defaults to Configuration.getConfigPath()
Parameters:
  props - Properties to use for configpath variable substitutions




Method Detail
acceptAbsoluteFileNames
protected boolean acceptAbsoluteFileNames()(Code)
Determines if ConfigFinder client may specify absolute file names.



appendJarFile
protected JarFileInfo appendJarFile(URL jarFile)(Code)



appendJarFiles
protected void appendJarFiles(URL[] jarFiles)(Code)



copyFileToTempDirectory
protected File copyFileToTempDirectory(URL aUrl, String aFilename) throws IOException, GeneralSecurityException(Code)
Copy a file contained in a Jar file so that it can be opened using a File handle.



createJarFileCacheDirectory
protected void createJarFileCacheDirectory()(Code)
create a set of uniquely-named temporary directories for our use.



find
public URL find(String aURL) throws IOException(Code)
Attempt to find the URL which would be opened by the open method. Note that this must actually attempt to open the various URLs under consideration, so this is not an inexpensive operation. The file being searched should be specified as one of:
  • The name of the file being searched, e.g. just the last name in the pathname's name sequence. For example, a component might lookup a file by specifying "config.txt"
  • The last few elements in the pathname of the file being searched. For example, a component might lookup a file by specifying "org/cougaar/config.txt"
  • The full URL of the file in the JAR file For example, a component might lookup a file by specifying "jar:file://usr/local/cougaar/configs.jar!org/cougaar/config.txt"

Parameters:
  aURL - The name of a file being searched



getJarFile
protected JarFile getJarFile(File aFile)(Code)
Return a JarFile if the file is really a Jar file. Return null otherwise.



getTmpBaseDirectoryName
protected String getTmpBaseDirectoryName()(Code)
Return a pathname to use as the directory argument for File.createTempFile. to construct _tmpBaseDirectory. If null, then we'll use the system-defined tmp directory location The default implementation returns the value of the system property "org.cougaar.workspace" if defined, otherwise null.



isValidUrl
protected boolean isValidUrl(URL aUrl)(Code)
Determines if a simple configuration file can be loaded. When signed jar files are used, files that are not in signed jar files are not loaded. However, there might be exceptions to the rule and specific files may be authorized even if they are not signed. By default, the base JarConfigFinder always allows unsigned jar files.
Parameters:
  aUrl - The URL of a configuration file



jarFilesOnly
protected boolean jarFilesOnly()(Code)
Determines if configuration files must be stored in signed jar files. true if configuration files must be in signed jar files only



launchJarInfoCleanupThread
protected void launchJarInfoCleanupThread()(Code)



locateFile
public File locateFile(String aFilename)(Code)
Locate an actual file in the config path.
Parameters:
  aFilename - The name of a file being searched



locateFileInFileElement
protected URL locateFileInFileElement(URL base, String aFileName)(Code)



locateFileInHttpElement
protected URL locateFileInHttpElement(URL base, String aFileName)(Code)



locateFileInJarFile
protected URL locateFileInJarFile(String aFileName, JarFileInfo entry)(Code)
Attempts to locate a file in a JAR file.
Parameters:
  aFileName - the name of a file being searched.
Parameters:
  entry - a cache entry representing a JAR file the URL of the file in the JAR file, if an entry was found.null if no entry was found in the JAR file.



locateFileInPathElement
protected URL locateFileInPathElement(URL base, String aFileName)(Code)

Parameters:
  base - - The path element where to search files.
Parameters:
  aFileName - - The name of a file to search.If aFileName is null, then no search is performed. The pathelement is still added to the cache.



open
public InputStream open(String aURL) throws IOException(Code)
Opens an InputStream to access the named file. The file is sought in all the places specified in configPath. The file being searched should be specified as one of:
  • The name of the file being searched, e.g. just the last name in the pathname's name sequence. For example, a component might lookup a file by specifying "config.txt"
  • The last few elements in the pathname of the file being searched. For example, a component might lookup a file by specifying "org/cougaar/config.txt"
  • The full URL of the file in the JAR file For example, a component might lookup a file by specifying "jar:file://usr/local/cougaar/configs.jar!org/cougaar/config.txt"

Parameters:
  aURL - The name of a file being searched
throws:
  FileNotFoundException - if the resource cannot be found.



refreshJarFileCache
protected void refreshJarFileCache()(Code)
Add Jar files back to the cache of Jar files.



resolveUrl
protected URL resolveUrl(String aFileName)(Code)
Resolve a logical reference to a URL
Parameters:
  aFileName - the name of a file to be resolved null if no file can be found at that location



verifyInputStream
protected void verifyInputStream(URL aURL) throws IOException, GeneralSecurityException(Code)
Verify the integrity of the data contained at a URL. Some integrity issues might be discovered late when reading an input stream. For example, digest errors are discovered when the entire stream has been read. This gives the opportunity for a secure file finder to verify the data before the stream is returned to the caller. Does nothing in the default implementation, but should typically be defined in a derived class.
Parameters:
  aURL - the URL to check.
exception:
  IOException - if an IO Exception occurs while opening the stream
exception:
  GeneralSecurityException - if there was a problem while checkingthe integrity of the input stream.



verifyJarFile
protected void verifyJarFile(JarFile aJarFile) throws GeneralSecurityException(Code)
Check the integrity of a jar file. Do nothing in the base implementation.



Fields inherited from org.cougaar.util.ConfigFinder
final protected HashMap urlCache(Code)(Java Doc)

Methods inherited from org.cougaar.util.ConfigFinder
public URL find(String aURL) throws IOException(Code)(Java Doc)
public List getConfigPath()(Code)(Java Doc)
protected ConfigResolver getConfigResolver()(Code)(Java Doc)
public static ConfigFinder getInstance()(Code)(Java Doc)
public static ConfigFinder getInstance(String module)(Code)(Java Doc)
final protected synchronized Logger getLogger()(Code)(Java Doc)
public File locateFile(String aFilename)(Code)(Java Doc)
public InputStream open(String aURL) throws IOException(Code)(Java Doc)
public Document parseXMLConfigFile(String xmlfile) throws IOException(Code)(Java Doc)
protected Document parseXMLConfigFile(InputStream isstream, String xmlfile)(Code)(Java Doc)
public URL resolveName(String logicalName) throws MalformedURLException(Code)(Java Doc)
final protected String substituteProperties(String s)(Code)(Java Doc)

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.