IOException.
*/
- public void cacheObjectEvicted(Object obj) throws CacheEvictionException;
-
+ public void cacheObjectEvicted( T obj ) throws CacheEvictionException;
}
Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/DefaultSerializer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/DefaultSerializer.java?rev=916036&r1=916035&r2=916036&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/DefaultSerializer.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/helper/DefaultSerializer.java Wed Feb 24 23:27:29 2010
@@ -43,22 +43,22 @@
* Contributions are Copyright (C) 2001 by their associated contributors.
*
*/
-
package jdbm.helper;
+
import java.io.IOException;
+
/**
* Default java serializer.
*
* @author Alex Boisvert
* @version $Id: DefaultSerializer.java,v 1.2 2003/09/21 15:47:00 boisvert Exp $
*/
-public class DefaultSerializer
- implements Serializer
+public class DefaultSerializer implements Serializer
{
+ private static final long serialVersionUID = -3818545055661017388L;
-
public static final DefaultSerializer INSTANCE = new DefaultSerializer();
@@ -77,27 +77,27 @@
* @param obj Object to serialize
* @return a byte array representing the object's state
*/
- public byte[] serialize( Object obj )
- throws IOException
+ public byte[] serialize( Object obj ) throws IOException
{
return Serialization.serialize( obj );
}
/**
- * Deserialize the content of an object from a byte array.
+ * De-serialize the content of an object from a byte array.
*
* @param serialized Byte array representation of the object
- * @return deserialized object
+ * @return de-serialized object
*/
- public Object deserialize( byte[] serialized )
- throws IOException
+ public Object deserialize( byte[] serialized ) throws IOException
{
- try {
+ try
+ {
return Serialization.deserialize( serialized );
- } catch ( ClassNotFoundException except ) {
+ }
+ catch ( ClassNotFoundException except )
+ {
throw new WrappedRuntimeException( except );
}
}
-
}
Modified: directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java?rev=916036&r1=916035&r2=916036&view=diff
==============================================================================
--- directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java (original)
+++ directory/apacheds/trunk/jdbm/src/main/java/jdbm/recman/BaseRecordManager.java Wed Feb 24 23:27:29 2010
@@ -86,82 +86,62 @@
implements RecordManager
{
- /**
- * Underlying record file.
- */
- private RecordFile _file;
+ /** Underlying record file. */
+ private RecordFile recordFile;
+ /** Physical row identifier manager. */
+ private PhysicalRowIdManager physMgr;
- /**
- * Physical row identifier manager.
- */
- private PhysicalRowIdManager _physMgr;
+ /** Logical to Physical row identifier manager. */
+ private LogicalRowIdManager logMgr;
+ /** Page manager. */
+ private PageManager pageMgr;
- /**
- * Logigal to Physical row identifier manager.
- */
- private LogicalRowIdManager _logMgr;
-
-
- /**
- * Page manager.
- */
- private PageManager _pageman;
-
-
- /**
- * Reserved slot for name directory.
- */
+ /** Reserved slot for name directory. */
public static final int NAME_DIRECTORY_ROOT = 0;
-
- /**
- * Static debugging flag
- */
+ /** Static debugging flag */
public static final boolean DEBUG = false;
-
/**
* Directory of named JDBMHashtables. This directory is a persistent
- * directory, stored as a Hashtable. It can be retrived by using
+ * directory, stored as a Hashtable. It can be retrieved by using
* the NAME_DIRECTORY_ROOT.
*/
- private Map _nameDirectory;
+ private Map
* Only call this method directly after opening the file, otherwise
* the results will be undefined.
@@ -169,53 +149,49 @@
public synchronized void disableTransactions()
{
checkIfClosed();
-
- _file.disableTransactions();
+ recordFile.disableTransactions();
}
/**
- * Closes the record manager.
+ * Closes the record manager.
*
- * @throws IOException when one of the underlying I/O operations fails.
+ * @throws IOException when one of the underlying I/O operations fails.
*/
- public synchronized void close()
- throws IOException
+ public synchronized void close() throws IOException
{
checkIfClosed();
- _pageman.close();
- _pageman = null;
+ pageMgr.close();
+ pageMgr = null;
- _file.close();
- _file = null;
+ recordFile.close();
+ recordFile = null;
}
/**
- * Inserts a new record using standard java object serialization.
+ * Inserts a new record using standard java object serialization.
*
- * @param obj the object for the new record.
- * @return the rowid for the new record.
- * @throws IOException when one of the underlying I/O operations fails.
+ * @param obj the object for the new record.
+ * @return the rowid for the new record.
+ * @throws IOException when one of the underlying I/O operations fails.
*/
- public long insert( Object obj )
- throws IOException
+ public long insert( Object obj ) throws IOException
{
return insert( obj, DefaultSerializer.INSTANCE );
}
/**
- * Inserts a new record using a custom serializer.
+ * Inserts a new record using a custom serializer.
*
- * @param obj the object for the new record.
- * @param serializer a custom serializer
- * @return the rowid for the new record.
- * @throws IOException when one of the underlying I/O operations fails.
+ * @param obj the object for the new record.
+ * @param serializer a custom serializer
+ * @return the rowid for the new record.
+ * @throws IOException when one of the underlying I/O operations fails.
*/
- public synchronized long insert( Object obj, Serializer serializer )
- throws IOException
+ public synchronized long insert( Object obj, Serializer serializer ) throws IOException
{
byte[] data;
long recid;
@@ -224,105 +200,114 @@
checkIfClosed();
data = serializer.serialize( obj );
- physRowId = _physMgr.insert( data, 0, data.length );
- recid = _logMgr.insert( physRowId ).toLong();
- if ( DEBUG ) {
+ physRowId = physMgr.insert( data, 0, data.length );
+ recid = logMgr.insert( physRowId ).toLong();
+
+ if ( DEBUG )
+ {
System.out.println( "BaseRecordManager.insert() recid " + recid + " length " + data.length ) ;
}
+
return recid;
}
+
/**
- * Deletes a record.
+ * Deletes a record.
*
- * @param recid the rowid for the record that should be deleted.
- * @throws IOException when one of the underlying I/O operations fails.
+ * @param recid the rowid for the record that should be deleted.
+ * @throws IOException when one of the underlying I/O operations fails.
*/
- public synchronized void delete( long recid )
- throws IOException
+ public synchronized void delete( long recid ) throws IOException
{
checkIfClosed();
- if ( recid <= 0 ) {
+
+ if ( recid <= 0 )
+ {
throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) );
}
- if ( DEBUG ) {
+ if ( DEBUG )
+ {
System.out.println( "BaseRecordManager.delete() recid " + recid ) ;
}
Location logRowId = new Location( recid );
- Location physRowId = _logMgr.fetch( logRowId );
- _physMgr.delete( physRowId );
- _logMgr.delete( logRowId );
+ Location physRowId = logMgr.fetch( logRowId );
+ physMgr.delete( physRowId );
+ logMgr.delete( logRowId );
}
/**
- * Updates a record using standard java object serialization.
+ * Updates a record using standard java object serialization.
*
- * @param recid the recid for the record that is to be updated.
- * @param obj the new object for the record.
- * @throws IOException when one of the underlying I/O operations fails.
+ * @param recid the recid for the record that is to be updated.
+ * @param obj the new object for the record.
+ * @throws IOException when one of the underlying I/O operations fails.
*/
- public void update( long recid, Object obj )
- throws IOException
+ public void update( long recid, Object obj ) throws IOException
{
update( recid, obj, DefaultSerializer.INSTANCE );
}
/**
- * Updates a record using a custom serializer.
+ * Updates a record using a custom serializer.
*
- * @param recid the recid for the record that is to be updated.
- * @param obj the new object for the record.
- * @param serializer a custom serializer
- * @throws IOException when one of the underlying I/O operations fails.
+ * @param recid the recid for the record that is to be updated.
+ * @param obj the new object for the record.
+ * @param serializer a custom serializer
+ * @throws IOException when one of the underlying I/O operations fails.
*/
- public synchronized void update( long recid, Object obj, Serializer serializer )
- throws IOException
+ public synchronized void update( long recid, Object obj, Serializer serializer ) throws IOException
{
checkIfClosed();
- if ( recid <= 0 ) {
+
+ if ( recid <= 0 )
+ {
throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) );
}
Location logRecid = new Location( recid );
- Location physRecid = _logMgr.fetch( logRecid );
+ Location physRecid = logMgr.fetch( logRecid );
byte[] data = serializer.serialize( obj );
- if ( DEBUG ) {
+
+ if ( DEBUG )
+ {
System.out.println( "BaseRecordManager.update() recid " + recid + " length " + data.length ) ;
}
- Location newRecid = _physMgr.update( physRecid, data, 0, data.length );
- if ( ! newRecid.equals( physRecid ) ) {
- _logMgr.update( logRecid, newRecid );
+ Location newRecid = physMgr.update( physRecid, data, 0, data.length );
+
+ if ( ! newRecid.equals( physRecid ) )
+ {
+ logMgr.update( logRecid, newRecid );
}
}
/**
- * Fetches a record using standard java object serialization.
+ * Fetches a record using standard java object serialization.
*
- * @param recid the recid for the record that must be fetched.
- * @return the object contained in the record.
- * @throws IOException when one of the underlying I/O operations fails.
+ * @param recid the recid for the record that must be fetched.
+ * @return the object contained in the record.
+ * @throws IOException when one of the underlying I/O operations fails.
*/
- public Object fetch( long recid )
- throws IOException
+ public Object fetch( long recid ) throws IOException
{
return fetch( recid, DefaultSerializer.INSTANCE );
}
/**
- * Fetches a record using a custom serializer.
+ * Fetches a record using a custom serializer.
*
- * @param recid the recid for the record that must be fetched.
- * @param serializer a custom serializer
- * @return the object contained in the record.
- * @throws IOException when one of the underlying I/O operations fails.
+ * @param recid the recid for the record that must be fetched.
+ * @param serializer a custom serializer
+ * @return the object contained in the record.
+ * @throws IOException when one of the underlying I/O operations fails.
*/
public synchronized Object fetch( long recid, Serializer serializer )
throws IOException
@@ -330,11 +315,16 @@
byte[] data;
checkIfClosed();
- if ( recid <= 0 ) {
+
+ if ( recid <= 0 )
+ {
throw new IllegalArgumentException( I18n.err( I18n.ERR_536, recid ) );
}
- data = _physMgr.fetch( _logMgr.fetch( new Location( recid ) ) );
- if ( DEBUG ) {
+
+ data = physMgr.fetch( logMgr.fetch( new Location( recid ) ) );
+
+ if ( DEBUG )
+ {
System.out.println( "BaseRecordManager.fetch() recid " + recid + " length " + data.length ) ;
}
return serializer.deserialize( data );
@@ -342,27 +332,27 @@
/**
- * Returns the number of slots available for "root" rowids. These slots
- * can be used to store special rowids, like rowids that point to
- * other rowids. Root rowids are useful for bootstrapping access to
- * a set of data.
+ * Returns the number of slots available for "root" rowids. These slots
+ * can be used to store special rowids, like rowids that point to
+ * other rowids. Root rowids are useful for bootstrapping access to
+ * a set of data.
*/
public int getRootCount()
{
return FileHeader.NROOTS;
}
+
/**
* Returns the indicated root rowid.
*
* @see #getRootCount
*/
- public synchronized long getRoot( int id )
- throws IOException
+ public synchronized long getRoot( int id ) throws IOException
{
checkIfClosed();
- return _pageman.getFileHeader().getRoot( id );
+ return pageMgr.getFileHeader().getRoot( id );
}
@@ -371,12 +361,11 @@
*
* @see #getRootCount
*/
- public synchronized void setRoot( int id, long rowid )
- throws IOException
+ public synchronized void setRoot( int id, long rowid ) throws IOException
{
checkIfClosed();
- _pageman.getFileHeader().setRoot( id, rowid );
+ pageMgr.getFileHeader().setRoot( id, rowid );
}
@@ -384,33 +373,38 @@
* Obtain the record id of a named object. Returns 0 if named object
* doesn't exist.
*/
- public long getNamedObject( String name )
- throws IOException
+ public long getNamedObject( String name ) throws IOException
{
checkIfClosed();
- Map nameDirectory = getNameDirectory();
- Long recid = (Long) nameDirectory.get( name );
- if ( recid == null ) {
+ Map