Sho SHIMIZU
Committed by Gerrit Code Review

Use ConcurrentHashMap instead of FastHashMap

Apache Commons Collections doesn't support Generics

Change-Id: I8125b5e1aca9054ae399f9cabe8f76970294f848
...@@ -3,7 +3,6 @@ package org.onosproject.security.impl; ...@@ -3,7 +3,6 @@ package org.onosproject.security.impl;
3 3
4 import com.google.common.collect.ImmutableSet; 4 import com.google.common.collect.ImmutableSet;
5 import com.google.common.collect.Sets; 5 import com.google.common.collect.Sets;
6 -import org.apache.commons.collections.FastHashMap;
7 import org.onosproject.core.Permission; 6 import org.onosproject.core.Permission;
8 import org.onosproject.security.AppPermission; 7 import org.onosproject.security.AppPermission;
9 import org.osgi.service.permissionadmin.PermissionInfo; 8 import org.osgi.service.permissionadmin.PermissionInfo;
...@@ -47,8 +46,9 @@ import org.osgi.framework.AdaptPermission; ...@@ -47,8 +46,9 @@ import org.osgi.framework.AdaptPermission;
47 46
48 47
49 import java.util.Collections; 48 import java.util.Collections;
50 -import java.util.HashMap; 49 +import java.util.Map;
51 import java.util.Set; 50 import java.util.Set;
51 +import java.util.concurrent.ConcurrentHashMap;
52 import java.util.stream.Collectors; 52 import java.util.stream.Collectors;
53 53
54 public final class PolicyBuilder { 54 public final class PolicyBuilder {
...@@ -56,7 +56,7 @@ public final class PolicyBuilder { ...@@ -56,7 +56,7 @@ public final class PolicyBuilder {
56 private PolicyBuilder(){ 56 private PolicyBuilder(){
57 } 57 }
58 58
59 - public static PermissionInfo[] getApplicationPermissions(HashMap<Permission, Set<String>> serviceDirectory, 59 + public static PermissionInfo[] getApplicationPermissions(Map<Permission, Set<String>> serviceDirectory,
60 Set<Permission> permissions) { 60 Set<Permission> permissions) {
61 Set<PermissionInfo> permSet = Sets.newHashSet(); 61 Set<PermissionInfo> permSet = Sets.newHashSet();
62 Collections.addAll(permSet, getDefaultPerms()); 62 Collections.addAll(permSet, getDefaultPerms());
...@@ -69,7 +69,7 @@ public final class PolicyBuilder { ...@@ -69,7 +69,7 @@ public final class PolicyBuilder {
69 return permSet.toArray(permissionInfos); 69 return permSet.toArray(permissionInfos);
70 } 70 }
71 71
72 - public static PermissionInfo[] getAdminApplicationPermissions(HashMap<Permission, Set<String>> serviceDirectory) { 72 + public static PermissionInfo[] getAdminApplicationPermissions(Map<Permission, Set<String>> serviceDirectory) {
73 Set<PermissionInfo> permSet = Sets.newHashSet(); 73 Set<PermissionInfo> permSet = Sets.newHashSet();
74 Collections.addAll(permSet, getDefaultPerms()); 74 Collections.addAll(permSet, getDefaultPerms());
75 Collections.addAll(permSet, getAdminDefaultPerms()); 75 Collections.addAll(permSet, getAdminDefaultPerms());
...@@ -166,9 +166,9 @@ public final class PolicyBuilder { ...@@ -166,9 +166,9 @@ public final class PolicyBuilder {
166 } 166 }
167 167
168 168
169 - public static HashMap<Permission, Set<String>> getServiceDirectory() { 169 + public static Map<Permission, Set<String>> getServiceDirectory() {
170 170
171 - HashMap<Permission, Set<String>> serviceDirectory = new FastHashMap(); 171 + Map<Permission, Set<String>> serviceDirectory = new ConcurrentHashMap<>();
172 172
173 serviceDirectory.put(Permission.APP_READ, ImmutableSet.of( 173 serviceDirectory.put(Permission.APP_READ, ImmutableSet.of(
174 ApplicationService.class.getName(), CoreService.class.getName())); 174 ApplicationService.class.getName(), CoreService.class.getName()));
......
1 package org.onosproject.security.impl; 1 package org.onosproject.security.impl;
2 2
3 -import org.apache.commons.collections.FastHashMap;
4 import org.apache.felix.scr.annotations.Component; 3 import org.apache.felix.scr.annotations.Component;
5 import org.apache.felix.scr.annotations.Reference; 4 import org.apache.felix.scr.annotations.Reference;
6 import org.apache.felix.scr.annotations.ReferenceCardinality; 5 import org.apache.felix.scr.annotations.ReferenceCardinality;
...@@ -33,9 +32,10 @@ import org.osgi.service.permissionadmin.PermissionInfo; ...@@ -33,9 +32,10 @@ import org.osgi.service.permissionadmin.PermissionInfo;
33 import java.security.AccessControlException; 32 import java.security.AccessControlException;
34 import java.security.AllPermission; 33 import java.security.AllPermission;
35 import java.util.ArrayList; 34 import java.util.ArrayList;
36 -import java.util.HashMap;
37 import java.util.List; 35 import java.util.List;
36 +import java.util.Map;
38 import java.util.Set; 37 import java.util.Set;
38 +import java.util.concurrent.ConcurrentHashMap;
39 import java.util.stream.Collectors; 39 import java.util.stream.Collectors;
40 40
41 import org.osgi.service.permissionadmin.PermissionAdmin; 41 import org.osgi.service.permissionadmin.PermissionAdmin;
...@@ -75,9 +75,9 @@ public class SecurityModeManager { ...@@ -75,9 +75,9 @@ public class SecurityModeManager {
75 75
76 private PermissionAdmin permissionAdmin = null; 76 private PermissionAdmin permissionAdmin = null;
77 77
78 - private HashMap<String, ApplicationId> appTracker = null; 78 + private Map<String, ApplicationId> appTracker = null;
79 79
80 - private HashMap<Permission, Set<String>> serviceDirectory = null; 80 + private Map<Permission, Set<String>> serviceDirectory = null;
81 81
82 82
83 @Activate 83 @Activate
...@@ -93,7 +93,7 @@ public class SecurityModeManager { ...@@ -93,7 +93,7 @@ public class SecurityModeManager {
93 bundleContext.addBundleListener(securityBundleListener); 93 bundleContext.addBundleListener(securityBundleListener);
94 appAdminService.addListener(securityApplicationListener); 94 appAdminService.addListener(securityApplicationListener);
95 logReaderService.addLogListener(securityLogListener); 95 logReaderService.addLogListener(securityLogListener);
96 - appTracker = new FastHashMap(); 96 + appTracker = new ConcurrentHashMap<>();
97 97
98 permissionAdmin = getPermissionAdmin(bundleContext); 98 permissionAdmin = getPermissionAdmin(bundleContext);
99 if (permissionAdmin == null) { 99 if (permissionAdmin == null) {
......