| 118 | } |
| 119 | |
| 120 | void |
| 121 | CoreBundleContext::Init() |
| 122 | { |
| 123 | DIAG_LOG(*sink) << "initializing"; |
| 124 | initCount++; |
| 125 | |
| 126 | auto storageCleanProp = frameworkProperties.find(Constants::FRAMEWORK_STORAGE_CLEAN); |
| 127 | if (firstInit && storageCleanProp != frameworkProperties.end() |
| 128 | && storageCleanProp->second == Constants::FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT) |
| 129 | { |
| 130 | // DeleteFWDir(); |
| 131 | firstInit = false; |
| 132 | } |
| 133 | |
| 134 | // We use a "pseudo" random UUID. |
| 135 | std::string const sid_base = "04f4f884-31bb-45c0-b176-"; |
| 136 | std::stringstream ss; |
| 137 | ss << sid_base << std::setfill('0') << std::setw(8) << std::hex << static_cast<int32_t>(id * 65536 + initCount); |
| 138 | |
| 139 | frameworkProperties[Constants::FRAMEWORK_UUID] = ss.str(); |
| 140 | |
| 141 | // $TODO we only support non-persistent (main memory) storage yet |
| 142 | storage = std::make_unique<BundleStorageMemory>(); |
| 143 | // if (frameworkProperties[FWProps::READ_ONLY_PROP] == true) |
| 144 | // { |
| 145 | // dataStorage.clear(); |
| 146 | // } |
| 147 | // else |
| 148 | // { |
| 149 | // dataStorage = GetFileStorage(this, "data"); |
| 150 | // } |
| 151 | try |
| 152 | { |
| 153 | dataStorage = GetPersistentStoragePath(this, "data", /*create=*/false); |
| 154 | } |
| 155 | catch (std::exception const& e) |
| 156 | { |
| 157 | DIAG_LOG(*sink) << "Ignored runtime exception with message'" << e.what() |
| 158 | << "' from the GetPersistentStoragePath function.\n"; |
| 159 | } |
| 160 | |
| 161 | auto bundleValidationFunc = frameworkProperties.find(Constants::FRAMEWORK_BUNDLE_VALIDATION_FUNC); |
| 162 | if (bundleValidationFunc != frameworkProperties.end()) |
| 163 | { |
| 164 | validationFunc |
| 165 | = any_cast<std::function<bool(cppmicroservices::Bundle const&)>>(bundleValidationFunc->second); |
| 166 | } |
| 167 | |
| 168 | systemBundle->InitSystemBundle(); |
| 169 | US_SET_CTX_FUNC(system_bundle)(systemBundle->bundleContext.Load().get()); |
| 170 | |
| 171 | bundleRegistry.Init(); |
| 172 | |
| 173 | serviceHooks.Open(); |
| 174 | |
| 175 | bundleRegistry.Load(); |
| 176 | |
| 177 | logger = std::make_shared<cppmicroservices::cfrimpl::CFRLogger>(GetBundleContext()); |
nothing calls this directly
no test coverage detected