org.apache.maven.dotnet.registry
Class PropertyRepository

java.lang.Object
  extended by org.apache.maven.dotnet.registry.PropertyRepository
All Implemented Interfaces:
Repository

public class PropertyRepository
extends java.lang.Object
implements Repository

This class is a simple facade for java.util.properties. Repositories that use an underlying properties file (name, value pairs) can extend from this class and add additional domain specific methods. If the extending class provides methods for adding additional properties after a loadRegistry, the getValue method may need to be re-implemented to handle synchronization.

 RepositoryRegistry.loadFromFile("./sample-config.xml");
 PropertyRepository repository = (PropertyRepository) RepositoryRegistry.find("adapter");
 String value = repository.getValue("myprop");    `
 

Author:
Shane Isbell

Field Summary
protected  java.util.Properties properties
          Internal reference for properties
protected  RepositoryRegistry repositoryRegistry
          Internal reference for repositoryRegistry
 
Constructor Summary
PropertyRepository()
           
 
Method Summary
 java.lang.String getValue(java.lang.String name)
          Accessor for properties
 void load(java.io.InputStream inputStream, java.util.Hashtable prop)
          Loads the configuration file and configuration properties.
 void setRepositoryRegistry(RepositoryRegistry repositoryRegistry)
          Mutator for RepositoryRegistry
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

properties

protected java.util.Properties properties
Internal reference for properties


repositoryRegistry

protected RepositoryRegistry repositoryRegistry
Internal reference for repositoryRegistry

Constructor Detail

PropertyRepository

public PropertyRepository()
Method Detail

getValue

public java.lang.String getValue(java.lang.String name)
Accessor for properties

Parameters:
name - the name of the property
Returns:
String value for the given name

load

public void load(java.io.InputStream inputStream,
                 java.util.Hashtable prop)
          throws java.io.IOException
Description copied from interface: Repository
Loads the configuration file and configuration properties. In the case below, the inputStream contains the adapters.txt file and the properties holds the init-params. The init params should be used to specialize the repository configuration. The example below shows that you can add new properties to MyRepository but not delete them.
 <registry-config>
 <repositories>
 <repository>
 <repository-name>adapter</repository-name>
 <repository-class>org.jvending.sample.MyRepository</repository-class>
 <repository-config>${basedir}/adapters.txt</repository-config>
 <init-param>
 <param-name>add</param-name>
 <param-value>true</param-value>
 </init-param>
 <init-param>
 <param-name>delete</param-name>
 <param-value>false</param-value>
 </init-param>
 </repository>
 </repositories>
 </registry-config>
 

Since this method uses an InputStream parameter, the configuration file can be loaded off of the local file system or from a specific URL located at an HTTP address.

Specified by:
load in interface Repository
Parameters:
inputStream - the configuration file
prop - the properties used to configure the repository
Throws:
java.io.IOException - thrown on interrupted I/O. Implementing class may also use this exception to throw other exceptions like invalid properties.
See Also:
Repository.load(InputStream inputStream, Hashtable prop)

setRepositoryRegistry

public void setRepositoryRegistry(RepositoryRegistry repositoryRegistry)
Mutator for RepositoryRegistry

Specified by:
setRepositoryRegistry in interface Repository
Parameters:
repositoryRegistry -


Copyright © 2007 NMaven. All Rights Reserved.