in src/main/java/org/apache/sling/settings/impl/SlingSettingsServiceImpl.java [123:148]
private void setupSlingId(final BundleContext context) {
// try to read the id from the id file first
final File idFile = context.getDataFile(ID_FILE);
if (idFile == null) {
// the osgi framework does not support storing something in the file system
throw new RuntimeException("Unable to read from bundle data file.");
}
try {
slingId = SlingIdUtil.readSlingId(idFile);
logger.info("Read Sling ID {} from file {}", slingId, idFile);
} catch (final Throwable t) {
logger.error("Failed reading Sling ID from file " + idFile, t);
}
// no sling id yet or failure to read file: create an id and store
if (slingId == null) {
slingId = SlingIdUtil.createSlingId();
logger.info("Created new Sling ID {}", slingId);
try {
SlingIdUtil.writeSlingId(idFile, slingId);
} catch (final Throwable t) {
logger.error("Failed writing Sling ID to file " + idFile, t);
}
}
}