Wiki Markup |
---|
{scrollbar} |
Adding your own partition resp. suffix
This section describes how to add your own data partition.
Table of Contents | ||||||
---|---|---|---|---|---|---|
|
What are partitions?
In ApacheDS entries are stored in partitions. Each partition contains a complete entry tree, also referred to as a DIT. Multiple partitions may exist and the entry trees they contain are disconnected from each other, meaning that changes to entries in partition A would never affect entries in partition B. The entries in a particular partition are stored below some naming context called the partition suffix.
...
The schema subsystem and ApacheDS itself store their information in special partitions, "ou=schema" and "ou=system" respectively.
Minimal partition definition
For the examples in the following sections, we want to add a partition with the suffix "o=sevenSeas". This requires editing of the server.xml file, and injecting a first entry, associated with the root of this partition (here, "o=sevenseas") .
...
The following image depicts the partitions after reconnecting with Apache Directory Studio (LDAP Browser view).
Laoding the context entry automatically on startup
If you don't want to launch Apache Studio, or to inject the LDIF file using a command line tool, you can also tells the server to load the file when it will be laucnhed the first time. Just create a ldif file containing the context entry, and add some tag into the server.xml file. For instance, you have created the sevenSeasRoot.ldif file containing
...
The contextEntry will be loaded when the server will be started the first time.
Adding a partition programmatically
The same o=sevenseas partition can be created through the application code using the Partition and DirectoryService API
...
Code Block |
---|
JdbmPartition sevenseasPartition = new JdbmPartition(); sevenseasPartition.setId("sevenseas"); sevenseasPartition.setSuffix("o=sevenseas"); sevenseasPartition.setCacheSize(1000); sevenseasPartition.init(directoryService); // Create some indices (optional) Set<Index<?,ServerEntry>> indexedAttrs = new HashSet<Index<?, ServerEntry>>(); indexedAttrs.add( new JdbmIndex<Object, ServerEntry>("objectClass")); indexedAttrs.add( new JdbmIndex<Object, ServerEntry>("o")); sevenseasPartition.setIndexedAttributes( indexedAttrs ); //Add partition to the directory service directoryService.addPartition(sevenseasPartition); // start the directory service directoryService.startup(); // create the context entry ServerEntry entry = new DefaultServerEntry( directoryService.getRegistries(), new LdapDN( "o=sevenseas") ); entry.put( "objectClass", "top", "organization" ); entry.put("o","sevenseas"); // add the context entry AddContextPartitionOperationContext adOpContext = new AddContextPartitionOperationContext( directoryService.getAdminSession(), sevenseasPartition ); adOpContext.add( entry, null ); directoryService.getPartitionNexus().addContextPartition( adOpContext ); |
More configuration options for a JDBM partition
Here is a list of the used attributes, their default values and meaning
...