directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cheong Chung Onn <chung...@greenfossil.com>
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 org.apache.directory.server.unit.AbstractServerTest 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.

Regards
chung-onn


private void createPartition(String suffix,DefaultDirectoryService 
directoryService)
            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") );
        entry.put(SchemaConstants.OBJECT_CLASS_AT,  
SchemaConstants.TOP_OC, SchemaConstants.ORGANIZATIONAL_UNIT_OC );
        entry.put("dc","technetium");
        directoryService.getPartitionNexus().add(new 
AddOperationContext(directoryService.getAdminSession(), entry));

        JdbmPartition tcPartition = new JdbmPartition();
        tcPartition.setId("technetium");
        tcPartition.setCacheSize(1000);

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

        //Add suffix
        tcPartition.setSuffix(suffix);
        tcPartition.init(directoryService);
        directoryService.addPartition(tcPartition);

    }


Stefan Zoerner wrote:
> Hi all,
>
> after some valid complaints on this list about its outdated state I 
> have updated the following documentation page
> http://directory.apache.org/apacheds/1.5/embedding-apacheds-as-a-web-application.html

>
> 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

Mime
View raw message