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: 493916 $, $Date: 2007-01-08 03:44:33 +0100 (Mon, 08 Jan 2007) $
Author:
Apache Directory Project

Field Summary
 
Fields inherited from interface org.apache.directory.server.core.partition.Partition
ALIAS_ATTRIBUTE, ALIAS_OBJECT
 
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.
 PartitionConfiguration getConfiguration()
          Returns PartitionConfiguration that is provided from init(DirectoryServiceConfiguration, PartitionConfiguration).
 DirectoryServiceConfiguration getFactoryConfiguration()
          Returns DirectoryServiceConfiguration that is provided from init(DirectoryServiceConfiguration, PartitionConfiguration).
 org.apache.directory.shared.ldap.name.LdapDN getSuffix()
          Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.
 boolean hasEntry(org.apache.directory.shared.ldap.name.LdapDN name)
          This method calls Partition.lookup(org.apache.directory.shared.ldap.name.LdapDN) and return true if it returns an entry by default.
 void init(DirectoryServiceConfiguration factoryCfg, PartitionConfiguration cfg)
          Sets up default properties(factoryConfiguration and configuration) and calls doInit() where you have to put your initialization code in.
 boolean isInitialized()
          Returns true if this context partition is initialized successfully.
 boolean isSuffix(org.apache.directory.shared.ldap.name.LdapDN name)
          Checks to see if name is a context suffix.
 javax.naming.directory.Attributes lookup(org.apache.directory.shared.ldap.name.LdapDN name)
          This method calls Partition.lookup(org.apache.directory.shared.ldap.name.LdapDN,String[]) with null attributeIds by default.
 void modify(org.apache.directory.shared.ldap.name.LdapDN name, int modOp, javax.naming.directory.Attributes mods)
          This method forwards the request to Partition#modify(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.ModificationItem[]) after translating parameters to ModificationItem[] by default.
 void move(org.apache.directory.shared.ldap.name.LdapDN oldName, org.apache.directory.shared.ldap.name.LdapDN newParentName)
          This method throws OperationNotSupportedException by default.
 void move(org.apache.directory.shared.ldap.name.LdapDN oldName, org.apache.directory.shared.ldap.name.LdapDN newParentName, java.lang.String newRn, boolean deleteOldRn)
          This method calls Partition.move(org.apache.directory.shared.ldap.name.LdapDN,org.apache.directory.shared.ldap.name.LdapDN) and Partition.modifyRn(org.apache.directory.shared.ldap.name.LdapDN,String,boolean) subsequently 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, getUpSuffix, list, lookup, modify, modifyRn, search, unbind
 

Constructor Detail

AbstractPartition

protected AbstractPartition()
Method Detail

init

public final void init(DirectoryServiceConfiguration factoryCfg,
                       PartitionConfiguration cfg)
                throws javax.naming.NamingException
Sets up default properties(factoryConfiguration and configuration) 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
Throws:
javax.naming.NamingException

doInit

protected void doInit()
               throws javax.naming.NamingException
Override this method to put your initialization code.

Throws:
javax.naming.NamingException

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

getFactoryConfiguration

public final DirectoryServiceConfiguration getFactoryConfiguration()
Returns DirectoryServiceConfiguration that is provided from init(DirectoryServiceConfiguration, PartitionConfiguration).


getConfiguration

public final PartitionConfiguration getConfiguration()
Returns PartitionConfiguration that is provided from init(DirectoryServiceConfiguration, PartitionConfiguration).


getSuffix

public final org.apache.directory.shared.ldap.name.LdapDN getSuffix()
                                                             throws javax.naming.NamingException
Description copied from interface: Partition
Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.

Specified by:
getSuffix in interface Partition
Returns:
Name representing the distinguished/absolute name of this ContextPartitions root context.
Throws:
javax.naming.NamingException

isSuffix

public final boolean isSuffix(org.apache.directory.shared.ldap.name.LdapDN name)
                       throws javax.naming.NamingException
Description copied from interface: Partition
Checks to see if name is a context suffix.

Specified by:
isSuffix in interface Partition
Parameters:
name - the normalized distinguished/absolute name of the context
Returns:
true if the name is a context suffix, false if it is not.
Throws:
javax.naming.NamingException - if there are any problems

sync

public void sync()
          throws javax.naming.NamingException
This method does nothing by default.

Specified by:
sync in interface Partition
Throws:
javax.naming.NamingException

hasEntry

public boolean hasEntry(org.apache.directory.shared.ldap.name.LdapDN name)
                 throws javax.naming.NamingException
This method calls Partition.lookup(org.apache.directory.shared.ldap.name.LdapDN) 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:
name - the normalized distinguished/absolute name of the object to check for existance
Returns:
true if the entry exists, false if it does not
Throws:
javax.naming.NamingException - if there are any problems

lookup

public javax.naming.directory.Attributes lookup(org.apache.directory.shared.ldap.name.LdapDN name)
                                         throws javax.naming.NamingException
This method calls Partition.lookup(org.apache.directory.shared.ldap.name.LdapDN,String[]) 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:
name - the normalized distinguished name of the object to lookup
Returns:
an Attributes object representing the entry
Throws:
javax.naming.NamingException - if there are any problems

modify

public void modify(org.apache.directory.shared.ldap.name.LdapDN name,
                   int modOp,
                   javax.naming.directory.Attributes mods)
            throws javax.naming.NamingException
This method forwards the request to Partition#modify(org.apache.directory.shared.ldap.name.LdapDN,javax.naming.directory.ModificationItem[]) after translating parameters to ModificationItem[] by default. Please override this method if there is more effactive way for your implementation.

Specified by:
modify in interface Partition
Parameters:
name - the normalized distinguished/absolute name of the entry to modify
modOp - the modification operation to perform on the entry which is one of constants specified by the DirContext interface: ADD_ATTRIBUTE, REMOVE_ATTRIBUTE, REPLACE_ATTRIBUTE.
mods - the attributes and their values used to affect the modification with.
Throws:
javax.naming.NamingException - if there are any problems
See Also:
DirContext, DirContext.ADD_ATTRIBUTE, DirContext.REMOVE_ATTRIBUTE, DirContext.REPLACE_ATTRIBUTE

move

public void move(org.apache.directory.shared.ldap.name.LdapDN oldName,
                 org.apache.directory.shared.ldap.name.LdapDN newParentName,
                 java.lang.String newRn,
                 boolean deleteOldRn)
          throws javax.naming.NamingException
This method calls Partition.move(org.apache.directory.shared.ldap.name.LdapDN,org.apache.directory.shared.ldap.name.LdapDN) and Partition.modifyRn(org.apache.directory.shared.ldap.name.LdapDN,String,boolean) subsequently by default. Please override this method if there is more effactive way for your implementation.

Specified by:
move in interface Partition
Parameters:
oldName - the normalized distinguished/absolute name of the original child name representing the child entry to move
newParentName - the normalized distinguished/absolute name of the new parent to move the targeted entry to
newRn - the new RN of the entry
deleteOldRn - boolean flag which removes the old RN attribute from the entry if set to true, and has no affect if set to false
Throws:
javax.naming.NamingException - if there are any problems

move

public void move(org.apache.directory.shared.ldap.name.LdapDN oldName,
                 org.apache.directory.shared.ldap.name.LdapDN newParentName)
          throws javax.naming.NamingException
This method throws OperationNotSupportedException by default. Please override this method to implement move operation.

Specified by:
move in interface Partition
Parameters:
oldName - the normalized distinguished/absolute name of the original child name representing the child entry to move
newParentName - the normalized distinguished/absolute name of the new parent to move the target entry to
Throws:
javax.naming.NamingException - if there are any problems


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