org.apache.ldap.server.partition
Class AbstractContextPartition

java.lang.Object
  extended byorg.apache.ldap.server.partition.AbstractContextPartition
All Implemented Interfaces:
ContextPartition

public abstract class AbstractContextPartition
extends java.lang.Object
implements ContextPartition

A ContextPartition 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: 264732 $, $Date: 2005-08-30 04:04:51 -0400 (Tue, 30 Aug 2005) $
Author:
The Apache Directory Project

Field Summary
 
Fields inherited from interface org.apache.ldap.server.partition.ContextPartition
ALIAS_ATTRIBUTE, ALIAS_OBJECT
 
Constructor Summary
protected AbstractContextPartition()
           
 
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.
 ContextPartitionConfiguration getConfiguration()
          Returns ContextPartitionConfiguration that is provided from init(ContextFactoryConfiguration, ContextPartitionConfiguration).
 ContextFactoryConfiguration getFactoryConfiguration()
          Returns ContextFactoryConfiguration that is provided from init(ContextFactoryConfiguration, ContextPartitionConfiguration).
 javax.naming.Name getSuffix(boolean normalized)
          Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.
 boolean hasEntry(javax.naming.Name name)
          This method calls lookup(Name) and return true if it returns an entry by default.
 void init(ContextFactoryConfiguration factoryCfg, ContextPartitionConfiguration 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(javax.naming.Name name)
          Checks to see if name is a context suffix.
 javax.naming.directory.Attributes lookup(javax.naming.Name name)
          This method calls ContextPartition.lookup(Name, String[]) with null attributeIds by default.
 void modify(javax.naming.Name name, int modOp, javax.naming.directory.Attributes mods)
          This method forwards the request to ContextPartition.modify(Name, ModificationItem[]) after translating parameters to ModificationItem[] by default.
 void move(javax.naming.Name oldName, javax.naming.Name newParentName)
          This method throws OperationNotSupportedException by default.
 void move(javax.naming.Name oldName, javax.naming.Name newParentName, java.lang.String newRn, boolean deleteOldRn)
          This method calls ContextPartition.move(Name, Name) and ContextPartition.modifyRn(Name, 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.ldap.server.partition.ContextPartition
add, delete, list, lookup, modify, modifyRn, search
 

Constructor Detail

AbstractContextPartition

protected AbstractContextPartition()
Method Detail

init

public final void init(ContextFactoryConfiguration factoryCfg,
                       ContextPartitionConfiguration 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 ContextPartition
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 ContextPartition

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 ContextPartition

getFactoryConfiguration

public final ContextFactoryConfiguration getFactoryConfiguration()
Returns ContextFactoryConfiguration that is provided from init(ContextFactoryConfiguration, ContextPartitionConfiguration).


getConfiguration

public final ContextPartitionConfiguration getConfiguration()
Returns ContextPartitionConfiguration that is provided from init(ContextFactoryConfiguration, ContextPartitionConfiguration).


getSuffix

public final javax.naming.Name getSuffix(boolean normalized)
                                  throws javax.naming.NamingException
Description copied from interface: ContextPartition
Gets the distinguished/absolute name of the suffix for all entries stored within this ContextPartition.

Specified by:
getSuffix in interface ContextPartition
Parameters:
normalized - boolean value used to control the normalization of the returned Name. If true the normalized Name is returned, otherwise the original user provided Name without normalization is returned.
Returns:
Name representing the distinguished/absolute name of this ContextPartitions root context.
Throws:
javax.naming.NamingException

isSuffix

public final boolean isSuffix(javax.naming.Name name)
                       throws javax.naming.NamingException
Description copied from interface: ContextPartition
Checks to see if name is a context suffix.

Specified by:
isSuffix in interface ContextPartition
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 ContextPartition
Throws:
javax.naming.NamingException

hasEntry

public boolean hasEntry(javax.naming.Name name)
                 throws javax.naming.NamingException
This method calls lookup(Name) 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 ContextPartition
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(javax.naming.Name name)
                                         throws javax.naming.NamingException
This method calls ContextPartition.lookup(Name, String[]) with null attributeIds by default. Please override this method if there is more effective way for your implementation.

Specified by:
lookup in interface ContextPartition
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(javax.naming.Name name,
                   int modOp,
                   javax.naming.directory.Attributes mods)
            throws javax.naming.NamingException
This method forwards the request to ContextPartition.modify(Name, 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 ContextPartition
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(javax.naming.Name oldName,
                 javax.naming.Name newParentName,
                 java.lang.String newRn,
                 boolean deleteOldRn)
          throws javax.naming.NamingException
This method calls ContextPartition.move(Name, Name) and ContextPartition.modifyRn(Name, String, boolean) subsequently by default. Please override this method if there is more effactive way for your implementation.

Specified by:
move in interface ContextPartition
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(javax.naming.Name oldName,
                 javax.naming.Name newParentName)
          throws javax.naming.NamingException
This method throws OperationNotSupportedException by default. Please override this method to implement move operation.

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


Copyright © 2002-2005 . All Rights Reserved.