I'm not sure it can be done.   The reason is that the provider default
class name is usually embedded in a static method of the factory which is
part of the api and not in the FactoryFinder.
For example I have the following code coming from the stax XMLInputFactory
class on my mac jre:

  public static XMLInputFactory newInstance()
    throws FactoryConfigurationError
  {
    return (XMLInputFactory) FactoryFinder.find(
      "javax.xml.stream.XMLInputFactory",
      "com.sun.xml.internal.stream.XMLInputFactoryImpl");
  }

Loading this class is not really easy if we deploy our own specs as
endorsed and I suppose we'd have ClassCastException if we really use that
one.


Also, there's always the possibility to configure the system properties
which would be used after any implementation provided by an osgi bundle,
but before the default factory.
If we look at how the packages are loaded by the karaf main class using
${jre-${java.specification.version}}, we might be able to do the same for
those properties using ${java.specification.vendor} .


On Fri, Nov 18, 2011 at 16:45, Daniel Kulp <[email protected]> wrote:

> On Friday, November 18, 2011 4:39:57 PM Guillaume Nodet wrote:
> > On Fri, Nov 18, 2011 at 16:25, Guillaume Nodet <[email protected]> wrote:
> > > On Fri, Nov 18, 2011 at 16:19, Daniel Kulp <[email protected]> wrote:
> > >> Can I have more details on that last point?    Keep in mind, the class
> > >> names
> > >> for the defaults are very different depending on the JDK in use.
> > >> Thus,
> > >> you
> > >> cannot just change the default classname in spec jar as that may not
> > >> work on
> > >> the JDK.    You may need to find a way to actually get it to dig into
> > >> the Provider factory thing in the JDK to get the right class name.
> > >
> > > Yes, that's really one point I still have to investigate as I'd like to
> > > be able to use the JRE provided implementations when possible.
> > > I don't really see any other solution than to hardcode the names as the
> > > implementation class names aren't available easily (I really don't want
> > > to start hacking into byte code to find the value of parameter calls).
> > > I suppose that would mean supporting a limited set of JDK that we would
> > > have tested our default values with.
>
> Is there a way to get the bytecode for the original FactoryFinder out of
> the
> rt.jar (or wherever on Mac), create class out of it and just call it?
>
> Guess that still involves a little bytecode manipulation.  :-(
>
>
> --
> Daniel Kulp
> [email protected] - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
>



-- 
------------------------
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
------------------------
Open Source SOA
http://fusesource.com

Reply via email to