startService method
Constructs and starts the service described by descriptor
and returns
if the service has been started and registered successfully.
Service dependencies aren't checked or validated by this method, when
calling manually, make sure to check ServiceDescriptor.isSatisfied
before invoking this method.
Implementation
Future<bool> startService(ServiceDescriptor descriptor) async {
var logger = (this as DarwinSystemLoggingMixin).logger;
logger
.finer("Trying to start service ${descriptor.serviceType}...");
if (!serviceDescriptors.contains(descriptor)) {
serviceDescriptors.add(descriptor);
}
var matchesConditions = await descriptor.conditions.match(this as DarwinSystem);
if (!matchesConditions) {
logger.finer(
"Service conditions aren't met, skipping service registration");
return false;
}
var obj = await descriptor.instantiate(injector);
await descriptor.start(this as DarwinSystem, obj);
darwinSystemModule.bind(descriptor.bindingType).toConstant(obj);
runningServices.add(RunningService(obj, descriptor));
logger.fine("Started service ${descriptor.serviceType}");
return true;
}