Create internal objects dynamically

Jean Morissette <[email protected]> Mon, 10 Jan 2005 16:44:33 -0500
Newsgroups gmane.comp.java.seda.user
Message-ID <[email protected]>
Hi,
I think that Sandstorm should create objects dynamically (like RTC, 
BatchSorter, Queue, StageStats) by using Class.forName().newInstance() 
instead of something like:

   if (type.equals("direct"))
     rtc = new ResponseTimeControllerDirect(mgr, sw);
   else if (type.equals("pid"))
     rtc = new ResponseTimeControllerPID(mgr, sw);
   else if ...


With dynamic object creation, by exemple, any developer could create a 
RTC class and use it without recompile Sandstorm.


But, to implement that, I would like to add a new interface in 
seda.sandstorm.api.internal

/**
  * All InitializableIF implementation classes should provide
  * a "standard" constructor: a void (no arguments) constructor, which
  * creates an empty InitializableIF object.
  *
  * This interface is intended to initialize internal objects created
  * dynamically with Class.forName().newInstance().
  */
public interface InitializableIF {

   void init(ManagerIF mgr, StageWrapperIF stage);
}


So, RTC, Queue, BatchSorter and StageStats would extend this interface.


InitializableIF.init would be called only by the SW when the stage is 
programmed.  I wish that the name of this interface is not too 
confusing, because it has nothing to do with [init/destroy] lifecycle 
level?  Maybe it should be better to call it ProgrammableIF.program() ?






-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt