[jboss-cvs] JBossAS SVN: r99219 - in projects/jboss-mdr/tags: 2.2.0.Alpha1 and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Jan 11 11:50:37 EST 2010


Author: alesj
Date: 2010-01-11 11:50:36 -0500 (Mon, 11 Jan 2010)
New Revision: 99219

Added:
   projects/jboss-mdr/tags/2.2.0.Alpha1/
   projects/jboss-mdr/tags/2.2.0.Alpha1/pom.xml
   projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java
   projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java
Removed:
   projects/jboss-mdr/tags/2.2.0.Alpha1/pom.xml
   projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java
   projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java
Log:
[maven-release-plugin]  copy for tag 2.2.0.Alpha1

Copied: projects/jboss-mdr/tags/2.2.0.Alpha1 (from rev 99152, projects/jboss-mdr/trunk)

Deleted: projects/jboss-mdr/tags/2.2.0.Alpha1/pom.xml
===================================================================
--- projects/jboss-mdr/trunk/pom.xml	2010-01-08 10:22:18 UTC (rev 99152)
+++ projects/jboss-mdr/tags/2.2.0.Alpha1/pom.xml	2010-01-11 16:50:36 UTC (rev 99219)
@@ -1,126 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <parent>
-    <groupId>org.jboss</groupId>
-    <artifactId>jboss-parent</artifactId>
-    <version>4</version>
-  </parent>
-  <modelVersion>4.0.0</modelVersion>
-  <artifactId>jboss-mdr</artifactId>
-  <version>2.2.0-SNAPSHOT</version>
-  <packaging>jar</packaging>
-  <name>JBoss MetaData Repository</name>
-  <url>http://www.jboss.com/products/jbossmc</url>
-  <description>JBoss MetaData Repository</description>
-  <scm>
-    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-mdr/trunk/</connection>
-    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-mdr/trunk/</developerConnection>
-    <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-mdr/trunk/</url>
-  </scm>
-
-  <properties>
-    <version.jboss.common.core>2.2.16.GA</version.jboss.common.core>
-    <version.jboss.logging.spi>2.0.5.GA</version.jboss.logging.spi>
-    <version.jboss.logging.log4j>2.0.5.GA</version.jboss.logging.log4j>
-    <version.javassist>3.11.0.GA</version.javassist>
-    <version.org.jboss.reflect>2.0.2.GA</version.org.jboss.reflect>
-    <version.org.jboss.test>1.1.1.GA</version.org.jboss.test>
-    <version.junit>4.4</version.junit>
-  </properties>
-
-  <build>
-    <finalName>${artifactId}</finalName>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.4.3</version>
-        <configuration>
-          <redirectTestOutputToFile>true</redirectTestOutputToFile>
-          <includes>
-            <include>org/jboss/test/**/*TestCase.java</include>
-          </includes>
-          <useSystemClassLoader>true</useSystemClassLoader>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-assembly-plugin</artifactId>
-        <version>2.2-beta-2</version>
-        <configuration>
-          <descriptors>
-            <descriptor>src/assembly/metadata-spi.xml</descriptor>
-            <descriptor>src/assembly/metadata.xml</descriptor>
-          </descriptors>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-compiler-plugin</artifactId>
-        <version>2.0.2</version>
-        <configuration>
-          <source>1.5</source>
-          <target>1.5</target>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-jar-plugin</artifactId>
-        <version>2.2</version>
-        <executions>
-          <execution>
-            <goals>
-              <goal>test-jar</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-  <dependencies>
-    <!-- Global dependencies -->
-    <dependency>
-      <groupId>org.jboss</groupId>
-      <artifactId>jboss-reflect</artifactId>
-      <version>${version.org.jboss.reflect}</version>
-      <exclusions>
-        <exclusion>
-          <groupId>org.jboss</groupId>
-          <artifactId>jboss-common-core</artifactId>
-        </exclusion>
-        <exclusion>
-          <groupId>jboss</groupId>
-          <artifactId>jboss-common-logging-spi</artifactId>
-        </exclusion>
-      </exclusions>
-    </dependency>
-    <dependency>
-      <groupId>javassist</groupId>
-      <artifactId>javassist</artifactId>
-      <version>${version.javassist}</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss.logging</groupId>
-      <artifactId>jboss-logging-spi</artifactId>
-      <version>${version.jboss.logging.spi}</version>
-    </dependency>
-    <dependency>
-      <groupId>org.jboss</groupId>
-      <artifactId>jboss-common-core</artifactId>
-      <version>${version.jboss.common.core}</version>
-    </dependency>
-    <!-- Test dependencies -->
-    <dependency>
-      <groupId>org.jboss.test</groupId>
-      <artifactId>jboss-test</artifactId>
-      <version>${version.org.jboss.test}</version>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>${version.junit}</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-</project>

Copied: projects/jboss-mdr/tags/2.2.0.Alpha1/pom.xml (from rev 99218, projects/jboss-mdr/trunk/pom.xml)
===================================================================
--- projects/jboss-mdr/tags/2.2.0.Alpha1/pom.xml	                        (rev 0)
+++ projects/jboss-mdr/tags/2.2.0.Alpha1/pom.xml	2010-01-11 16:50:36 UTC (rev 99219)
@@ -0,0 +1,126 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.jboss</groupId>
+    <artifactId>jboss-parent</artifactId>
+    <version>4</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>jboss-mdr</artifactId>
+  <version>2.2.0.Alpha1</version>
+  <packaging>jar</packaging>
+  <name>JBoss MetaData Repository</name>
+  <url>http://www.jboss.com/products/jbossmc</url>
+  <description>JBoss MetaData Repository</description>
+  <scm>
+    <connection>scm:svn:http://anonsvn.jboss.org/repos/jbossas/projects/jboss-mdr/tags/2.2.0.Alpha1</connection>
+    <developerConnection>scm:svn:https://svn.jboss.org/repos/jbossas/projects/jboss-mdr/tags/2.2.0.Alpha1</developerConnection>
+    <url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossas/projects/jboss-mdr/tags/2.2.0.Alpha1</url>
+  </scm>
+
+  <properties>
+    <version.jboss.common.core>2.2.17.GA</version.jboss.common.core>
+    <version.jboss.logging.spi>2.1.1.GA</version.jboss.logging.spi>
+    <version.jboss.logging.log4j>2.1.1.GA</version.jboss.logging.log4j>
+    <version.javassist>3.11.0.GA</version.javassist>
+    <version.org.jboss.reflect>2.2.0.Alpha2</version.org.jboss.reflect>
+    <version.org.jboss.test>1.1.1.GA</version.org.jboss.test>
+    <version.junit>4.4</version.junit>
+  </properties>
+
+  <build>
+    <finalName>${artifactId}</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.4.3</version>
+        <configuration>
+          <redirectTestOutputToFile>true</redirectTestOutputToFile>
+          <includes>
+            <include>org/jboss/test/**/*TestCase.java</include>
+          </includes>
+          <useSystemClassLoader>true</useSystemClassLoader>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.2-beta-2</version>
+        <configuration>
+          <descriptors>
+            <descriptor>src/assembly/metadata-spi.xml</descriptor>
+            <descriptor>src/assembly/metadata.xml</descriptor>
+          </descriptors>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>2.0.2</version>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>2.2</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <dependencies>
+    <!-- Global dependencies -->
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-reflect</artifactId>
+      <version>${version.org.jboss.reflect}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>jboss-common-core</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-common-logging-spi</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>javassist</groupId>
+      <artifactId>javassist</artifactId>
+      <version>${version.javassist}</version>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.logging</groupId>
+      <artifactId>jboss-logging-spi</artifactId>
+      <version>${version.jboss.logging.spi}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss</groupId>
+      <artifactId>jboss-common-core</artifactId>
+      <version>${version.jboss.common.core}</version>
+    </dependency>
+    <!-- Test dependencies -->
+    <dependency>
+      <groupId>org.jboss.test</groupId>
+      <artifactId>jboss-test</artifactId>
+      <version>${version.org.jboss.test}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>${version.junit}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Deleted: projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java	2010-01-08 10:22:18 UTC (rev 99152)
+++ projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java	2010-01-11 16:50:36 UTC (rev 99219)
@@ -1,414 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.metadata.spi.scope;
-
-import org.jboss.util.collection.ConcurrentSkipListMap;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-
-/**
- * The ScopeKey represents a path which is made up of the path entries.  Elements may be added dynamically
- * until the ScopeKey is frozen.  If you want to add more elements to a frozen ScopeKey, clone it
- * (cloned objects are not frozen).
- *
- * To use the ScopeKey as a key object, use the UnmodifiableScopeKey returned from getOptimizedKey().
- * UnmodifiableScopeKey's are immutable and suitable for use as a key (also thread-safe with no object lock contention). 
- *
- * The ScopeKey (Server=Bob,Deployment=Foo.war,Class=Bar)
- * is the child of (Server=Bob,Deployment=Foo.war),
- * which is the child of (Server=Bob).  Think about this statement in terms of
- * a path relationship.  The server (Bob) contains a deployment (Foo.war) and
- * the deployment contains a class (Bar).
- *
- * See historical design notes
- * http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3972233#3972233
- * http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4013747#4013747
- *
- * Thread Safety:  This class is thread safe.
- *
- * Warning:  This class is (delicately) extended by UnmodifiableScopeKey.
- * Since there is no common interface class between the two classes, there are risks to be
- * aware of.  If a new method is added to ScopeKey and not to UnmodifiableScopeKey, undesireable
- * behavior will occur when that UnmodifiableScopeKey.method is invoked (ScopeKey's member variables will be null). 
- *
- * @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
- */
-public class ScopeKey implements Serializable, Cloneable
-{
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -496238095349593371L + 1L;
-
-   /** The default scope */
-   public static final ScopeKey DEFAULT_SCOPE = new ScopeKey(new Scope(CommonLevels.JVM, "THIS"));
-   
-   /** The scopes () */
-   private ConcurrentSkipListMap<ScopeLevel, Scope> scopes = new ConcurrentSkipListMap<ScopeLevel, Scope>();
-
-   /** The scope level for this key */
-   private ScopeLevel maxScopeLevel;
-   
-   /** Whether the key is frozen */
-   private volatile boolean frozen;
-
-   static
-   {
-      DEFAULT_SCOPE.freeze();
-   }
-   
-   /**
-    * Create a new ScopeKey.
-    */
-   public ScopeKey()
-   {
-   }
-
-   /**
-    * Create a new ScopeKey.
-    * 
-    * @param scope the scope
-    */
-   public ScopeKey(Scope scope)
-   {
-      addScope(scope);
-   }
-
-   /**
-    * Create a new ScopeKey.
-    * 
-    * @param level the scope level
-    * @param qualifier the scope qualifier
-    */
-   public ScopeKey(ScopeLevel level, Object qualifier)
-   {
-      addScope(level, qualifier);
-   }
-
-   /**
-    * Create a new ScopeKey.
-    * 
-    * @param scopes is a collection of Scope instances that make up the represented path
-    * @throws IllegalArgumentException if parameter scopes is null
-    */
-   public ScopeKey(Collection<Scope> scopes)
-   {
-      if (scopes == null)
-         throw new IllegalArgumentException("Null scopes");
-      for (Scope scope : scopes)
-         addScope(scope);
-   }
-
-   /**
-    * Create a new ScopeKey.
-    * 
-    * @param scopes is zero or more Scope instances that make up the represented path
-    * @throws IllegalArgumentException if parameter scopes is null
-    */
-   public ScopeKey(Scope[] scopes)
-   {
-      if (scopes == null)
-         throw new IllegalArgumentException("Null scopes");
-      for (Scope scope : scopes)
-         addScope(scope);
-   }
-   
-   /**
-    * Get the frozen.
-    * 
-    * @return the frozen.
-    */
-   public boolean isFrozen()
-   {
-      return frozen;
-   }
-
-   /**
-    * Set to frozen.
-    * @throws IllegalArgumentException if there are no Scope entries added.
-    */
-   public void freeze()
-   {
-      if (scopes.isEmpty())
-         throw new IllegalStateException("Attempt to freeze an empty key");
-      this.frozen = true;
-   }
-   
-   /**
-    * The returned ScopeKey is immutable and optimized for use at runtime.
-    * @return Optimized immutable ScopeKey
-    */
-   public ScopeKey getOptimizedKey()
-   {
-      return new UnmodifiableScopeKey(this);
-   }
-
-   /**
-    * Get the scopes 
-    * 
-    * @return the scopes in expected path order
-    */
-   public Collection<Scope> getScopes()
-   {
-      return Collections.unmodifiableCollection(scopes.values());
-   }
-
-   /**
-    * Get a scope
-    * 
-    * @param level the scope level
-    * @return the scope
-    * @throws IllegalArgumentException if level is null.
-    */
-   public Scope getScope(ScopeLevel level)
-   {
-      if (level == null)
-         throw new IllegalArgumentException("Null level");
-      return scopes.get(level);
-   }
-   
-   /**
-    * Get the maximum scope level
-    * 
-    * @return the largest scope level
-    */
-   public ScopeLevel getMaxScopeLevel()
-   {
-      return maxScopeLevel;
-   }
-   
-   /**
-    * Get the parent scope key
-    * 
-    * @return the parent or null if there is no parent (meaning that we
-    * are at the top most element in the path)
-    */
-   public ScopeKey getParent()
-   {
-      if (scopes.size() < 2)
-         return null;
-      
-      ScopeKey result = new ScopeKey();
-      for (Iterator<Scope> i = scopes.values().iterator(); i.hasNext();)
-      {
-         Scope scope = i.next();
-         if (i.hasNext())
-            result.addScope(scope);
-      }
-      return result;
-   }
-
-   /**
-    * Is this parent of key parameter.
-    *
-    * @param key the key parameter
-    * @return true if this is direct parent of key param
-    * @throws IllegalArgumentException if parameter key is null
-    */
-   public boolean isParent(ScopeKey key)
-   {
-      if (key == null)
-         throw new IllegalArgumentException("Null key");
-      Collection keyValues = key.getScopesCollection();
-
-      // The passed key doesn't have a parent
-      if (keyValues.size() < 2)
-         return false;
-      
-      // If it is a child, it will have one more scope
-      if (scopes.size() != keyValues.size() - 1)
-         return false;
-
-      Iterator<Scope> thisScopes = scopes.values().iterator();
-      Iterator<Scope> keyScopes = keyValues.iterator();
-      
-      while (thisScopes.hasNext())
-      {
-         Scope thisScope = thisScopes.next();
-         Scope keyScope = keyScopes.next();
-         if (thisScope.equals(keyScope) == false)
-            return false;
-      }
-      
-      return true;
-   }
-   
-   /**
-    * Add a scope
-    * 
-    * @param scope the scope
-    * @return the previous value or null if there wasn't one
-    * @throws IllegalArgumentException if scope is null.
-    * @throws IllegalStateException if frozen
-    */
-   public Scope addScope(Scope scope)
-   {
-      if (scope == null)
-         throw new IllegalArgumentException("Null scope");
-      if (frozen)
-         throw new IllegalStateException("The scope key is frozen");
-
-      ScopeLevel level = scope.getScopeLevel();
-      Scope result = scopes.put(level, scope);
-      if (maxScopeLevel == null || level.compareTo(maxScopeLevel) >= 0)
-         maxScopeLevel = level;
-      return result;
-   }
-   
-   /**
-    * Add a scope
-    * 
-    * @param level the scope level
-    * @param qualifier the scope qualifier
-    * @return the previous value or null if there wasn't one
-    */
-   public Scope addScope(ScopeLevel level, Object qualifier)
-   {
-      Scope scope = new Scope(level, qualifier);
-      return addScope(scope);
-   }
-   
-   /**
-    * Remove a scope
-    * 
-    * @param scope the scope
-    * @return the previous value or null if there wasn't one
-    */
-   public Scope removeScope(Scope scope)
-   {
-      if (scope == null)
-         throw new IllegalArgumentException("Null scope");
-
-      return removeScopeLevel(scope.getScopeLevel());
-   }
-   
-   /**
-    * Get a scope level
-    * 
-    * @param scopeLevel the scope level
-    * @return the scope or null if there is no such level
-    * @throws IllegalArgumentException if parameter key is null    
-    */
-   public Scope getScopeLevel(ScopeLevel scopeLevel)
-   {
-      if (scopeLevel == null)
-         throw new IllegalArgumentException("Null scope level");
-
-      return scopes.get(scopeLevel);
-   }
-   
-   /**
-    * Remove a scope level
-    * 
-    * @param scopeLevel the scope level
-    * @return the scope or null if there is no such level
-    */
-   public Scope removeScopeLevel(ScopeLevel scopeLevel)
-   {
-      if (scopeLevel == null)
-         throw new IllegalArgumentException("Null scope level");
-      if (frozen)
-         throw new IllegalStateException("The scope key is frozen");
-
-      Scope result = scopes.remove(scopeLevel);
-      if (scopeLevel.equals(maxScopeLevel))
-      {
-         maxScopeLevel = null;
-         for (ScopeLevel level : scopes.keySet())
-            maxScopeLevel = level; 
-      }
-      return result;
-   }
-
-   public String toString()
-   {
-      return scopes.values().toString();
-   }
-   
-   public boolean equals(Object object)
-   {
-      if (object == this)
-         return true;
-      if (object == null || object instanceof ScopeKey == false)
-         return false;
-      ScopeKey other = (ScopeKey) object;
-      if (other instanceof UnmodifiableScopeKey)
-         return other.equals(this);
-      else
-         return scopes.equals(other.scopes);
-   }
-
-   public int hashCode()
-   {
-      return computeHashCode(scopes.values());  
-   }
-
-   /**
-    * Clone a ScopeKey instance.
-    *
-    * @Return an unfrozen instance (even if the current instance is frozen).
-    */
-   public ScopeKey clone()
-   {
-      try
-      {
-         ScopeKey result = (ScopeKey) super.clone();
-         result.scopes = new ConcurrentSkipListMap<ScopeLevel, Scope>(scopes);
-         result.frozen = false;
-         return result;
-      }
-      catch (CloneNotSupportedException e)
-      {
-         throw new Error(e);
-      }
-   }
-
-   protected Scope[] getArray()
-   {
-      Collection<Scope> scopes = getScopes();
-      return scopes.toArray(new Scope[0]);
-   }
-
-   protected Collection<Scope> getScopesCollection()
-   {
-      return scopes.values();
-   }
-   
-   protected static int computeHashCode(Scope[] scopeArray) 
-   {
-      int hashCode = 0;
-      for (Scope scope : scopeArray)
-         hashCode += scope.getScopeLevel().hashCode();
-      return hashCode;
-   }
-
-   protected static int computeHashCode(Collection<Scope> scopeCollection) 
-   {
-      int hashCode = 0;
-      for (Scope scope : scopeCollection)
-         hashCode += scope.getScopeLevel().hashCode();
-      return hashCode;
-   }
-  
-}

Copied: projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java (from rev 99153, projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java)
===================================================================
--- projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java	                        (rev 0)
+++ projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/ScopeKey.java	2010-01-11 16:50:36 UTC (rev 99219)
@@ -0,0 +1,413 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.spi.scope;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+
+import org.jboss.util.collection.ConcurrentSkipListMap;
+
+/**
+ * The ScopeKey represents a path which is made up of the path entries.  Elements may be added dynamically
+ * until the ScopeKey is frozen.  If you want to add more elements to a frozen ScopeKey, clone it
+ * (cloned objects are not frozen).
+ *
+ * To use the ScopeKey as a key object, use the UnmodifiableScopeKey returned from getOptimizedKey().
+ * UnmodifiableScopeKey's are immutable and suitable for use as a key (also thread-safe with no object lock contention). 
+ *
+ * The ScopeKey (Server=Bob,Deployment=Foo.war,Class=Bar)
+ * is the child of (Server=Bob,Deployment=Foo.war),
+ * which is the child of (Server=Bob).  Think about this statement in terms of
+ * a path relationship.  The server (Bob) contains a deployment (Foo.war) and
+ * the deployment contains a class (Bar).
+ *
+ * See historical design notes
+ * http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3972233#3972233
+ * http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4013747#4013747
+ *
+ * Thread Safety:  This class is thread safe.
+ *
+ * Warning:  This class is (delicately) extended by UnmodifiableScopeKey.
+ * Since there is no common interface class between the two classes, there are risks to be
+ * aware of.  If a new method is added to ScopeKey and not to UnmodifiableScopeKey, undesireable
+ * behavior will occur when that UnmodifiableScopeKey.method is invoked (ScopeKey's member variables will be null). 
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision$
+ */
+public class ScopeKey implements Serializable, Cloneable
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -496238095349593371L + 1L;
+
+   /** The default scope */
+   public static final ScopeKey DEFAULT_SCOPE = new ScopeKey(new Scope(CommonLevels.JVM, "THIS"));
+   
+   /** The scopes () */
+   private ConcurrentSkipListMap<ScopeLevel, Scope> scopes = new ConcurrentSkipListMap<ScopeLevel, Scope>();
+
+   /** The scope level for this key */
+   private ScopeLevel maxScopeLevel;
+   
+   /** Whether the key is frozen */
+   private volatile boolean frozen;
+
+   static
+   {
+      DEFAULT_SCOPE.freeze();
+   }
+   
+   /**
+    * Create a new ScopeKey.
+    */
+   public ScopeKey()
+   {
+   }
+
+   /**
+    * Create a new ScopeKey.
+    * 
+    * @param scope the scope
+    */
+   public ScopeKey(Scope scope)
+   {
+      addScope(scope);
+   }
+
+   /**
+    * Create a new ScopeKey.
+    * 
+    * @param level the scope level
+    * @param qualifier the scope qualifier
+    */
+   public ScopeKey(ScopeLevel level, Object qualifier)
+   {
+      addScope(level, qualifier);
+   }
+
+   /**
+    * Create a new ScopeKey.
+    * 
+    * @param scopes is a collection of Scope instances that make up the represented path
+    * @throws IllegalArgumentException if parameter scopes is null
+    */
+   public ScopeKey(Collection<Scope> scopes)
+   {
+      if (scopes == null)
+         throw new IllegalArgumentException("Null scopes");
+      for (Scope scope : scopes)
+         addScope(scope);
+   }
+
+   /**
+    * Create a new ScopeKey.
+    * 
+    * @param scopes is zero or more Scope instances that make up the represented path
+    * @throws IllegalArgumentException if parameter scopes is null
+    */
+   public ScopeKey(Scope[] scopes)
+   {
+      if (scopes == null)
+         throw new IllegalArgumentException("Null scopes");
+      for (Scope scope : scopes)
+         addScope(scope);
+   }
+   
+   /**
+    * Get the frozen.
+    * 
+    * @return the frozen.
+    */
+   public boolean isFrozen()
+   {
+      return frozen;
+   }
+
+   /**
+    * Set to frozen.
+    *
+    * @throws IllegalArgumentException if there are no Scope entries added.
+    */
+   public void freeze()
+   {
+      if (scopes.isEmpty())
+         throw new IllegalStateException("Attempt to freeze an empty key");
+      this.frozen = true;
+   }
+   
+   /**
+    * The returned ScopeKey is immutable and optimized for use at runtime.
+    *
+    * @return Optimized immutable ScopeKey
+    */
+   public ScopeKey getOptimizedKey()
+   {
+      return new UnmodifiableScopeKey(this);
+   }
+
+   /**
+    * Get the scopes 
+    * 
+    * @return the scopes in expected path order
+    */
+   public Collection<Scope> getScopes()
+   {
+      return Collections.unmodifiableCollection(scopes.values());
+   }
+
+   /**
+    * Get a scope
+    * 
+    * @param level the scope level
+    * @return the scope
+    * @throws IllegalArgumentException if level is null.
+    */
+   public Scope getScope(ScopeLevel level)
+   {
+      if (level == null)
+         throw new IllegalArgumentException("Null level");
+      return scopes.get(level);
+   }
+   
+   /**
+    * Get the maximum scope level
+    * 
+    * @return the largest scope level
+    */
+   public ScopeLevel getMaxScopeLevel()
+   {
+      return maxScopeLevel;
+   }
+   
+   /**
+    * Get the parent scope key
+    * 
+    * @return the parent or null if there is no parent (meaning that we
+    * are at the top most element in the path)
+    */
+   public ScopeKey getParent()
+   {
+      if (scopes.size() < 2)
+         return null;
+      
+      ScopeKey result = new ScopeKey();
+      for (Iterator<Scope> i = scopes.values().iterator(); i.hasNext();)
+      {
+         Scope scope = i.next();
+         if (i.hasNext())
+            result.addScope(scope);
+      }
+      return result;
+   }
+
+   /**
+    * Is this parent of key parameter.
+    *
+    * @param key the key parameter
+    * @return true if this is direct parent of key param
+    * @throws IllegalArgumentException if parameter key is null
+    */
+   public boolean isParent(ScopeKey key)
+   {
+      if (key == null)
+         throw new IllegalArgumentException("Null key");
+      Collection keyValues = key.getScopesCollection();
+
+      // The passed key doesn't have a parent
+      if (keyValues.size() < 2)
+         return false;
+      
+      // If it is a child, it will have one more scope
+      if (scopes.size() != keyValues.size() - 1)
+         return false;
+
+      Iterator<Scope> thisScopes = scopes.values().iterator();
+      Iterator<Scope> keyScopes = keyValues.iterator();
+      
+      while (thisScopes.hasNext())
+      {
+         Scope thisScope = thisScopes.next();
+         Scope keyScope = keyScopes.next();
+         if (thisScope.equals(keyScope) == false)
+            return false;
+      }
+      
+      return true;
+   }
+   
+   /**
+    * Add a scope
+    * 
+    * @param scope the scope
+    * @return the previous value or null if there wasn't one
+    * @throws IllegalArgumentException if scope is null.
+    * @throws IllegalStateException if frozen
+    */
+   public Scope addScope(Scope scope)
+   {
+      if (scope == null)
+         throw new IllegalArgumentException("Null scope");
+      if (frozen)
+         throw new IllegalStateException("The scope key is frozen");
+
+      ScopeLevel level = scope.getScopeLevel();
+      Scope result = scopes.put(level, scope);
+      if (maxScopeLevel == null || level.compareTo(maxScopeLevel) >= 0)
+         maxScopeLevel = level;
+      return result;
+   }
+   
+   /**
+    * Add a scope
+    * 
+    * @param level the scope level
+    * @param qualifier the scope qualifier
+    * @return the previous value or null if there wasn't one
+    */
+   public Scope addScope(ScopeLevel level, Object qualifier)
+   {
+      Scope scope = new Scope(level, qualifier);
+      return addScope(scope);
+   }
+   
+   /**
+    * Remove a scope
+    * 
+    * @param scope the scope
+    * @return the previous value or null if there wasn't one
+    */
+   public Scope removeScope(Scope scope)
+   {
+      if (scope == null)
+         throw new IllegalArgumentException("Null scope");
+
+      return removeScopeLevel(scope.getScopeLevel());
+   }
+   
+   /**
+    * Get a scope level
+    * 
+    * @param scopeLevel the scope level
+    * @return the scope or null if there is no such level
+    * @throws IllegalArgumentException if parameter key is null    
+    */
+   public Scope getScopeLevel(ScopeLevel scopeLevel)
+   {
+      if (scopeLevel == null)
+         throw new IllegalArgumentException("Null scope level");
+
+      return scopes.get(scopeLevel);
+   }
+   
+   /**
+    * Remove a scope level
+    * 
+    * @param scopeLevel the scope level
+    * @return the scope or null if there is no such level
+    */
+   public Scope removeScopeLevel(ScopeLevel scopeLevel)
+   {
+      if (scopeLevel == null)
+         throw new IllegalArgumentException("Null scope level");
+      if (frozen)
+         throw new IllegalStateException("The scope key is frozen");
+
+      Scope result = scopes.remove(scopeLevel);
+      if (scopeLevel.equals(maxScopeLevel))
+      {
+         maxScopeLevel = null;
+         for (ScopeLevel level : scopes.keySet())
+            maxScopeLevel = level; 
+      }
+      return result;
+   }
+
+   public String toString()
+   {
+      return scopes.values().toString();
+   }
+   
+   public boolean equals(Object object)
+   {
+      if (object == this)
+         return true;
+      if (object == null || object instanceof ScopeKey == false)
+         return false;
+      ScopeKey other = (ScopeKey) object;
+      if (other instanceof UnmodifiableScopeKey)
+         return other.equals(this);
+      else
+         return scopes.equals(other.scopes);
+   }
+
+   public int hashCode()
+   {
+      return computeHashCode(scopes.values());  
+   }
+
+   /**
+    * Clone a ScopeKey instance.
+    *
+    * @return an unfrozen instance (even if the current instance is frozen).
+    */
+   public ScopeKey clone()
+   {
+      try
+      {
+         ScopeKey result = (ScopeKey) super.clone();
+         result.scopes = new ConcurrentSkipListMap<ScopeLevel, Scope>(scopes);
+         result.frozen = false;
+         return result;
+      }
+      catch (CloneNotSupportedException e)
+      {
+         throw new Error(e);
+      }
+   }
+
+   protected Scope[] getArray()
+   {
+      Collection<Scope> scopes = getScopes();
+      return scopes.toArray(new Scope[0]);
+   }
+
+   protected Collection<Scope> getScopesCollection()
+   {
+      return scopes.values();
+   }
+   
+   protected static int computeHashCode(Scope[] scopeArray)
+   {
+      return computeHashCode(Arrays.asList(scopeArray));
+   }
+
+   protected static int computeHashCode(Iterable<Scope> scopeCollection)
+   {
+      int hashCode = 0;
+      for (Scope scope : scopeCollection)
+         hashCode += scope.getScopeLevel().hashCode();
+      return hashCode;
+   }
+}

Deleted: projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java
===================================================================
--- projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java	2010-01-08 10:22:18 UTC (rev 99152)
+++ projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java	2010-01-11 16:50:36 UTC (rev 99219)
@@ -1,376 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.metadata.spi.scope;
-
-import java.io.Serializable;
-import java.util.*;
-
-/**
- * The UnmodifiableScopeKey represents a path which is made up of the path entries.
- *
- * The UnmodifiableScopeKey (Server=Bob,Deployment=Foo.war,Class=Bar)
- * is the child of (Server=Bob,Deployment=Foo.war),
- * which is the child of (Server=Bob).  Think about this statement in terms of
- * a path relationship.  The server (Bob) contains a deployment (Foo.war) and
- * the deployment contains a class (Bar).
- *
- * See historical design notes
- * http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3972233#3972233
- * http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4013747#4013747
- *
- * Thread Safety:  This class is immutable and therefore thread safe.
- *
- * Note: this class requires that class Scope implement Comparable, so that it
- * can correctly sort the array of Scopes.  Note that is not needed for 
- * UnmodifiableScopeKey(ScopeKey), which is already sorted.
- *
- * Warning:  This class (delicately) extends ScopeKey and overides all ScopeKey methods.
- * Since there is no common interface class between the two classes, there are risks to be
- * aware of.  If a new method is added to ScopeKey and not to UnmodifiableScopeKey, undesireable
- * behavior will occur when that new method is invoked (ScopeKey's member variables will be null). 
- *
- * @author <a href="smarlow at redhat.com">Scott Marlow</a>
- * @version $Revision: 75678 $
- */
-
-public final class UnmodifiableScopeKey extends ScopeKey implements Serializable, Cloneable
-{
-
-   /** The serialVersionUID */
-   private static final long serialVersionUID = -442157853443439820L;
-
-   // the entries in this array are always sorted by (int) Scope.level.level
-   // Therefore, the maxScopeLevel is always found at the last element.
-   private final Scope theScopes[];
-
-   // Scopes in collection form
-   private final Collection<Scope> theScopesCollection;
-
-   // The cached hashCode that is calculated only once by the constructor
-   private final int hashcode;
-
-   public UnmodifiableScopeKey( ScopeKey key)
-   {
-      theScopes = new Scope[key.getScopes().size()];
-      key.getScopes().toArray(theScopes);
-      // sort(theScopes);  // already sorted
-      hashcode = ScopeKey.computeHashCode(theScopes);
-      theScopesCollection = Collections.unmodifiableCollection(Arrays.asList(theScopes));
-   }
-
-   /**
-    * Create a new ScopeKey.
-    *
-    * @param level the scope level
-    * @param qualifier the scope qualifier
-    */
-   public UnmodifiableScopeKey(ScopeLevel level, Object qualifier)
-   {
-      this( new Scope(level, qualifier));
-   }
-
-   /**
-    * Create a new ScopeKey.
-    *
-    * @param scopes is a collection of Scope instances that make up the represented path
-    * @throws IllegalArgumentException if parameter scopes is null
-    */
-   public UnmodifiableScopeKey(Collection<Scope> scopes)
-   {
-      if (scopes == null)
-         throw new IllegalArgumentException("Null scopes");
-      theScopes = new Scope[scopes.size()];
-      scopes.toArray(theScopes);
-      sort(theScopes);
-      hashcode = ScopeKey.computeHashCode(theScopes);
-      theScopesCollection = Collections.unmodifiableCollection(Arrays.asList(theScopes));
-   }
-
-   /**
-    * Create a new ScopeKey.
-    *
-    * @param scopes is zero or more Scope instances that make up the represented path
-    * @throws IllegalArgumentException if parameter scopes is null
-    */
-   public UnmodifiableScopeKey(Scope... scopes)
-   {
-      if (scopes == null)
-         throw new IllegalArgumentException("Null scopes");
-      theScopes = setup(scopes.length, scopes);
-      hashcode = ScopeKey.computeHashCode(theScopes);
-      theScopesCollection = Collections.unmodifiableCollection(Arrays.asList(theScopes));
-   }
-
-   /**
-    * Create a new ScopeKey.
-    *
-    * @param max number of passed Scope instances to use
-    * @param scopes is zero or more Scope instances that make up the represented path
-    * @throws IllegalArgumentException if parameter scopes is null
-    */
-   public UnmodifiableScopeKey(int max, Scope... scopes)
-   {
-      if (scopes == null)
-         throw new IllegalArgumentException("Null scopes");
-      theScopes = setup(max, scopes);
-      hashcode = ScopeKey.computeHashCode(theScopes);
-      theScopesCollection = Collections.unmodifiableCollection(Arrays.asList(theScopes));
-   }
-
-   public ScopeKey getOptimizedKey()
-   {
-      return this;
-   }
-
-   /**
-    * Get the scopes
-    *
-    * @return the unmodifiable collection of the scopes in expected path order
-    */
-   public Collection<Scope> getScopes()
-   {
-      return theScopesCollection;
-   }
-
-   
-
-   /**
-    * Get a scope
-    *
-    * @param level the scope level
-    * @return the scope
-    * @throws IllegalArgumentException if level is null.
-    */
-   public Scope getScope(ScopeLevel level)
-   {
-      if (level == null)
-         throw new IllegalArgumentException("Null level");
-      // Note that the following search succeeds because we know that the qualifier (empty string)
-      // is ignored during the search.
-      int idx = Arrays.binarySearch(theScopes, new Scope(level,""));
-      if(idx >= 0)
-         return theScopes[idx];
-      return null;   // not found
-   }
-
-   /**
-    * Get the maximum scope level
-    *
-    * @return the largest scope level
-    */
-   public ScopeLevel getMaxScopeLevel()
-   {
-      // the maximum scope level is always the last entry (since we are sorted by scopelevel)
-      if (theScopes.length > 0)
-         return theScopes[theScopes.length - 1].getScopeLevel();
-      else
-         return null;
-   }
-
-   /**
-    * Get the parent scope key
-    *
-    * @return the parent or null if there is no parent (meaning that we
-    * are at the top most element in the path)
-    */
-   public ScopeKey getParent()
-   {
-    if (theScopes.length < 2)
-         return null;
-    ScopeKey result = new UnmodifiableScopeKey(theScopes.length - 1, theScopes);
-    return result;
-   }
-
-   /**
-    * Is this parent of key parameter.
-    *
-    * @param key the key parameter
-    * @return true if this is direct parent of key param
-    * @throws IllegalArgumentException if parameter key is null
-    */
-   public boolean isParent(ScopeKey key)
-   {
-      if (key == null)
-         throw new IllegalArgumentException("Null key");
-
-      Scope[] keyArray = key.getArray();
-
-      // The passed key doesn't have a parent
-      if (keyArray.length < 2)
-         return false;
-
-      // If it is a child, it will have one more scope
-      if (theScopes.length != keyArray.length - 1)
-         return false;
-
-      for (int looper = 0; looper < keyArray.length - 1; looper ++)
-      {
-         if(keyArray[looper].equals(theScopes[looper]) == false)
-            return false;
-      }
-      return true;
-   }
-
-
-   /**
-    * Get scope for the specified scopeLevel
-    *
-    * @param scopeLevel the scope level
-    * @return the scope or null if there is no such level
-    * @throws IllegalArgumentException if parameter scopeLevel is null
-    */
-   public Scope getScopeLevel(ScopeLevel scopeLevel)
-   {
-      if (scopeLevel == null)
-         throw new IllegalArgumentException("Null scope level");
-      return getScope(scopeLevel);
-   }
-
-
-   public String toString()
-   {
-      return getScopes().toString();
-   }
-
-   public boolean equals(Object object)
-   {
-      if (object == this)
-         return true;
-      if (object == null || object instanceof ScopeKey == false)
-         return false;
-      ScopeKey other = (ScopeKey) object;
-      Scope[] otherArray = other.getArray();
-      return Arrays.equals(theScopes, otherArray);
-   }
-
-   public int hashCode()
-   {
-      return hashcode;
-   }
-
-   /**
-    * Get the frozen.
-    *
-    * @return true as UnmodifiableScopeKey is always frozen
-    */
-   public boolean isFrozen()
-   {
-      return true;
-   }
-
-   /**
-    * This method is ignored as UnmodifiableScopeKey is always frozen
-    */
-   public void freeze()
-   {
-   }   
-
-   /**
-    * Scope cannot be added to an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).  
-    * Calling addScope will always fail.
-    * 
-    * @param scope the scope
-    * @throws IllegalArgumentException if scope is null.
-    * @throws IllegalStateException because UnmodifiableScopeKey is always frozen
-    */
-   public Scope addScope(Scope scope)
-   {
-      if (scope == null)
-         throw new IllegalArgumentException("Null scope");
-      throw new IllegalStateException("The scope key is frozen");
-   }
-
-    /**
-    * Scope cannot be added to an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).  
-    * Calling addScope will always fail.
-    *
-    * @param level the scope level
-    * @param qualifier the scope qualifier
-    * @throws IllegalStateException because UnmodifiableScopeKey is always frozen
-    */
-   public Scope addScope(ScopeLevel level, Object qualifier)
-   {
-      throw new IllegalStateException("The scope key is frozen"); 
-   }
-
-   /**
-    * Scope cannot be removed from an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).  
-    * Calling removeScope will always fail.
-    *
-    * @param scope the scope
-    * @throws IllegalStateException because UnmodifiableScopeKey is always frozen
-    */
-   public Scope removeScope(Scope scope)
-   {
-      throw new IllegalStateException("The scope key is frozen");
-   }
-
-   /**
-    * ScopeLevel cannot be removed from an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).  
-    * Calling removeScope will always fail.
-    *
-    * @param scopeLevel the scopeLevel
-    * @throws IllegalStateException because UnmodifiableScopeKey is always frozen
-    */
-   public Scope removeScopeLevel(ScopeLevel scopeLevel)
-   {
-      throw new IllegalStateException("The scope key is frozen");
-   }
-
-   
-   /**
-    * clone will always return a frozen copy of the UnmodifiableScopeKey.  
-    * This is different then ScopeKey.clone(), which returns an unfrozen ScopeKey.
-    */
-   public ScopeKey clone()
-   {
-      ScopeKey result = super.clone();
-      return result;
-   }
-
-   private static Scope[] setup(int max, Scope... scopes)
-   {
-      if (max > scopes.length)
-         max = scopes.length;
-      Scope createdScopes[] = new Scope[max];
-      for (int looper = 0; looper < max; looper++)
-         createdScopes[looper] = scopes[looper];
-      sort(createdScopes);
-      return createdScopes;
-   }
-
-   private static void sort(Scope scopes[])
-   {
-      Arrays.sort(scopes);
-   }
-
-   protected Scope[] getArray()
-   {
-      return theScopes;
-   }
-
-   protected Collection<Scope> getScopesCollection()
-   {
-      return theScopesCollection;
-   }
-
-}

Copied: projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java (from rev 99153, projects/jboss-mdr/trunk/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java)
===================================================================
--- projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java	                        (rev 0)
+++ projects/jboss-mdr/tags/2.2.0.Alpha1/src/main/java/org/jboss/metadata/spi/scope/UnmodifiableScopeKey.java	2010-01-11 16:50:36 UTC (rev 99219)
@@ -0,0 +1,369 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.metadata.spi.scope;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * The UnmodifiableScopeKey represents a path which is made up of the path entries.
+ *
+ * The UnmodifiableScopeKey (Server=Bob,Deployment=Foo.war,Class=Bar)
+ * is the child of (Server=Bob,Deployment=Foo.war),
+ * which is the child of (Server=Bob).  Think about this statement in terms of
+ * a path relationship.  The server (Bob) contains a deployment (Foo.war) and
+ * the deployment contains a class (Bar).
+ *
+ * See historical design notes
+ * http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3972233#3972233
+ * http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4013747#4013747
+ *
+ * Thread Safety:  This class is immutable and therefore thread safe.
+ *
+ * Note: this class requires that class Scope implement Comparable, so that it
+ * can correctly sort the array of Scopes.  Note that is not needed for 
+ * UnmodifiableScopeKey(ScopeKey), which is already sorted.
+ *
+ * Warning:  This class (delicately) extends ScopeKey and overides all ScopeKey methods.
+ * Since there is no common interface class between the two classes, there are risks to be
+ * aware of.  If a new method is added to ScopeKey and not to UnmodifiableScopeKey, undesireable
+ * behavior will occur when that new method is invoked (ScopeKey's member variables will be null). 
+ *
+ * @author <a href="smarlow at redhat.com">Scott Marlow</a>
+ * @version $Revision: 75678 $
+ */
+
+public final class UnmodifiableScopeKey extends ScopeKey implements Serializable, Cloneable
+{
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -442157853443439820L;
+
+   // the entries in this array are always sorted by (int) Scope.level.level
+   // Therefore, the maxScopeLevel is always found at the last element.
+   private final Scope theScopes[];
+
+   // Scopes in collection form
+   private final Collection<Scope> theScopesCollection;
+
+   // The cached hashCode that is calculated only once by the constructor
+   private final int hashcode;
+
+   public UnmodifiableScopeKey( ScopeKey key)
+   {
+      theScopes = new Scope[key.getScopes().size()];
+      key.getScopes().toArray(theScopes);
+      // sort(theScopes);  // already sorted
+      hashcode = ScopeKey.computeHashCode(theScopes);
+      theScopesCollection = Collections.unmodifiableCollection(Arrays.asList(theScopes));
+   }
+
+   /**
+    * Create a new ScopeKey.
+    *
+    * @param level the scope level
+    * @param qualifier the scope qualifier
+    */
+   public UnmodifiableScopeKey(ScopeLevel level, Object qualifier)
+   {
+      this(new Scope(level, qualifier));
+   }
+
+   /**
+    * Create a new ScopeKey.
+    *
+    * @param scopes is a collection of Scope instances that make up the represented path
+    * @throws IllegalArgumentException if parameter scopes is null
+    */
+   public UnmodifiableScopeKey(Collection<Scope> scopes)
+   {
+      if (scopes == null)
+         throw new IllegalArgumentException("Null scopes");
+      theScopes = new Scope[scopes.size()];
+      scopes.toArray(theScopes);
+      sort(theScopes);
+      hashcode = ScopeKey.computeHashCode(theScopes);
+      theScopesCollection = Collections.unmodifiableCollection(Arrays.asList(theScopes));
+   }
+
+   /**
+    * Create a new ScopeKey.
+    *
+    * @param scopes is zero or more Scope instances that make up the represented path
+    * @throws IllegalArgumentException if parameter scopes is null
+    */
+   public UnmodifiableScopeKey(Scope... scopes)
+   {
+      if (scopes == null)
+         throw new IllegalArgumentException("Null scopes");
+      theScopes = setup(scopes.length, scopes);
+      hashcode = ScopeKey.computeHashCode(theScopes);
+      theScopesCollection = Collections.unmodifiableCollection(Arrays.asList(theScopes));
+   }
+
+   /**
+    * Create a new ScopeKey.
+    *
+    * @param max number of passed Scope instances to use
+    * @param scopes is zero or more Scope instances that make up the represented path
+    * @throws IllegalArgumentException if parameter scopes is null
+    */
+   public UnmodifiableScopeKey(int max, Scope... scopes)
+   {
+      if (scopes == null)
+         throw new IllegalArgumentException("Null scopes");
+      theScopes = setup(max, scopes);
+      hashcode = ScopeKey.computeHashCode(theScopes);
+      theScopesCollection = Collections.unmodifiableCollection(Arrays.asList(theScopes));
+   }
+
+   public ScopeKey getOptimizedKey()
+   {
+      return this;
+   }
+
+   /**
+    * Get the scopes
+    *
+    * @return the unmodifiable collection of the scopes in expected path order
+    */
+   public Collection<Scope> getScopes()
+   {
+      return theScopesCollection;
+   }
+
+   /**
+    * Get a scope
+    *
+    * @param level the scope level
+    * @return the scope
+    * @throws IllegalArgumentException if level is null.
+    */
+   public Scope getScope(ScopeLevel level)
+   {
+      if (level == null)
+         throw new IllegalArgumentException("Null level");
+      // Note that the following search succeeds because we know that the qualifier (empty string)
+      // is ignored during the search.
+      int idx = Arrays.binarySearch(theScopes, new Scope(level,""));
+      if(idx >= 0)
+         return theScopes[idx];
+      return null;   // not found
+   }
+
+   /**
+    * Get the maximum scope level
+    *
+    * @return the largest scope level
+    */
+   public ScopeLevel getMaxScopeLevel()
+   {
+      // the maximum scope level is always the last entry (since we are sorted by scopelevel)
+      if (theScopes.length > 0)
+         return theScopes[theScopes.length - 1].getScopeLevel();
+      else
+         return null;
+   }
+
+   /**
+    * Get the parent scope key
+    *
+    * @return the parent or null if there is no parent (meaning that we
+    * are at the top most element in the path)
+    */
+   public ScopeKey getParent()
+   {
+    if (theScopes.length < 2)
+         return null;
+    ScopeKey result = new UnmodifiableScopeKey(theScopes.length - 1, theScopes);
+    return result;
+   }
+
+   /**
+    * Is this parent of key parameter.
+    *
+    * @param key the key parameter
+    * @return true if this is direct parent of key param
+    * @throws IllegalArgumentException if parameter key is null
+    */
+   public boolean isParent(ScopeKey key)
+   {
+      if (key == null)
+         throw new IllegalArgumentException("Null key");
+
+      Scope[] keyArray = key.getArray();
+
+      // The passed key doesn't have a parent
+      if (keyArray.length < 2)
+         return false;
+
+      // If it is a child, it will have one more scope
+      if (theScopes.length != keyArray.length - 1)
+         return false;
+
+      for (int looper = 0; looper < keyArray.length - 1; looper ++)
+      {
+         if(keyArray[looper].equals(theScopes[looper]) == false)
+            return false;
+      }
+      return true;
+   }
+
+   /**
+    * Get scope for the specified scopeLevel
+    *
+    * @param scopeLevel the scope level
+    * @return the scope or null if there is no such level
+    * @throws IllegalArgumentException if parameter scopeLevel is null
+    */
+   public Scope getScopeLevel(ScopeLevel scopeLevel)
+   {
+      if (scopeLevel == null)
+         throw new IllegalArgumentException("Null scope level");
+      return getScope(scopeLevel);
+   }
+
+   public String toString()
+   {
+      return getScopes().toString();
+   }
+
+   public boolean equals(Object object)
+   {
+      if (object == this)
+         return true;
+      if (object == null || object instanceof ScopeKey == false)
+         return false;
+      ScopeKey other = (ScopeKey) object;
+      Scope[] otherArray = other.getArray();
+      return Arrays.equals(theScopes, otherArray);
+   }
+
+   public int hashCode()
+   {
+      return hashcode;
+   }
+
+   /**
+    * Get the frozen.
+    *
+    * @return true as UnmodifiableScopeKey is always frozen
+    */
+   public boolean isFrozen()
+   {
+      return true;
+   }
+
+   /**
+    * This method is ignored as UnmodifiableScopeKey is always frozen
+    */
+   public void freeze()
+   {
+   }   
+
+   /**
+    * Scope cannot be added to an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).  
+    * Calling addScope will always fail.
+    * 
+    * @param scope the scope
+    * @throws IllegalArgumentException if scope is null.
+    * @throws IllegalStateException because UnmodifiableScopeKey is always frozen
+    */
+   public Scope addScope(Scope scope)
+   {
+      if (scope == null)
+         throw new IllegalArgumentException("Null scope");
+      throw new IllegalStateException("The scope key is frozen");
+   }
+
+    /**
+    * Scope cannot be added to an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).  
+    * Calling addScope will always fail.
+    *
+    * @param level the scope level
+    * @param qualifier the scope qualifier
+    * @throws IllegalStateException because UnmodifiableScopeKey is always frozen
+    */
+   public Scope addScope(ScopeLevel level, Object qualifier)
+   {
+      throw new IllegalStateException("The scope key is frozen"); 
+   }
+
+   /**
+    * Scope cannot be removed from an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).  
+    * Calling removeScope will always fail.
+    *
+    * @param scope the scope
+    * @throws IllegalStateException because UnmodifiableScopeKey is always frozen
+    */
+   public Scope removeScope(Scope scope)
+   {
+      throw new IllegalStateException("The scope key is frozen");
+   }
+
+   /**
+    * ScopeLevel cannot be removed from an UnmodifiableScopeKey (instead construct a new UnmodifiableScopeKey).  
+    * Calling removeScope will always fail.
+    *
+    * @param scopeLevel the scopeLevel
+    * @throws IllegalStateException because UnmodifiableScopeKey is always frozen
+    */
+   public Scope removeScopeLevel(ScopeLevel scopeLevel)
+   {
+      throw new IllegalStateException("The scope key is frozen");
+   }
+
+   /**
+    * clone will always return a frozen copy of the UnmodifiableScopeKey.  
+    * This is different then ScopeKey.clone(), which returns an unfrozen ScopeKey.
+    */
+   public ScopeKey clone()
+   {
+      ScopeKey result = super.clone();
+      return result;
+   }
+
+   private static Scope[] setup(int max, Scope... scopes)
+   {
+      if (max > scopes.length)
+         max = scopes.length;
+      Scope createdScopes[] = new Scope[max];
+      for (int looper = 0; looper < max; looper++)
+         createdScopes[looper] = scopes[looper];
+      sort(createdScopes);
+      return createdScopes;
+   }
+
+   private static void sort(Scope scopes[])
+   {
+      Arrays.sort(scopes);
+   }
+
+   protected Scope[] getArray()
+   {
+      return theScopes;
+   }
+
+   protected Collection<Scope> getScopesCollection()
+   {
+      return theScopesCollection;
+   }
+}




More information about the jboss-cvs-commits mailing list