You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/04/06 11:33:56 UTC
svn commit: r1310262 [12/14] - in /archiva/redback/redback-components/trunk:
./ plexus-command-line/ plexus-command-line/src/
plexus-command-line/src/main/ plexus-command-line/src/main/java/
plexus-command-line/src/main/java/org/ plexus-command-line/sr...
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryException.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryException.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryException.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryException.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,35 @@
+package org.codehaus.plexus.registry;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Exception occurring in the registry component.
+ */
+public class RegistryException
+ extends Exception
+{
+ public RegistryException( String message )
+ {
+ super( message );
+ }
+
+ public RegistryException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryListener.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryListener.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryListener.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryListener.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,41 @@
+package org.codehaus.plexus.registry;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Receives notifications of configuration changes in thre registry.
+ */
+public interface RegistryListener
+{
+ /**
+ * Notify the object that there is about to be a configuration change.
+ *
+ * @param registry the registry that was changed
+ * @param propertyName the property being changed
+ * @param propertyValue the value the property is about to be changed to
+ */
+ void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue );
+
+ /**
+ * Notify the object that there has been a configuration change.
+ *
+ * @param registry the registry that was changed
+ * @param propertyName the property what was changed
+ * @param propertyValue the value the property was changed to
+ */
+ void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue );
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-api/src/main/java/org/codehaus/plexus/registry/RegistryListener.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/pom.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/pom.xml (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/pom.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,102 @@
+<!--
+ ~ Copyright 2007 The Codehaus Foundation.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.codehaus.redback.components.registry</groupId>
+ <artifactId>spring-registry</artifactId>
+ <version>1.1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>spring-registry-commons</artifactId>
+ <name>Redback Spring Registry commons-configuration</name>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interpolation</artifactId>
+ <version>1.14</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.redback.components.registry</groupId>
+ <artifactId>spring-registry-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-configuration</groupId>
+ <artifactId>commons-configuration</artifactId>
+ <version>1.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils-core</artifactId>
+ </exclusion>
+ <!-- targeting JDK 1.4, xml parser/apis not needed -->
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xerces</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>xml-apis</groupId>
+ <artifactId>xml-apis</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>servletapi</groupId>
+ <artifactId>servletapi</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <basedir>${basedir}</basedir>
+ </systemPropertyVariables>
+ <forkMode>once</forkMode>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/CommonsConfigurationRegistry.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/CommonsConfigurationRegistry.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/CommonsConfigurationRegistry.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/CommonsConfigurationRegistry.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,416 @@
+package org.codehaus.redback.components.registry.commons;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.configuration.CombinedConfiguration;
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.DefaultConfigurationBuilder;
+import org.apache.commons.configuration.FileConfiguration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.configuration.SystemConfiguration;
+import org.apache.commons.configuration.XMLConfiguration;
+import org.apache.commons.configuration.event.EventSource;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.plexus.interpolation.InterpolationException;
+import org.codehaus.plexus.interpolation.PropertiesBasedValueSource;
+import org.codehaus.plexus.interpolation.StringSearchInterpolator;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.registry.RegistryListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.io.File;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+/**
+ * Implementation of the registry component using
+ * <a href="http://jakarta.apache.org/commons/configuration">Commons Configuration</a>. The use of Commons Configuration
+ * enables a variety of sources to be used, including XML files, properties, JNDI, JDBC, etc.
+ * <p/>
+ * The component can be configured using the {@link #properties} configuration item, the content of which should take
+ * the format of an input to the Commons Configuration
+ * <a href="http://jakarta.apache.org/commons/configuration/howto_configurationbuilder.html">configuration
+ * builder</a>.
+ *
+ * @plexus.component role-hint="commons-configuration"
+ */
+@Service("commons-configuration")
+public class CommonsConfigurationRegistry
+ implements Registry
+{
+ /**
+ * The combined configuration instance that houses the registry.
+ */
+ private Configuration configuration;
+
+ private Logger logger = LoggerFactory.getLogger( getClass() );
+
+ /**
+ * The configuration properties for the registry. This should take the format of an input to the Commons
+ * Configuration
+ * <a href="http://commons.apache.org/configuration/howto_configurationbuilder.html">configuration
+ * builder</a>.
+ */
+ private String properties;
+
+
+ public CommonsConfigurationRegistry()
+ {
+ // default constructor for plexus
+ }
+
+ public CommonsConfigurationRegistry( Configuration configuration )
+ {
+ if ( configuration == null )
+ {
+ throw new NullPointerException( "configuration can not be null" );
+ }
+
+ this.configuration = configuration;
+ }
+
+ public String dump()
+ {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append( "Configuration Dump." );
+ for ( Iterator i = configuration.getKeys(); i.hasNext(); )
+ {
+ String key = (String) i.next();
+ Object value = configuration.getProperty( key );
+ buffer.append( "\n\"" ).append( key ).append( "\" = \"" ).append( value ).append( "\"" );
+ }
+ return buffer.toString();
+ }
+
+ public boolean isEmpty()
+ {
+ return configuration.isEmpty();
+ }
+
+ public Registry getSubset( String key )
+ {
+ return new CommonsConfigurationRegistry( configuration.subset( key ) );
+ }
+
+ public List getList( String key )
+ {
+ return configuration.getList( key );
+ }
+
+ public List getSubsetList( String key )
+ {
+ List subsets = new ArrayList();
+
+ boolean done = false;
+ do
+ {
+ Registry registry = getSubset( key + "(" + subsets.size() + ")" );
+ if ( !registry.isEmpty() )
+ {
+ subsets.add( registry );
+ }
+ else
+ {
+ done = true;
+ }
+ }
+ while ( !done );
+
+ return subsets;
+ }
+
+ public Properties getProperties( String key )
+ {
+ Configuration configuration = this.configuration.subset( key );
+
+ Properties properties = new Properties();
+ for ( Iterator i = configuration.getKeys(); i.hasNext(); )
+ {
+ String property = (String) i.next();
+ properties.setProperty( property, configuration.getString( property ) );
+ }
+ return properties;
+ }
+
+ public void save()
+ throws RegistryException
+ {
+ if ( configuration instanceof FileConfiguration )
+ {
+ FileConfiguration fileConfiguration = (FileConfiguration) configuration;
+ try
+ {
+ fileConfiguration.save();
+ }
+ catch ( ConfigurationException e )
+ {
+ throw new RegistryException( e.getMessage(), e );
+ }
+ }
+ else
+ {
+ throw new RegistryException( "Can only save file-based configurations" );
+ }
+ }
+
+ public void addChangeListener( RegistryListener listener )
+ {
+ EventSource configuration = (EventSource) this.configuration;
+
+ configuration.addConfigurationListener( new ConfigurationListenerDelegate( listener, this ) );
+ }
+
+ public Collection getKeys()
+ {
+ Set keys = new HashSet();
+
+ for ( Iterator i = configuration.getKeys(); i.hasNext(); )
+ {
+ String key = (String) i.next();
+
+ int index = key.indexOf( '.' );
+ if ( index < 0 )
+ {
+ keys.add( key );
+ }
+ else
+ {
+ keys.add( key.substring( 0, index ) );
+ }
+ }
+
+ return keys;
+ }
+
+ public void remove( String key )
+ {
+ configuration.clearProperty( key );
+ }
+
+ public void removeSubset( String key )
+ {
+ // create temporary list since removing a key will modify the iterator from configuration
+ List keys = new ArrayList();
+ for ( Iterator i = configuration.getKeys( key ); i.hasNext(); )
+ {
+ keys.add( i.next() );
+ }
+
+ for ( Iterator i = keys.iterator(); i.hasNext(); )
+ {
+ configuration.clearProperty( (String) i.next() );
+ }
+ }
+
+ public String getString( String key )
+ {
+ return configuration.getString( key );
+ }
+
+ public String getString( String key, String defaultValue )
+ {
+ return configuration.getString( key, defaultValue );
+ }
+
+ public void setString( String key, String value )
+ {
+ configuration.setProperty( key, value );
+ }
+
+ public int getInt( String key )
+ {
+ return configuration.getInt( key );
+ }
+
+ public int getInt( String key, int defaultValue )
+ {
+ return configuration.getInt( key, defaultValue );
+ }
+
+ public void setInt( String key, int value )
+ {
+ configuration.setProperty( key, Integer.valueOf( value ) );
+ }
+
+ public boolean getBoolean( String key )
+ {
+ return configuration.getBoolean( key );
+ }
+
+ public boolean getBoolean( String key, boolean defaultValue )
+ {
+ return configuration.getBoolean( key, defaultValue );
+ }
+
+ public void setBoolean( String key, boolean value )
+ {
+ configuration.setProperty( key, Boolean.valueOf( value ) );
+ }
+
+ public void addConfigurationFromResource( String resource )
+ throws RegistryException
+ {
+ addConfigurationFromResource( resource, null );
+ }
+
+ public void addConfigurationFromResource( String resource, String prefix )
+ throws RegistryException
+ {
+ CombinedConfiguration configuration = (CombinedConfiguration) this.configuration;
+ if ( resource.endsWith( ".properties" ) )
+ {
+ try
+ {
+ logger.debug( "Loading properties configuration from classloader resource: {}", resource );
+ configuration.addConfiguration( new PropertiesConfiguration( resource ), null, prefix );
+ }
+ catch ( ConfigurationException e )
+ {
+ throw new RegistryException(
+ "Unable to add configuration from resource '" + resource + "': " + e.getMessage(), e );
+ }
+ }
+ else if ( resource.endsWith( ".xml" ) )
+ {
+ try
+ {
+ logger.debug( "Loading XML configuration from classloader resource: {}", resource );
+ configuration.addConfiguration( new XMLConfiguration( resource ), null, prefix );
+ }
+ catch ( ConfigurationException e )
+ {
+ throw new RegistryException(
+ "Unable to add configuration from resource '" + resource + "': " + e.getMessage(), e );
+ }
+ }
+ else
+ {
+ throw new RegistryException(
+ "Unable to add configuration from resource '" + resource + "': unrecognised type" );
+ }
+ }
+
+ public void addConfigurationFromFile( File file )
+ throws RegistryException
+ {
+ addConfigurationFromFile( file, null );
+ }
+
+ public void addConfigurationFromFile( File file, String prefix )
+ throws RegistryException
+ {
+ CombinedConfiguration configuration = (CombinedConfiguration) this.configuration;
+ if ( file.getName().endsWith( ".properties" ) )
+ {
+ try
+ {
+ logger.debug( "Loading properties configuration from file: {}", file );
+ configuration.addConfiguration( new PropertiesConfiguration( file ), null, prefix );
+ }
+ catch ( ConfigurationException e )
+ {
+ throw new RegistryException(
+ "Unable to add configuration from file '" + file.getName() + "': " + e.getMessage(), e );
+ }
+ }
+ else if ( file.getName().endsWith( ".xml" ) )
+ {
+ try
+ {
+ logger.debug( "Loading XML configuration from file: {}", file );
+ configuration.addConfiguration( new XMLConfiguration( file ), null, prefix );
+ }
+ catch ( ConfigurationException e )
+ {
+ throw new RegistryException(
+ "Unable to add configuration from file '" + file.getName() + "': " + e.getMessage(), e );
+ }
+ }
+ else
+ {
+ throw new RegistryException(
+ "Unable to add configuration from file '" + file.getName() + "': unrecognised type" );
+ }
+ }
+
+ @PostConstruct
+ public void initialize()
+ throws RegistryException
+ {
+ try
+ {
+ CombinedConfiguration configuration;
+ if ( StringUtils.isNotBlank( properties) )
+ {
+ try
+ {
+ DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+
+ StringSearchInterpolator interpolator = new StringSearchInterpolator( "${", "}" );
+ // interpolation as plexus did it before
+ interpolator.addValueSource( new PropertiesBasedValueSource( System.getProperties() ) );
+
+ String interpolatedProps = interpolator.interpolate( properties );
+
+ logger.debug( "Loading configuration into commons-configuration, xml {}",interpolatedProps );
+ builder.load( new StringReader( interpolatedProps ) );
+ configuration = builder.getConfiguration( false );
+ }
+ catch ( InterpolationException e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+ }
+ }
+ else
+ {
+ logger.debug( "Creating a default configuration - no configuration was provided" );
+ configuration = new CombinedConfiguration();
+ }
+
+ configuration.addConfiguration( new SystemConfiguration() );
+
+ this.configuration = configuration;
+ }
+ catch ( ConfigurationException e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+ }
+ }
+
+ public void setProperties( String properties )
+ {
+ this.properties = properties;
+ }
+
+ public Registry getSection( String name )
+ {
+ CombinedConfiguration combinedConfiguration = (CombinedConfiguration) configuration;
+ Configuration configuration = combinedConfiguration.getConfiguration( name );
+ return configuration == null ? null : new CommonsConfigurationRegistry( configuration );
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/CommonsConfigurationRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/CommonsConfigurationRegistry.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/ConfigurationListenerDelegate.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/ConfigurationListenerDelegate.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/ConfigurationListenerDelegate.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/ConfigurationListenerDelegate.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,61 @@
+package org.codehaus.redback.components.registry.commons;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.configuration.event.ConfigurationEvent;
+import org.apache.commons.configuration.event.ConfigurationListener;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryListener;
+
+/**
+ * Commons configuration listener that delegates to the given registry listener.
+ */
+public class ConfigurationListenerDelegate
+ implements ConfigurationListener
+{
+ /**
+ * Delegate listener.
+ */
+ private RegistryListener listener;
+
+ /**
+ * Delegate registry.
+ */
+ private Registry registry;
+
+ public ConfigurationListenerDelegate( RegistryListener listener, Registry registry )
+ {
+ this.listener = listener;
+
+ this.registry = registry;
+ }
+
+ public void configurationChanged( ConfigurationEvent event )
+ {
+ if ( event.getPropertyName() != null )
+ {
+ if ( event.isBeforeUpdate() )
+ {
+ listener.beforeConfigurationChange( registry, event.getPropertyName(), event.getPropertyValue() );
+ }
+ else
+ {
+ listener.afterConfigurationChange( registry, event.getPropertyName(), event.getPropertyValue() );
+ }
+ }
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/ConfigurationListenerDelegate.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/java/org/codehaus/redback/components/registry/commons/ConfigurationListenerDelegate.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/resources/META-INF/spring-context.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/resources/META-INF/spring-context.xml (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/resources/META-INF/spring-context.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+ default-lazy-init="true">
+
+ <context:annotation-config />
+ <context:component-scan
+ base-package="org.codehaus.redback.components.registry.commons"/>
+
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/AbstractRegistryTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/AbstractRegistryTest.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/AbstractRegistryTest.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/AbstractRegistryTest.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,186 @@
+package org.codehaus.redback.components.registry;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.TestCase;
+import org.codehaus.plexus.registry.Registry;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.context.ApplicationContext;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import java.util.NoSuchElementException;
+
+/**
+ * @author <a href="mailto:olamy@codehaus.org">olamy</a>
+ * @version $Id$
+ * @since 8 feb. 07
+ */
+@RunWith( value = SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public abstract class AbstractRegistryTest
+ extends TestCase
+{
+
+ @Inject
+ protected ApplicationContext applicationContext;
+
+ public abstract String getRoleHint();
+
+ public Registry getRegistry()
+ throws Exception
+ {
+ return getRegistry( getRoleHint() );
+ }
+
+ public Registry getRegistry( String name )
+ throws Exception
+ {
+ Registry registry = applicationContext.getBean( name, Registry.class );
+ registry.initialize();
+ return registry;
+ }
+
+ @Test
+ public void testInt()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ assertEquals( "not 2 ", 2, registry.getInt( "two" ) );
+ }
+
+ @Test
+ public void testIntUnknown()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ try
+ {
+ registry.getInt( "unknown" );
+ assertTrue( "no NoSuchElementException", false );
+ }
+ catch ( NoSuchElementException e )
+ {
+ // cool it works
+ }
+ }
+
+ @Test
+ public void testString()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ assertEquals( "not foo ", "foo", registry.getString( "string" ) );
+ }
+
+ @Test
+ public void testStringUnknown()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ String value = registry.getString( "unknown" );
+ assertNull( "unknow not null", value );
+
+ }
+
+ @Test
+ public void testBoolean()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ assertEquals( "not true ", true, registry.getBoolean( "boolean" ) );
+ }
+
+ @Test
+ public void testBooleanUnknown()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ try
+ {
+ registry.getBoolean( "unknown" );
+ assertTrue( "no NoSuchElementException", false );
+ }
+ catch ( NoSuchElementException e )
+ {
+ // cool it works
+ }
+ }
+
+ @Test
+ public void testIsNotEmpty()
+ throws Exception
+ {
+ assertFalse( getRegistry().isEmpty() );
+ }
+
+ @Test
+ public void testGetSubRegistry()
+ throws Exception
+ {
+ assertNotNull( getRegistry().getSubset( "subOne" ) );
+ }
+
+ @Test
+ public void testgetSubsetValues()
+ throws Exception
+ {
+ Registry sub = getRegistry().getSubset( "subOne" );
+ assertNotNull( sub );
+ assertEquals( "entryOne", sub.getString( "firstEntry" ) );
+ assertEquals( "entryTwo", sub.getString( "secondEntry" ) );
+ }
+
+ @Test
+ public void testgetSubsetEmpty()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ assertNotNull( registry.getSubset( "none" ) );
+ assertTrue( registry.getSubset( "none" ).isEmpty() );
+
+ }
+
+ @Test
+ public void testSetBoolean()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ registry.setBoolean( "keyTrue", true );
+ assertTrue( registry.getBoolean( "keyTrue" ) );
+ }
+
+ @Test
+ public void testSetInt()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ registry.setInt( "keyInt", 3 );
+ assertEquals( 3, registry.getInt( "keyInt" ) );
+ }
+
+ @Test
+ public void testSetString()
+ throws Exception
+ {
+ Registry registry = getRegistry();
+ registry.setString( "what", "zorglub" );
+ assertEquals( "zorglub", registry.getString( "what" ) );
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/AbstractRegistryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/AbstractRegistryTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/CommonsConfigurationRegistryTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/CommonsConfigurationRegistryTest.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/CommonsConfigurationRegistryTest.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/CommonsConfigurationRegistryTest.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,368 @@
+package org.codehaus.redback.components.registry;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.configuration.XMLConfiguration;
+import org.codehaus.plexus.registry.Registry;
+import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.util.FileUtils;
+import org.junit.Test;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+
+/**
+ * Test the commons configuration registry.
+ */
+public class CommonsConfigurationRegistryTest
+ extends AbstractRegistryTest
+{
+ private Registry registry;
+
+ private static final int INT_TEST_VALUE = 8080;
+
+ public String getRoleHint()
+ {
+ return "builder";
+ }
+
+ @Test
+ public void testDefaultConfiguration()
+ throws Exception
+ {
+ registry = getRegistry ( "default" );
+
+ assertEquals( "Check system property override", System.getProperty( "user.dir" ), registry
+ .getString( "user.dir" ) );
+ assertEquals( "Check system property", System.getProperty( "user.home" ), registry.getString( "user.home" ) );
+ assertNull( "Check other properties are not loaded", registry.getString( "test.value" ) );
+ }
+
+ @Test
+ public void testBuilderConfiguration()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ assertEquals( "Check system property override", "new user dir", registry.getString( "user.dir" ) );
+ assertEquals( "Check system property default", System.getProperty( "user.home" ), registry
+ .getString( "user.home" ) );
+ assertEquals( "Check other properties are loaded", "foo", registry.getString( "test.value" ) );
+ assertEquals( "Check other properties are loaded", 1, registry.getInt( "test.number" ) );
+ assertTrue( "Check other properties are loaded", registry.getBoolean( "test.boolean" ) );
+ }
+
+ @Test
+ public void testDump()
+ throws Exception
+ {
+ registry = getRegistry ( "default" );
+
+ String dump = registry.dump();
+ assertTrue( dump.startsWith( "Configuration Dump.\n\"" ) );
+ }
+
+ @Test
+ public void testDefaults()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ assertNull( "Check getString returns null", registry.getString( "foo" ) );
+ assertEquals( "Check getString returns default", "bar", registry.getString( "foo", "bar" ) );
+
+ try
+ {
+ registry.getInt( "foo" );
+ fail();
+ }
+ catch ( NoSuchElementException e )
+ {
+ // success
+ }
+
+ assertEquals( "Check getInt returns default", INT_TEST_VALUE, registry.getInt( "foo", INT_TEST_VALUE ) );
+
+ try
+ {
+ registry.getBoolean( "foo" );
+ fail();
+ }
+ catch ( NoSuchElementException e )
+ {
+ // success
+ }
+
+ assertTrue( "Check getBoolean returns default", registry.getBoolean( "foo", true ) );
+ }
+
+ @Test
+ public void testInterpolation()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ assertEquals( "Check system property interpolation", System.getProperty( "user.home" ) + "/.m2/repository",
+ registry.getString( "repository" ) );
+
+ assertEquals( "Check configuration value interpolation", "foo/bar",
+ registry.getString( "test.interpolation" ) );
+ }
+
+ @Test
+ public void testAddConfigurationXmlFile()
+ throws Exception
+ {
+ registry = getRegistry ( "default" );
+
+ registry.addConfigurationFromFile( new File( "./src/test/resources/org/codehaus/plexus/registry/test.xml" ) );
+
+ assertEquals( "Check system property default", System.getProperty( "user.dir" ), registry
+ .getString( "user.dir" ) );
+ assertEquals( "Check other properties are loaded", "foo", registry.getString( "test.value" ) );
+ }
+
+ @Test
+ public void testAddConfigurationPropertiesFile()
+ throws Exception
+ {
+ registry = getRegistry ( "default" );
+
+ registry
+ .addConfigurationFromFile(
+ new File( "./src/test/resources/org/codehaus/plexus/registry/test.properties" ) );
+
+ assertEquals( "Check system property default", System.getProperty( "user.dir" ), registry
+ .getString( "user.dir" ) );
+ assertEquals( "Check other properties are loaded", "baz", registry.getString( "foo.bar" ) );
+ assertNull( "Check other properties are not loaded", registry.getString( "test.value" ) );
+ }
+
+ @Test
+ public void testAddConfigurationXmlResource()
+ throws Exception
+ {
+ registry = getRegistry ( "default" );
+
+ registry.addConfigurationFromResource( "org/codehaus/plexus/registry/test.xml" );
+
+ assertEquals( "Check system property default", System.getProperty( "user.dir" ), registry
+ .getString( "user.dir" ) );
+ assertEquals( "Check other properties are loaded", "foo", registry.getString( "test.value" ) );
+ }
+
+ @Test
+ public void testAddConfigurationPropertiesResource()
+ throws Exception
+ {
+ registry = getRegistry ( "default" );
+
+ registry.addConfigurationFromResource( "org/codehaus/plexus/registry/test.properties" );
+
+ assertEquals( "Check system property default", System.getProperty( "user.dir" ), registry
+ .getString( "user.dir" ) );
+ assertEquals( "Check other properties are loaded", "baz", registry.getString( "foo.bar" ) );
+ assertNull( "Check other properties are not loaded", registry.getString( "test.value" ) );
+ }
+
+ @Test
+ public void testAddConfigurationUnrecognisedType()
+ throws Exception
+ {
+ registry = getRegistry ( "default" );
+
+ try
+ {
+ registry.addConfigurationFromResource( "org/codehaus/plexus/registry/test.foo" );
+ fail();
+ }
+ catch ( RegistryException e )
+ {
+ // success
+ }
+
+ try
+ {
+ registry
+ .addConfigurationFromFile( new File( "./src/test/resources/org/codehaus/plexus/registry/test.foo" ) );
+ fail();
+ }
+ catch ( RegistryException e )
+ {
+ // success
+ }
+ }
+
+ @Test
+ public void testIsEmpty()
+ throws Exception
+ {
+ registry = getRegistry ( "default" );
+
+ assertFalse( registry.isEmpty() );
+ assertTrue( registry.getSubset( "foo" ).isEmpty() );
+ }
+
+ @Test
+ public void testGetSubset()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ Registry registry = this.registry.getSubset( "test" );
+ assertEquals( "Check other properties are loaded", "foo", registry.getString( "value" ) );
+ assertEquals( "Check other properties are loaded", 1, registry.getInt( "number" ) );
+ assertTrue( "Check other properties are loaded", registry.getBoolean( "boolean" ) );
+ }
+
+ @Test
+ public void testGetSubsetList()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ List list = registry.getSubsetList( "objects.object" );
+ assertEquals( 2, list.size() );
+ Registry r = (Registry) list.get( 0 );
+ assertTrue( "bar".equals( r.getString( "foo" ) ) || "baz".equals( r.getString( "foo" ) ) );
+ r = (Registry) list.get( 1 );
+ assertTrue( "bar".equals( r.getString( "foo" ) ) || "baz".equals( r.getString( "foo" ) ) );
+ }
+
+ @Test
+ public void testGetProperties()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ Properties properties = registry.getProperties( "properties" );
+ assertEquals( 2, properties.size() );
+ assertEquals( "bar", properties.getProperty( "foo" ) );
+ assertEquals( "baz", properties.getProperty( "bar" ) );
+ }
+
+ @Test
+ public void testGetList()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ List list = registry.getList( "strings.string" );
+ assertEquals( 3, list.size() );
+ assertEquals( "s1", list.get( 0 ) );
+ assertEquals( "s2", list.get( 1 ) );
+ assertEquals( "s3", list.get( 2 ) );
+ }
+
+ @Test
+ public void testGetSection()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ Registry registry = this.registry.getSection( "properties" );
+ assertNull( registry.getString( "test.value" ) );
+ assertEquals( "baz", registry.getString( "foo.bar" ) );
+ }
+
+ @Test
+ public void testRemoveKey()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ Registry registry = this.registry.getSection( "properties" );
+ assertEquals( "baz", registry.getString( "foo.bar" ) );
+ registry.remove( "foo.bar" );
+ assertNull( registry.getString( "foo.bar" ) );
+ }
+
+ @Test
+ public void testRemoveSubset()
+ throws Exception
+ {
+ registry = getRegistry ( "builder" );
+
+ registry.removeSubset( "strings" );
+ assertEquals( Collections.EMPTY_LIST, registry.getList( "strings.string" ) );
+
+ Registry registry = this.registry.getSection( "properties" );
+ assertEquals( "baz", registry.getString( "foo.bar" ) );
+ registry.remove( "foo" );
+ assertEquals( "baz", registry.getString( "foo.bar" ) );
+ registry.removeSubset( "foo" );
+ assertNull( registry.getString( "foo.bar" ) );
+ }
+
+/* TODO: for 1.4
+ public void testGetForcedCreateByName()
+ throws Exception
+ {
+ registry = (Registry) lookup( Registry.class.getName(), "forceCreate" );
+
+ String testFile = getTestFile( "target/foo-forced" ).getAbsolutePath();
+ assertFalse( FileUtils.fileExists( testFile ) );
+
+ assertNotNull( registry.getSection( "foo" ) );
+ }
+*/
+
+ @Test
+ public void testGetDontForceCreateByName()
+ throws Exception
+ {
+ registry = getRegistry ( "noForceCreate" );
+
+ assertNull( registry.getSection( "foo" ) );
+ }
+
+ @Test
+ public void testSaveSection()
+ throws Exception
+ {
+ File src = new File( "./src/test/resources/test-save.xml" );
+ File dest = new File( "./target/test-classes/test-save.xml" );
+ FileUtils.copyFile( src, dest );
+
+ registry = getRegistry ( "test-save" );
+
+ Registry registry = this.registry.getSection( "org.codehaus.plexus.registry" );
+ assertEquals( "check list elements", Arrays.asList( new String[]{"1", "2", "3"} ),
+ registry.getList( "listElements.listElement" ) );
+
+ registry.remove( "listElements.listElement(1)" );
+ registry.save();
+
+
+
+ XMLConfiguration configuration = new XMLConfiguration( dest );
+ assertEquals( Arrays.asList( new String[]{"1", "3"} ), configuration.getList( "listElements.listElement" ) );
+
+ // file in ${basedir}/target/conf/shared.xml
+ Registry section = this.registry.getSection( "org.apache.maven.shared.app.user" );
+ section.setString( "foo", "zloug" );
+ section.save();
+
+ configuration = new XMLConfiguration( new File("target/conf/shared.xml") );
+ assertNotNull( configuration.getString( "foo" ) );
+
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/CommonsConfigurationRegistryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/CommonsConfigurationRegistryTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Component.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Component.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Component.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Component.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,57 @@
+package org.codehaus.redback.components.registry;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Test component.
+ */
+public interface Component
+{
+ String ROLE = Component.class.getName();
+
+ String getKey();
+
+ Properties getProperties();
+
+ String getConfigKey();
+
+ Properties getConfigProperties();
+
+ Map getMap();
+
+ List getList();
+
+ Map getConfigMap();
+
+ List getConfigList();
+
+ Properties getMergeProperties();
+
+ int getNumber();
+
+ int getConfigNumber();
+
+ Nested getNested();
+
+ Nested getConfigNested();
+
+ List getMergeList();
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Component.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Component.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/DefaultComponent.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/DefaultComponent.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/DefaultComponent.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/DefaultComponent.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,126 @@
+package org.codehaus.redback.components.registry;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Test component.
+ */
+public class DefaultComponent
+ implements Component
+{
+ private String key;
+
+ private Properties properties;
+
+ private Map map;
+
+ private List list;
+
+ private String configKey;
+
+ private Properties configProperties;
+
+ private Map configMap;
+
+ private List configList;
+
+ private Properties mergeProperties;
+
+ private int number;
+
+ private int configNumber;
+
+ private Nested nested;
+
+ private Nested configNested;
+
+ private List mergeList;
+
+ public List getMergeList()
+ {
+ return mergeList;
+ }
+
+ public Nested getConfigNested()
+ {
+ return configNested;
+ }
+
+ public Nested getNested()
+ {
+ return nested;
+ }
+
+ public int getNumber()
+ {
+ return number;
+ }
+
+ public int getConfigNumber()
+ {
+ return configNumber;
+ }
+
+ public String getConfigKey()
+ {
+ return configKey;
+ }
+
+ public Properties getConfigProperties()
+ {
+ return configProperties;
+ }
+
+ public String getKey()
+ {
+ return key;
+ }
+
+ public Properties getProperties()
+ {
+ return properties;
+ }
+
+ public Map getMap()
+ {
+ return map;
+ }
+
+ public List getList()
+ {
+ return list;
+ }
+
+ public Map getConfigMap()
+ {
+ return configMap;
+ }
+
+ public List getConfigList()
+ {
+ return configList;
+ }
+
+ public Properties getMergeProperties()
+ {
+ return mergeProperties;
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/DefaultComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/DefaultComponent.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Nested.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Nested.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Nested.java (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Nested.java Fri Apr 6 09:33:40 2012
@@ -0,0 +1,30 @@
+package org.codehaus.redback.components.registry;
+
+/*
+ * Copyright 2007 The Codehaus Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Nested class for testing.
+ */
+public class Nested
+{
+ private String foo;
+
+ public String getFoo()
+ {
+ return foo;
+ }
+}
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Nested.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/java/org/codehaus/redback/components/registry/Nested.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/phase.properties
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/phase.properties?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/phase.properties (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/phase.properties Fri Apr 6 09:33:40 2012
@@ -0,0 +1,26 @@
+#
+# Copyright 2007 The Codehaus Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+Component.default.number=2
+Component.default.key=value1
+Component.default.properties.org.jpox.PreserveCase=always
+Component.default.properties.key=value2
+Component.default.list=S1, S2
+Component.default.map.org.jpox.PreserveCase=always
+Component.default.map.key=value3
+Component.default.mergeProperties.key32=value32
+Component.default.mergeList=v3, v4
+Component.default.nested.foo=bar
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/phase.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/phase.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.properties
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.properties?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.properties (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.properties Fri Apr 6 09:33:40 2012
@@ -0,0 +1,25 @@
+#
+# Copyright 2007 The Codehaus Foundation.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+user.dir=new user dir
+foo.bar=baz
+
+# test from plexus-registry tests
+subOne.firstEntry=entryOne
+subOne.secondEntry=entryTwo
+two=2
+string=foo
+boolean=true
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.properties
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.xml (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,42 @@
+<!--
+ ~ Copyright 2007 The Codehaus Foundation.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<configuration>
+ <test>
+ <value>foo</value>
+ <number>1</number>
+ <boolean>true</boolean>
+ <interpolation>${test.value}/bar</interpolation>
+ </test>
+ <repository>${user.home}/.m2/repository</repository>
+ <objects>
+ <object>
+ <foo>bar</foo>
+ </object>
+ <object>
+ <foo>baz</foo>
+ </object>
+ </objects>
+ <properties>
+ <foo>bar</foo>
+ <bar>baz</bar>
+ </properties>
+ <strings>
+ <string>s1</string>
+ <string>s2</string>
+ <string>s3</string>
+ </strings>
+</configuration>
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/org/codehaus/plexus/registry/test.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/spring-context.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/spring-context.xml (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/spring-context.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,105 @@
+<?xml version="1.0"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+ http://www.springframework.org/schema/context
+ http://www.springframework.org/schema/context/spring-context-2.5.xsd">
+
+
+ <alias name="commons-configuration" alias="default"/>
+
+ <bean name="builder" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <xml fileName="org/codehaus/plexus/registry/test.xml"/>
+ <properties fileName="org/codehaus/plexus/registry/test.properties" config-name="properties"/>
+
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+
+ <bean name="test-save" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <system/>
+ <xml fileName="${basedir}/target/test-classes/test-save.xml"
+ config-name="org.codehaus.plexus.registry"
+ config-at="org.codehaus.plexus.registry"/>
+ <jndi prefix="java:comp/env" config-optional="true"/>
+ <xml fileName="${basedir}/target/conf/continuum.xml" config-optional="true"
+ config-at="org.apache.maven.continuum" config-forceCreate="true"/>
+ <xml fileName="${basedir}/target/conf/shared.xml" config-optional="true"
+ config-name="org.apache.maven.shared.app.user" config-at="org.apache.maven.shared.app"
+ config-forceCreate="true"/>
+ <xml fileName="${basedir}/target/conf/shared.xml" config-optional="true"
+ config-name="org.apache.maven.shared.app.base" config-at="org.apache.maven.shared.app"/>
+ <xml fileName="${basedir}/target/conf/common.xml" config-optional="true"/>
+ <properties fileName="${basedir}/conf/security.properties" config-optional="true"
+ config-at="org.codehaus.plexus.redback"/>
+ <xml fileName="${basedir}/target/conf/continuum.xml" config-optional="true"
+ config-at="org.apache.maven.continuum" config-name="org.apache.maven.continuum.user"
+ config-forceCreate="true"/>
+ <xml fileName="${basedir}/target/conf/shared.xml" config-optional="true"
+ config-at="org.apache.maven.shared.app" />
+ <xml fileName="${basedir}/target/conf/common.xml" config-optional="true"/>
+ <properties fileName="${basedir}/conf/security.properties" config-optional="true"
+ config-at="org.codehaus.plexus.redback"/>
+
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+
+ <bean name="forceCreate" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <xml fileName="${basedir}/target/foo-forced" config-name="foo" config-forceCreate="true" config-optional="true"/>
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+
+ <bean name="noForceCreate" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry">
+ <property name="properties">
+ <value>
+ <![CDATA[
+ <configuration>
+ <xml fileName="${basedir}/target/foo" config-name="foo" config-optional="true"/>
+ </configuration>
+ ]]>
+ </value>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:executable =
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/spring-context.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/test-save.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/test-save.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/test-save.xml (added)
+++ archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/test-save.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,23 @@
+<!--
+ ~ Copyright 2007 The Codehaus Foundation.
+ ~
+ ~ Licensed under the Apache License, Version 2.0 (the "License");
+ ~ you may not use this file except in compliance with the License.
+ ~ You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<registry>
+ <listElements>
+ <listElement>1</listElement>
+ <listElement>2</listElement>
+ <listElement>3</listElement>
+ </listElements>
+</registry>
\ No newline at end of file
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/test-save.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/spring-registry-commons/src/test/resources/test-save.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-registry/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-registry/src/site/apt/index.apt?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-registry/src/site/apt/index.apt (added)
+++ archiva/redback/redback-components/trunk/spring-registry/src/site/apt/index.apt Fri Apr 6 09:33:40 2012
@@ -0,0 +1,135 @@
+ -----
+ Plexus Registry Component
+ -----
+ Brett Porter
+ -----
+ 7 February 2007
+ -----
+
+Plexus Registry
+
+ The Plexus registry is a single source of external configuration for Plexus components and applications.
+ It can be used by components to source configuration, knowing that it can be used from within applications
+ without the information being hard coded into the component.
+
+ To facilitate a variety of providers, {{{http://jakarta.apache.org/commons/configuration/} Commons Configuration}}
+ is used to implement the backing storage.
+
+ This relies on a pull-based (or lookup) mechanism - the applications request specific pieces of configuration at
+ the time they need them, and it is retrieved from the registry.
+
+ The registry is configurable so that configuration can be placed in any location desired, and is shared container
+ wide. A registry using the same file as other running VMs should operate correctly.
+
+ <Note:> Inside the application server, this means that the scope is application wide as each application has it's
+ own container. It may be feasible to provide a single registry for the whole server, but this has not yet been
+ tested. This would only be necessary if the server was to dictate configuration locations that the registry was
+ not already configured to use. Of course, such additional locations could be added to the application registry
+ instances programmatically as well.
+
+* Example Configuration
+
+-----
+<component>
+ <role>org.codehaus.redback.components.registry.Registry</role>
+ <implementation>org.codehaus.plexus.registry.CommonsConfigurationRegistry</implementation>
+ <role-hint>commons-configuration</role-hint>
+ <configuration>
+ <properties>
+ <system/>
+ <jndi prefix="java:comp/env" config-optional="true"/>
+ <xml fileName="${user.home}/.m2/archiva.xml" config-optional="true" config-name="org.apache.maven.archiva"
+ config-at="org.apache.maven.archiva" config-forceCreate="true"/>
+ <properties fileName="${user.home}/.m2/security.properties" config-optional="true"
+ config-at="org.codehaus.plexus.security"/>
+ </properties>
+ </configuration>
+</component>
+-----
+
+ The configuration inside the outer <<<\<properties\>>>> element is equivalent to the
+ {{{http://jakarta.apache.org/commons/configuration/howto_configurationbuilder.html#Using_DefaultConfigurationBuilder} builder syntax}}
+ for Commons Configuration. This maps to similar concepts in the registry.
+
+ In this example, the precedence is to first look in the system properties, then JNDI, then the given XML file, and
+ finally the given properties file.
+
+ Registries can have 'sections', which are declared as partitioned areas of the registry. This is done using the
+ <<<config-name>>> attribute in Commons Configuration. While the sections behave normally as a part of the global
+ registry, they can easily be retrieved independently. This is particularly useful for write-back operations so the
+ file the section is stored in can be saved when the registry is modified.
+
+ Each configuration source can be configured with a given mount-point in the registry using the <<<config-at>>>
+ attribute. This will cause all of the properties to be stored with the given prefix.
+
+* Using the Registry
+
+ The registry can be used as a simple directory, for example:
+
+-----
+int value = registry.getInt( "test.property" );
+String text = registry.getString( "text.data" );
+boolean enabled = registry.getBoolean( "system.enabled", true );
+-----
+
+ The first parameter is always a key. The registry is hierachical, so in the key, a <<<.>>> (period) represents a
+ nested configuration, and can be traversed to any level.
+
+ The second parameter specifies a default value. If it is not given, then <<<null>>> is returned for strings if the
+ key is not found in the registry, and an exception is thrown for integers and booleans under the same circumstances.
+
+** Subsets and Sections
+
+ There are two ways to work with a portion of the registry at a time: subsets and sections.
+
+ Sections were encountered earlier - and while they return a subset it may span a number of different base prefixes,
+ depending on whether <<<config-at>>> was specified on the section or not. Even so, if it is a subset of the
+ hierachy, some elements of the hierachy at the same level might not be returned because they come from a different
+ section.
+
+ On the other hand, subsets are reductions of the registry to keys descending from a given prefix.
+
+ Once a subset (or section) is obtained, it behaves the same as the registry as a whole, however it will have fewer
+ values, and looking up values will not have the prefix as a part of the key.
+
+ For example:
+
+-----
+String value = registry.getString( "org.codehaus.plexus.registry.value" );
+Registry subset = registry.getSubset( "org.codehaus.plexus.registry" );
+value = subset.getString( "value" ); // this will equal the earlier value retrieved
+-----
+
+** Lists and Maps
+
+ It is also possible to retrieve subsets of the registry as collections.
+
+ * <<<getProperties(key)>>>: Maps and properties are straightforward - the subset is converted into key/value pairs
+ and returned as a map.
+
+ * <<<getSubsetList(key)>>>: For lists of complex types that will still contain more than one key/value pair,
+ this method can be used to retrieve them as a list of subset registries.
+
+ * <<<getList(key)>>>: For lists of simple types, this method can be used to get a list of value objects.
+
+** Using Models
+
+ To simplify the translation of configuration into reusable beans and to produce a self-documenting system, Modello
+ can be used to generate registry I/O classes. The appropriate goals in the plugin are <<<registry-reader>>> and
+ <<<registry-writer>>>.
+
+** Saving Changes
+
+ Saving changes to a registry is quite simple:
+
+-----
+registry.save();
+-----
+
+ Note that the registry must be a file-based section (saving the entire registry will not succeed). It will be saved
+ to the same location that it was loaded from.
+
+** Adding Change Listeners
+
+ ~~TODO
+
Propchange: archiva/redback/redback-components/trunk/spring-registry/src/site/apt/index.apt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-registry/src/site/apt/index.apt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: archiva/redback/redback-components/trunk/spring-taskqueue/pom.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-taskqueue/pom.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-taskqueue/pom.xml (added)
+++ archiva/redback/redback-components/trunk/spring-taskqueue/pom.xml Fri Apr 6 09:33:40 2012
@@ -0,0 +1,78 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.codehaus.redback.components</groupId>
+ <artifactId>redback-components</artifactId>
+ <version>1.3-SNAPSHOT</version>
+ <relativePath>../redback-components-parent/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>spring-taskqueue</artifactId>
+ <name>Spring Task Queue</name>
+ <version>1.1-SNAPSHOT</version>
+
+ <url>http://redback.codehaus.org/components/${project.artifactId}</url>
+
+ <distributionManagement>
+ <site>
+ <id>codehaus.org</id>
+ <url>dav:https://dav.codehaus.org/redback/components/${project.artifactId}</url>
+ </site>
+ </distributionManagement>
+
+ <scm>
+ <connection>scm:svn:https://svn.codehaus.org/redback/components/trunk/spring-taskqueue</connection>
+ <developerConnection>scm:svn:https://svn.codehaus.org/redback/components/trunk/spring-taskqueue</developerConnection>
+ <url>http://fisheye.codehaus.org/browse/redback/components/trunk/spring-taskqueue</url>
+ </scm>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
Propchange: archiva/redback/redback-components/trunk/spring-taskqueue/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: archiva/redback/redback-components/trunk/spring-taskqueue/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision