nuun-io / kernel

Nuun Kernel is an IOC component for creation of powerfull enterprise stack.
Other
8 stars 5 forks source link

Add Lifecycle hooks #54

Open pith opened 8 years ago

pith commented 8 years ago

Currently start() and stop() methods comes from the Plugin interface. It can be a good idea to move then to a new Lifecycle interface. The AbstractPlugin should extends this new interface for compatibility.

It will allow application developers to easily start/stop resources without creating a Plugin. Lifecycle implementations can be scanned during the init phase so there will be no need for ServiceLoader here.

ejemba commented 8 years ago

I think it is a good idea ! Let us think what can be the downside of this. Why do not create a plugin that will do this exact thing ? Will the Resource be injected ? or Injectable ? both ? I imagine having this can be great. Does plugin and resource really need to share this interface ?

pith commented 8 years ago

Yes they should be injectable. Exactly like plugins currently.

And Yes, I think it should be the same interface. It's frequent that plugins don't implement lifecycle methods. So I think these methods could be extracted as a separate concern.

The kernel will start/stop all the Lifecycle implementations whether they are plugins or not. And not all the plugins have to implements Lifecycle.

ejemba commented 8 years ago

@pith you're right. This is a must for the 1.0 milestone.

I wonder If we might or not fullfill the JSR 250 which purpose is Resource Management. https://en.wikipedia.org/wiki/JSR_250

We have to be carefull that when we scan for Lifecycle we do not reach plugin themselves.

ejemba commented 8 years ago

I think the JSR 250 is also a must have but in another issue. Adding jsr250 annotations on injected pojo might also be a good addition to the kernel. I create the issue.