no need of synchronized block here

git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1428123 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2013-01-03 00:15:15 +00:00
parent fef0fdf2d4
commit b951dc02fd
1 changed files with 16 additions and 18 deletions

View File

@ -46,7 +46,7 @@ import java.util.Set;
* *
* @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a> * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
*/ */
@Service( "rbacManager#cached" ) @Service("rbacManager#cached")
public class CachedRbacManager public class CachedRbacManager
implements RBACManager, RBACManagerListener implements RBACManager, RBACManagerListener
{ {
@ -54,35 +54,35 @@ public class CachedRbacManager
private Logger log = LoggerFactory.getLogger( getClass() ); private Logger log = LoggerFactory.getLogger( getClass() );
@Inject @Inject
@Named( value = "rbacManager#jdo" ) @Named(value = "rbacManager#jdo")
private RBACManager rbacImpl; private RBACManager rbacImpl;
@Inject @Inject
@Named( value = "cache#operations" ) @Named(value = "cache#operations")
private Cache operationsCache; private Cache operationsCache;
@Inject @Inject
@Named( value = "cache#permissions" ) @Named(value = "cache#permissions")
private Cache permissionsCache; private Cache permissionsCache;
@Inject @Inject
@Named( value = "cache#resources" ) @Named(value = "cache#resources")
private Cache resourcesCache; private Cache resourcesCache;
@Inject @Inject
@Named( value = "cache#roles" ) @Named(value = "cache#roles")
private Cache rolesCache; private Cache rolesCache;
@Inject @Inject
@Named( value = "cache#userAssignments" ) @Named(value = "cache#userAssignments")
private Cache userAssignmentsCache; private Cache userAssignmentsCache;
@Inject @Inject
@Named( value = "cache#userPermissions" ) @Named(value = "cache#userPermissions")
private Cache userPermissionsCache; private Cache userPermissionsCache;
@Inject @Inject
@Named( value = "cache#effectiveRoleSet" ) @Named(value = "cache#effectiveRoleSet")
private Cache effectiveRoleSetCache; private Cache effectiveRoleSetCache;
public void addChildRole( Role role, Role childRole ) public void addChildRole( Role role, Role childRole )
@ -206,7 +206,7 @@ public class CachedRbacManager
/** /**
* @see org.apache.archiva.redback.rbac.RBACManager#getAssignedPermissionMap(java.lang.String) * @see org.apache.archiva.redback.rbac.RBACManager#getAssignedPermissionMap(java.lang.String)
*/ */
@SuppressWarnings( "unchecked" ) @SuppressWarnings("unchecked")
public Map<String, List<Permission>> getAssignedPermissionMap( String principal ) public Map<String, List<Permission>> getAssignedPermissionMap( String principal )
throws RbacObjectNotFoundException, RbacManagerException throws RbacObjectNotFoundException, RbacManagerException
{ {
@ -217,13 +217,11 @@ public class CachedRbacManager
log.debug( "using cached user permission map" ); log.debug( "using cached user permission map" );
return el; return el;
} }
synchronized ( userPermissionsCache )
{ log.debug( "building user permission map" );
log.debug( "building user permission map" ); Map<String, List<Permission>> userPermMap = this.rbacImpl.getAssignedPermissionMap( principal );
Map<String, List<Permission>> userPermMap = this.rbacImpl.getAssignedPermissionMap( principal ); userPermissionsCache.put( principal, userPermMap );
userPermissionsCache.put( principal, userPermMap ); return userPermMap;
return userPermMap;
}
} }
@ -276,7 +274,7 @@ public class CachedRbacManager
return this.rbacImpl.getEffectivelyUnassignedRoles( principal ); return this.rbacImpl.getEffectivelyUnassignedRoles( principal );
} }
@SuppressWarnings( "unchecked" ) @SuppressWarnings("unchecked")
public Set<Role> getEffectiveRoles( Role role ) public Set<Role> getEffectiveRoles( Role role )
throws RbacObjectNotFoundException, RbacManagerException throws RbacObjectNotFoundException, RbacManagerException
{ {