Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jasig.portal.car
Class CarResources

    java.lang.Object
      org.jasig.portal.car.CarResources

    public class CarResources

extends java.lang.Object

Provides access to resources stored in channel archive files or CARs for short.

Version:
  $Revision: 1.18 $
Author:
  Mark Boyd

Field Summary
`private static java.lang.String` | `CAR_DIR_PROP_NAME`
`static java.lang.String` | `CAR_RESOURCE_PARM`
`static java.lang.String` | `CAR_WORKER_ID`
`private java.util.Hashtable` | `carContents`
`private boolean` | `carDirExists`
`private java.lang.String` | `carDirPath`
`private java.io.FileFilter` | `carFilter` A fileFilter for obtaining a list of CARs.
`private java.util.Hashtable` | `carsByJars`
`private java.util.Hashtable` | `carsByPath`
`private boolean` | `carsLoaded`
`(package private) static java.lang.String` | `DEPLOYMENT_DESCRIPTOR`
`private java.io.FileFilter` | `dirFilter` A fileFilter for obtaining a list of directories.
`private static java.util.Map.Entry[]` | `ENTRY_ARRAY`
`private static CarResources` | `instance`
`private java.util.Vector` | `jarsWithDescriptors`
`private static CarClassLoader` | `loader`
`private static org.apache.commons.logging.Log` | `log`
`static java.lang.String` | `RCS_ID`
`private java.util.Hashtable` | `resourceJars`
`private SAX2BufferImpl` | `services`
`private static java.lang.String[]` | `STRING_ARRAY`
`private static java.lang.String` | `WELL_KNOWN_DIR`
`private java.util.Properties` | `workers`

Constructor Summary
`private` | `CarResources()` Instantiate a CarResources object and load information about all CARs and their contained resources.

Method Summary
`boolean` | `containsResource(java.lang.String resource)` Returns true if the indicated resource is available, false otherwise.
`java.net.URL` | `findResource(java.lang.String entry)` Returns a URL to the requested entry if found in one of the installed CARs or null if not found.
`private java.lang.String` | `getCarPath(java.io.File car)` Return the path of a car file relative to the car directory.
`java.lang.ClassLoader` | `getClassLoader()` Return the single instance of CarClassLoader.
`java.lang.String` | `getContainingCarPath(java.lang.String entry)` Returns the path of the CAR containing the indicated resource.
`static CarResources` | `getInstance()` Return the single instance of CarResources.
`private java.io.File` | `getPropertySpecifiedDir()` Return a File object representing the channel archive base directory whose fully-qualified path is specified by the 'org.jasig.portal.car.CarResources.directory' property in portal.properties.
`java.io.InputStream` | `getResourceAsStream(java.lang.String resource)` Return an input stream for reading the raw bytes making up the resource contained in one of the installed CARs.
`long` | `getResourceSize(java.lang.String resource)` Return the size of the indicated resource or -1 if the resource is not found or its size is unknown.
`void` | `getServices(org.xml.sax.ContentHandler contentHandler)` Push into the passed in content handler events for any services declared in any component archive's deployment descriptor.
`private java.io.File` | `getWellKnownDir()` Return a File object representing the well-known channel archive base directory '/WEB-INF/cars' where channel archives are located.
`void` | `getWorkers(java.util.Properties workers)` Push into the passed in properties object workers defined in any component archive's deployment descriptor.
`boolean` | `hasDescriptors()` Returns true if any archive included a deployment descriptor.
`java.lang.String[]` | `listAllResources()` Returns an enumeration of String objects each containing the path of a resource available from the installed CARs.
`java.lang.String[]` | `listCarResources(java.lang.String carPath)` Returns a list of resources available in the car identified by the passed in relative car file path name.
`java.lang.String[]` | `listCars()` Returns a String array of car file paths relative to the car directory specified via the property in portal.properties.
`private void` | `loadCarEntries(java.io.File car)` Load information about the passed in CAR and any contained resources.
`private void` | `loadCars()` Load information about all installed CARs and their contained resources.
`private void` | `processDescriptors()` Process the descriptors of the channel archives if any.
`private java.lang.String` | `replace(java.lang.String entry, java.lang.String regExpr, java.lang.String replacement)` Home-grown version of the String replace method.
`private java.lang.String` | `resolveRegExpr(java.lang.String entry)` Resolves the String entry and removes any regular expression patterns that would indicate a directory move (i.e.
`private void` | `scanDir(java.io.File dir)` Scan the passed in directory loading any cars there-in and calling this method for any nested directories.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    private static final org.apache.commons.logging.Log log

### instance

    private static CarResources instance

### loader

    private static CarClassLoader loader

### RCS_ID

    public static final java.lang.String RCS_ID

See Also:
  Constant Field Values

### DEPLOYMENT_DESCRIPTOR

    static final java.lang.String DEPLOYMENT_DESCRIPTOR

See Also:
  Constant Field Values

### WELL_KNOWN_DIR

    private static final java.lang.String WELL_KNOWN_DIR

See Also:
  Constant Field Values

### CAR_DIR_PROP_NAME

    private static final java.lang.String CAR_DIR_PROP_NAME

See Also:
  Constant Field Values

### CAR_WORKER_ID

    public static final java.lang.String CAR_WORKER_ID

See Also:
  Constant Field Values

### CAR_RESOURCE_PARM

    public static final java.lang.String CAR_RESOURCE_PARM

See Also:
  Constant Field Values

### ENTRY_ARRAY

    private static final java.util.Map.Entry[] ENTRY_ARRAY

### STRING_ARRAY

    private static final java.lang.String[] STRING_ARRAY

### resourceJars

    private java.util.Hashtable resourceJars

### carsByJars

    private java.util.Hashtable carsByJars

### carContents

    private java.util.Hashtable carContents

### carsByPath

    private java.util.Hashtable carsByPath

### services

    private SAX2BufferImpl services

### workers

    private java.util.Properties workers

### carsLoaded

    private boolean carsLoaded

### jarsWithDescriptors

    private java.util.Vector jarsWithDescriptors

### carDirPath

    private java.lang.String carDirPath

### carDirExists

    private boolean carDirExists

### carFilter

    private java.io.FileFilter carFilter

  A fileFilter for obtaining a list of CARs.

### dirFilter

    private java.io.FileFilter dirFilter

  A fileFilter for obtaining a list of directories.

Constructor Detail

### CarResources

    private CarResources()

  Instantiate a CarResources object and load information about all CARs and their contained resources.

Method Detail

### processDescriptors

    private void processDescriptors()

  Process the descriptors of the channel archives if any.

### getInstance

    public static CarResources getInstance()

  Return the single instance of CarResources.

### getClassLoader

    public java.lang.ClassLoader getClassLoader()

  Return the single instance of CarClassLoader.

### getWellKnownDir

    private java.io.File getWellKnownDir()

  Return a File object representing the well-known channel archive base directory '/WEB-INF/cars' where channel archives are located.

### getPropertySpecifiedDir

    private java.io.File getPropertySpecifiedDir()

  Return a File object representing the channel archive base directory whose fully-qualified path is specified by the 'org.jasig.portal.car.CarResources.directory' property in portal.properties.

### loadCars

    private void loadCars()

  Load information about all installed CARs and their contained resources.

### scanDir

    private void scanDir(java.io.File dir)

  Scan the passed in directory loading any cars there-in and calling this method for any nested directories.

### loadCarEntries

    private void loadCarEntries(java.io.File car)

  Load information about the passed in CAR and any contained resources.

### getWorkers

    public void getWorkers(java.util.Properties workers)

  Push into the passed in properties object workers defined in any component archive's deployment descriptor.

### hasDescriptors

    public boolean hasDescriptors()

  Returns true if any archive included a deployment descriptor.

### getServices

    public void getServices(org.xml.sax.ContentHandler contentHandler)
                     throws org.xml.sax.SAXException

  Push into the passed in content handler events for any services declared in any component archive's deployment descriptor.

  Throws:
    `org.xml.sax.SAXException`

### getResourceAsStream

    public java.io.InputStream getResourceAsStream(java.lang.String resource)
                                            throws PortalException

  Return an input stream for reading the raw bytes making up the resource contained in one of the installed CARs. Returns null if the resource is not found.

  Throws:
    `PortalException`

### getResourceSize

    public long getResourceSize(java.lang.String resource)

  Return the size of the indicated resource or -1 if the resource is not found or its size is unknown.

### findResource

    public java.net.URL findResource(java.lang.String entry)

  Returns a URL to the requested entry if found in one of the installed CARs or null if not found.

### getContainingCarPath

    public java.lang.String getContainingCarPath(java.lang.String entry)

  Returns the path of the CAR containing the indicated resource. This path is relative to the CAR directory configured via the property in portal.properties. If a CAR for that entry is not found it returns null.

### containsResource

    public boolean containsResource(java.lang.String resource)

  Returns true if the indicated resource is available, false otherwise. The resource is identified by its complete path within the CAR file.

### listCars

    public java.lang.String[] listCars()

  Returns a String array of car file paths relative to the car directory specified via the property in portal.properties.

### listCarResources

    public java.lang.String[] listCarResources(java.lang.String carPath)

  Returns a list of resources available in the car identified by the passed in relative car file path name. This name is the path to the car file relative to the car directory. If no car file is found for the passed-in path then null is returned.

### getCarPath

    private java.lang.String getCarPath(java.io.File car)

  Return the path of a car file relative to the car directory.

### listAllResources

    public java.lang.String[] listAllResources()

  Returns an enumeration of String objects each containing the path of a resource available from the installed CARs.

### replace

    private java.lang.String replace(java.lang.String entry,
                                     java.lang.String regExpr,
                                     java.lang.String replacement)

  Home-grown version of the String replace method. This one replaces the supplied String (generally a regular expression '../') with the supplied replacement. It returns the original String as is if no matches were found or a modified version of it if matches were found.

  Parameters:
    `entry` - the String to search for the regExpr.
    `regExpr` - the regular expression to find and replace
    `replacement` - the String to replace the regExpr with
  Returns:
    A modified String of match(es) were found, otherwise the original String unmodified.

### resolveRegExpr

    private java.lang.String resolveRegExpr(java.lang.String entry)

  Resolves the String entry and removes any regular expression patterns that would indicate a directory move (i.e. '../'). The returned String is the supplied 'entry' String minus the '../' pattern and the directory directly preceding it if any.

  Parameters:
    `entry` - the String entry to resolve
  Returns:
    the modified String minus the reg expr.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD