archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1425372 - in /archiva/trunk/archiva-modules: archiva-base/archiva-configuration/src/main/mdo/ archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ archiva-web/archiva-rest/a...
Date Sat, 22 Dec 2012 23:43:37 GMT
Author: olamy
Date: Sat Dec 22 23:43:37 2012
New Revision: 1425372

URL: http://svn.apache.org/viewvc?rev=1425372&view=rev
Log:
refactor the model for cache setup to have something reusable for url cache failure

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
    archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RedbackRuntimeConfiguration.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo?rev=1425372&r1=1425371&r2=1425372&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo
Sat Dec 22 23:43:37 2012
@@ -1494,18 +1494,12 @@
           <defaultValue>true</defaultValue>
         </field>
         <field>
-          <name>usersCacheTimeToIdleSeconds</name>
-          <description>TimeToIdleSeconds for users cache</description>
+          <name>usersCacheConfiguration</name>
+          <description>the users cache configuration</description>
           <version>1.4.0+</version>
-          <type>int</type>
-          <defaultValue>14400</defaultValue>
-        </field>
-        <field>
-          <name>usersCacheTimeToLiveSeconds</name>
-          <description>TimeToLiveSeconds for users cache</description>
-          <version>1.4.0+</version>
-          <type>int</type>
-          <defaultValue>14400</defaultValue>
+          <association>
+            <type>CacheConfiguration</type>
+          </association>
         </field>
       </fields>
     </class>
@@ -1584,6 +1578,29 @@
       </fields>
     </class>
 
+
+    <class>
+      <name>CacheConfiguration</name>
+      <version>1.4.0+</version>
+      <description>Cache configuration.</description>
+      <fields>
+        <field>
+          <name>timeToIdleSeconds</name>
+          <description>TimeToIdleSeconds</description>
+          <version>1.4.0+</version>
+          <type>int</type>
+          <defaultValue>-1</defaultValue>
+        </field>
+        <field>
+          <name>timeToLiveSeconds</name>
+          <description>TimeToLiveSeconds</description>
+          <version>1.4.0+</version>
+          <type>int</type>
+          <defaultValue>-1</defaultValue>
+        </field>
+      </fields>
+    </class>
+
   </classes>
 </model>
 

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RedbackRuntimeConfiguration.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RedbackRuntimeConfiguration.java?rev=1425372&r1=1425371&r2=1425372&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RedbackRuntimeConfiguration.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/RedbackRuntimeConfiguration.java
Sat Dec 22 23:43:37 2012
@@ -59,15 +59,7 @@ public class RedbackRuntimeConfiguration
      */
     private boolean useUsersCache = false;
 
-    /**
-     * TimeToIdleSeconds for users cache.
-     */
-    private int usersCacheTimeToIdleSeconds = 14400;
-
-    /**
-     * TimeToLiveSeconds for users cache.
-     */
-    private int usersCacheTimeToLiveSeconds = 14400;
+    private CacheConfiguration usersCacheConfiguration;
 
     public RedbackRuntimeConfiguration()
     {
@@ -151,24 +143,14 @@ public class RedbackRuntimeConfiguration
         this.useUsersCache = useUsersCache;
     }
 
-    public int getUsersCacheTimeToIdleSeconds()
-    {
-        return usersCacheTimeToIdleSeconds;
-    }
-
-    public void setUsersCacheTimeToIdleSeconds( int usersCacheTimeToIdleSeconds )
-    {
-        this.usersCacheTimeToIdleSeconds = usersCacheTimeToIdleSeconds;
-    }
-
-    public int getUsersCacheTimeToLiveSeconds()
+    public CacheConfiguration getUsersCacheConfiguration()
     {
-        return usersCacheTimeToLiveSeconds;
+        return usersCacheConfiguration;
     }
 
-    public void setUsersCacheTimeToLiveSeconds( int usersCacheTimeToLiveSeconds )
+    public void setUsersCacheConfiguration( CacheConfiguration usersCacheConfiguration )
     {
-        this.usersCacheTimeToLiveSeconds = usersCacheTimeToLiveSeconds;
+        this.usersCacheConfiguration = usersCacheConfiguration;
     }
 
     @Override
@@ -182,8 +164,7 @@ public class RedbackRuntimeConfiguration
         sb.append( ", configurationProperties=" ).append( configurationProperties );
         sb.append( ", configurationPropertiesEntries=" ).append( configurationPropertiesEntries
);
         sb.append( ", useUsersCache=" ).append( useUsersCache );
-        sb.append( ", usersCacheTimeToIdleSeconds=" ).append( usersCacheTimeToIdleSeconds
);
-        sb.append( ", usersCacheTimeToLiveSeconds=" ).append( usersCacheTimeToLiveSeconds
);
+        sb.append( ", usersCacheConfiguration=" ).append( usersCacheConfiguration );
         sb.append( '}' );
         return sb.toString();
     }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java?rev=1425372&r1=1425371&r2=1425372&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java
Sat Dec 22 23:43:37 2012
@@ -19,6 +19,7 @@ package org.apache.archiva.rest.services
  */
 
 import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.CacheConfiguration;
 import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
 import org.apache.archiva.admin.model.beans.LdapConfiguration;
 import org.apache.archiva.admin.model.runtime.RedbackRuntimeConfigurationAdmin;
@@ -54,7 +55,7 @@ import java.util.Properties;
  * @author Olivier Lamy
  * @since 1.4-M4
  */
-@Service("archivaRuntimeConfigurationService#rest")
+@Service( "archivaRuntimeConfigurationService#rest" )
 public class DefaultRedbackRuntimeConfigurationService
     extends AbstractRestService
     implements RedbackRuntimeConfigurationService
@@ -63,14 +64,14 @@ public class DefaultRedbackRuntimeConfig
     private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin;
 
     @Inject
-    @Named(value = "userManager#configurable")
+    @Named( value = "userManager#configurable" )
     private UserManager userManager;
 
     @Inject
     private ApplicationContext applicationContext;
 
     @Inject
-    @Named(value = "ldapConnectionFactory#configurable")
+    @Named( value = "ldapConnectionFactory#configurable" )
     private LdapConnectionFactory ldapConnectionFactory;
 
     @Inject
@@ -83,8 +84,31 @@ public class DefaultRedbackRuntimeConfig
     {
         RedbackRuntimeConfiguration redbackRuntimeConfiguration =
             redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
-        usersCache.setTimeToIdleSeconds( redbackRuntimeConfiguration.getUsersCacheTimeToIdleSeconds()
);
-        usersCache.setTimeToLiveSeconds( redbackRuntimeConfiguration.getUsersCacheTimeToLiveSeconds()
);
+
+        // NPE free
+        if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
+        {
+            redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration()
);
+        }
+        // if -1 it means non initialized to take values from the spring bean
+        if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds()
< 0 )
+        {
+            redbackRuntimeConfiguration.getUsersCacheConfiguration().setTimeToIdleSeconds(
+                usersCache.getTimeToIdleSeconds() );
+
+        }
+        usersCache.setTimeToIdleSeconds(
+            redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds()
);
+
+        if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds()
< 0 )
+        {
+            redbackRuntimeConfiguration.getUsersCacheConfiguration().setTimeToLiveSeconds(
+                usersCache.getTimeToLiveSeconds() );
+
+        }
+        usersCache.setTimeToLiveSeconds(
+            redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds()
);
+
     }
 
     public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
@@ -148,8 +172,10 @@ public class DefaultRedbackRuntimeConfig
             }
 
             // users cache
-            usersCache.setTimeToIdleSeconds( redbackRuntimeConfiguration.getUsersCacheTimeToIdleSeconds()
);
-            usersCache.setTimeToLiveSeconds( redbackRuntimeConfiguration.getUsersCacheTimeToLiveSeconds()
);
+            usersCache.setTimeToIdleSeconds(
+                redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds()
);
+            usersCache.setTimeToLiveSeconds(
+                redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds()
);
 
             return Boolean.TRUE;
         }



Mime
View raw message