Add-Ons & Services

Effective use of subsystem

Please post support and help requests here.

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: 48
Joined: 09 Feb 2009, 19:20
Location: San Francisco bay area.

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"));
Posts: 1091
Joined: 11 Jul 2006, 16:27
Location: Austria

Return to Support

Who is online

Users browsing this forum: No registered users and 1 guest