From portal-commits at lists.jboss.org Thu Jan 18 18:55:49 2007 Content-Type: multipart/mixed; boundary="===============7049012508718880968==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6044 - in trunk: security/src/main/org/jboss/portal/security/impl and 1 other directory. Date: Thu, 18 Jan 2007 18:55:48 -0500 Message-ID: --===============7049012508718880968== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Author: julien(a)jboss.com Date: 2007-01-18 18:55:48 -0500 (Thu, 18 Jan 2007) New Revision: 6044 Modified: trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.j= ava trunk/security/src/main/org/jboss/portal/security/impl/JBossAuthorizatio= nDomainRegistryImpl.java Log: use CopyOnWriteRegistry in JBossAuthorizationDomainRegistryImpl Modified: trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteReg= istry.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.= java 2007-01-18 23:53:20 UTC (rev 6043) +++ trunk/common/src/main/org/jboss/portal/common/util/CopyOnWriteRegistry.= java 2007-01-18 23:55:48 UTC (rev 6044) @@ -26,6 +26,7 @@ import java.util.HashMap; import java.util.Set; import java.util.Collections; +import java.util.Collection; = /** * @author Julien Viet @@ -104,7 +105,17 @@ } = /** + * Return the registrations. * + * @return the registrations + */ + public Collection getRegistrations() + { + return Collections.unmodifiableCollection(content.values()); + } + + /** + * * @param key the registration key * @return the registeted object * @throws IllegalArgumentException if the key is null Modified: trunk/security/src/main/org/jboss/portal/security/impl/JBossAutho= rizationDomainRegistryImpl.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- trunk/security/src/main/org/jboss/portal/security/impl/JBossAuthorizati= onDomainRegistryImpl.java 2007-01-18 23:53:20 UTC (rev 6043) +++ trunk/security/src/main/org/jboss/portal/security/impl/JBossAuthorizati= onDomainRegistryImpl.java 2007-01-18 23:55:48 UTC (rev 6044) @@ -24,6 +24,7 @@ = import org.jboss.portal.jems.as.system.AbstractJBossService; import org.jboss.portal.security.spi.provider.AuthorizationDomain; +import org.jboss.portal.common.util.CopyOnWriteRegistry; = import java.util.Collection; import java.util.HashMap; @@ -40,7 +41,7 @@ { = /** A map of permission types to stores. */ - private Map domains =3D new HashMap(); + private CopyOnWriteRegistry domains =3D new CopyOnWriteRegistry(); = public void addDomain(AuthorizationDomain domain) { @@ -48,17 +49,8 @@ { throw new IllegalArgumentException("Authorization Domain is null"= ); } - synchronized (this) - { - if (domains.containsKey(domain.getType())) - { - throw new IllegalArgumentException("Authorization Domain is al= ready registered"); - } - log.debug("Add authorization domain " + domain.getType()); - Map copy =3D new HashMap(domains); - copy.put(domain.getType(), domain); - domains =3D copy; - } + log.debug("Add authorization domain " + domain.getType()); + domains.register(domain.getType(), domain); } = public void removeDomain(AuthorizationDomain domain) @@ -67,13 +59,8 @@ { throw new IllegalArgumentException(); } - synchronized (this) - { - log.debug("Remove authorization domain " + domain.getType()); - Map copy =3D new HashMap(domains); - copy.remove(domain.getType()); - domains =3D copy; - } + log.debug("Remove authorization domain " + domain.getType()); + domains.unregister(domain.getType()); } = public AuthorizationDomain getDomain(String domainType) @@ -83,6 +70,6 @@ = public Collection getDomains() { - return domains.values(); + return domains.getRegistrations(); } } --===============7049012508718880968==--