directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r826194 - /directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/
Date Sat, 17 Oct 2009 08:36:41 GMT
Author: elecharny
Date: Sat Oct 17 08:36:40 2009
New Revision: 826194

URL: http://svn.apache.org/viewvc?rev=826194&view=rev
Log:
Added the missing Registries clone methods

Modified:
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/LdapSyntaxRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleUseRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NameFormRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NormalizerRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ObjectClassRegistry.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
    directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SyntaxCheckerRegistry.java

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ComparatorRegistry.java
Sat Oct 17 08:36:40 2009
@@ -153,4 +153,15 @@
             }
         }
     }
+    
+    
+    /**
+     * Clone the ComparatorRegistry
+     */
+    public ComparatorRegistry clone() throws CloneNotSupportedException
+    {
+        ComparatorRegistry clone = (ComparatorRegistry)super.clone();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITContentRuleRegistry.java
Sat Oct 17 08:36:40 2009
@@ -41,4 +41,15 @@
     {
         super( SchemaObjectType.DIT_CONTENT_RULE, oidRegistry );
     }
+    
+    
+    /**
+     * Clone the DITContentRuleRegistry
+     */
+    public DITContentRuleRegistry clone() throws CloneNotSupportedException
+    {
+        DITContentRuleRegistry clone = (DITContentRuleRegistry)super.clone();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/DITStructureRuleRegistry.java
Sat Oct 17 08:36:40 2009
@@ -20,9 +20,9 @@
 package org.apache.directory.shared.ldap.schema.registries;
 
 
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javax.naming.NamingException;
 
@@ -48,7 +48,7 @@
     private static final boolean DEBUG = LOG.isDebugEnabled();
     
     /** a map of DITStructureRule looked up by RuleId */
-    protected final Map<Integer, DITStructureRule> byRuleId;
+    protected Map<Integer, DITStructureRule> byRuleId;
     
     /**
      * Creates a new default NormalizerRegistry instance.
@@ -58,7 +58,7 @@
     public DITStructureRuleRegistry( OidRegistry oidRegistry )
     {
         super( SchemaObjectType.DIT_STRUCTURE_RULE, oidRegistry );
-        byRuleId = new ConcurrentHashMap<Integer, DITStructureRule>();
+        byRuleId = new HashMap<Integer, DITStructureRule>();
     }
 
 
@@ -246,4 +246,18 @@
             }
         }
     }
+    
+    
+    /**
+     * Clone the DITStructureRuleRegistry
+     */
+    public DITStructureRuleRegistry clone() throws CloneNotSupportedException
+    {
+        DITStructureRuleRegistry clone = (DITStructureRuleRegistry)super.clone();
+        
+        // Clone the RuleId map
+        clone.byRuleId = new HashMap<Integer, DITStructureRule>();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/LdapSyntaxRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/LdapSyntaxRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/LdapSyntaxRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/LdapSyntaxRegistry.java
Sat Oct 17 08:36:40 2009
@@ -40,4 +40,15 @@
     {
         super( SchemaObjectType.LDAP_SYNTAX, oidRegistry );
     }
+    
+    
+    /**
+     * Clone the LdapSyntaxRegistry
+     */
+    public LdapSyntaxRegistry clone() throws CloneNotSupportedException
+    {
+        LdapSyntaxRegistry clone = (LdapSyntaxRegistry)super.clone();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleRegistry.java
Sat Oct 17 08:36:40 2009
@@ -41,4 +41,15 @@
     {
         super( SchemaObjectType.MATCHING_RULE, oidRegistry );
     }
+    
+    
+    /**
+     * Clone the MatchingRuleRegistry
+     */
+    public MatchingRuleRegistry clone() throws CloneNotSupportedException
+    {
+        MatchingRuleRegistry clone = (MatchingRuleRegistry)super.clone();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleUseRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleUseRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleUseRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/MatchingRuleUseRegistry.java
Sat Oct 17 08:36:40 2009
@@ -43,4 +43,15 @@
     {
         super( SchemaObjectType.MATCHING_RULE_USE, oidRegistry );
     }
+    
+    
+    /**
+     * Clone the MatchingRuleUseRegistry
+     */
+    public MatchingRuleUseRegistry clone() throws CloneNotSupportedException
+    {
+        MatchingRuleUseRegistry clone = (MatchingRuleUseRegistry)super.clone();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NameFormRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NameFormRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NameFormRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NameFormRegistry.java
Sat Oct 17 08:36:40 2009
@@ -41,4 +41,15 @@
     {
         super( SchemaObjectType.NAME_FORM, oidRegistry );
     }
+    
+    
+    /**
+     * Clone the DITContentRuleRegistry
+     */
+    public NameFormRegistry clone() throws CloneNotSupportedException
+    {
+        NameFormRegistry clone = (NameFormRegistry)super.clone();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NormalizerRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NormalizerRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NormalizerRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/NormalizerRegistry.java
Sat Oct 17 08:36:40 2009
@@ -153,4 +153,15 @@
             }
         }
     }
+    
+    
+    /**
+     * Clone the NormalizerRegistry
+     */
+    public NormalizerRegistry clone() throws CloneNotSupportedException
+    {
+        NormalizerRegistry clone = (NormalizerRegistry)super.clone();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ObjectClassRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ObjectClassRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ObjectClassRegistry.java
Sat Oct 17 08:36:40 2009
@@ -21,12 +21,12 @@
 
 
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
 
 import javax.naming.NamingException;
 import javax.naming.directory.NoSuchAttributeException;
@@ -52,7 +52,7 @@
     private static final boolean IS_DEBUG = LOG.isDebugEnabled();
 
     /** maps OIDs to a Set of descendants for that OID */
-    private final Map<String,Set<ObjectClass>> oidToDescendantSet;
+    private Map<String,Set<ObjectClass>> oidToDescendants;
 
     /**
      * Creates a new default ObjectClassRegistry instance.
@@ -62,7 +62,7 @@
     public ObjectClassRegistry( OidRegistry oidRegistry )
     {
         super( SchemaObjectType.OBJECT_CLASS, oidRegistry );
-        oidToDescendantSet= new ConcurrentHashMap<String,Set<ObjectClass>>();
+        oidToDescendants = new HashMap<String,Set<ObjectClass>>();
     }
     
     
@@ -80,7 +80,7 @@
         try
         {
             String oid = getOidByName( ancestorId );
-            Set<ObjectClass> descendants = oidToDescendantSet.get( oid );
+            Set<ObjectClass> descendants = oidToDescendants.get( oid );
             return (descendants != null) && !descendants.isEmpty();
         }
         catch ( NamingException ne )
@@ -106,7 +106,7 @@
         try
         {
             String oid = getOidByName( ancestorId );
-            Set<ObjectClass> descendants = oidToDescendantSet.get( oid );
+            Set<ObjectClass> descendants = oidToDescendants.get( oid );
             
             if ( descendants == null )
             {
@@ -141,13 +141,13 @@
         for ( ObjectClass ancestor : ancestors )
         {
             // Get the ancestor's descendant, if any
-            Set<ObjectClass> descendants = oidToDescendantSet.get( ancestor.getOid()
);
+            Set<ObjectClass> descendants = oidToDescendants.get( ancestor.getOid()
);
     
             // Initialize the descendant Set to store the descendants for the attributeType
             if ( descendants == null )
             {
                 descendants = new HashSet<ObjectClass>( 1 );
-                oidToDescendantSet.put( ancestor.getOid(), descendants );
+                oidToDescendants.put( ancestor.getOid(), descendants );
             }
             
             // Add the current ObjectClass as a descendant
@@ -186,7 +186,7 @@
         for ( ObjectClass ancestor : ancestors )
         {
             // Get the ancestor's descendant, if any
-            Set<ObjectClass> descendants = oidToDescendantSet.get( ancestor.getOid()
);
+            Set<ObjectClass> descendants = oidToDescendants.get( ancestor.getOid()
);
     
             if ( descendants != null )
             {
@@ -194,7 +194,7 @@
                 
                 if ( descendants.size() == 0 )
                 {
-                    oidToDescendantSet.remove( descendants );
+                    oidToDescendants.remove( descendants );
                 }
             }
             
@@ -255,7 +255,7 @@
             // Deleting an ObjectClass which might be used as a superior means we have
             // to recursively update the descendant map. We also have to remove
             // the at.oid -> descendant relation
-            oidToDescendantSet.remove( numericOid );
+            oidToDescendants.remove( numericOid );
             
             // Now recurse if needed
             unregisterDescendants( removed, removed.getSuperiors() );
@@ -267,4 +267,18 @@
             throw new NoSuchAttributeException( ne.getMessage() );
         }
     }
+    
+    
+    /**
+     * Clone the ObjectClassRegistry
+     */
+    public ObjectClassRegistry clone() throws CloneNotSupportedException
+    {
+        ObjectClassRegistry clone = (ObjectClassRegistry)super.clone();
+        
+        // Clone the oidToDescendantSet (will be empty)
+        clone.oidToDescendants = new HashMap<String, Set<ObjectClass>>();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/Registries.java
Sat Oct 17 08:36:40 2009
@@ -56,7 +56,7 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class Registries implements SchemaLoaderListener
+public class Registries implements SchemaLoaderListener, Cloneable
 {
     /** A logger for this class */
     private static final Logger LOG = LoggerFactory.getLogger( Registries.class );
@@ -1723,4 +1723,46 @@
     {
         this.acceptDisabled = acceptDisabled;
     }
+    
+    
+    /**
+     * Clone the Registries
+     */
+    public Registries clone() throws CloneNotSupportedException
+    {
+        // First clone the structure
+        Registries clone = (Registries)super.clone();
+        
+        // We have to clone every SchemaObject registries now
+        clone.attributeTypeRegistry = attributeTypeRegistry.clone();
+        clone.comparatorRegistry = comparatorRegistry.clone();
+        clone.ditContentRuleRegistry = ditContentRuleRegistry.clone();
+        clone.ditStructureRuleRegistry = ditStructureRuleRegistry.clone();
+        clone.ldapSyntaxRegistry = ldapSyntaxRegistry.clone();
+        clone.matchingRuleRegistry = matchingRuleRegistry.clone();
+        clone.matchingRuleUseRegistry = matchingRuleUseRegistry.clone();
+        clone.nameFormRegistry = nameFormRegistry.clone();
+        clone.normalizerRegistry = normalizerRegistry.clone();
+        clone.objectClassRegistry = objectClassRegistry.clone();
+        clone.syntaxCheckerRegistry = syntaxCheckerRegistry.clone();
+        
+        // Now, clone the oidRegistry
+        clone.oidRegistry = oidRegistry.clone();
+        
+        // Clone the schema list
+        clone.loadedSchemas = new HashMap<String, Schema>();
+        
+        for ( String schemaName : loadedSchemas.keySet() )
+        {
+            // We don't cone the schemas
+            clone.loadedSchemas.put( schemaName, loadedSchemas.get( schemaName ) );
+        }
+        
+        // Last, not least, clone the Using and usedBy structures
+        // They will be empty
+        clone.using = new HashMap<SchemaWrapper, Set<SchemaWrapper>>();
+        clone.usedBy = new HashMap<SchemaWrapper, Set<SchemaWrapper>>();
+        
+        return clone;
+    }
 }

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SyntaxCheckerRegistry.java?rev=826194&r1=826193&r2=826194&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SyntaxCheckerRegistry.java
(original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SyntaxCheckerRegistry.java
Sat Oct 17 08:36:40 2009
@@ -153,4 +153,15 @@
             }
         }
     }
+    
+    
+    /**
+     * Clone the SyntaxCheckerRegistry
+     */
+    public SyntaxCheckerRegistry clone() throws CloneNotSupportedException
+    {
+        SyntaxCheckerRegistry clone = (SyntaxCheckerRegistry)super.clone();
+        
+        return clone;
+    }
 }



Mime
View raw message