From portal-commits at lists.jboss.org Thu Jan 18 18:53:21 2007 Content-Type: multipart/mixed; boundary="===============3096867056797233090==" MIME-Version: 1.0 From: portal-commits at lists.jboss.org To: portal-commits at lists.jboss.org Subject: [portal-commits] JBoss Portal SVN: r6043 - trunk/core/src/main/org/jboss/portal/core/impl/model/portal. Date: Thu, 18 Jan 2007 18:53:20 -0500 Message-ID: --===============3096867056797233090== 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:53:20 -0500 (Thu, 18 Jan 2007) New Revision: 6043 Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPort= alObjectContainer.java Log: use CopyOnWriteRegistry in AbstractPortalObjectContainer for the content ha= ndler registry Modified: trunk/core/src/main/org/jboss/portal/core/impl/model/portal/Abstr= actPortalObjectContainer.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/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPor= talObjectContainer.java 2007-01-18 23:51:07 UTC (rev 6042) +++ trunk/core/src/main/org/jboss/portal/core/impl/model/portal/AbstractPor= talObjectContainer.java 2007-01-18 23:53:20 UTC (rev 6043) @@ -40,12 +40,11 @@ import org.jboss.portal.security.spi.provider.PermissionFactory; import org.jboss.portal.security.spi.provider.PermissionRepository; import org.jboss.portal.security.spi.provider.SecurityConfigurationExcepti= on; +import org.jboss.portal.common.util.CopyOnWriteRegistry; = import java.util.Collection; import java.util.HashSet; import java.util.Set; -import java.util.Map; -import java.util.HashMap; = /** * @author Julien Viet @@ -62,7 +61,7 @@ private InstanceContainer instanceContainer; = /** . */ - private volatile Map contentHandlerRegistry; + private CopyOnWriteRegistry contentHandlerRegistry; = public InstanceContainer getInstanceContainer() { @@ -72,31 +71,12 @@ public void setInstanceContainer(InstanceContainer instanceContainer) { this.instanceContainer =3D instanceContainer; - this.contentHandlerRegistry =3D new HashMap(); + this.contentHandlerRegistry =3D new CopyOnWriteRegistry(); } = public void registerHandler(ContentType contentType, ContentHandler han= dler) throws IllegalArgumentException { - if (contentType =3D=3D null) - { - throw new IllegalArgumentException(); - } - if (handler =3D=3D null) - { - throw new IllegalArgumentException(); - } - synchronized(this) - { - if (contentHandlerRegistry.containsKey(contentType)) - { - throw new IllegalArgumentException("Content type " + contentTy= pe + " is already registered"); - } - - // - Map tmp =3D new HashMap(contentHandlerRegistry); - tmp.put(contentType, handler); - contentHandlerRegistry =3D tmp; - } + contentHandlerRegistry.register(contentType, handler); } = public ContentHandler getHandler(ContentType contentType) @@ -106,22 +86,7 @@ = public void unregisterHandler(ContentType contentType) { - if (contentType =3D=3D null) - { - throw new IllegalArgumentException(); - } - synchronized(this) - { - if (contentHandlerRegistry.containsKey(contentType) =3D=3D false) - { - throw new IllegalArgumentException("Content type " + contentTy= pe + " is not registered"); - } - - // - Map tmp =3D new HashMap(contentHandlerRegistry); - tmp.remove(contentType); - contentHandlerRegistry =3D tmp; - } + contentHandlerRegistry.unregister(contentType); } = public PortalObject getRootObject() --===============3096867056797233090==--