On 4/22/11 11:00 PM, Michael Anstis wrote:
> Hi,
>
> I am trying to resolve a problem that I assume relates to class loading.
>
> My application contains a JAR that contains a file in META-INF\services:-
>
> MyApp
> \-- WEB-INF
> \-- lib
> \-- AJar.jar
> \-- META-INF
> \-- services
> \-- Afile
>
> MyApp tries to load Afile using:-
>
> ClassLoader.getSystemResources("META-INF/services/AFile)
Typically the way that services are used:
\-- my.jar
\-- META-INF
\-- services
\-- org.package.SomeInterface
Containing:
org.package.impls.SomeInterfaceImpl
which is a class requiring a no arg constructor.
Then, in your code:
import java.util.ServiceLoader;
... etc ...
ServiceLoader<SomeInterface> loader =
ServiceLoader.load(SomeInterface.class);
for (SomeInterface si : loader) {
// use implementation
}
p
signature.asc
Description: OpenPGP digital signature
