Effective use of subsystem

Please post support and help requests here.
Posts: 52
Joined: 09 Feb 2009, 19:20
Location: San Francisco bay area.

Effective use of subsystem

Postby rmoffer » 06 Jun 2009, 12:21

I'm trying to write a server application (subclassed from ServerApplication) that uses subsystems. The docs say to register the subsystem in the Server's constructor. Okay, done that.

That seems to immediately create and initialize the subsystem before the Server class initializes.

Which was okay - until I started to add configuration data. I'd like the server application to load all the configuration data (rather than delegate that to each subsystem) so I call loadConfiguration() from the server's initialize() routine.

But because the configuration hasn't yet been loaded when the subsystem's initalize() starts I don't have a way to pass in user configured data.

I can think of several possibilities

  • have each subsystem load the configuration data.
  • split the subsystems initialize into multiple functions and manually call the "worker" function from the Server after loading the configuration data
  • ?

Does anyone have any recommendations ?


Posts: 1268
Joined: 11 Jul 2006, 16:27
Location: Austria

Re: Effective use of subsystem

Postby guenter » 08 Jun 2009, 18:58

If you call loadConfiguration() before the base class initialize(), then the configuration file(s) are loaded before the subsystems are initialized.

Code: Select all

   void initialize(Application& self)
      loadConfiguration(); // load default configuration files, if present

In the subsystem's initialize() function you can then access the configuration data using app.config().

Code: Select all

void OSPSubsystem::initialize(Poco::Util::Application& app)
   if (_cancelInit) return;

   std::string codeCache        = app.config().getString("osp.codeCache", app.config().expand("${application.dir}codeCache"));

Return to “Support”

Who is online

Users browsing this forum: No registered users and 2 guests