Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Using the partition

Embedded mode

Code Block
java
java

package org.apache.directory.samples.partition.hello;

import org.apache.directory.server.core.DefaultDirectoryService;
import org.apache.directory.server.core.DirectoryService;
import org.apache.directory.server.ldap.LdapService;
import org.apache.directory.server.protocol.shared.SocketAcceptor;

public class Main {

    public static void main(String[] args) throws Exception {
        DirectoryService directoryService;

        SocketAcceptor socketAcceptor;
        LdapService ldapService;

        directoryService = new DefaultDirectoryService();
        directoryService.setShutdownHookEnabled(true);

        socketAcceptor = new SocketAcceptor(null);
        ldapService = new LdapService();
        ldapService.setSocketAcceptor(socketAcceptor);
        ldapService.setDirectoryService(directoryService);
        ldapService.setIpPort(10389);

        HelloWorldPartition helloPartition = new HelloWorldPartition();
        helloPartition.setSuffix("ou=helloWorld");
        helloPartition.init(directoryService);
        
        directoryService.addPartition(helloPartition);       
        
        directoryService.startup();
        ldapService.start();
    }
}

Adding it to a server.xml file

...