Archived
This forum has been archived. Please start a new discussion on GitHub.
IceBox and service creation patterns
I noticed the following note in IceBox.ServiceManagerI.java (v3.4.1)
// NOTE: the class isn't final on purpose to allow users to eventually
// extend it.
This is exactly what I would like to do: Extend ServiceManagerI to support more flexible (than c.newInstance()) creation patterns. Specifically, I would like to load the service implementations from a Spring application context.
My initial thought is to separate service instantiation from invoking the service (currently all done in start(), ServiceManagerI:471).
I suggest adding a method:
protected ServiceInfo createService(String className);
Which would encapsulate the initial block of code in start() that creates the ServiceInfo and instantiate the service class. Then, in the for-block in run() [line 355], call both createService() and start(). And wrap them in a try/catch so uncaught exceptions will interrupt only one service, not all.
Is this a reasonable approach? Am I missing anything?
There would also have to be a hook in IceBox.Server.java to instantiate an overridden ServiceManagerI, but I think the code in Server is small/simple enough to clone/own. (And I would consider combining them.)
I am happy to provide a patch for this if you would find it useful.
Thanks,
- Paul Philion
// NOTE: the class isn't final on purpose to allow users to eventually
// extend it.
This is exactly what I would like to do: Extend ServiceManagerI to support more flexible (than c.newInstance()) creation patterns. Specifically, I would like to load the service implementations from a Spring application context.
My initial thought is to separate service instantiation from invoking the service (currently all done in start(), ServiceManagerI:471).
I suggest adding a method:
protected ServiceInfo createService(String className);
Which would encapsulate the initial block of code in start() that creates the ServiceInfo and instantiate the service class. Then, in the for-block in run() [line 355], call both createService() and start(). And wrap them in a try/catch so uncaught exceptions will interrupt only one service, not all.
Is this a reasonable approach? Am I missing anything?
There would also have to be a hook in IceBox.Server.java to instantiate an overridden ServiceManagerI, but I think the code in Server is small/simple enough to clone/own. (And I would consider combining them.)
I am happy to provide a patch for this if you would find it useful.
Thanks,
- Paul Philion
0