diff --git a/src/libraries/JANA/JApplication.cc b/src/libraries/JANA/JApplication.cc index 36760b6e7..71638c33f 100644 --- a/src/libraries/JANA/JApplication.cc +++ b/src/libraries/JANA/JApplication.cc @@ -12,7 +12,6 @@ #include #include #include -#include #include JApplication *japp = nullptr; @@ -122,14 +121,14 @@ void JApplication::Initialize() { // Obtain final values of parameters and loggers m_plugin_loader->InitPhase2(); m_component_manager->InitPhase2(); + m_logger = m_service_locator->get()->get_logger("JApplication"); + m_logger.show_classname = false; // Attach all plugins m_plugin_loader->attach_plugins(m_component_manager.get()); - // Look for factories to auto-activate - if (JAutoActivator::IsRequested(m_params)) { - m_component_manager->add(new JAutoActivator); - } + // Resolve all event sources now that all plugins have been loaded + m_component_manager->resolve_event_sources(); // Set desired nthreads. We parse the 'nthreads' parameter two different ways for backwards compatibility. m_desired_nthreads = 1; @@ -141,7 +140,6 @@ void JApplication::Initialize() { m_params->SetDefaultParameter("jana:ticker_interval", m_ticker_interval_ms, "Controls the ticker interval (in ms)"); m_params->SetDefaultParameter("jana:extended_report", m_extended_report, "Controls whether the ticker shows simple vs detailed performance metrics"); - m_component_manager->resolve_event_sources(); /* int engine_choice = 0; diff --git a/src/libraries/JANA/JApplicationFwd.h b/src/libraries/JANA/JApplicationFwd.h index 3a453623d..f2625e429 100644 --- a/src/libraries/JANA/JApplicationFwd.h +++ b/src/libraries/JANA/JApplicationFwd.h @@ -6,6 +6,8 @@ #include #include +#include +#include class JEventProcessor; class JEventSource; diff --git a/src/libraries/JANA/Omni/JComponentFwd.h b/src/libraries/JANA/Omni/JComponentFwd.h index d2ff4b3ca..7ce6f78e4 100644 --- a/src/libraries/JANA/Omni/JComponentFwd.h +++ b/src/libraries/JANA/Omni/JComponentFwd.h @@ -10,6 +10,7 @@ class JParameterManager; #include #include #include +#include namespace jana { namespace omni { diff --git a/src/libraries/JANA/Services/JComponentManager.cc b/src/libraries/JANA/Services/JComponentManager.cc index 2dbb938ad..548e03656 100644 --- a/src/libraries/JANA/Services/JComponentManager.cc +++ b/src/libraries/JANA/Services/JComponentManager.cc @@ -7,6 +7,7 @@ #include #include #include +#include JComponentManager::JComponentManager() {} @@ -38,6 +39,12 @@ void JComponentManager::InitPhase2() { m_params().SetDefaultParameter("jana:nevents", m_nevents, "Max number of events that sources can emit"); m_params().SetDefaultParameter("jana:nskip", m_nskip, "Number of events that sources should skip before starting emitting"); m_params().FilterParameters(m_default_tags, "DEFTAG:"); + + // Look for factories to auto-activate + // Right now AutoActivator parameter won't show up in parameters list. Reconsider this. + if (JAutoActivator::IsRequested(m_params())) { + add(new JAutoActivator); + } } void JComponentManager::next_plugin(std::string plugin_name) { diff --git a/src/libraries/JANA/Utils/JAutoActivator.cc b/src/libraries/JANA/Utils/JAutoActivator.cc index 5669d5c07..c4497d2ac 100644 --- a/src/libraries/JANA/Utils/JAutoActivator.cc +++ b/src/libraries/JANA/Utils/JAutoActivator.cc @@ -9,8 +9,8 @@ JAutoActivator::JAutoActivator() { SetTypeName("JAutoActivator"); } -bool JAutoActivator::IsRequested(std::shared_ptr params) { - return params->Exists("autoactivate") && (!params->GetParameterValue("autoactivate").empty()); +bool JAutoActivator::IsRequested(JParameterManager& params) { + return params.Exists("autoactivate") && (!params.GetParameterValue("autoactivate").empty()); } void JAutoActivator::AddAutoActivatedFactory(string factory_name, string factory_tag) { diff --git a/src/libraries/JANA/Utils/JAutoActivator.h b/src/libraries/JANA/Utils/JAutoActivator.h index 2b2ed34f4..695a6d958 100644 --- a/src/libraries/JANA/Utils/JAutoActivator.h +++ b/src/libraries/JANA/Utils/JAutoActivator.h @@ -16,7 +16,7 @@ class JAutoActivator : public JEventProcessor { public: JAutoActivator(); - static bool IsRequested(std::shared_ptr params); + static bool IsRequested(JParameterManager& params); static std::pair Split(std::string factory_name); void AddAutoActivatedFactory(string factory_name, string factory_tag); void Init() override;