private void addRegistryChangeListener(RegistryListener listener) { Registry section = registry.getSection(KEY + ".user"); if (section != null) { section.addChangeListener(listener); } section = registry.getSection(KEY + ".base"); if (section != null) { section.addChangeListener(listener); } }
private void addRegistryChangeListener( RegistryListener listener ) { Registry section = registry.getSection( KEY + ".user" ); if ( section != null ) { section.addChangeListener( listener ); } section = registry.getSection( KEY + ".base" ); if ( section != null ) { section.addChangeListener( listener ); } }
@Override public void removeChangeListener(RegistryListener listener) { boolean removed = registryListeners.remove(listener); log.debug("RegistryListener: '{}' removed {}", listener, removed); Registry section = registry.getSection(KEY + ".user"); if (section != null) { section.removeChangeListener(listener); } section = registry.getSection(KEY + ".base"); if (section != null) { section.removeChangeListener(listener); } }
@Override public void removeChangeListener( RegistryListener listener ) { boolean removed = registryListeners.remove( listener ); log.debug( "RegistryListener: '{}' removed {}", listener, removed ); Registry section = registry.getSection( KEY + ".user" ); if ( section != null ) { section.removeChangeListener( listener ); } section = registry.getSection( KEY + ".base" ); if ( section != null ) { section.removeChangeListener( listener ); } }
public synchronized void save(Configuration configuration) throws IndeterminateConfigurationException, RegistryException { Registry section = registry.getSection(KEY + ".user"); Registry baseSection = registry.getSection(KEY + ".base"); if (section == null) { section = baseSection;
throws IndeterminateConfigurationException, RegistryException Registry section = registry.getSection( KEY + ".user" ); Registry baseSection = registry.getSection( KEY + ".base" ); if ( section == null )
private Registry createDefaultConfigurationFile() throws RegistryException { // TODO: may not be needed under commons-configuration 1.4 - check String contents = "<configuration />"; String fileLocation = userConfigFilename; if (!writeFile("user configuration", userConfigFilename, contents)) { fileLocation = altConfigFilename; if (!writeFile("alternative configuration", altConfigFilename, contents)) { throw new RegistryException( "Unable to create configuration file in either user [" + userConfigFilename + "] or alternative [" + altConfigFilename + "] locations on disk, usually happens when not allowed to write to those locations."); } } // olamy hackish I know :-) contents = "<configuration><xml fileName=\"" + fileLocation + "\" config-forceCreate=\"true\" config-name=\"org.apache.archiva.user\"/>" + "</configuration>"; ((CommonsConfigurationRegistry) registry).setProperties(contents); registry.initialize(); for (RegistryListener regListener : registryListeners) { addRegistryChangeListener(regListener); } triggerEvent(ConfigurationEvent.SAVED); Registry section = registry.getSection(KEY + ".user"); return section == null ? new CommonsConfigurationRegistry(new BaseConfiguration()) : section; }
private Registry createDefaultConfigurationFile() throws RegistryException { // TODO: may not be needed under commons-configuration 1.4 - check String contents = "<configuration />"; String fileLocation = userConfigFilename; if ( !writeFile( "user configuration", userConfigFilename, contents ) ) { fileLocation = altConfigFilename; if ( !writeFile( "alternative configuration", altConfigFilename, contents ) ) { throw new RegistryException( "Unable to create configuration file in either user [" + userConfigFilename + "] or alternative [" + altConfigFilename + "] locations on disk, usually happens when not allowed to write to those locations." ); } } // olamy hackish I know :-) contents = "<configuration><xml fileName=\"" + fileLocation + "\" config-forceCreate=\"true\" config-name=\"org.apache.archiva.user\"/>" + "</configuration>"; ( (CommonsConfigurationRegistry) registry ).setProperties( contents ); registry.initialize(); for ( RegistryListener regListener : registryListeners ) { addRegistryChangeListener( regListener ); } triggerEvent( ConfigurationEvent.SAVED ); Registry section = registry.getSection( KEY + ".user" ); return section == null ? new CommonsConfigurationRegistry( new BaseConfiguration() ) : section; }