directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheong Chung Onn <>
Subject Re: "Embedding ApacheDS as a Web Application" revisited for 1.5.4
Date Mon, 06 Oct 2008 05:03:12 GMT
Hi Stefan,

A couple months back i managed to figure out something similar to what 
you did using class. 
However apart from embedding apacheds, i would like to programatically 
create a partition (jdbm partition). I tried using 
DefaultDirectoryServer class as an example but i failed to get it going.

My problem seems to be I am unable to set the ServerEntry correctly 
during the creation of the partition. Also I realized that creating a 
partition can only be done after DirectoryService is started else the 
partitionNexus will not be initialized.

Below is my code.

Thanks in advance.


private void createPartition(String suffix,DefaultDirectoryService 
            throws Exception {
       // My problem is here, not able to set up the ServerEntry correctly
        ServerEntry entry = new DefaultServerEntry( 
directoryService.getRegistries(), new LdapDN( "dc=technetium,dc=com") );
SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC );
AddOperationContext(directoryService.getAdminSession(), entry));

        JdbmPartition tcPartition = new JdbmPartition();

        // Create some indices
        Set<Index<?,ServerEntry>> indexedAttrs = new HashSet<Index<?, 
        indexedAttrs.add( new JdbmIndex<Object, 
        indexedAttrs.add( new JdbmIndex<Object, ServerEntry>("o"));
        tcPartition.setIndexedAttributes( indexedAttrs );

        //Add suffix


Stefan Zoerner wrote:
> Hi all,
> after some valid complaints on this list about its outdated state I 
> have updated the following documentation page

> in order to reflect the changes in 1.5.4.
> Fo those of you you don't know the little article: It is a simple 
> example on how to embed ApacheDS in a Java application.
> Main difference: Creating, starting and stopping the server is easier 
> now and feels more natural for me, because the directory service, the 
> LDAP protocol adapter, which were always simply JavaBeans components, 
> are now used as such. No JNDI configuration wizardry needed to act 
> with the server.
> Feel free to provide feedback, streamline the English phrases (this != 
> nativeSpeaker) in the wiki etc.
> I hope the example is now helpful again,
>     Greetings from Hamburg,
>         Stefan

View raw message