Page Edited : DIRxSBOX : Draft - How to write a simple custom partition for ApacheDS
Draft - How to write a simple custom partition for ApacheDS has been edited by Stefan Zoerner (Nov 15, 2008).Content:
On the mailing list, people ask regularly on how to write a custom partition. Please note that this is not an easy task. Nevertheless I try to give you a starting point with some simple examples.
If you simply plan to add another suffix to ApacheDS (besides example.com, for instance), it is not necessary to write any code. You can simply add some lines to the configuration.
The following is for those who plan to use another storage mechanism than the provided default.
Within ApacheDS, a partition is a physically distinct store for a subset of the entries contained within the server. A partition can be implemented using any storage mechanism or can even be backed in memory. The default storage mechanism for a partition is JDBM.
Implementing your own partition is basically implementing the Partition interface from the org.apache.directory.server.core.partition package.
Let's start with a minimal partition, the hello world. Minimal means here, that it is possible to add it to ApacheDS and see it with an LDAP browser. The partition ...
Currently, the sources are checked in here
In order to build it, simply check it out and type "mvn install".
In order to use the partition in a standard installation of ApacheDS, simply add it to the server.xml configuration. Provide a "native" Spring bean like this.
<spring:beans xmlns:spring="http://xbean.apache.org/schemas/spring/1.0" xmlns:s="http://www.springframework.org/schema/beans" xmlns="http://apacheds.org/config/1.0"> ... <defaultDirectoryService ...> ... <partitions> ... <s:bean id="helloPartition" class="org.apache.directory.samples.partition.hello.HelloWorldPartition"> <s:property name="suffix" value="ou=helloWorld" /> </s:bean> </partitions> ... </defaultDirectoryService> ...
Note that the class HelloWorldPartition has to be in the class path of the server. Withgout, starting the server leads to a ClassNotFoundException. You can copy the jar file which results from the build to the lib directory and adjust the command line parameters in the apacheds.sh script.