Hi Asiri, On Dec 8, 2009, at 3:26 AM, Asiri Rathnayake wrote:
Hi Devs,
I've looked into Google Guice to find out what's the buzz is all about. But as far as I can understand (with only about 30 mins scan through their user guide), XWiki Component management framework is more flexible than Guice. I'm not a Guice user but being familiar with XWiki Components, the closest thing I found on Guice was JIT bindings: http://code.google.com/p/google-guice/wiki/JustInTimeBindings.
With access to ComponentManager, XWiki Component management framework provides components the ability to lookup for component implementations dynamically using a component hint, I didn't see anything similar in Guice.
This exists in Guice, it's called annotations. See http://code.google.com/p/google-guice/wiki/BindingAnnotations It's done in a better way in Guice since it allows for typed hints (it also support the @Named("hinthere") solution).
Am I missing something? Are these two frameworks mutually exclusive or something?
What doesn't seem to exist in Guice is the ability to dynamically register a new component. They do have the @Provides and Provider solutions see http://code.google.com/p/google-guice/wiki/ProviderBindings see http://code.google.com/p/google-guice/wiki/ProvidesMethods But this is not nice since if we wanted to do this for all components then we'd find ourselves reimplementing the creation of instances manually. The solution I've seen recommended to support dynamic registration/ unreg is to use peaberry. My personal opinion: - our implementation seems to work fine so far (which is strange for me since I was expecting threading issues, maybe we just haven't found them yet ;)) and is lightweight so there's no reason to change for something equivalent. Thus I don't see any need to move to Guice right now (even though Guice is a very nice fwk and supports more stuff than we do - except for the dynamicity part). - we might need something more powerful in the future like the ability to handle classloading isolation to support the ability to load several versions of the same components. Should we need this we should probably move to either Peaberry or to OSGi directly. This need may arise when we implement our Extension Manager - we need to move to JSR299 annotation ASAP Thanks -Vincent