open method
Opens the component.
correlationId
(optional) transaction id to trace execution through call chain. Return Future that receives null no errors occured. Throws error
Implementation
@override
Future open(String? correlationId) async {
if (references != null) {
var err = InvalidStateException(
correlationId, 'ALREADY_OPENED', 'Container was already opened');
throw err;
}
try {
logger.trace(correlationId, 'Starting container.');
// Create references with configured components
references = ContainerReferences([]);
_initReferences(references!);
if (config != null) references!.putFromConfig(config!);
setReferences(references!);
// Get custom description if available
var infoDescriptor = Descriptor('*', 'context-info', '*', '*', '*');
info = references!.getOneOptional<ContextInfo>(infoDescriptor);
try {
await references!.open(correlationId);
// Get reference to logger
logger = CompositeLogger(references);
logger.info(correlationId, 'Container %s started.', [info?.name]);
return null;
} catch (err) {
logger.fatal(
correlationId, err as Exception, 'Failed to start container');
await close(correlationId);
}
} catch (ex) {
logger.fatal(correlationId, ex as Exception, 'Failed to start container');
await close(correlationId);
}
}