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.getWorkingDirectory(), 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( createPartition.suffix() );
if ( partition instanceof BTreePartition<?> )
{
BTreePartition<?> btreePartition = ( BTreePartition<?> ) partition;
btreePartition.setCacheSize( createPartition.cacheSize() );
btreePartition.setPartitionDir( new File( service.getWorkingDirectory(), createPartition.name() ) );
// Process the indexes if any
CreateIndex[] indexes = createPartition.indexes();
for ( CreateIndex createIndex : indexes )
{
Index index;
if ( createIndex.type() == Index.class )
{
// The annotation does not specify a specific index type.
// We use the generic index implementation.
index = new GenericIndex( createIndex.attribute(), createIndex.cacheSize() );
}
else
{
// The annotation contains a specific index type, we use that type.
index = createIndex.type().newInstance();
index.setAttributeId( createIndex.attribute() );
index.setCacheSize( createIndex.cacheSize() );
}
btreePartition.addIndexedAttributes( index );
}
}
}
partition.setSchemaManager( service.getSchemaManager() );
// Inject the partition into the DirectoryService
service.addPartition( partition );
// Last, process the context entry