directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seelm...@apache.org
Subject svn commit: r937657 - in /directory/apacheds/trunk: avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/ jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/ ldif-partition/src/main/java/org/apache...
Date Sat, 24 Apr 2010 17:46:50 GMT
Author: seelmann
Date: Sat Apr 24 17:46:50 2010
New Revision: 937657

URL: http://svn.apache.org/viewvc?rev=937657&view=rev
Log:
Created AbstractStore class for common code of all Store implementations, moved some properties
to AbstractStore

Added:
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Modified:
    directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
    directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
    directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java
    directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java

Modified: directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java?rev=937657&r1=937656&r2=937657&view=diff
==============================================================================
--- directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
(original)
+++ directory/apacheds/trunk/avl-partition/src/main/java/org/apache/directory/server/core/partition/avl/AvlStore.java
Sat Apr 24 17:46:50 2010
@@ -33,18 +33,18 @@ import org.apache.directory.server.const
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.core.partition.impl.btree.LongComparator;
 import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.server.xdbm.AbstractStore;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.IndexNotFoundException;
-import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.Cursor;
-import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.EntryAttribute;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
 import org.apache.directory.shared.ldap.entry.ServerEntry;
+import org.apache.directory.shared.ldap.entry.StringValue;
 import org.apache.directory.shared.ldap.entry.Value;
 import org.apache.directory.shared.ldap.exception.LdapException;
 import org.apache.directory.shared.ldap.exception.LdapInvalidDnException;
@@ -72,7 +72,7 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class AvlStore<E> implements Store<E, Long>
+public class AvlStore<E> extends AbstractStore<E, Long>
 {
     /** static logger */
     private static final Logger LOG = LoggerFactory.getLogger( AvlStore.class );
@@ -123,12 +123,6 @@ public class AvlStore<E> implements Stor
     /** a map of attributeType numeric ID to system userIndices */
     private Map<String, AvlIndex<? extends Object, E>> systemIndices = new HashMap<String,
AvlIndex<? extends Object, E>>();
 
-    /** true if initialized */
-    private boolean initialized;
-
-    /** A pointer on the schemaManager */
-    private SchemaManager schemaManager;
-
     /** 
      * TODO we need to check out why we have so many suffix 
      * dn and string accessor/mutators on both Store and Partition
@@ -138,9 +132,6 @@ public class AvlStore<E> implements Stor
      */
     private DN suffixDn;
 
-    private String name;
-
-
     /**
      * {@inheritDoc}
      */
@@ -426,15 +417,6 @@ public class AvlStore<E> implements Stor
     /**
      * {@inheritDoc}
      */
-    public String getName()
-    {
-        return name;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public Index<String, E, Long> getNdnIndex()
     {
         return ndnIdx;
@@ -873,15 +855,6 @@ public class AvlStore<E> implements Stor
     /**
      * {@inheritDoc}
      */
-    public boolean isInitialized()
-    {
-        return initialized;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public IndexCursor<Long, E, Long> list( Long id ) throws Exception
     {
         IndexCursor<Long, E, Long> cursor = oneLevelIdx.forwardCursor( id );
@@ -1538,16 +1511,6 @@ public class AvlStore<E> implements Stor
     /**
      * {@inheritDoc}
      */
-    public void setName( String name )
-    {
-        protect( "name" );
-        this.name = name;
-    }
-
-
-    /**
-     * {@inheritDoc}
-     */
     public void setNdnIndex( Index<String, E, Long> index ) throws Exception
     {
         protect( "ndnIndex" );
@@ -1737,14 +1700,6 @@ public class AvlStore<E> implements Stor
     }
 
 
-    private void protect( String method )
-    {
-        if ( initialized )
-        {
-            throw new IllegalStateException( I18n.err( I18n.ERR_222, method ) );
-        }
-    }
-
 
     /**
      * {@inheritDoc}
@@ -2139,18 +2094,7 @@ public class AvlStore<E> implements Stor
     }
 
 
-    public void setSyncOnWrite( boolean sync )
-    {
-        // do nothing
-    }
-
-
-    public void setWorkingDirectory( File wkDir )
-    {
-        //do nothing
-    }
-
-
+    @Override
     public File getWorkingDirectory()
     {
         // returns null always
@@ -2164,12 +2108,6 @@ public class AvlStore<E> implements Stor
     }
 
 
-    public void setCacheSize( int size )
-    {
-        // do nothing
-    }
-
-
     public void setObjectClassIndex( Index<String, E, Long> index )
     {
         protect( "objectClassIndex" );

Modified: directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java?rev=937657&r1=937656&r2=937657&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
(original)
+++ directory/apacheds/trunk/jdbm-store/src/main/java/org/apache/directory/server/core/partition/impl/btree/jdbm/JdbmStore.java
Sat Apr 24 17:46:50 2010
@@ -37,11 +37,11 @@ import jdbm.recman.CacheRecordManager;
 import org.apache.directory.server.constants.ApacheSchemaConstants;
 import org.apache.directory.server.core.entry.ClonedServerEntry;
 import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.server.xdbm.AbstractStore;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexEntry;
 import org.apache.directory.server.xdbm.IndexNotFoundException;
-import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.shared.ldap.MultiException;
 import org.apache.directory.shared.ldap.constants.SchemaConstants;
 import org.apache.directory.shared.ldap.cursor.Cursor;
@@ -67,14 +67,11 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 
-public class JdbmStore<E> implements Store<E, Long>
+public class JdbmStore<E> extends AbstractStore<E, Long>
 {
     /** static logger */
     private static final Logger LOG = LoggerFactory.getLogger( JdbmStore.class );
 
-    /** The default cache size is set to 10 000 objects */
-    static final int DEFAULT_CACHE_SIZE = 10000;
-
     /** the JDBM record manager used by this database */
     private RecordManager recMan;
 
@@ -84,9 +81,6 @@ public class JdbmStore<E> implements Sto
     /** the user provided suffix DN of this backend database */
     private DN upSuffix;
 
-    /** the working directory to use for files */
-    private File workingDirectory;
-
     /** the master table storing entries by primary key */
     private JdbmMasterTable<ServerEntry> master;
 
@@ -96,12 +90,6 @@ public class JdbmStore<E> implements Sto
     /** a map of attributeType numeric ID to system userIndices */
     private Map<String, Index<?, E, Long>> systemIndices = new HashMap<String,
Index<?, E, Long>>();
 
-    /** true if initialized */
-    private boolean initialized;
-
-    /** true if we sync disks on every write operation */
-    private boolean isSyncOnWrite = true;
-
     /** the relative distinguished name index */
     private JdbmRdnIndex<RDN, Long> rdnIdx;
     
@@ -138,15 +126,8 @@ public class JdbmStore<E> implements Sto
     private static AttributeType ENTRY_UUID_AT;
     private static AttributeType ALIASED_OBJECT_NAME_AT;
 
-    /** A pointer on the schemaManager */
-    private SchemaManager schemaManager;
-
     private DN contextEntryDn;
     private String suffixDn;
-    private int cacheSize = DEFAULT_CACHE_SIZE;
-    private String name;
-
-
     // ------------------------------------------------------------------------
     // C O N S T R U C T O R S
     // ------------------------------------------------------------------------
@@ -161,26 +142,6 @@ public class JdbmStore<E> implements Sto
     // -----------------------------------------------------------------------
     // C O N F I G U R A T I O N   M E T H O D S
     // -----------------------------------------------------------------------
-    private void protect( String property )
-    {
-        if ( initialized )
-        {
-            throw new IllegalStateException( I18n.err( I18n.ERR_576, property ) );
-        }
-    }
-
-
-    public void setWorkingDirectory( File workingDirectory )
-    {
-        protect( "workingDirectory" );
-        this.workingDirectory = workingDirectory;
-    }
-
-
-    public File getWorkingDirectory()
-    {
-        return workingDirectory;
-    }
 
 
     public void setSuffixDn( String suffixDn )
@@ -196,49 +157,6 @@ public class JdbmStore<E> implements Sto
     }
 
 
-    public void setSyncOnWrite( boolean isSyncOnWrite )
-    {
-        protect( "syncOnWrite" );
-        this.isSyncOnWrite = isSyncOnWrite;
-    }
-
-
-    public boolean isSyncOnWrite()
-    {
-        return isSyncOnWrite;
-    }
-
-
-    public void setCacheSize( int cacheSize )
-    {
-        protect( "cacheSize" );
-        this.cacheSize = cacheSize;
-    }
-
-
-    public int getCacheSize()
-    {
-        return cacheSize;
-    }
-
-
-    public void setName( String name )
-    {
-        protect( "name" );
-        this.name = name;
-    }
-
-
-    public String getName()
-    {
-        return name;
-    }
-
-
-    // -----------------------------------------------------------------------
-    // E N D   C O N F I G U R A T I O N   M E T H O D S
-    // -----------------------------------------------------------------------
-
     public Long getDefaultId()
     {
         return 1L;
@@ -516,17 +434,6 @@ public class JdbmStore<E> implements Sto
 
 
     /**
-     * Gets whether the store is initialized.
-     *
-     * @return true if the partition store is initialized
-     */
-    public boolean isInitialized()
-    {
-        return initialized;
-    }
-
-
-    /**
      * This method is called when the synch thread is waking up, to write
      * the modified data.
      * 
@@ -2338,12 +2245,4 @@ public class JdbmStore<E> implements Sto
         }
     }
 
-
-    /**
-     * @param schemaManager the schemaManager to set
-     */
-    public void setSchemaManager( SchemaManager schemaManager )
-    {
-        this.schemaManager = schemaManager;
-    }
 }

Modified: directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java?rev=937657&r1=937656&r2=937657&view=diff
==============================================================================
--- directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java
(original)
+++ directory/apacheds/trunk/ldif-partition/src/main/java/org/apache/directory/server/core/partition/ldif/LdifStore.java
Sat Apr 24 17:46:50 2010
@@ -30,10 +30,10 @@ import java.util.Set;
 
 import org.apache.directory.server.core.partition.avl.AvlStore;
 import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.server.xdbm.AbstractStore;
 import org.apache.directory.server.xdbm.Index;
 import org.apache.directory.server.xdbm.IndexCursor;
 import org.apache.directory.server.xdbm.IndexNotFoundException;
-import org.apache.directory.server.xdbm.Store;
 import org.apache.directory.shared.ldap.entry.DefaultServerEntry;
 import org.apache.directory.shared.ldap.entry.Modification;
 import org.apache.directory.shared.ldap.entry.ModificationOperation;
@@ -54,20 +54,12 @@ import org.slf4j.LoggerFactory;
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Rev$, $Date$
  */
-public class LdifStore<E> implements Store<E, Long>
+public class LdifStore<E> extends AbstractStore<E, Long>
 {
 
-    /** the working directory to use for files */
-    private File workingDirectory;
-
-    /** true if we sync disks on every write operation */
-    private boolean isSyncOnWrite = true;
-
     /** in memory store used for serving the config data present in LDIF files  */
     private AvlStore<E> wrappedStore = new AvlStore<E>();
 
-    private SchemaManager schemaManager;
-
     private LdifReader ldifReader;
 
     private FileFilter dirFilter = new FileFilter()
@@ -269,18 +261,6 @@ public class LdifStore<E> implements Sto
     }
 
 
-    public void setWorkingDirectory( File workingDirectory )
-    {
-        this.workingDirectory = workingDirectory;
-    }
-
-
-    public File getWorkingDirectory()
-    {
-        return workingDirectory;
-    }
-
-
     public void setSyncOnWrite( boolean isSyncOnWrite )
     {
         this.isSyncOnWrite = isSyncOnWrite;

Added: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java?rev=937657&view=auto
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
(added)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/AbstractStore.java
Sat Apr 24 17:46:50 2010
@@ -0,0 +1,126 @@
+/*
+ *  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.server.xdbm;
+
+
+import java.io.File;
+
+import org.apache.directory.server.i18n.I18n;
+import org.apache.directory.shared.ldap.schema.SchemaManager;
+
+
+/**
+ * Base implementation of a {@link Store}.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $$Rev$$
+ */
+public abstract class AbstractStore<E, ID> implements Store<E, ID>
+{
+
+    /** The default cache size is set to 10 000 objects */
+    public static final int DEFAULT_CACHE_SIZE = 10000;
+
+    /** true if initialized */
+    protected boolean initialized;
+
+    /** the working directory to use for files */
+    protected File workingDirectory;
+
+    /** true if we sync disks on every write operation */
+    protected boolean isSyncOnWrite = true;
+
+    /** The store cache size */
+    protected int cacheSize = DEFAULT_CACHE_SIZE;
+
+    /** The store name */
+    protected String name;
+
+    /** A pointer on the schemaManager */
+    protected SchemaManager schemaManager;
+
+
+    protected void protect( String property )
+    {
+        if ( initialized )
+        {
+            throw new IllegalStateException( I18n.err( I18n.ERR_576, property ) );
+        }
+    }
+
+
+    public boolean isInitialized()
+    {
+        return initialized;
+    }
+
+
+    public void setWorkingDirectory( File workingDirectory )
+    {
+        protect( "workingDirectory" );
+        this.workingDirectory = workingDirectory;
+    }
+
+
+    public File getWorkingDirectory()
+    {
+        return workingDirectory;
+    }
+
+
+    public void setSyncOnWrite( boolean isSyncOnWrite )
+    {
+        protect( "syncOnWrite" );
+        this.isSyncOnWrite = isSyncOnWrite;
+    }
+
+
+    public boolean isSyncOnWrite()
+    {
+        return isSyncOnWrite;
+    }
+
+
+    public void setCacheSize( int cacheSize )
+    {
+        protect( "cacheSize" );
+        this.cacheSize = cacheSize;
+    }
+
+
+    public int getCacheSize()
+    {
+        return cacheSize;
+    }
+
+
+    public void setName( String name )
+    {
+        protect( "name" );
+        this.name = name;
+    }
+
+
+    public String getName()
+    {
+        return name;
+    }
+
+}

Modified: directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java?rev=937657&r1=937656&r2=937657&view=diff
==============================================================================
--- directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
(original)
+++ directory/apacheds/trunk/xdbm-base/src/main/java/org/apache/directory/server/xdbm/Store.java
Sat Apr 24 17:46:50 2010
@@ -134,26 +134,30 @@ public interface Store<E, ID>
 
 
     /**
-     * Sets the cache size for this store
+     * Sets the cache size for this store.
      * @param cacheSize The cache size
      */
     void setCacheSize( int cacheSize );
 
 
     /**
+     * Gets the cache size for this store.
+     * 
      * @return The cache size
      */
     int getCacheSize();
 
 
     /**
-     * Sets the store's name
+     * Sets the store's name.
      * @param name The store's name
      */
     void setName( String name );
 
 
     /**
+     * Gets the store's name.
+     * 
      * @return The store's name
      */
     String getName();
@@ -170,7 +174,7 @@ public interface Store<E, ID>
 
 
     /**
-     * Close the parttion : we have to close all the userIndices and the master table.
+     * Close the store : we have to close all the userIndices and the master table.
      *
      * @throws Exception lazily thrown on any closer failures to avoid leaving
      * open files



Mime
View raw message