directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r833647 [17/17] - in /directory: apacheds/branches/apacheds-schema/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ apacheds/branches/apacheds-schema/avl-partition/src/test/java/org/apache/directory/server/core/pa...
Date Sat, 07 Nov 2009 07:57:42 GMT
Added: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleRegistry.java?rev=833647&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleRegistry.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleRegistry.java Sat Nov  7 07:57:34 2009
@@ -0,0 +1,180 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.registries;
+
+import java.util.Iterator;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.MatchingRule;
+import org.apache.directory.shared.ldap.schema.SchemaObjectType;
+
+
+
+
+/**
+ * An immutable wrapper of the MatchingRule registry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 828111 $
+ */
+public class ImmutableMatchingRuleRegistry implements MatchingRuleRegistry
+{
+    /** The wrapped MatchingRule registry */
+    MatchingRuleRegistry immutableMatchingRuleRegistry;
+    
+    /**
+     * Creates a new instance of ImmutableMatchingRuleRegistry.
+     *
+     * @param matchingRuleRegistry The wrapped MatchingRule registry
+     */
+    public ImmutableMatchingRuleRegistry( MatchingRuleRegistry matchingRuleRegistry )
+    {
+        immutableMatchingRuleRegistry = matchingRuleRegistry;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public ImmutableMatchingRuleRegistry clone() throws CloneNotSupportedException
+    {
+        return (ImmutableMatchingRuleRegistry)immutableMatchingRuleRegistry.clone();
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int size()
+    {
+        return immutableMatchingRuleRegistry.size();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean contains( String oid )
+    {
+        return immutableMatchingRuleRegistry.contains( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean containsName( String name )
+    {
+        return immutableMatchingRuleRegistry.containsName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOidByName( String name ) throws NamingException
+    {
+        return immutableMatchingRuleRegistry.getOidByName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getSchemaName( String oid ) throws NamingException
+    {
+        return immutableMatchingRuleRegistry.getSchemaName( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SchemaObjectType getType()
+    {
+        return immutableMatchingRuleRegistry.getType();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<MatchingRule> iterator()
+    {
+        return immutableMatchingRuleRegistry.iterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public MatchingRule lookup( String oid ) throws NamingException
+    {
+        return immutableMatchingRuleRegistry.lookup( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<String> oidsIterator()
+    {
+        return immutableMatchingRuleRegistry.oidsIterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void register( MatchingRule schemaObject ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the MatchingRuleRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void renameSchema( String originalSchemaName, String newSchemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the MatchingRuleRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public MatchingRule unregister( String numericOid ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the MatchingRuleRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterSchemaElements( String schemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the MatchingRuleRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+}

Added: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleUseRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleUseRegistry.java?rev=833647&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleUseRegistry.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableMatchingRuleUseRegistry.java Sat Nov  7 07:57:34 2009
@@ -0,0 +1,179 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.registries;
+
+
+import java.util.Iterator;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.MatchingRuleUse;
+import org.apache.directory.shared.ldap.schema.SchemaObjectType;
+
+
+/**
+ * An immutable wrapper of the MatchingRuleUse registry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 828111 $
+ */
+public class ImmutableMatchingRuleUseRegistry implements MatchingRuleUseRegistry
+{
+    /** The wrapped MatchingRuleUse registry */
+    MatchingRuleUseRegistry immutableMatchingRuleUseRegistry;
+    
+    /**
+     * Creates a new instance of ImmutableMatchingRuleUseRegistry.
+     *
+     * @param matchingRuleUseRegistry The wrapped MatchingRuleUse registry
+     */
+    public ImmutableMatchingRuleUseRegistry( MatchingRuleUseRegistry matchingRuleUseRegistry )
+    {
+        immutableMatchingRuleUseRegistry = matchingRuleUseRegistry;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public ImmutableMatchingRuleUseRegistry clone() throws CloneNotSupportedException
+    {
+        return (ImmutableMatchingRuleUseRegistry)immutableMatchingRuleUseRegistry.clone();
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int size()
+    {
+        return immutableMatchingRuleUseRegistry.size();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean contains( String oid )
+    {
+        return immutableMatchingRuleUseRegistry.contains( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean containsName( String name )
+    {
+        return immutableMatchingRuleUseRegistry.containsName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOidByName( String name ) throws NamingException
+    {
+        return immutableMatchingRuleUseRegistry.getOidByName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getSchemaName( String oid ) throws NamingException
+    {
+        return immutableMatchingRuleUseRegistry.getSchemaName( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SchemaObjectType getType()
+    {
+        return immutableMatchingRuleUseRegistry.getType();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<MatchingRuleUse> iterator()
+    {
+        return immutableMatchingRuleUseRegistry.iterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public MatchingRuleUse lookup( String oid ) throws NamingException
+    {
+        return immutableMatchingRuleUseRegistry.lookup( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<String> oidsIterator()
+    {
+        return immutableMatchingRuleUseRegistry.oidsIterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void register( MatchingRuleUse schemaObject ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the MatchingRuleUseRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void renameSchema( String originalSchemaName, String newSchemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the MatchingRuleUseRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public MatchingRuleUse unregister( String numericOid ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the MatchingRuleUseRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterSchemaElements( String schemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the MatchingRuleUseRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+}

Added: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNameFormRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNameFormRegistry.java?rev=833647&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNameFormRegistry.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNameFormRegistry.java Sat Nov  7 07:57:34 2009
@@ -0,0 +1,180 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.registries;
+
+import java.util.Iterator;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.NameForm;
+import org.apache.directory.shared.ldap.schema.SchemaObjectType;
+
+
+
+
+/**
+ * An immutable wrapper of the NameForm registry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 828111 $
+ */
+public class ImmutableNameFormRegistry implements NameFormRegistry
+{
+    /** The wrapped NameForm registry */
+    NameFormRegistry immutableNameFormRegistry;
+    
+    /**
+     * Creates a new instance of ImmutableNameFormRegistry.
+     *
+     * @param nameFormRegistry The wrapped NameForm registry
+     */
+    public ImmutableNameFormRegistry( NameFormRegistry nameFormRegistry )
+    {
+        immutableNameFormRegistry = nameFormRegistry;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public ImmutableNameFormRegistry clone() throws CloneNotSupportedException
+    {
+        return (ImmutableNameFormRegistry)immutableNameFormRegistry.clone();
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int size()
+    {
+        return immutableNameFormRegistry.size();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean contains( String oid )
+    {
+        return immutableNameFormRegistry.contains( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean containsName( String name )
+    {
+        return immutableNameFormRegistry.containsName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOidByName( String name ) throws NamingException
+    {
+        return immutableNameFormRegistry.getOidByName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getSchemaName( String oid ) throws NamingException
+    {
+        return immutableNameFormRegistry.getSchemaName( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SchemaObjectType getType()
+    {
+        return immutableNameFormRegistry.getType();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<NameForm> iterator()
+    {
+        return immutableNameFormRegistry.iterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public NameForm lookup( String oid ) throws NamingException
+    {
+        return immutableNameFormRegistry.lookup( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<String> oidsIterator()
+    {
+        return immutableNameFormRegistry.oidsIterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void register( NameForm schemaObject ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the NameFormRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void renameSchema( String originalSchemaName, String newSchemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the NameFormRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public NameForm unregister( String numericOid ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the NameFormRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterSchemaElements( String schemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the NameFormRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+}

Added: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNormalizerRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNormalizerRegistry.java?rev=833647&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNormalizerRegistry.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableNormalizerRegistry.java Sat Nov  7 07:57:34 2009
@@ -0,0 +1,180 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.registries;
+
+
+import java.util.Iterator;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.Normalizer;
+import org.apache.directory.shared.ldap.schema.SchemaObjectType;
+
+
+/**
+ * An immutable wrapper of the Normalizer registry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 831344 $
+ */
+public class ImmutableNormalizerRegistry implements NormalizerRegistry
+{
+    /** The wrapped Normalizer registry */
+    NormalizerRegistry immutableNormalizerRegistry;
+    
+    
+    /**
+     * Creates a new immutable NormalizerRegistry instance.
+     * 
+     * @param The wrapped Normalizer registry 
+     */
+    public ImmutableNormalizerRegistry( NormalizerRegistry normalizerRegistry )
+    {
+        immutableNormalizerRegistry = normalizerRegistry;
+    }
+    
+    
+    /**
+     *  {@inheritDoc}
+     */
+    public void register( Normalizer normalizer ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the NormalizerRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public Normalizer unregister( String numericOid ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the NormalizerRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+    
+    
+    /**
+     *  {@inheritDoc}
+     */
+    public void unregisterSchemaElements( String schemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the NormalizerRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+    
+    
+    /**
+     *  {@inheritDoc}
+     */
+    public ImmutableNormalizerRegistry clone() throws CloneNotSupportedException
+    {
+        return (ImmutableNormalizerRegistry)immutableNormalizerRegistry.clone();
+    }
+    
+    
+    /**
+     *  {@inheritDoc}
+     */
+    public int size()
+    {
+        return immutableNormalizerRegistry.size();
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public boolean contains( String oid )
+    {
+        return immutableNormalizerRegistry.contains( oid );
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public boolean containsName( String name )
+    {
+        return immutableNormalizerRegistry.containsName( name );
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public String getOidByName( String name ) throws NamingException
+    {
+        return immutableNormalizerRegistry.getOidByName( name );
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public String getSchemaName( String oid ) throws NamingException
+    {
+        return immutableNormalizerRegistry.getSchemaName( oid );
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public SchemaObjectType getType()
+    {
+        return immutableNormalizerRegistry.getType();
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public Iterator<Normalizer> iterator()
+    {
+        return immutableNormalizerRegistry.iterator();
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public Normalizer lookup( String oid ) throws NamingException
+    {
+        return immutableNormalizerRegistry.lookup( oid );
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public Iterator<String> oidsIterator()
+    {
+        return immutableNormalizerRegistry.oidsIterator();
+    }
+
+
+    /**
+     *  {@inheritDoc}
+     */
+    public void renameSchema( String originalSchemaName, String newSchemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the NormalizerRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+}

Added: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableObjectClassRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableObjectClassRegistry.java?rev=833647&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableObjectClassRegistry.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableObjectClassRegistry.java Sat Nov  7 07:57:34 2009
@@ -0,0 +1,218 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.registries;
+
+
+import java.util.Iterator;
+import java.util.List;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.ObjectClass;
+import org.apache.directory.shared.ldap.schema.SchemaObjectType;
+
+
+/**
+ * An immutable wrapper of the ObjectClass registry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 828111 $
+ */
+public class ImmutableObjectClassRegistry implements ObjectClassRegistry, Cloneable
+{
+    /** The wrapped ObjectClass registry */
+    private ObjectClassRegistry immutableObjectClassRegistry;
+
+    /**
+     * Creates a new instance of ImmutableAttributeTypeRegistry.
+     *
+     * @param atRegistry The wrapped Attrib uteType registry
+     */
+    public ImmutableObjectClassRegistry( ObjectClassRegistry ocRegistry )
+    {
+        immutableObjectClassRegistry = ocRegistry;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public boolean hasDescendants( String ancestorId ) throws NamingException
+    {
+        return immutableObjectClassRegistry.hasDescendants( ancestorId );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<ObjectClass> descendants( String ancestorId ) throws NamingException
+    {
+        return immutableObjectClassRegistry.descendants( ancestorId );
+    }
+
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void registerDescendants( ObjectClass objectClass, List<ObjectClass> ancestors ) 
+        throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the ObjectClassRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors ) 
+        throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the ObjectClassRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void register( ObjectClass objectClass ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the ObjectClassRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public ObjectClass unregister( String numericOid ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the ObjectClassRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+    
+    
+    /**
+     * Clone the ObjectClassRegistry
+     */
+    public ImmutableObjectClassRegistry clone() throws CloneNotSupportedException
+    {
+        return (ImmutableObjectClassRegistry)immutableObjectClassRegistry.clone();
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int size()
+    {
+        return immutableObjectClassRegistry.size();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean contains( String oid )
+    {
+        return immutableObjectClassRegistry.contains( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean containsName( String name )
+    {
+        return immutableObjectClassRegistry.containsName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOidByName( String name ) throws NamingException
+    {
+        return immutableObjectClassRegistry.getOidByName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getSchemaName( String oid ) throws NamingException
+    {
+        return immutableObjectClassRegistry.getSchemaName( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SchemaObjectType getType()
+    {
+        return immutableObjectClassRegistry.getType();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<ObjectClass> iterator()
+    {
+        return immutableObjectClassRegistry.iterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public ObjectClass lookup( String oid ) throws NamingException
+    {
+        return immutableObjectClassRegistry.lookup( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<String> oidsIterator()
+    {
+        return immutableObjectClassRegistry.oidsIterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void renameSchema( String originalSchemaName, String newSchemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the ObjectClassRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterSchemaElements( String schemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the ObjectClassRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+}

Added: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableSyntaxCheckerRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableSyntaxCheckerRegistry.java?rev=833647&view=auto
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableSyntaxCheckerRegistry.java (added)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/ImmutableSyntaxCheckerRegistry.java Sat Nov  7 07:57:34 2009
@@ -0,0 +1,179 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *  
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *  
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License. 
+ *  
+ */
+package org.apache.directory.shared.ldap.schema.registries;
+
+
+import java.util.Iterator;
+
+import javax.naming.NamingException;
+
+import org.apache.directory.shared.ldap.exception.LdapOperationNotSupportedException;
+import org.apache.directory.shared.ldap.message.ResultCodeEnum;
+import org.apache.directory.shared.ldap.schema.SchemaObjectType;
+import org.apache.directory.shared.ldap.schema.SyntaxChecker;
+
+
+/**
+ * An immutable wrapper of the SyntaxChecker registry.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev: 831344 $
+ */
+public class ImmutableSyntaxCheckerRegistry implements SyntaxCheckerRegistry
+{
+    /** The wrapped SyntaxChecker registry */
+    SyntaxCheckerRegistry immutableSyntaxCheckerRegistry;
+    
+    /**
+     * Creates a new instance of ImmutableSyntaxCheckerRegistry.
+     *
+     * @param syntaxCheckerRegistry The wrapped SyntaxChecker registry
+     */
+    public ImmutableSyntaxCheckerRegistry( SyntaxCheckerRegistry syntaxCheckerRegistry )
+    {
+        immutableSyntaxCheckerRegistry = syntaxCheckerRegistry;
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void register( SyntaxChecker syntaxChecker ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the SyntaxCheckerRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SyntaxChecker unregister( String numericOid ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the SyntaxCheckerRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public void unregisterSchemaElements( String schemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the SyntaxCheckerRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public ImmutableSyntaxCheckerRegistry clone() throws CloneNotSupportedException
+    {
+        return (ImmutableSyntaxCheckerRegistry)immutableSyntaxCheckerRegistry.clone();
+    }
+    
+    
+    /**
+     * {@inheritDoc}
+     */
+    public int size()
+    {
+        return immutableSyntaxCheckerRegistry.size();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean contains( String oid )
+    {
+        return immutableSyntaxCheckerRegistry.contains( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean containsName( String name )
+    {
+        return immutableSyntaxCheckerRegistry.containsName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getOidByName( String name ) throws NamingException
+    {
+        return immutableSyntaxCheckerRegistry.getOidByName( name );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getSchemaName( String oid ) throws NamingException
+    {
+        return immutableSyntaxCheckerRegistry.getSchemaName( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SchemaObjectType getType()
+    {
+        return immutableSyntaxCheckerRegistry.getType();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<SyntaxChecker> iterator()
+    {
+        return immutableSyntaxCheckerRegistry.iterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public SyntaxChecker lookup( String oid ) throws NamingException
+    {
+        return immutableSyntaxCheckerRegistry.lookup( oid );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Iterator<String> oidsIterator()
+    {
+        return immutableSyntaxCheckerRegistry.oidsIterator();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void renameSchema( String originalSchemaName, String newSchemaName ) throws NamingException
+    {
+        throw new LdapOperationNotSupportedException( "Cannot modify the SyntaxCheckerRegistry copy", ResultCodeEnum.NO_SUCH_OPERATION );
+    }
+}

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=833647&r1=833646&r2=833647&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 Nov  7 07:57:34 2009
@@ -20,44 +20,25 @@
 package org.apache.directory.shared.ldap.schema.registries;
 
 import org.apache.directory.shared.ldap.schema.LdapSyntax;
-import org.apache.directory.shared.ldap.schema.SchemaObjectType;
 
 
 /**
- * Manages the lookup and registration of LdapSyntaxes within the system by OID.
+ * An LdapSyntax registry service interface.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class LdapSyntaxRegistry extends SchemaObjectRegistry<LdapSyntax>
+public interface LdapSyntaxRegistry extends SchemaObjectRegistry<LdapSyntax>,
+    Iterable<LdapSyntax>, Cloneable
 {
     /**
-     * Creates a new default LdapSyntaxRegistry instance.
-     * 
-     * @param oidRegistry The global OID registry 
-     */
-    public LdapSyntaxRegistry( OidRegistry oidRegistry )
-    {
-        super( SchemaObjectType.LDAP_SYNTAX, oidRegistry );
-    }
-    
-    
-    /**
      * Clone the LdapSyntaxRegistry
      */
-    public LdapSyntaxRegistry clone() throws CloneNotSupportedException
-    {
-        LdapSyntaxRegistry clone = (LdapSyntaxRegistry)super.clone();
-        
-        return clone;
-    }
+    LdapSyntaxRegistry clone() throws CloneNotSupportedException;
     
     
     /**
      *  @return The number of Syntaxes stored
      */
-    public int size()
-    {
-        return oidRegistry.size();
-    }
+    int size();
 }

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=833647&r1=833646&r2=833647&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 Nov  7 07:57:34 2009
@@ -21,44 +21,25 @@
 
 
 import org.apache.directory.shared.ldap.schema.MatchingRule;
-import org.apache.directory.shared.ldap.schema.SchemaObjectType;
 
 
 /**
- * A registry used to track system matchingRules.
+ * An AttributeType registry service interface.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class MatchingRuleRegistry extends SchemaObjectRegistry<MatchingRule>
+public interface MatchingRuleRegistry extends SchemaObjectRegistry<MatchingRule>,
+    Iterable<MatchingRule>, Cloneable
 {
     /**
-     * Creates a new default MatchingRuleRegistry instance.
-     * 
-     * @param oidRegistry The global OID registry 
-     */
-    public MatchingRuleRegistry( OidRegistry oidRegistry )
-    {
-        super( SchemaObjectType.MATCHING_RULE, oidRegistry );
-    }
-    
-    
-    /**
      * Clone the MatchingRuleRegistry
      */
-    public MatchingRuleRegistry clone() throws CloneNotSupportedException
-    {
-        MatchingRuleRegistry clone = (MatchingRuleRegistry)super.clone();
-        
-        return clone;
-    }
+    MatchingRuleRegistry clone() throws CloneNotSupportedException;
     
     
     /**
-     *  @return The number of MatchingRule stored
+     * @return The number of MatchingRule stored
      */
-    public int size()
-    {
-        return oidRegistry.size();
-    }
+    int size();
 }

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=833647&r1=833646&r2=833647&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 Nov  7 07:57:34 2009
@@ -21,7 +21,6 @@
 
 
 import org.apache.directory.shared.ldap.schema.MatchingRuleUse;
-import org.apache.directory.shared.ldap.schema.SchemaObjectType;
 
 
 /**
@@ -32,35 +31,17 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class MatchingRuleUseRegistry extends SchemaObjectRegistry<MatchingRuleUse>
+public interface MatchingRuleUseRegistry extends SchemaObjectRegistry<MatchingRuleUse>,
+    Iterable<MatchingRuleUse>, Cloneable
 {
     /**
-     * Creates a new default MatchingRuleUseRegistry instance.
-     * 
-     * @param oidRegistry The global OID registry 
-     */
-    public MatchingRuleUseRegistry( OidRegistry oidRegistry )
-    {
-        super( SchemaObjectType.MATCHING_RULE_USE, oidRegistry );
-    }
-    
-    
-    /**
      * Clone the MatchingRuleUseRegistry
      */
-    public MatchingRuleUseRegistry clone() throws CloneNotSupportedException
-    {
-        MatchingRuleUseRegistry clone = (MatchingRuleUseRegistry)super.clone();
-        
-        return clone;
-    }
+    MatchingRuleUseRegistry clone() throws CloneNotSupportedException;
     
     
     /**
      *  @return The number of MatchingRuleUse stored
      */
-    public int size()
-    {
-        return oidRegistry.size();
-    }
+    int size();
 }

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=833647&r1=833646&r2=833647&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 Nov  7 07:57:34 2009
@@ -21,7 +21,6 @@
 
 
 import org.apache.directory.shared.ldap.schema.NameForm;
-import org.apache.directory.shared.ldap.schema.SchemaObjectType;
 
 
 /**
@@ -30,35 +29,17 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class NameFormRegistry extends SchemaObjectRegistry<NameForm>
+public interface NameFormRegistry extends SchemaObjectRegistry<NameForm>,
+    Iterable<NameForm>, Cloneable
 {
     /**
-     * Creates a new default NameFormRegistry instance.
-     * 
-     * @param oidRegistry The global OID registry 
+     * Clone the NameFormRegistry
      */
-    public NameFormRegistry( OidRegistry oidRegistry )
-    {
-        super( SchemaObjectType.NAME_FORM, oidRegistry );
-    }
-    
-    
-    /**
-     * Clone the DITContentRuleRegistry
-     */
-    public NameFormRegistry clone() throws CloneNotSupportedException
-    {
-        NameFormRegistry clone = (NameFormRegistry)super.clone();
-        
-        return clone;
-    }
+    NameFormRegistry clone() throws CloneNotSupportedException;
     
     
     /**
      *  @return The number of NameForms stored
      */
-    public int size()
-    {
-        return oidRegistry.size();
-    }
+    int size();
 }

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=833647&r1=833646&r2=833647&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 Nov  7 07:57:34 2009
@@ -22,13 +22,7 @@
 
 import javax.naming.NamingException;
 
-import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.schema.Normalizer;
-import org.apache.directory.shared.ldap.schema.SchemaObject;
-import org.apache.directory.shared.ldap.schema.SchemaObjectType;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -37,25 +31,9 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class NormalizerRegistry extends SchemaObjectRegistry<Normalizer>
+public interface NormalizerRegistry extends SchemaObjectRegistry<Normalizer>,
+    Iterable<Normalizer>, Cloneable
 {
-    /** static class logger */
-    private static final Logger LOG = LoggerFactory.getLogger( NormalizerRegistry.class );
-
-    /** A speedup for debug */
-    private static final boolean DEBUG = LOG.isDebugEnabled();
-    
-    /**
-     * Creates a new default NormalizerRegistry instance.
-     * 
-     * @param oidRegistry The global OID registry 
-     */
-    public NormalizerRegistry( OidRegistry oidRegistry )
-    {
-        super( SchemaObjectType.NORMALIZER, oidRegistry );
-    }
-    
-    
     /**
      * Registers a new Normalizer with this registry.
      *
@@ -63,33 +41,7 @@
      * @throws NamingException if the Normalizer is already registered or
      * the registration operation is not supported
      */
-    public void register( Normalizer normalizer ) throws NamingException
-    {
-        String oid = normalizer.getOid();
-        
-        if ( byName.containsKey( oid ) )
-        {
-            String msg = type.name() + " with OID " + oid + " already registered!";
-            LOG.warn( msg );
-            throw new NamingException( msg );
-        }
-
-        byName.put( oid, normalizer );
-        
-        /*
-         * add the aliases/names to the name map along with their toLowerCase
-         * versions of the name: this is used to make sure name lookups work
-         */
-        for ( String name : normalizer.getNames() )
-        {
-            byName.put( StringTools.trim( StringTools.toLowerCase( name ) ), normalizer );
-        }
-        
-        if ( LOG.isDebugEnabled() )
-        {
-            LOG.debug( "registered " + normalizer.getName() + " for OID {}", oid );
-        }
-    }
+    void register( Normalizer normalizer ) throws NamingException;
 
 
     /**
@@ -99,29 +51,7 @@
      * @param numericOid the numeric identifier
      * @throws NamingException if the numeric identifier is invalid
      */
-    public Normalizer unregister( String numericOid ) throws NamingException
-    {
-        if ( !OID.isOID( numericOid ) )
-        {
-            String msg = "OID " + numericOid + " is not a numeric OID";
-            LOG.error( msg );
-            throw new NamingException( msg );
-        }
-
-        Normalizer normalizer = byName.remove( numericOid );
-        
-        for ( String name : normalizer.getNames() )
-        {
-            byName.remove( name );
-        }
-        
-        if ( DEBUG )
-        {
-            LOG.debug( "Removed {} with oid {} from the registry", normalizer, numericOid );
-        }
-        
-        return normalizer;
-    }
+    Normalizer unregister( String numericOid ) throws NamingException;
     
     
     /**
@@ -130,47 +60,17 @@
      * 
      * @param schemaName the name of the schema whose Normalizers will be removed from
      */
-    public void unregisterSchemaElements( String schemaName ) throws NamingException
-    {
-        if ( schemaName == null )
-        {
-            return;
-        }
-        
-        // Loop on all the SchemaObjects stored and remove those associated
-        // with the give schemaName
-        for ( Normalizer normalizer : this )
-        {
-            if ( schemaName.equalsIgnoreCase( normalizer.getSchemaName() ) )
-            {
-                String oid = normalizer.getOid();
-                SchemaObject removed = unregister( oid );
-                
-                if ( DEBUG )
-                {
-                    LOG.debug( "Removed {} with oid {} from the registry", removed, oid );
-                }
-            }
-        }
-    }
+    void unregisterSchemaElements( String schemaName ) throws NamingException;
     
     
     /**
      * Clone the NormalizerRegistry
      */
-    public NormalizerRegistry clone() throws CloneNotSupportedException
-    {
-        NormalizerRegistry clone = (NormalizerRegistry)super.clone();
-        
-        return clone;
-    }
+    NormalizerRegistry clone() throws CloneNotSupportedException;
     
     
     /**
      *  @return The number of Normalizers stored
      */
-    public int size()
-    {
-        return byName.values().size();
-    }
+    int size();
 }

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=833647&r1=833646&r2=833647&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 Nov  7 07:57:34 2009
@@ -20,21 +20,12 @@
 package org.apache.directory.shared.ldap.schema.registries;
 
 
-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 javax.naming.NamingException;
-import javax.naming.directory.NoSuchAttributeException;
 
 import org.apache.directory.shared.ldap.schema.ObjectClass;
-import org.apache.directory.shared.ldap.schema.SchemaObjectType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -43,29 +34,9 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class ObjectClassRegistry extends SchemaObjectRegistry<ObjectClass>
+public interface ObjectClassRegistry extends SchemaObjectRegistry<ObjectClass>,
+    Iterable<ObjectClass>, Cloneable
 {
-    /** static class logger */
-    private static final Logger LOG = LoggerFactory.getLogger( ObjectClassRegistry.class );
-
-    /** Speedup for DEBUG mode */
-    private static final boolean IS_DEBUG = LOG.isDebugEnabled();
-
-    /** maps OIDs to a Set of descendants for that OID */
-    private Map<String,Set<ObjectClass>> oidToDescendants;
-
-    /**
-     * Creates a new default ObjectClassRegistry instance.
-     * 
-     * @param oidRegistry The global OID registry 
-     */
-    public ObjectClassRegistry( OidRegistry oidRegistry )
-    {
-        super( SchemaObjectType.OBJECT_CLASS, oidRegistry );
-        oidToDescendants = new HashMap<String,Set<ObjectClass>>();
-    }
-    
-    
     /**
      * Quick lookup to see if an objectClass has descendants.
      * 
@@ -75,19 +46,7 @@
      * @throws NamingException if the ancestor ObjectClass cannot be 
      * discerned from the ancestorId supplied
      */
-    public boolean hasDescendants( String ancestorId ) throws NamingException
-    {
-        try
-        {
-            String oid = getOidByName( ancestorId );
-            Set<ObjectClass> descendants = oidToDescendants.get( oid );
-            return (descendants != null) && !descendants.isEmpty();
-        }
-        catch ( NamingException ne )
-        {
-            throw new NoSuchAttributeException( ne.getMessage() );
-        }
-    }
+    boolean hasDescendants( String ancestorId ) throws NamingException;
     
     
     /**
@@ -100,26 +59,7 @@
      * @throws NamingException if the ancestor ObjectClass cannot be 
      * discerned from the ancestorId supplied
      */
-    @SuppressWarnings("unchecked")
-    public Iterator<ObjectClass> descendants( String ancestorId ) throws NamingException
-    {
-        try
-        {
-            String oid = getOidByName( ancestorId );
-            Set<ObjectClass> descendants = oidToDescendants.get( oid );
-            
-            if ( descendants == null )
-            {
-                return Collections.EMPTY_SET.iterator();
-            }
-            
-            return descendants.iterator();
-        }
-        catch ( NamingException ne )
-        {
-            throw new NoSuchAttributeException( ne.getMessage() );
-        }
-    }
+    Iterator<ObjectClass> descendants( String ancestorId ) throws NamingException;
 
     
     /**
@@ -129,41 +69,8 @@
      * @param attributeType The ObjectClass to register
      * @throws NamingException If something went wrong
      */
-    public void registerDescendants( ObjectClass objectClass, List<ObjectClass> ancestors ) 
-        throws NamingException
-    {
-        // add this attribute to descendant list of other attributes in superior chain
-        if ( ( ancestors == null ) || ( ancestors.size() == 0 ) ) 
-        {
-            return;
-        }
-        
-        for ( ObjectClass ancestor : ancestors )
-        {
-            // Get the ancestor's descendant, if any
-            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 );
-                oidToDescendants.put( ancestor.getOid(), descendants );
-            }
-            
-            // Add the current ObjectClass as a descendant
-            descendants.add( objectClass );
-            
-            try
-            {
-                // And recurse until we reach the top of the hierarchy
-                registerDescendants( objectClass, ancestor.getSuperiors() );
-            }
-            catch ( NamingException ne )
-            {
-                throw new NoSuchAttributeException( ne.getMessage() );
-            }
-        }
-    }
+    void registerDescendants( ObjectClass objectClass, List<ObjectClass> ancestors ) 
+        throws NamingException;
     
     
     /**
@@ -174,41 +81,8 @@
      * @param ancestor its ancestor 
      * @throws NamingException If something went wrong
      */
-    public void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors ) 
-        throws NamingException
-    {
-        // add this attribute to descendant list of other attributes in superior chain
-        if ( ( ancestors == null ) || ( ancestors.size() == 0 ) ) 
-        {
-            return;
-        }
-        
-        for ( ObjectClass ancestor : ancestors )
-        {
-            // Get the ancestor's descendant, if any
-            Set<ObjectClass> descendants = oidToDescendants.get( ancestor.getOid() );
-    
-            if ( descendants != null )
-            {
-                descendants.remove( attributeType );
-                
-                if ( descendants.size() == 0 )
-                {
-                    oidToDescendants.remove( descendants );
-                }
-            }
-            
-            try
-            {
-                // And recurse until we reach the top of the hierarchy
-                unregisterDescendants( attributeType, ancestor.getSuperiors() );
-            }
-            catch ( NamingException ne )
-            {
-                throw new NoSuchAttributeException( ne.getMessage() );
-            }
-        }
-    }
+    void unregisterDescendants( ObjectClass attributeType, List<ObjectClass> ancestors ) 
+        throws NamingException;
     
     
     /**
@@ -218,26 +92,7 @@
      * @throws NamingException if the ObjectClass is already registered or
      * the registration operation is not supported
      */
-    public void register( ObjectClass objectClass ) throws NamingException
-    {
-        try
-        {
-            super.register( objectClass );
-            
-            // Register this ObjectClass into the Descendant map
-            registerDescendants( objectClass, objectClass.getSuperiors() );
-            
-            // Internally associate the OID to the registered AttributeType
-            if ( IS_DEBUG )
-            {
-                LOG.debug( "registred objectClass: {}", objectClass );
-            }
-        }
-        catch ( NamingException ne )
-        {
-            throw new NoSuchAttributeException( ne.getMessage() );
-        }
-    }
+    void register( ObjectClass objectClass ) throws NamingException;
     
     
     /**
@@ -246,48 +101,17 @@
      * @param numericOid the numeric identifier
      * @throws NamingException if the numeric identifier is invalid
      */
-    public ObjectClass unregister( String numericOid ) throws NamingException
-    {
-        try
-        {
-            ObjectClass removed = super.unregister( numericOid );
-    
-            // 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
-            oidToDescendants.remove( numericOid );
-            
-            // Now recurse if needed
-            unregisterDescendants( removed, removed.getSuperiors() );
-            
-            return removed;
-        }
-        catch ( NamingException ne )
-        {
-            throw new NoSuchAttributeException( ne.getMessage() );
-        }
-    }
+    ObjectClass unregister( String numericOid ) throws NamingException;
     
     
     /**
      * 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;
-    }
+    ObjectClassRegistry clone() throws CloneNotSupportedException;
     
     
     /**
      *  @return The number of ObjectClasses stored
      */
-    public int size()
-    {
-        return oidRegistry.size();
-    }
+    int size();
 }

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=833647&r1=833646&r2=833647&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 Nov  7 07:57:34 2009
@@ -137,17 +137,17 @@
     public Registries()
     {
         this.oidRegistry = new OidRegistry();
-        attributeTypeRegistry = new AttributeTypeRegistry( oidRegistry );
-        comparatorRegistry = new ComparatorRegistry( oidRegistry );
-        ditContentRuleRegistry = new DITContentRuleRegistry( oidRegistry );
-        ditStructureRuleRegistry = new DITStructureRuleRegistry( oidRegistry );
-        ldapSyntaxRegistry = new LdapSyntaxRegistry( oidRegistry );
-        matchingRuleRegistry = new MatchingRuleRegistry( oidRegistry );
-        matchingRuleUseRegistry = new MatchingRuleUseRegistry( oidRegistry );
-        nameFormRegistry = new NameFormRegistry( oidRegistry );
-        normalizerRegistry = new NormalizerRegistry( oidRegistry );
-        objectClassRegistry = new ObjectClassRegistry( oidRegistry );
-        syntaxCheckerRegistry = new SyntaxCheckerRegistry( oidRegistry );
+        attributeTypeRegistry = new DefaultAttributeTypeRegistry( oidRegistry );
+        comparatorRegistry = new DefaultComparatorRegistry( oidRegistry );
+        ditContentRuleRegistry = new DefaultDITContentRuleRegistry( oidRegistry );
+        ditStructureRuleRegistry = new DefaultDITStructureRuleRegistry( oidRegistry );
+        ldapSyntaxRegistry = new DefaultLdapSyntaxRegistry( oidRegistry );
+        matchingRuleRegistry = new DefaultMatchingRuleRegistry( oidRegistry );
+        matchingRuleUseRegistry = new DefaultMatchingRuleUseRegistry( oidRegistry );
+        nameFormRegistry = new DefaultNameFormRegistry( oidRegistry );
+        normalizerRegistry = new DefaultNormalizerRegistry( oidRegistry );
+        objectClassRegistry = new DefaultObjectClassRegistry( oidRegistry );
+        syntaxCheckerRegistry = new DefaultSyntaxCheckerRegistry( oidRegistry );
         schemaObjectsBySchemaName = new HashMap<String, Set<SchemaWrapper>>();
         usedBy = new HashMap<SchemaWrapper, Set<SchemaWrapper>>();
         using = new HashMap<SchemaWrapper, Set<SchemaWrapper>>();
@@ -977,6 +977,10 @@
 	    // First call the specific registry's register method
 	    switch ( schemaObject.getObjectType() )
 	    {
+	        case ATTRIBUTE_TYPE :
+	            attributeTypeRegistry.register( (AttributeType)schemaObject );
+	            break;
+	            
             case DIT_CONTENT_RULE : 
                 ditContentRuleRegistry.register( (DITContentRule)schemaObject );
                 break;
@@ -1046,57 +1050,58 @@
 	 * @param schemaObject The SchemaObject we want to deregister
 	 * @throws NamingException If the removal failed
 	 */
-    public void unregister( SchemaObject schemaObject ) throws NamingException
+    public SchemaObject unregister( SchemaObject schemaObject ) throws NamingException
     {
         LOG.debug( "Unregistering {}:{}", schemaObject.getObjectType(), schemaObject.getOid() );
 
         String oid = schemaObject.getOid();
+        SchemaObject unregistered = null;
         
         // First call the specific registry's register method
         switch ( schemaObject.getObjectType() )
         {
             case ATTRIBUTE_TYPE : 
-                attributeTypeRegistry.unregister( oid );
+                unregistered = attributeTypeRegistry.unregister( oid );
                 break;
                 
             case COMPARATOR : 
-                comparatorRegistry.unregister( oid );
+                unregistered = comparatorRegistry.unregister( oid );
                 break;
                 
             case DIT_CONTENT_RULE : 
-                ditContentRuleRegistry.unregister( oid );
+                unregistered = ditContentRuleRegistry.unregister( oid );
                 break;
                 
             case DIT_STRUCTURE_RULE : 
-                ditStructureRuleRegistry.unregister( oid );
+                unregistered = ditStructureRuleRegistry.unregister( oid );
                 break;
                 
             case LDAP_SYNTAX : 
-                ldapSyntaxRegistry.unregister( oid );
+                unregistered = ldapSyntaxRegistry.unregister( oid );
                 break;
                 
             case MATCHING_RULE : 
-                matchingRuleRegistry.unregister( oid );
+                unregistered = matchingRuleRegistry.unregister( oid );
                 break;
                 
             case MATCHING_RULE_USE : 
-                matchingRuleUseRegistry.unregister( oid );
+                unregistered = matchingRuleUseRegistry.unregister( oid );
                 break;
                 
             case NAME_FORM : 
-                nameFormRegistry.unregister( oid );
+                unregistered = nameFormRegistry.unregister( oid );
                 break;
                 
             case NORMALIZER : 
-                normalizerRegistry.unregister( oid );
+                unregistered = normalizerRegistry.unregister( oid );
                 break;
                 
             case OBJECT_CLASS : 
-                objectClassRegistry.unregister( oid );
+                unregistered = objectClassRegistry.unregister( oid );
                 break;
                 
             case SYNTAX_CHECKER : 
-                syntaxCheckerRegistry.unregister( oid );
+                unregistered = syntaxCheckerRegistry.unregister( oid );
                 break;
         }
         
@@ -1117,6 +1122,8 @@
             LOG.debug( "Unregistering of {}:{} failed, not found in Registries", 
                 schemaObject.getObjectType(), schemaObject.getOid() );
         }
+        
+        return unregistered;
     }
     
     
@@ -1779,7 +1786,7 @@
         Registries clone = (Registries)super.clone();
         
         // We have to clone every SchemaObject registries now
-        clone.attributeTypeRegistry = attributeTypeRegistry.clone();
+        clone.attributeTypeRegistry = (AttributeTypeRegistry)attributeTypeRegistry.clone();
         clone.comparatorRegistry = comparatorRegistry.clone();
         clone.ditContentRuleRegistry = ditContentRuleRegistry.clone();
         clone.ditStructureRuleRegistry = ditStructureRuleRegistry.clone();

Modified: directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java?rev=833647&r1=833646&r2=833647&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/main/java/org/apache/directory/shared/ldap/schema/registries/SchemaObjectRegistry.java Sat Nov  7 07:57:34 2009
@@ -20,18 +20,12 @@
 package org.apache.directory.shared.ldap.schema.registries;
 
 
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.Map;
 
 import javax.naming.NamingException;
 
-import org.apache.directory.shared.asn1.primitives.OID;
 import org.apache.directory.shared.ldap.schema.SchemaObject;
 import org.apache.directory.shared.ldap.schema.SchemaObjectType;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -40,35 +34,8 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class SchemaObjectRegistry<T extends SchemaObject> implements Iterable<T>, Cloneable
+public interface SchemaObjectRegistry<T extends SchemaObject>
 {
-    /** static class logger */
-    private static final Logger LOG = LoggerFactory.getLogger( SchemaObjectRegistry.class );
-
-    /** A speedup for debug */
-    private static final boolean DEBUG = LOG.isDebugEnabled();
-    
-    /** a map of SchemaObject looked up by name */
-    protected Map<String, T> byName;
-    
-    /** The SchemaObject type */
-    protected SchemaObjectType type;
-
-    /** the global OID Registry */
-    protected OidRegistry oidRegistry;
-    
-
-    /**
-     * Creates a new SchemaObjectRegistry instance.
-     */
-    protected SchemaObjectRegistry( SchemaObjectType schemaObjectType, OidRegistry oidRegistry )
-    {
-        byName = new HashMap<String, T>();
-        type = schemaObjectType;
-        this.oidRegistry = oidRegistry;
-    }
-    
-    
     /**
      * Checks to see if an SchemaObject exists in the registry, by its
      * OID or name. 
@@ -77,15 +44,7 @@
      * @return true if a SchemaObject definition exists for the oid, false
      * otherwise
      */
-    public boolean contains( String oid )
-    {
-        if ( !byName.containsKey( oid ) )
-        {
-            return byName.containsKey( StringTools.toLowerCase( oid ) );
-        }
-        
-        return true;
-    }
+    boolean contains( String oid );
     
     
     /**
@@ -95,26 +54,7 @@
      * @return the schema name
      * @throws NamingException if the schema object does not exist
      */
-    public String getSchemaName( String oid ) throws NamingException
-    {
-        if ( ! OID.isOID( oid ) )
-        {
-            String msg = "Looks like the arg is not a numeric OID";
-            LOG.warn( msg );
-            throw new NamingException( msg );
-        }
-        
-        SchemaObject schemaObject = byName.get( oid );
-
-        if ( schemaObject != null )
-        {
-            return schemaObject.getSchemaName();
-        }
-        
-        String msg = "OID " + oid + " not found in oid to schema name map!";
-        LOG.warn( msg );
-        throw new NamingException( msg );
-    }
+    String getSchemaName( String oid ) throws NamingException;
 
     
     /**
@@ -122,24 +62,9 @@
      *
      * @param originalSchemaName The original Schema name
      * @param newSchemaName The new Schema name
+     * @throws NamingException if the schema object does not exist
      */
-    public void renameSchema( String originalSchemaName, String newSchemaName )
-    {
-        // Loop on all the SchemaObjects stored and remove those associated
-        // with the give schemaName
-        for ( T schemaObject : this )
-        {
-            if ( originalSchemaName.equalsIgnoreCase( schemaObject.getSchemaName() ) )
-            {
-                schemaObject.setSchemaName( newSchemaName );
-                
-                if ( DEBUG )
-                {
-                    LOG.debug( "Renamed {} schemaName to {}", schemaObject, newSchemaName );
-                }
-            }
-        }
-    }
+    void renameSchema( String originalSchemaName, String newSchemaName ) throws NamingException;
     
     
     /**
@@ -147,10 +72,7 @@
      *
      * @return an Iterator of homogeneous schema objects
      */
-    public Iterator<T> iterator()
-    {
-        return byName.values().iterator();
-    }
+    Iterator<T> iterator();
 
     
     /**
@@ -158,10 +80,7 @@
      *
      * @return an Iterator of OIDs
      */
-    public Iterator<String> oidsIterator()
-    {
-        return byName.keySet().iterator();
-    }
+    Iterator<String> oidsIterator();
 
     
     /**
@@ -171,35 +90,7 @@
      * @return the SchemaObject instance for the id
      * @throws NamingException if the SchemaObject does not exist
      */
-    public T lookup( String oid ) throws NamingException
-    {
-        if ( oid == null )
-        {
-            return null;
-        }
-        
-        T schemaObject = byName.get( oid );
-        
-        if ( schemaObject == null )
-        {
-            // let's try with trimming and lowercasing now
-            schemaObject = byName.get( StringTools.trim( StringTools.toLowerCase( oid ) ) );
-        }
-
-        if ( schemaObject == null )
-        {
-            String msg = type.name() + " for OID " + oid + " does not exist!";
-            LOG.debug( msg );
-            throw new NamingException( msg );
-        }
-
-        if ( DEBUG )
-        {
-    		LOG.debug( "Found {} with oid: {}", schemaObject, oid );
-        }
-        
-        return schemaObject;
-    }
+    T lookup( String oid ) throws NamingException;
     
     
     /**
@@ -209,39 +100,7 @@
      * @throws NamingException if the SchemaObject is already registered or
      * the registration operation is not supported
      */
-    public void register( T schemaObject ) throws NamingException
-    {
-        String oid = schemaObject.getOid();
-        
-        if ( schemaObject.isEnabled() )
-        {
-            if ( byName.containsKey( oid ) )
-            {
-                String msg = type.name() + " with OID " + oid + " already registered!";
-                LOG.warn( msg );
-                throw new NamingException( msg );
-            }
-    
-            byName.put( oid, schemaObject );
-            
-            /*
-             * add the aliases/names to the name map along with their toLowerCase
-             * versions of the name: this is used to make sure name lookups work
-             */
-            for ( String name : schemaObject.getNames() )
-            {
-            	byName.put( StringTools.trim( StringTools.toLowerCase( name ) ), schemaObject );
-            }
-        }
-        
-        if ( LOG.isDebugEnabled() )
-        {
-            LOG.debug( "registered " + schemaObject.getName() + " for OID {}", oid );
-        }
-        
-        // And register the oid -> schemaObject relation
-        oidRegistry.register( schemaObject );
-    }
+    void register( T schemaObject ) throws NamingException;
 
 
     /**
@@ -251,32 +110,7 @@
      * @param numericOid the numeric identifier
      * @throws NamingException if the numeric identifier is invalid
      */
-    public T unregister( String numericOid ) throws NamingException
-    {
-        if ( !OID.isOID( numericOid ) )
-        {
-            String msg = "OID " + numericOid + " is not a numeric OID";
-            LOG.error( msg );
-            throw new NamingException( msg );
-        }
-
-        T schemaObject = byName.remove( numericOid );
-        
-        for ( String name : schemaObject.getNames() )
-        {
-            byName.remove( name );
-        }
-        
-        // And remove the SchemaObject from the oidRegistry
-        oidRegistry.unregister( numericOid );
-        
-        if ( DEBUG )
-        {
-            LOG.debug( "Removed {} with oid {} from the registry", schemaObject, numericOid );
-        }
-        
-        return schemaObject;
-    }
+    T unregister( String numericOid ) throws NamingException;
     
     
     /**
@@ -285,30 +119,7 @@
      * 
      * @param schemaName the name of the schema whose SchemaObjects will be removed from
      */
-    public void unregisterSchemaElements( String schemaName ) throws NamingException
-    {
-        if ( schemaName == null )
-        {
-            return;
-        }
-        
-        // Loop on all the SchemaObjects stored and remove those associated
-        // with the give schemaName
-        for ( T schemaObject : this )
-        {
-            if ( schemaName.equalsIgnoreCase( schemaObject.getSchemaName() ) )
-            {
-                String oid = schemaObject.getOid();
-                SchemaObject removed = unregister( oid );
-                oidRegistry.unregister( oid );
-                
-                if ( DEBUG )
-                {
-                    LOG.debug( "Removed {} with oid {} from the registry", removed, oid );
-                }
-            }
-        }
-    }
+    void unregisterSchemaElements( String schemaName ) throws NamingException;
     
     
     /**
@@ -322,27 +133,7 @@
      * @return The numericOID associated with this name
      * @throws NamingException If the OID can't be found
      */
-    public String getOidByName( String name ) throws NamingException
-    {
-        T schemaObject = byName.get( name );
-
-    	if ( schemaObject == null )
-    	{
-    		// last resort before giving up check with lower cased version
-        	String lowerCased = name.toLowerCase();
-    		
-        	schemaObject = byName.get( lowerCased );
-        	
-        	// ok this name is not for a schema object in the registry
-    		if ( schemaObject == null )
-    		{
-    	        throw new NamingException( "Can't find an OID for the name " + name );
-    		}
-    	}
-    	
-    	// we found the schema object by key on the first lookup attempt
-        return schemaObject.getOid();
-    }
+    String getOidByName( String name ) throws NamingException;
 
 
     /**
@@ -355,48 +146,23 @@
      * @return true if the name or it's cannonical form is mapped to a 
      * schemaObject in this registry, false otherwise.
      */
-    public boolean containsName( String name )
-    {
-    	if ( ! byName.containsKey( name ) )
-    	{
-    		// last resort before giving up check with lower cased version
-        	return byName.containsKey( name.toLowerCase() );
-    	}
-
-        return true;
-    }
+    boolean containsName( String name );
     
 
     /**
-     * Clone a SchemaObjectRegistry
-     */
-    protected SchemaObjectRegistry<T> clone() throws CloneNotSupportedException
-    {
-        // Clone the base object
-        SchemaObjectRegistry<T> clone = (SchemaObjectRegistry<T>)super.clone();
-        
-        // Clone the byName Map
-        clone.byName = new HashMap<String, T>();
-        
-        for ( String key : byName.keySet() )
-        {
-            // Clone each SchemaObject
-            SchemaObject value = byName.get( key );
-            clone.byName.put( key, (T)value.clone() );
-        }
-        
-        // Clone the oidRegistry
-        clone.oidRegistry = oidRegistry.clone();
-        
-        return clone;
-    }
+     * Clone a DefaultSchemaObjectRegistry
+     */
+    SchemaObjectRegistry<T> clone() throws CloneNotSupportedException;
 
 
     /**
      * @return the type
      */
-    public SchemaObjectType getType()
-    {
-        return type;
-    }
+    SchemaObjectType getType();
+
+
+    /**
+     *  @return The number of AttributeType stored
+     */
+    int size();
 }

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=833647&r1=833646&r2=833647&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 Nov  7 07:57:34 2009
@@ -22,13 +22,7 @@
 
 import javax.naming.NamingException;
 
-import org.apache.directory.shared.asn1.primitives.OID;
-import org.apache.directory.shared.ldap.schema.SchemaObject;
-import org.apache.directory.shared.ldap.schema.SchemaObjectType;
 import org.apache.directory.shared.ldap.schema.SyntaxChecker;
-import org.apache.directory.shared.ldap.util.StringTools;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -37,25 +31,9 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$
  */
-public class SyntaxCheckerRegistry extends  SchemaObjectRegistry<SyntaxChecker>
+public interface SyntaxCheckerRegistry extends SchemaObjectRegistry<SyntaxChecker>,
+    Iterable<SyntaxChecker>, Cloneable
 {
-    /** static class logger */
-    private static final Logger LOG = LoggerFactory.getLogger( SyntaxCheckerRegistry.class );
-
-    /** A speedup for debug */
-    private static final boolean DEBUG = LOG.isDebugEnabled();
-    
-    /**
-     * Creates a new default SyntaxCheckerRegistry instance.
-     * 
-     * @param oidRegistry The global OID registry 
-     */
-    public SyntaxCheckerRegistry( OidRegistry oidRegistry )
-    {
-        super( SchemaObjectType.SYNTAX_CHECKER, oidRegistry );
-    }
-    
-    
     /**
      * Registers a new SyntaxChecker with this registry.
      *
@@ -63,33 +41,7 @@
      * @throws NamingException if the SyntaxChecker is already registered or
      * the registration operation is not supported
      */
-    public void register( SyntaxChecker syntaxChecker ) throws NamingException
-    {
-        String oid = syntaxChecker.getOid();
-        
-        if ( byName.containsKey( oid ) )
-        {
-            String msg = type.name() + " with OID " + oid + " already registered!";
-            LOG.warn( msg );
-            //throw new NamingException( msg );
-        }
-
-        byName.put( oid, syntaxChecker );
-        
-        /*
-         * add the aliases/names to the name map along with their toLowerCase
-         * versions of the name: this is used to make sure name lookups work
-         */
-        for ( String name : syntaxChecker.getNames() )
-        {
-            byName.put( StringTools.trim( StringTools.toLowerCase( name ) ), syntaxChecker );
-        }
-        
-        if ( LOG.isDebugEnabled() )
-        {
-            LOG.debug( "registered " + syntaxChecker.getName() + " for OID {}", oid );
-        }
-    }
+    void register( SyntaxChecker syntaxChecker ) throws NamingException;
 
 
     /**
@@ -99,29 +51,7 @@
      * @param numericOid the numeric identifier
      * @throws NamingException if the numeric identifier is invalid
      */
-    public SyntaxChecker unregister( String numericOid ) throws NamingException
-    {
-        if ( !OID.isOID( numericOid ) )
-        {
-            String msg = "OID " + numericOid + " is not a numeric OID";
-            LOG.error( msg );
-            throw new NamingException( msg );
-        }
-
-        SyntaxChecker syntaxChecker = byName.remove( numericOid );
-        
-        for ( String name : syntaxChecker.getNames() )
-        {
-            byName.remove( name );
-        }
-        
-        if ( DEBUG )
-        {
-            LOG.debug( "Removed {} with oid {} from the registry", syntaxChecker, numericOid );
-        }
-        
-        return syntaxChecker;
-    }
+    SyntaxChecker unregister( String numericOid ) throws NamingException;
     
     
     /**
@@ -130,47 +60,17 @@
      * 
      * @param schemaName the name of the schema whose SyntaxCheckers will be removed from
      */
-    public void unregisterSchemaElements( String schemaName ) throws NamingException
-    {
-        if ( schemaName == null )
-        {
-            return;
-        }
-        
-        // Loop on all the SchemaObjects stored and remove those associated
-        // with the give schemaName
-        for ( SyntaxChecker syntaxChecker : this )
-        {
-            if ( schemaName.equalsIgnoreCase( syntaxChecker.getSchemaName() ) )
-            {
-                String oid = syntaxChecker.getOid();
-                SchemaObject removed = unregister( oid );
-                
-                if ( DEBUG )
-                {
-                    LOG.debug( "Removed {} with oid {} from the registry", removed, oid );
-                }
-            }
-        }
-    }
+    void unregisterSchemaElements( String schemaName ) throws NamingException;
     
     
     /**
      * Clone the SyntaxCheckerRegistry
      */
-    public SyntaxCheckerRegistry clone() throws CloneNotSupportedException
-    {
-        SyntaxCheckerRegistry clone = (SyntaxCheckerRegistry)super.clone();
-        
-        return clone;
-    }
+    SyntaxCheckerRegistry clone() throws CloneNotSupportedException;
     
     
     /**
      *  @return The number of SyntaxCheckers stored
      */
-    public int size()
-    {
-        return byName.values().size();
-    }
+    int size();
 }

Modified: directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java?rev=833647&r1=833646&r2=833647&view=diff
==============================================================================
--- directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java (original)
+++ directory/shared/branches/shared-schema/ldap/src/test/java/org/apache/directory/shared/ldap/schema/registries/AttributeTypeRegistryTest.java Sat Nov  7 07:57:34 2009
@@ -27,8 +27,6 @@
 import javax.naming.NamingException;
 
 import org.apache.directory.shared.ldap.schema.AttributeType;
-import org.apache.directory.shared.ldap.schema.registries.AttributeTypeRegistry;
-import org.apache.directory.shared.ldap.schema.registries.OidRegistry;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -46,7 +44,7 @@
     @Before
     public void setup()
     {
-        atRegistry = new AttributeTypeRegistry( new OidRegistry() );
+        atRegistry = new DefaultAttributeTypeRegistry( new OidRegistry() );
     }
     
     
@@ -114,7 +112,7 @@
         atRegistry.register( at1 );
         
         // Clone the ATRegistry
-        AttributeTypeRegistry clone = atRegistry.clone();
+        AttributeTypeRegistry clone = (AttributeTypeRegistry)atRegistry.clone();
         
         assertEquals( at0, clone.lookup( "1.1" ) );
         assertEquals( at1, clone.lookup( "1.2" ) );



Mime
View raw message