List<Interceptor> interceptors = directoryService.getInterceptors();
interceptors.add(new KeyDerivationInterceptor());
directoryService.setInterceptors(interceptors);
directoryServiceFactory.init("defaultDS");
PartitionFactory partitionFactory = directoryServiceFactory.getPartitionFactory();
Partition partition = partitionFactory.createPartition("example", "dc=example,dc=com",
1000, new File(directoryService.getWorkingDirectory(), "example"));
partitionFactory.addIndex(partition, "objectClass", 1000);
partitionFactory.addIndex(partition, "dc", 1000);
partitionFactory.addIndex(partition, "ou", 1000);
partition.setSchemaManager(directoryService.getSchemaManager());
// Inject the partition into the DirectoryService
directoryService.addPartition(partition);