Comment #6 on issue 436 by mcculls: Provide access to Guice's own internal  
TypeConverters
http://code.google.com/p/google-guice/issues/detail?id=436

> I gotta reject this patch because it overreaches the Guice injector to  
> become
> a general type conversion tool.

That's disappointing, without this patch I'll have to duplicate  
functionality already
contained inside Guice because it's not available via an external API.
(I'm working on replacing Plexus type conversion with a Guice-driven  
solution.)

BTW, here's how I came up with this patch...

Your original suggestion was to simply expose the ~10 internal type  
converter
implementations as constant objects on the API. IMHO this would lead to  
tight
coupling and make it harder to change the set of converters provided by  
Guice.

I considered adding an API/SPI to list/query the installed set of type  
converters
including the internal set (like you can do with all bindings, incl.  
just-in-time)
but clients would still be using the raw TypeConverter API which is not  
type-safe.
They would also be duplicating the lookup+checking already done by the  
Injector.

Therefore I decided to provide a type-safe "convertConstant" method, which  
linked the
required type and return value. The injector already has code to find the  
right
converter and check the converted value is of the right type, so this is  
really just
a bit of refactoring and a new method to allow clients to request the same  
sort of
conversions as done by the injector itself.

> We actually have a full type converter framework that's built upon Guice,  
> but
> it's currently Google proprietary. Like a solid framework, that converter
> architecture is fully typesafe (it doesn't return Object instances), it
> supports lots of target types (protobuffers, possibly DOM elements), plus
> polymorphism and composition.

Hehe, knowing there's a great proprietary system out there isn't much  
comfort ;)

> I'd like to avoid supporting weak converters when I know that it's  
> insufficient
> for general purpose use.

Sure, but this is really just allowing clients to apply the same  
conversions that
Guice applies internally to satisfy constant bindings. We're not adding  
additional
logic to the Injector, merely exposing the constant conversion feature to  
clients.

> That said, there is a market for a general purpose type converter  
> framework.
> I'm not sure whether ours is worthy of open sourcing, or if we have the  
> manpower
> to do so.

Unfortunately I'm on a tight schedule. We were hoping to replace Plexus  
completely
with Guice, but it looks like we may have to keep the Plexus type  
conversion system
around, or swap in something like XStream. Then again I could do a simple  
copy-paste
of the bits I need (although I hate duplicating code) or maintain a patched  
build of
Guice for our own use (which I also hate doing).

Oh well, back to the drawing board...

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to