}
// Process the Partition, if any.
for ( CreatePartition createPartition : dsBuilder.partitions() )
{
Partition partition;
// Determine the partition type
if ( createPartition.type() == Partition.class )
{
// The annotation does not specify a specific partition type.
// We use the partition factory to create partition and index
// instances.
PartitionFactory partitionFactory = dsf.getPartitionFactory();
partition = partitionFactory.createPartition(
schemaManager,
service.getDnFactory(),
createPartition.name(),
createPartition.suffix(),
createPartition.cacheSize(),
new File( service.getInstanceLayout().getPartitionsDirectory(), createPartition.name() ) );
partition.setCacheService( service.getCacheService() );
CreateIndex[] indexes = createPartition.indexes();
for ( CreateIndex createIndex : indexes )
{
partitionFactory.addIndex( partition,
createIndex.attribute(), createIndex.cacheSize() );
}
partition.initialize();
}
else
{
// The annotation contains a specific partition type, we use
// that type.
Class<?> partypes[] = new Class[]
{ SchemaManager.class, DnFactory.class };
Constructor<?> constructor = createPartition.type().getConstructor( partypes );
partition = ( Partition ) constructor.newInstance( new Object[]
{ schemaManager, service.getDnFactory() } );
partition.setId( createPartition.name() );
partition.setSuffixDn( new Dn( schemaManager, createPartition.suffix() ) );
if ( partition instanceof AbstractBTreePartition )
{
AbstractBTreePartition btreePartition = ( AbstractBTreePartition ) partition;
btreePartition.setCacheSize( createPartition.cacheSize() );
btreePartition.setPartitionPath( new File( service
.getInstanceLayout().getPartitionsDirectory(),
createPartition.name() ).toURI() );
// Process the indexes if any
CreateIndex[] indexes = createPartition.indexes();
for ( CreateIndex createIndex : indexes )
{
// The annotation does not specify a specific index
// type.
// We use the generic index implementation.
JdbmIndex index = new JdbmIndex( createIndex.attribute(), false );
btreePartition.addIndexedAttributes( index );
}
}
}
partition.setSchemaManager( schemaManager );
// Inject the partition into the DirectoryService
service.addPartition( partition );
// Last, process the context entry