Fix OPENDJ-346 Consider using java.util.ServiceLoader for loading extensions and requesting transport implementations
This a a part of OPENDJ-175 - Decouple OpenDJ LDAP SDK from Grizzly
CR-2440
* LDAPConnectionFactory/LDAPListener load its implementation via java.util.ServiceLoader, the JDK loader facility.
An implementation is given by a transport provider.
Common code to load a provider is implemented in StaticUtils#getProvider
* New package org.forgerock.opendj.ldap.spi that contains interfaces for providers and implementations.
TransportProvider interface which provides:
- LDAPConnectionFactoryImpl, implementation for LDAPConnectionFactory
- LDAPListenerImpl, implementation for LDAPListener
* There is one transport provider based on Grizzly: GrizzlyTransportProvider class which provides the two implementation classes
- GrizzlyLDAPConnectionFactory
- GrizzlyLDAPListener
In order to locate transport provider to use, the file 'org.forgerock.opendj.ldap.spi.TransportProvider'
must be available in the classpath in META-INF/services directory.
That file is included with the value "com.forgerock.opendj.ldap.GrizzlyTransportProvider" to have Grizzly as the default provider
* LDAPOptions and LDAPListenerOptions:
- have no more TCPNIOTransport option,
- have two new options transportProvider and providerClassLoader to tune loading of providers.
- transportProvider allow to require a given provider (eg, "Grizzly"), otherwise the first provider found will be used.
- providerClassLoader allow to provide a class loader to use when several class loaders are used by an application.
ServiceLoader needs to load both provider-configuration file and provider class from the same class loader,
so there are case where you must provide the correct class loader to find the provider class.
* Fixed all the tests in opendj-ldap-sdk, because they suffer from the class loader problem if not providing the right class loader
- Systematically provide the class loader used by test class when creating LDAPConnectionFactory or LDAPListener
- Added utility methods in TestCaseUtils class to ease the use of custom class loader
* Fixed tests in modules: opendj-ldap-toolkit and opendj-server2x-adapter
- Same fix than for opendj-ldap-sdk
- Added new TestCaseUtils.java class in both modules to hold utility methods