[OpenJDK 2D-Dev] Howto install a custom rendering engine?

Andrew John Hughes gnu_andrew at member.fsf.org
Mon Nov 2 19:59:01 UTC 2009

2009/11/2 Clemens Eisserer <linuxhippy at gmail.com>:
> Hi,
> I am trying to install my own RenderingEngine implementation, however
> I am not accustomed to the ServiceLoader concept:
>>                    ServiceLoader<RenderingEngine> reLoader =
>>                        ServiceLoader.loadInstalled(RenderingEngine.class);
> the ServiceLoader doesn't e.g. contain my CairoRenderingEngine.
> Would it be enough to simply create a META-INF directory with a single
> file in it, similar to what has been done for pisces?
> Is there any way to influence the iteration-order?
> If possible I would prefer my RendeingEngine to be tried before Pisces
> when its mature and complete, at least it should be configureable
> without passing the cmd-line parameter every time.
> Whats the purpose of the ServiceLoader, wouldn't it be possible to
> simply load the class specified on the command-line directly?
> Thank you in advance, Clemens


You need a text file in META-INF/services/<package
name>.RenderingEngine which lists the provided implementations.
loadInstalled uses the extension class loader so that resources needs
to be loadable by that classloader.  I presume this means it needs to
be available in ${JAVA_HOME}/jre/lib/ext.

You seem to contradict yourself, you want it to be 'configurable
without passing the command-line parameter every time' but then ask
why we can't simply load a class specified on the command-line.  The
job of ServiceLoader and the META-INF/services files is to facilitate
exactly what you appear to want -- configuring things once and having
the service loaded on normal java invocations.

As to ordering, you can make sure your engine is first in this list at
least, but that is affected by caching and the time it takes to load a
Andrew :-)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK

PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint: F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8

More information about the 2d-dev mailing list