directory-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Krish <krishnendu....@gmail.com>
Subject Re: Embedded ApacheDS
Date Thu, 09 Feb 2017 15:49:29 GMT
Look into this project and see if it helps.
I have created an embedded apache ds and also loaded custom partook and Microsoft schema custom
attributes to it.

Thanks 
Krish

Sent from my iPhone

> On Feb 9, 2017, at 10:18 AM, Cyril FILLON <cyrilfillon@yahoo.fr.INVALID> wrote:
> 
> Hi all,
> 
> 
> I am trying to setup an embedded ApacheDS 2.0.0-M23 server from my java code, snippet
is given below.
> 
> I tried to create a new partition, but unfortunately it fails miserably since I cannot
see this partition from ApacheDS Studio.
> Anyone could help me or give me a code snippet in order to be able to start the ApacheDS
server from Java code and create a partition?
> I already gave a look to the documentation page http://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html,
however the code snippet does not work as well.
> 
> 
> Many thanks in advance.
> 
>  public void start()
>  {
>    ApacheDsService apacheDsService = new ApacheDsService();
> 
>    apacheDsService.start(new InstanceLayout(this.ldapInstanceFolder));
>    DirectoryService directoryService = this.apacheDsService.getDirectoryService();
> 
>    directoryService.getChangeLog().setEnabled(true);
>    directoryService.setAllowAnonymousAccess(true);
> 
>    final SchemaManager schemaManager = this.directoryService.getSchemaManager();
> 
> 
>    // Create the partition
>    final Dn suffixDn = new Dn(schemaManager, "o=sevenSeas");    final JdbmPartition partition
= getJdbmPartition(this.directoryService, "sevenSeas", suffixDn, contextEntry);
>    partition.initialize();
> 
> 
>    directoryService.addPartition(partition);
>  }
> 
> 
>  private JdbmPartition getJdbmPartition(final DirectoryService directoryService, final
String partitionId, final Dn suffixDN, final Entry entry) throws ConfigurationException
>   {
>    final JdbmPartition jdbmPartition = new JdbmPartition(directoryService.getSchemaManager(),
directoryService.getDnFactory());
> 
>    jdbmPartition.setId(partitionId);
>    jdbmPartition.setCacheSize(1000);
>    jdbmPartition.setOptimizerEnabled(true);
>    File partitionPath = new File(directoryService.getInstanceLayout().getPartitionsDirectory(),
partitionId);    
>    jdbmPartition.setPartitionPath(partitionPath.toURI());
> 
>    try
>    {
>      jdbmPartition.setSuffixDn(suffixDN);
>    }
>    catch (final LdapInvalidDnException lide)
>    {
>      lide.printStackTrace();
>      throw new ConfigurationException(lide.getMessage());
>    }
> 
>    jdbmPartition.setSyncOnWrite(true);
> 
>       return jdbmPartition;
>  }
> 
> Cyril

Mime
View raw message