dsf.init( dsBuilder.name() );
// 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( createPartition
.name(), createPartition.suffix(), createPartition
.cacheSize(), new File( service.getInstanceLayout()
.getPartitionsDirectory(), createPartition.name() ) );
CreateIndex[] indexes = createPartition.indexes();
for ( CreateIndex createIndex : indexes )
{
partitionFactory.addIndex( partition,
createIndex.attribute(), createIndex.cacheSize() );
}
}
else
{
// The annotation contains a specific partition type, we use
// that type.
partition = createPartition.type().newInstance();
partition.setId( createPartition.name() );
partition.setSuffix( new Dn( service.getSchemaManager(), createPartition.suffix() ) );
if ( partition instanceof BTreePartition<?> )
{
BTreePartition<?> btreePartition = ( BTreePartition<?> ) 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();
index.setAttributeId( createIndex.attribute() );
btreePartition.addIndexedAttributes( index );
}
}
}
partition.setSchemaManager( service.getSchemaManager() );
// Inject the partition into the DirectoryService
service.addPartition( partition );
// Last, process the context entry