public void contextInitialized()

in apacheds-archetype-webapp/src/main/resources/archetype-resources/src/main/java/StartStopListener.java [66:102]


    public void contextInitialized( ServletContextEvent evt )
    {
        try
        {
            directoryService = new DefaultDirectoryService();
            directoryService.setShutdownHookEnabled( true );

            ldapServer = new LdapServer();
            ldapServer.setDirectoryService( directoryService );
            ldapServer.setAllowAnonymousAccess( true );

            // Set LDAP port to 10389
            TcpTransport ldapTransport = new TcpTransport( 10389 );
            ldapServer.setTransports( ldapTransport );

            // Determine an appropriate working directory
            ServletContext servletContext = evt.getServletContext();
            File workingDir = ( File ) servletContext.getAttribute( "javax.servlet.context.tempdir" );
            workingDir = new File( workingDir, "server-work" );
            workingDir.mkdirs();
            
            directoryService.setWorkingDirectory( workingDir );

            initSchema();
            initSystemPartition();
            
            directoryService.startup();
            ldapServer.start();

            // Store directoryService in context to provide it to servlets etc.
            servletContext.setAttribute( DirectoryService.JNDI_KEY, directoryService );
        }
        catch ( Exception e )
        {
            throw new RuntimeException( e );
        }
    }