What are the best practices for using ServiceLoader in an Environment with multiple ClassLoaders? The documentation recommends to create and save a single service instance at initialization:

private static ServiceLoader&lt;CodecSet&gt; codecSetLoader = ServiceLoader.load(CodecSet.class);


This would initialize the ServiceLoader using the current context classloader. Now suppose this snippet is contained in a class loaded using a shared classloader in a web container and multiple web applications want to define their own service implementations. These would not get picked up in the above code, it might even be possible that the loader gets initialized using the first webapps context classloader and provide the wrong implementation to other users.

Always creating a new ServiceLoader seems wasteful performance wise since it has to enumerate and parse service files each time. Edit: This can even be a big performance problem as shown in this answer regarding java's XPath implementation.

How do other libraries handle this? Do they cache the implementations per classloader, do they reparse their configuration everytime or do they simply ignore this problem and only work for one classloader?


Question: Noise comparison for sensors the D800 vs the D600
Answer: All large sensor cameras top-notch for landscape photography because no matter which, noise is extremely low around base ISO which is what you will be most likely shooting at. From a tripod I might add, which is essential to get critical sharpness.

Noise being the same at such low ISO setting, what you are left is the question of resolution which depends on how big you intend to print. If large, the D800 is certainly worth the money. If not, then getting the D600 will probably afford you a better lens which is even more important when it comes to sharpness.

The one thing you did not mention which is important for landscape is dynamic-range. The D600 has a slightly wider DR than the D800. So, if the resolution is not an issue for the print sizes you make, I would strongly consider the D600 instead.