}
// Next-stage services
// Initial model
final ServerModel serverModel = new ServerModel(serverName, portOffset);
final Properties systemProperties = System.getProperties();
final ServerEnvironment environment = providedEnvironment != null
? providedEnvironment
: new ServerEnvironment(systemProperties, serverName, false);
log.info("Activating core services");
// The server controller
// TODO make ServerConfigurationPersister internal
// TODO share thread pool
ServerControllerImpl serverController = new ServerControllerImpl(serverModel, container, environment.isStandalone());
batchBuilder.addService(ServerController.SERVICE_NAME, serverController)
.addDependency(ServerConfigurationPersister.SERVICE_NAME, ServerConfigurationPersister.class, serverController.getConfigurationPersisterValue())
.addInjection(serverController.getExecutorValue(), Executors.newCachedThreadPool());
// Server environment services
ServerEnvironmentServices.addServices(environment, batchBuilder);
// Deployment repository
ServerDeploymentRepositoryImpl.addService(batchBuilder);
// Graceful shutdown
ShutdownHandlerImpl.addService(batchBuilder);
// Server model service - TODO: replace with ServerController
ServerModelService.addService(serverModel, batchBuilder);
// Server deployment manager - TODO: move into startServices, only start in standalone mode
ServerDeploymentManagerImpl.addService(serverModel, container, batchBuilder);
// Server configuration persister - TODO: move into startServices, only start in standalone mode
ServerConfigurationPersisterImpl.addService(serverModel, batchBuilder);
// Server deployment scanner factory
DeploymentScannerFactoryService.addService(batchBuilder);
batchBuilder.addService(SocketBindingManager.SOCKET_BINDING_MANAGER,
new SocketBindingManagerService(portOffset)).setInitialMode(ServiceController.Mode.ON_DEMAND);
// Activate deployment module loader
batchBuilder.addService(ClassifyingModuleLoaderService.SERVICE_NAME, new ClassifyingModuleLoaderService());
final DeploymentModuleLoaderService deploymentModuleLoaderService = new DeploymentModuleLoaderService(new DeploymentModuleLoaderImpl());
batchBuilder.addService(DeploymentModuleLoaderService.SERVICE_NAME, deploymentModuleLoaderService)
.addDependency(ClassifyingModuleLoaderService.SERVICE_NAME, ClassifyingModuleLoaderService.class, new ClassifyingModuleLoaderInjector("deployment", deploymentModuleLoaderService));
// todo move elsewhere...
new JarDeploymentActivator().activate(new ServiceActivatorContext() {
public BatchBuilder getBatchBuilder() {
return batchBuilder;
}
});
for (AbstractServerModelUpdate<?> update : updates) {
try {
serverModel.update(update);
} catch (UpdateFailedException e) {
throw new IllegalStateException("Failed to start server", e);
}
}