org.sape.carbon.services.config.classloader
Class ConfigurationSource

java.lang.Object
  |
  +--org.sape.carbon.services.config.classloader.ConfigurationSource

public class ConfigurationSource
extends Object

This class encapsulates the backing data store for classloader based nodes.

Copyright 2003 Sapient

Since:
carbon 2.1
Version:
$Revision: 1.2 $($Author: jdreed $ / $Date: 2004/01/26 19:10:56 $)
Author:
Douglas Voet, Nov 10, 2003

Field Summary
private  ClassLoader sourceLoader
           
private  URL[] sourceURLs
           
 
Constructor Summary
ConfigurationSource()
          Constructs the ConfigurationSource using this class' Classloader as the backing data store.
ConfigurationSource(String[] sourceURLStrings)
          Constructs the ConfigurationSource using a list of strings and the URLClassloader as the backing store.
ConfigurationSource(URL[] sourceURLs)
          Constructs the ConfigurationSource using a new URLClassloader as the backing data store.
 
Method Summary
 URL getResource(String resourcePath)
          Gets the URL for the given resource or null if the resouce does not exists.
 InputStream getResourceAsStream(String resourcePath)
          Gets the InputStream for the given resource or null if the resouce does not exists.
 void refresh()
          If a new URLClassloader is being used as the backing data store, this method will dereference the current URLClassloader, allowing it to be garbage collected, and create a new one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceURLs

private URL[] sourceURLs

sourceLoader

private ClassLoader sourceLoader
Constructor Detail

ConfigurationSource

public ConfigurationSource()
Constructs the ConfigurationSource using this class' Classloader as the backing data store.


ConfigurationSource

public ConfigurationSource(URL[] sourceURLs)
Constructs the ConfigurationSource using a new URLClassloader as the backing data store.

Parameters:
sourceURLs - the URLs that are used to construct the URLClassloader
See Also:
URLClassLoader

ConfigurationSource

public ConfigurationSource(String[] sourceURLStrings)
Constructs the ConfigurationSource using a list of strings and the URLClassloader as the backing store.

Parameters:
sourceURLStrings - the URLs as Strings that are used to construct the URLClassloader.
Throws:
InvalidParameterExecption - if there list of Strings is null or contains malformed urls.
Method Detail

refresh

public void refresh()
If a new URLClassloader is being used as the backing data store, this method will dereference the current URLClassloader, allowing it to be garbage collected, and create a new one. Otherwise this method does nothing as there is no way to unload this class' classloader.


getResourceAsStream

public InputStream getResourceAsStream(String resourcePath)
Gets the InputStream for the given resource or null if the resouce does not exists.

Parameters:
resourcePath - the resource to get
Returns:
the resource's InputStream
See Also:
ClassLoader.getResourceAsStream(java.lang.String)

getResource

public URL getResource(String resourcePath)
Gets the URL for the given resource or null if the resouce does not exists.

Parameters:
resourcePath - the resource to get
Returns:
the resource's URL
See Also:
ClassLoader.getResource(java.lang.String)


Copyright 1999-2003 Sapient Corporation. All Rights Reserved.