1 package org.apache.maven.archiva.configuration;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryReader;
23 import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryWriter;
24 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
25 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
26 import org.codehaus.plexus.registry.Registry;
27 import org.codehaus.plexus.registry.RegistryException;
28 import org.codehaus.plexus.registry.RegistryListener;
31 * Implementation of configuration holder that retrieves it from the registry.
35 public class DefaultArchivaConfiguration
36 implements ArchivaConfiguration, RegistryListener, Initializable
39 * Plexus registry to read the configuration from.
41 * @plexus.requirement role-hint="commons-configuration"
43 private Registry registry;
46 * The configuration that has been converted.
48 private Configuration configuration;
50 private static final String KEY = "org.apache.maven.archiva";
52 public synchronized Configuration getConfiguration()
54 if ( configuration == null )
56 // TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties)
57 configuration = new ConfigurationRegistryReader().read( registry.getSubset( KEY ) );
62 public void save( Configuration configuration )
63 throws RegistryException
65 Registry section = registry.getSection( KEY );
66 new ConfigurationRegistryWriter().write( configuration, section );
69 this.configuration = configuration;
72 public void addChangeListener( RegistryListener listener )
74 Registry section = registry.getSection( KEY );
75 section.addChangeListener( listener );
78 public void initialize()
79 throws InitializationException
81 registry.addChangeListener( this );
84 public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
89 public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )