Hmm, true, other modules throw a wrench into that plan. When any module is loaded that requires a spring restart (which is 90% of modules), the openmrsclassloader is null'd. I /think/ each ModuleClassLoader is null'd too, but I can't remember off hand.
Activators are notified before and after every spring restart. We don't give them a chance to persist objects across those, though. The activator would need to persist to the db or filesystem and reload it. There is a design pattern for allowing it to send a message to its future self, but then if sending objects and those objects are loaded by the classloader it would be a memory leak. Ben On Wed, Dec 7, 2011 at 9:20 PM, Darius Jazayeri <[email protected]>wrote: > I'm not sure we can preserve the same instance across Spring restarts > (e.g. if another module is started after this one). Ben, do you know if we > use a new classloader in that case? > > -Darius > > > On Wed, Dec 7, 2011 at 9:45 AM, Burke Mamlin <[email protected]>wrote: > >> Seems like a fair request. I can't think of any advantages of having >> separate instances and understand the assumption that it would be the same >> instance. Unless there's a architectural reason that we can't use the same >> instance (Ben?), it sounds ticket-worthy to me. >> >> -Burke >> >> >> On Wed, Dec 7, 2011 at 11:19 AM, Rowan Seymour <[email protected]>wrote: >> >>> Is there a reason why the instance of a module's activator used for >>> startup isn't the same instance as the one used for shutdown? Looking at >>> the getModuleActivator() method in Module one can see that a new >>> instance is created each time. I only ask because I spent forever tracking >>> down a bug where a instance variable was being shared unsuccessfully >>> between the startup and shutdown methods. >>> >>> public ModuleActivator getModuleActivator() { >>> try { >>> ModuleClassLoader classLoader = >>> ModuleFactory.getModuleClassLoader(this); >>> if (classLoader == null) >>> throw new ModuleException("The classloader is null", getModuleId()); >>> Class<?> c = classLoader.loadClass(getActivatorName()); >>> Object o = c.newInstance(); >>> if (ModuleActivator.class.isAssignableFrom(o.getClass())) >>> setModuleActivator((ModuleActivator) o); >>> } >>> catch (ClassNotFoundException e) { >>> throw new ModuleException("Unable to load/find moduleActivator: '" + >>> getActivatorName() + "'", name, e); >>> } >>> catch (IllegalAccessException e) { >>> throw new ModuleException("Unable to load/access moduleActivator: '" + >>> getActivatorName() + "'", name, e); >>> } >>> catch (InstantiationException e) { >>> throw new ModuleException("Unable to load/instantiate moduleActivator: >>> '" + getActivatorName() + "'", name, e); >>> } >>> return moduleActivator; >>> } >>> ------------------------------ >>> Click here to >>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from >>> OpenMRS Developers' mailing list >> >> >> ------------------------------ >> Click here to >> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from >> OpenMRS Developers' mailing list >> > > ------------------------------ > Click here to > unsubscribe<[email protected]?body=SIGNOFF%20openmrs-devel-l>from > OpenMRS Developers' mailing list > _________________________________________ To unsubscribe from OpenMRS Developers' mailing list, send an e-mail to [email protected] with "SIGNOFF openmrs-devel-l" in the body (not the subject) of your e-mail. [mailto:[email protected]?body=SIGNOFF%20openmrs-devel-l]

