Switching to generics for cache implementation

This commit is contained in:
Martin Schreier 2022-01-03 20:26:19 +01:00
parent c8fac6bd92
commit ac29dbbca6
17 changed files with 57 additions and 9 deletions

View File

@ -39,6 +39,8 @@
<bean name="cache#users" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#users" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String" />
<constructor-arg index="1" value="org.apache.archiva.redback.users.User"/>
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>

View File

@ -473,7 +473,7 @@ public class DefaultRoleManagementService
try try
{ {
org.apache.archiva.redback.rbac.Role rbacRole = rbacManager.getRole( roleName ); org.apache.archiva.redback.rbac.Role rbacRole = rbacManager.getRole( roleName );
rbacRole.setDescription( description ); rbacRole.setDescription( description == null ? "" : description);
rbacManager.saveRole( rbacRole ); rbacManager.saveRole( rbacRole );
} }
catch ( RbacManagerException e ) catch ( RbacManagerException e )

View File

@ -19,6 +19,7 @@ package org.apache.archiva.redback.keys;
* under the License. * under the License.
*/ */
import java.io.Serializable;
import java.util.Date; import java.util.Date;
/** /**
@ -29,7 +30,7 @@ import java.util.Date;
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* *
*/ */
public interface AuthenticationKey public interface AuthenticationKey extends Serializable
{ {
Date getDateCreated(); Date getDateCreated();

View File

@ -33,11 +33,13 @@
<bean name="cache#keys" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#keys" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String" />
<constructor-arg index="1" value="org.apache.archiva.redback.keys.AuthenticationKey"/>
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
<property name="memoryEvictionPolicy" value="LRU"/> <property name="memoryEvictionPolicy" value="LRU"/>
<property name="name" value="usersCache"/> <property name="name" value="keysCache"/>
<property name="timeToIdleSeconds" value="1800"/> <property name="timeToIdleSeconds" value="1800"/>
<property name="timeToLiveSeconds" value="14400"/> <property name="timeToLiveSeconds" value="14400"/>
</bean> </bean>

View File

@ -39,11 +39,13 @@
<bean name="cache#keys" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#keys" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String" />
<constructor-arg index="1" value="org.apache.archiva.redback.keys.AuthenticationKey"/>
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
<property name="memoryEvictionPolicy" value="LRU"/> <property name="memoryEvictionPolicy" value="LRU"/>
<property name="name" value="usersCache"/> <property name="name" value="keysCache"/>
<property name="timeToIdleSeconds" value="1800"/> <property name="timeToIdleSeconds" value="1800"/>
<property name="timeToLiveSeconds" value="14400"/> <property name="timeToLiveSeconds" value="14400"/>
</bean> </bean>

View File

@ -16,6 +16,8 @@ package org.apache.archiva.redback.rbac;
* limitations under the License. * limitations under the License.
*/ */
import java.io.Serializable;
/** /**
* Operation * Operation
* *
@ -27,7 +29,7 @@ package org.apache.archiva.redback.rbac;
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* *
*/ */
public interface Operation public interface Operation extends Serializable
{ {

View File

@ -16,6 +16,8 @@ package org.apache.archiva.redback.rbac;
* limitations under the License. * limitations under the License.
*/ */
import java.io.Serializable;
/** /**
* Permission * Permission
* *
@ -28,7 +30,7 @@ package org.apache.archiva.redback.rbac;
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* *
*/ */
public interface Permission public interface Permission extends Serializable
{ {
/** /**

View File

@ -16,6 +16,8 @@ package org.apache.archiva.redback.rbac;
* limitations under the License. * limitations under the License.
*/ */
import java.io.Serializable;
/** /**
* Resource * Resource
* *
@ -37,7 +39,7 @@ package org.apache.archiva.redback.rbac;
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
* *
*/ */
public interface Resource public interface Resource extends Serializable
{ {
/** /**
* Resource identifier refering to all objects. * Resource identifier refering to all objects.

View File

@ -18,6 +18,7 @@ package org.apache.archiva.redback.rbac;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import java.util.List; import java.util.List;
/** /**
@ -36,7 +37,7 @@ import java.util.List;
* @author Martin Stockhammer <martin_s@apache.org> * @author Martin Stockhammer <martin_s@apache.org>
* *
*/ */
public interface Role public interface Role extends Serializable
{ {
/** /**

View File

@ -1,5 +1,6 @@
package org.apache.archiva.redback.rbac; package org.apache.archiva.redback.rbac;
import java.io.Serializable;
import java.util.List; import java.util.List;
/* /*
@ -29,7 +30,7 @@ import java.util.List;
* *
* TODO expand on javadoc * TODO expand on javadoc
*/ */
public interface UserAssignment public interface UserAssignment extends Serializable
{ {

View File

@ -33,6 +33,8 @@
<bean name="cache#operations" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#operations" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.Operation" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
@ -44,6 +46,8 @@
<bean name="cache#permissions" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#permissions" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.Permission" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
@ -55,6 +59,8 @@
<bean name="cache#resources" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#resources" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.Resource" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
@ -66,6 +72,8 @@
<bean name="cache#roles" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#roles" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.Role" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
@ -77,6 +85,8 @@
<bean name="cache#rolesById" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#rolesById" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.Role" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
@ -88,6 +98,8 @@
<bean name="cache#effectiveRoleSet" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#effectiveRoleSet" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="java.util.HashSet" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
@ -103,6 +115,8 @@
<bean name="cache#userAssignments" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#userAssignments" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.UserAssignment" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
@ -114,6 +128,8 @@
<bean name="cache#userPermissions" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#userPermissions" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="java.util.HashMap" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>

View File

@ -53,6 +53,8 @@
<bean name="cache#userAssignments" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#userAssignments" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.UserAssignment" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>
@ -64,6 +66,8 @@
<bean name="cache#userPermissions" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#userPermissions" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="java.util.HashMap" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>

View File

@ -33,6 +33,8 @@
<bean name="cache#ldapRoles" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#ldapRoles" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.Role"/>
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>

View File

@ -100,6 +100,9 @@
<bean name="cache#userPermissions" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#userPermissions" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.rbac.Permission"/>
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>

View File

@ -33,6 +33,8 @@
<bean name="cache#users" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#users" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String" />
<constructor-arg index="1" value="org.apache.archiva.redback.users.User" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>

View File

@ -39,6 +39,8 @@
<bean name="cache#users" class="org.apache.archiva.components.cache.ehcache.EhcacheCache" <bean name="cache#users" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"
init-method="initialize"> init-method="initialize">
<constructor-arg index="0" value="java.lang.String" />
<constructor-arg index="1" value="org.apache.archiva.redback.users.User" />
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
<property name="maxElementsInMemory" value="1000"/> <property name="maxElementsInMemory" value="1000"/>

View File

@ -34,6 +34,8 @@
<!-- REDBACK-289/MRM-1488 --> <!-- REDBACK-289/MRM-1488 -->
<!-- Cache for LDAP users. Data is refreshed every 3 mins. --> <!-- Cache for LDAP users. Data is refreshed every 3 mins. -->
<bean name="cache#ldapUser" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"> <bean name="cache#ldapUser" class="org.apache.archiva.components.cache.ehcache.EhcacheCache">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="org.apache.archiva.redback.common.ldap.user.LdapUser"/>
<property name="diskExpiryThreadIntervalSeconds" value="180"/> <property name="diskExpiryThreadIntervalSeconds" value="180"/>
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>
@ -47,6 +49,8 @@
<!-- Cache for users' LDAP userDn. Data is refreshed every 3 mins. --> <!-- Cache for users' LDAP userDn. Data is refreshed every 3 mins. -->
<bean name="cache#ldapUserDn" class="org.apache.archiva.components.cache.ehcache.EhcacheCache"> <bean name="cache#ldapUserDn" class="org.apache.archiva.components.cache.ehcache.EhcacheCache">
<constructor-arg index="0" value="java.lang.String"/>
<constructor-arg index="1" value="java.lang.String"/>
<property name="diskExpiryThreadIntervalSeconds" value="180"/> <property name="diskExpiryThreadIntervalSeconds" value="180"/>
<property name="diskPersistent" value="false"/> <property name="diskPersistent" value="false"/>
<property name="eternal" value="false"/> <property name="eternal" value="false"/>