Re: [picocontainer-dev] JSR330 work progress

Mark Hobson <[email protected]> Fri, 30 Jul 2010 11:19:15 +0100
Newsgroups gmane.comp.java.picocontainer.devel
Message-ID <[email protected]>
Good to see that work is progressing on JSR330 Paul!

I know I've mentioned it before, and it may be more pertinent now
regarding TypeOf, but JType [1] has support for type literals via
Generic<T> [2].  It also provides various factory methods to construct
them in Generics and implements the complicated type assignability
logic in TypeUtils.isAssignable, which I guess you'll need.

I'm happy to help out from the JType side of things if you wanted to
integrate it into Pico?

Cheers,

Mark

[1] http://code.google.com/p/jtype/
[2] http://jtype.googlecode.com/svn/site/apidocs/com/googlecode/jtype/Gener=
ic.html

On 23 July 2010 10:23, Paul Hammant <[email protected]> wrote:
> Hi folks,
> I'm working towards JSR330 compatibility in the Git Pico3 repo. =A0There'=
s a
> TCK that comes with JSR330 so tracking progress is easy.
> First up, I've had to add a mechanism to a) preserve type erasure and b)
> allow lookup based on types. =A0Looking at the PicoContainer API, you'll =
see
> =A0=A0 =A0<T> T getComponent(TypeOf<T> componentType);
> .. in addition to ..
> =A0=A0 =A0<T> T getComponent(Class<T> componentType);
> TypeOf is used rather than Type itself because one cannot do the followin=
g
> in Java:
> =A0=A0 =A0 List<Color> colors =3D pico.getComponent(List<Color>.class);
> Instead (and like Guice), we'll have to do:
> =A0=A0 =A0 List<Color> colors =3D pico.getComponent(new TypeOf<Color>(){}=
); // note
> the anon inner class
> TypeOf is doing a=A0getGenericSuperclass() call to preserve the generics =
info.
> =A0I've to think more about references being held to TypeOf instances bec=
ause
> of the inner class consequences for garbage collection.
> Internally, PicoContainer is moving towards using TypeOf as the general k=
ey
> for items. =A0Thus even 'old fashioned' Class keys are morphed into TypeO=
fs
> via TypeOf.fromClass(Class c) calls.
> - Paul

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email