1 8 package org.nanocontainer; 9 10 import java.io.Serializable ; 11 import java.net.URL ; 12 import java.security.Permission ; 13 import java.security.PermissionCollection ; 14 import java.security.Permissions ; 15 import java.util.ArrayList ; 16 import java.util.List ; 17 18 23 public class ClassPathElement implements Serializable { 24 25 private final URL url; 26 private PermissionCollection permissionCollection; 27 private final List permissions = new ArrayList (); 28 29 public ClassPathElement(URL url) { 30 this.url = url; 31 } 32 33 public Permission grantPermission(Permission permission) { 34 if (permission == null) { 35 throw new NullPointerException (); 36 } 37 permissions.add(permission); 38 return permission; 39 } 40 41 public URL getUrl() { 42 return url; 43 } 44 45 public PermissionCollection getPermissionCollection() { 46 if (permissionCollection == null) { 47 permissionCollection = new Permissions (); 48 for (int i = 0; i < permissions.size(); i++) { 49 Permission permission = (Permission ) permissions.get(i); 50 permissionCollection.add(permission); 51 } 52 } 53 return permissionCollection; 54 } 55 56 public String toString() { 57 return "[" + System.identityHashCode(this) + " " + url + " " + permissions.size() +"]"; 58 } 59 60 } 61 | Popular Tags |