optimize a bit: no need to fully rebuild the bean if no change

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1445900 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-02-13 20:21:54 +00:00
parent dd4703f181
commit 84cc32a55f
1 changed files with 19 additions and 8 deletions

View File

@ -69,6 +69,8 @@ public class DefaultRedbackRuntimeConfigurationAdmin
@Named( value = "cache#users" )
private Cache usersCache;
private RedbackRuntimeConfiguration currentRedbackRuntimeConfiguration;
@PostConstruct
public void initialize()
throws UserConfigurationException
@ -217,6 +219,8 @@ public class DefaultRedbackRuntimeConfigurationAdmin
updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
}
this.currentRedbackRuntimeConfiguration = redbackRuntimeConfiguration;
}
catch ( RepositoryAdminException e )
{
@ -239,6 +243,7 @@ public class DefaultRedbackRuntimeConfigurationAdmin
try
{
archivaConfiguration.save( configuration );
this.currentRedbackRuntimeConfiguration = redbackRuntimeConfiguration;
}
catch ( RegistryException e )
{
@ -253,6 +258,10 @@ public class DefaultRedbackRuntimeConfigurationAdmin
private RedbackRuntimeConfiguration build(
org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration )
{
if ( this.currentRedbackRuntimeConfiguration != null )
{
return this.currentRedbackRuntimeConfiguration;
}
RedbackRuntimeConfiguration redbackRuntimeConfiguration =
new BeanReplicator().replicateBean( runtimeConfiguration, RedbackRuntimeConfiguration.class );
@ -283,7 +292,9 @@ public class DefaultRedbackRuntimeConfigurationAdmin
cleanupProperties( redbackRuntimeConfiguration );
t return redbackRuntimeConfiguration;
this.currentRedbackRuntimeConfiguration = redbackRuntimeConfiguration;
return redbackRuntimeConfiguration;
}
/**
@ -307,13 +318,13 @@ t return redbackRuntimeConfiguration;
properties.remove( UserConfigurationKeys.LDAP_WRITABLE );
properties.remove( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME );
// cleanup groups <-> role mapping
for ( Map.Entry<String, String> entry : new HashMap<String, String>( properties ).entrySet() )
{
if ( entry.getKey().startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
{
properties.remove( entry.getKey() );
}
}
/**for ( Map.Entry<String, String> entry : new HashMap<String, String>( properties ).entrySet() )
{
if ( entry.getKey().startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
{
properties.remove( entry.getKey() );
}
}*/
}
private org.apache.archiva.configuration.RedbackRuntimeConfiguration build(