// Figure out which cache container to use (by default we'll use Infinispan subsystem's default cache container) ...
String namedContainer = attribute(context, model, ModelAttributes.CACHE_CONTAINER, "modeshape");
// Create a document for the repository configuration ...
EditableDocument configDoc = Schematic.newDocument();
configDoc.set(FieldName.NAME, repositoryName);
// Determine the JNDI name ...
configDoc.set(FieldName.JNDI_NAME, "");// always set to empty string, since we'll register in JNDI here ...
final String jndiName = ModeShapeJndiNames.JNDI_BASE_NAME + repositoryName;
String jndiAlias = ModeShapeJndiNames.jndiNameFrom(model, repositoryName);
if (jndiName.equals(jndiAlias)) {
jndiAlias = null;
}
// Always set whether monitoring is enabled ...
enableMonitoring(enableMonitoring, configDoc);
// Initial node-types if configured
parseCustomNodeTypes(model, configDoc);
// Workspace information is on the repository model node (unlike the XML) ...
EditableDocument workspacesDoc = parseWorkspaces(context, model, configDoc);
// Set the storage information (that was set on the repository ModelNode) ...
setRepositoryStorageConfiguration(cacheName, configDoc);
// security
parseSecurity(context, model, configDoc);
// Now create the repository service that manages the lifecycle of the JcrRepository instance ...
RepositoryConfiguration repositoryConfig = new RepositoryConfiguration(configDoc, repositoryName);
RepositoryService repositoryService = new RepositoryService(repositoryConfig);
// Journaling
parseJournaling(repositoryService, context, model, configDoc);
ServiceName repositoryServiceName = ModeShapeServiceNames.repositoryServiceName(repositoryName);
// Add the EngineService's dependencies ...
ServiceBuilder<JcrRepository> repositoryServiceBuilder = target.addService(repositoryServiceName, repositoryService);
// Add dependency to the ModeShape engine service ...
repositoryServiceBuilder.addDependency(ModeShapeServiceNames.ENGINE,
ModeShapeEngine.class,
repositoryService.getEngineInjector());
repositoryServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
// Add garbage collection information ...
if (gcThreadPool != null) {
configDoc.getOrCreateDocument(FieldName.GARBAGE_COLLECTION).setString(FieldName.THREAD_POOL, gcThreadPool);
}
if (gcInitialTime != null) {
configDoc.getOrCreateDocument(FieldName.GARBAGE_COLLECTION).setString(FieldName.INITIAL_TIME, gcInitialTime);
}
configDoc.getOrCreateDocument(FieldName.GARBAGE_COLLECTION).setNumber(FieldName.INTERVAL_IN_HOURS, gcIntervalInHours);
// Add document optimization information ...
if (optTarget != null) {
EditableDocument docOpt = configDoc.getOrCreateDocument(FieldName.STORAGE)
.getOrCreateDocument(FieldName.DOCUMENT_OPTIMIZATION);
if (optThreadPool != null) {
docOpt.setString(FieldName.THREAD_POOL, optThreadPool);
}
if (optInitialTime != null) {
docOpt.setString(FieldName.INITIAL_TIME, optInitialTime);
}
docOpt.setNumber(FieldName.INTERVAL_IN_HOURS, optIntervalInHours);
docOpt.setNumber(FieldName.OPTIMIZATION_CHILD_COUNT_TARGET, optTarget.intValue());
if (optTolerance != null) {
docOpt.setNumber(FieldName.OPTIMIZATION_CHILD_COUNT_TOLERANCE, optTolerance.intValue());
}
}
// Add dependency to the Infinispan cache container used for content ...
repositoryServiceBuilder.addDependency(ServiceName.JBOSS.append("infinispan", namedContainer),