org.apache.directory.server.core.partition
Class AbstractPartition

java.lang.Object
  extended by org.apache.directory.server.core.partition.AbstractPartition
All Implemented Interfaces:
Partition

public abstract class AbstractPartition
extends java.lang.Object
implements Partition

A Partition that helps users to implement their own partition. Most methods are implemented by default. Please look at the description of each methods for the detail of implementations.

Version:
$Rev: 663827 $, $Date: 2008-06-06 07:38:03 +0200 (Fr, 06 Jun 2008) $
Author:
Apache Directory Project

Field Summary
protected  DirectoryService directoryService
          DirectoryService specified at init(DirectoryService).
protected  boolean initialized
          true if and only if this partition is initialized.
 
Fields inherited from interface org.apache.directory.server.core.partition.Partition
DEFAULT_CACHE_SIZE, DEFAULT_PARTITION_IMPLEMENTATION, SYSTEM_PARTITION_NAME
 
Constructor Summary
protected AbstractPartition()
           
 
Method Summary
 void destroy()
          Calls doDestroy() where you have to put your destroy code in, and clears default properties.
protected  void doDestroy()
          Override this method to put your initialization code.
protected  void doInit()
          Override this method to put your initialization code.
 DirectoryService getDirectoryService()
          Returns DirectoryService that is provided from init(DirectoryService).
 boolean hasEntry(EntryOperationContext entryContext)
          This method calls Partition.lookup(LookupOperationContext) and return true if it returns an entry by default.
 void init(DirectoryService directoryService)
          Sets up (directoryService and calls doInit() where you have to put your initialization code in.
 boolean isInitialized()
          Returns true if this context partition is initialized successfully.
 ClonedServerEntry lookup(LookupOperationContext lookupContext)
          This method calls Partition.lookup(LookupOperationContext) with null attributeIds by default.
 void sync()
          This method does nothing by default.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.server.core.partition.Partition
add, bind, delete, getCacheSize, getId, getSuffix, getSuffixDn, getUpSuffixDn, list, lookup, modify, move, moveAndRename, rename, search, setCacheSize, setId, setSuffix, unbind
 

Field Detail

directoryService

protected DirectoryService directoryService
DirectoryService specified at init(DirectoryService).


initialized

protected boolean initialized
true if and only if this partition is initialized.

Constructor Detail

AbstractPartition

protected AbstractPartition()
Method Detail

init

public final void init(DirectoryService directoryService)
                throws java.lang.Exception
Sets up (directoryService and calls doInit() where you have to put your initialization code in. isInitialized() will return true if doInit() returns without any errors. destroy() is called automatically as a clean-up process if doInit() throws an exception.

Specified by:
init in interface Partition
Parameters:
directoryService - the directory core for the server.
Throws:
java.lang.Exception - if initialization fails in any way

doInit

protected void doInit()
Override this method to put your initialization code.


destroy

public final void destroy()
Calls doDestroy() where you have to put your destroy code in, and clears default properties. Once this method is invoked, isInitialized() will return false.

Specified by:
destroy in interface Partition

doDestroy

protected void doDestroy()
Override this method to put your initialization code.


isInitialized

public final boolean isInitialized()
Returns true if this context partition is initialized successfully.

Specified by:
isInitialized in interface Partition
Returns:
true if the partition is initialized, false otherwise

getDirectoryService

public final DirectoryService getDirectoryService()
Returns DirectoryService that is provided from init(DirectoryService).

Returns:
return the directory service core

sync

public void sync()
          throws java.lang.Exception
This method does nothing by default.

Specified by:
sync in interface Partition
Throws:
java.lang.Exception - if buffers cannot be flushed to disk

hasEntry

public boolean hasEntry(EntryOperationContext entryContext)
                 throws java.lang.Exception
This method calls Partition.lookup(LookupOperationContext) and return true if it returns an entry by default. Please override this method if there is more effective way for your implementation.

Specified by:
hasEntry in interface Partition
Parameters:
entryContext - The context used to pass informations
Returns:
true if the entry exists, false if it does not
Throws:
java.lang.Exception - if there are any problems

lookup

public ClonedServerEntry lookup(LookupOperationContext lookupContext)
                         throws java.lang.Exception
This method calls Partition.lookup(LookupOperationContext) with null attributeIds by default. Please override this method if there is more effective way for your implementation.

Specified by:
lookup in interface Partition
Parameters:
lookupContext - The context containing the parameters
Returns:
an Attributes object representing the entry
Throws:
java.lang.Exception - if there are any problems


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.