Versions Compared

Key

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

...

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.LdapServiceLdapServer;


import org.apache.directory.server.protocol.shared.transport.SocketAcceptor;
TcpTransport;

/**
 * Starts the server with the HelloWorld partition.
 */
public class Main {

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

        DirectoryService directoryService;

        SocketAcceptor socketAcceptor;
        LdapService ldapService;

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

        LdapServer socketAcceptorldapServer = new SocketAcceptorLdapServer(null);
        ldapService = new LdapService(ldapServer.setDirectoryService(directoryService);
        ldapServiceldapServer.setSocketAcceptorsetAllowAnonymousAccess(socketAcceptortrue);

        TcpTransport ldapTransport = new ldapService.setDirectoryServiceTcpTransport(directoryService10389);
        ldapServiceldapServer.setIpPortsetTransports(10389ldapTransport);

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

Adding it to a server.xml file

...

Note that the class HelloWorldPartition has to be in the class path of the server. WithgoutWithout, 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/ext directory.

Verification

After adding the HelloWorldPartition to the directory service like above (embedded or via configuration in server.xml), you can browse it with an LDAP browser like the one from Apache Directory Studio. Here are some screen shots.

...