Contribute to the DSpace Development Fund

The newly established DSpace Development Fund supports the development of new features prioritized by DSpace Governance. For a list of planned features see the fund wiki page.

Refactor ConfigurationManager to use Commons Configuration for more flexible configuration

About Commons Configuration

http://jakarta.apche.org/commons/configuration  provides a flexible means to add and override configuration properties. Replacing ConfigurationManagers Properties file implementation with Commons Configuration will allow Plugins and Modules added to DSpace to easily inject their configuration to be exposed under the ConfigurationManager without any addition to dspace.cfg directly.

Areas of Change

dspace.cfg file XML format

Initially, I believed the dspace.cfg file format could be used as is. It is now apparent after a few attempts to rewrite the value parsing behavior of PluginManager, that it would be better to go straight to the Commons Configuration XML file format.

This replaces the earlier structure of the java properties as such:

dspace.dir = /dspace
dspace.url = http://dspace.myu.edu:8080/dspace
dspace.hostname = dspace.myu.edu
dspace.name = DSpace at My University

The basic structure of this file is as follows:

 <configuration>
	<dspace>
		<dir>/dspace</dir>
		<url>http://dspace.myu.edu:8080/dspace</url>
		<hostname>dspace.myu.edu</hostname>
		<name>DSpace at My University</name>
	</dspace>

An example of dspace.cfg converted to XML: ^ExampleDspaceConfig.xml

The benefit of the above approach in formating properties is that we get XML immediately without altering the inital lookup API of ConfigurationManager.

ConfigurationManager.getProperty("dspace.name")

Use of Hierarchical Properties and grouping

Commons Configuration provides a number of options for building groups or lists of properties, it also has a powerful XPath query facility that allows for the retrieval of properties matching very specific conditions.

In the current dspace.cfg

plugin.named.org.dspace.content.packager.PackageIngester = \
  org.dspace.content.packager.PDFPackager  = Adobe PDF, PDF, \
  org.dspace.content.packager.DSpaceMETSIngester = METS

Accessing these properties in PluginManager requires a significant amount of processing of the both the property key and its property value. Instead if a format similar to the following were adopted there would be a much more elegant startegy for getting at the content without further parsing:

<plugin type="named" interface="org.dspace.content.packager.PackageIngester">
   <name>Adobe PDF</name>
   <name>PDF</name>
   <class>org.dspace.content.packager.PDFPackager</class>
</plugin>
<plugin type="named" interface="org.dspace.content.packager.PackageIngester">
   <name>METS</name>
   <class>org.dspace.content.packager.DSpaceMETSIngester</class>
</plugin>

Accessing these properties using Commons Configuration simply looks as such:

Configuration config = ConfigurationManager.getConfiguration();

... work in progress ...

Supporting Required Libraries

Commons Configuration: Jars can be download from the Maven repository on ibiblio and placed into dspace lib:

ConfigurationManager rewrite

Initial efforts in converting ConfigurationManager resulted in the following patch (just for ConfigurationManager) which uses an XML'zed version of the properties file. This does not include changes neccessary to adapt the rest of the DSpace library to commons configuration. which are soon to come.

Missing File: Configuration-manager-patch.txt 

The way properties are accessed from ConfigurationManager will change significantly further patches are being written to handle those cases.

FilterMedia changes

PluginManager changes

Various smaller changes where regexp's are used to parse parameters.

JUnit Testing

The refactorings required to complete this effort span a significant number of classes to warrant some testing to verify the behavior is acceptable in each case, This project includes the additon of a JUnit based testing similar to and compatible with that of Maven and which can be called via Ant/build.xml

  • No labels