I am throwing this out there for general consumption. I have been thinking, Managers
inherently manage resources. That means that the resources must be initialized and
disposed of properly. Instead of forcing the class using the interface to perform
dynamic ***Manager instanceof Initializable calls, I propose to have a systemic
approach
that all Managers are Initializable and Disposable.
The proposed interfaces would be:
interface Manager extends Initializable, Disposable {}
interface ActiveManager extends Manager, Suspendable {}
This provides a nice and simple interface without the user of the manager having to
check for dynamic things. I don't want the Startable interface because it merely
confuses things. It is either initialized or not. This would allow me to provide
functionality like this:
ContainerManager manager = new ContainerManager( initialParams );
manager.initialize();
// do stuff
manager.dispose();
return;
If I decided to specialize ContainerManager to manage an active Container, I would
have something like this:
ActiveContainerManager manager = new ActiveContainerManager( initialParams );
manager.initialize();
// do stuff
manager.suspend();
// wait for a while
manager.resume();
// do more stuff
manager.dispose();
return;
As you can see the approach allows me to interact with the ContainerManager (the root
Manager in my system) in a consistent manner without having unnecessary casts).
Furthermore, certain managers like the CommandManager require the Suspendable interface
for those times when you really want to suspend a system. It provides a nice and tidy
method for doing things.
The concept behind the Manager is that it should be easy to use--without too many
lifecycle methods. Initialize and Dispose are very common in the world of managed
resources.
I am open to feedback on this issue.
--
"They that give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety."
- Benjamin Franklin
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>