Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Content Management (Extended ECM)
API, SDK, REST and Web Services
How to handle dynamic registration of objects
Robert_Davies_(unlondonadmin_-_(deleted))
Hi folks.I am developing a module that provides an object other modules are intended to subclass, then at run-time each subclass should be dynamically registered with the parent module who collects their functionality together.Since I want the registration of these objects to be completely automatic I would like to have my parent module do most of the work. The obvious place for this seems to be the ModuleRoot.Startup() method.So my intention was to put code in the ModuleRoot.Startup() method that uses $Kernel.OSpaceUtils.GetDescendants() to look for subclasses and register them.However since modules using this functionality will need to have a dependency on my module (and hence are loaded afterward) those subclasses won't be loaded at the time ModuleRoot.Startup() is called will they?What exactly are the rules about when a Startup() method wil get called? Does anyone have any suggestions about how I should implement this?Best regards/matt.
Find more posts tagged with
Comments
Robert_Davies_(unlondonadmin_-_(deleted))
Hi folks.Further to my previous message:I need to ensure that one of my modules methods is called after all other initialise is complete (i.e. all OSpaces loaded & open) and before the server starts accepting requests.ModuleRoot.Startup() isn't suitable since my module will get loaded before any of the modules that depend on it, hence when Startup() runs there will be nothing to find!Is there any way to ask for a method to be called at the end of the startup procedure?My alternative is to use lazy initialisation and do this work the first time one of my RequestHandlers is invoked. While i'm pretty sure this will work it will make things a little unwieldy for the first user.Does anyone (particularly OT) have any suggestions?Best regards/matt.
Bickers
Matt,In your base object, could you not have a __Init script which makes a call to whatever code you use for registering the orphans ? Then when you create an orphan in the other OSpaces (and run buildospace), the new orphan's __Init will also run, registering itself.This is the way most 'groups' of objects get registered, usually with a subsystem in the Kernel OSpace.Hope this helps.Phil.