| 452 | } |
| 453 | |
| 454 | std::exception_ptr |
| 455 | BundlePrivate::Start0() |
| 456 | { |
| 457 | // res is used to signal that start did not complete in a normal way |
| 458 | std::exception_ptr res; |
| 459 | auto const thisBundle = MakeBundle(this->shared_from_this()); |
| 460 | coreCtx->listeners.BundleChanged(BundleEvent(BundleEvent::BUNDLE_STARTING, thisBundle)); |
| 461 | |
| 462 | auto const& headers = thisBundle.GetHeaders(); |
| 463 | Any bundleActivatorVal; |
| 464 | if (headers.count(Constants::BUNDLE_ACTIVATOR) > 0) |
| 465 | { |
| 466 | bundleActivatorVal = headers.find(Constants::BUNDLE_ACTIVATOR)->second; |
| 467 | } |
| 468 | |
| 469 | bool useActivator = false; |
| 470 | if (!bundleActivatorVal.Empty()) |
| 471 | { |
| 472 | try |
| 473 | { |
| 474 | useActivator = any_cast<bool>(bundleActivatorVal); |
| 475 | } |
| 476 | catch (BadAnyCastException const& ex) |
| 477 | { |
| 478 | std::string message("Failed to read 'bundle.activator' property. Expected type : "); |
| 479 | message += typeid(useActivator).name(); |
| 480 | message += ", Found type : "; |
| 481 | message += bundleActivatorVal.Type().name(); |
| 482 | coreCtx->listeners.SendFrameworkEvent(FrameworkEvent(FrameworkEvent::Type::FRAMEWORK_WARNING, |
| 483 | thisBundle, |
| 484 | message, |
| 485 | std::make_exception_ptr(ex))); |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | // Activator in the bundle is not called if 'bundle.activator' property |
| 490 | // either does not exist or is set to false. If the property is set to true, |
| 491 | // the actiavtor inside the bundle is called. |
| 492 | if (useActivator) |
| 493 | { |
| 494 | try |
| 495 | { |
| 496 | if (coreCtx->validationFunc && (lib.GetFilePath() != util::GetExecutablePath()) |
| 497 | && !coreCtx->validationFunc(thisBundle)) |
| 498 | { |
| 499 | StartFailed(); |
| 500 | return std::make_exception_ptr(SecurityException { |
| 501 | "Bundle " + symbolicName + " (location=" + location + ") failed bundle validation.", |
| 502 | thisBundle }); |
| 503 | } |
| 504 | } |
| 505 | catch (...) |
| 506 | { |
| 507 | coreCtx->listeners.SendFrameworkEvent( |
| 508 | FrameworkEvent(FrameworkEvent::Type::FRAMEWORK_WARNING, |
| 509 | thisBundle, |
| 510 | "The bundle validation function threw an exception", |
| 511 | std::current_exception())); |
nothing calls this directly
no test coverage detected