harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lang Yang <yangl...@gmail.com>
Subject Re: [classlib] Is anyone working on java.util.ServiceLoader<S>
Date Tue, 15 Jun 2010 17:26:55 GMT
On Tue, Jun 15, 2010 at 1:00 PM, Tim Ellison <t.p.ellison@gmail.com> wrote:

> On 15/Jun/2010 17:41, Lang Yang wrote:
> > On Tue, Jun 15, 2010 at 12:26 PM, Tim Ellison <t.p.ellison@gmail.com>
> wrote:
> >
> >> On 15/Jun/2010 16:38, Lang Yang wrote:
> >>> Hello guys,
> >>>
> >>> I was trying to implement
> >>> javax.imageio.spi.ServiceRegistry.lookupProviders(Class) method (logged
> >> as
> >>> HARMONY-6553 [0]). What this method does is parse the service
> >>> provider-configuration file to get a set of service provider’s class
> >> name,
> >>> and instantiate them.[1]
> >>>
> >>> Alexei has found a really interesting documentation that shows Java 6
> has
> >>> introduced a new class, java.util.ServiceLoader<S> [2], a simple
> >>> service-provider loading facility. It can do everything that
> >>> lookupProviders(Class) needs to do, so we were thinking maybe we can
> >> re-use
> >>> this class? We found out later that this class is not implemented right
> >> now.
> >>> Is anyone working on this? Do we have any plan on this?
> >> Maybe you are looking in the wrong place?  I see code for
> >> java.util.ServiceLoader on the Java 6 stream here
> >>
> >>
> >>
> http://svn.apache.org/viewvc/harmony/enhanced/java/branches/java6/classlib/modules/luni/src/main/java/java/util/ServiceLoader.java?view=co
> >>
> >
> > Thanks, I found it now. I was looking in the trunk. There is another
> > question, how to re-use this class in Java 5 impl? Copy it class to
> > ServiceRegistry class and make it private?
>
> You can either 'steal' the code you need, and duplicate it into your
> class in the head stream; or copy it into a ServiceRegistryImpl type
> that you and the Java 6 stream share.
>
> I think it may be easier to create a near copy, since there is not too
> much code here, and it avoids the annoyances of having to also have a
> definition for the ServiceConfigurationError etc.


> But feel free to experiment!


> Regards,
> Tim
>

Actually, I found out that this impl is almost the same as the patch I
submitted to HARMONY-6553. But I forgot to verify if the provider class name
is a valid java name. So, I will just stick with my implementation, modify
that patch a bit and re-submit it later.

Thanks,

Lang


>
>
> >>>
> >>> [0] https://issues.apache.org/jira/browse/HARMONY-6553
> >>> [1]
> >>>
> >>
> http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/spi/ServiceRegistry.html#lookupProviders%28java.lang.Class%29
> >>> [2] http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html
> >>>
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message