org.gvsig.tools.util.impl
Class DefaultServiceLoader

java.lang.Object
  extended by org.gvsig.tools.util.impl.DefaultServiceLoader
All Implemented Interfaces:
ServiceLoader

public class DefaultServiceLoader
extends Object
implements ServiceLoader

Implementation which uses reflection to try to use first the standard JDK utilities to load service implementation classes, which are available since JDK 1.6. If it fails or the JDK used is < 1.6, the old mechanism based on the usage of internal sun classes is used.

To register your implementations classes eLfor a service, use the mechanism explained in the Java JAR file specification for the JDK version you are using:

Author:
Cèsar Ordiñana

Constructor Summary
DefaultServiceLoader()
          Constructor.
 
Method Summary
 void addClassLoader(ClassLoader classLoader)
          Adds a ClassLoader to use to find services, in the case we don't provide one.
 Set load(Class serviceClass)
          Loads a Set of a object instances which implement or extended a common service interface or class.
 Set load(Class serviceClass, ClassLoader classLoader)
          Loads a Set of a object instances which implement or extended a common service interface or class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultServiceLoader

public DefaultServiceLoader()
Constructor.

Method Detail

addClassLoader

public void addClassLoader(ClassLoader classLoader)
Description copied from interface: ServiceLoader
Adds a ClassLoader to use to find services, in the case we don't provide one.

Specified by:
addClassLoader in interface ServiceLoader

load

public Set load(Class serviceClass)
Description copied from interface: ServiceLoader
Loads a Set of a object instances which implement or extended a common service interface or class. The services will be loaded using the current ClassLoader and the list of ClassLoaders provided with the ServiceLoader.addClassLoader(ClassLoader) method, if any.

Specified by:
load in interface ServiceLoader
Parameters:
serviceClass - the interface or class which the loaded objects must implement or extend
Returns:
the Set of loaded object instances

load

public Set load(Class serviceClass,
                ClassLoader classLoader)
Description copied from interface: ServiceLoader
Loads a Set of a object instances which implement or extended a common service interface or class. The classes are loaded through the provided ClassLoader

Specified by:
load in interface ServiceLoader
Parameters:
serviceClass - the interface or class which the loaded objects must implement or extend
classLoader - the ClassLoader to load the classes from
Returns:
the Set of loaded object instances


Copyright © 2004-2011 gvSIG. All Rights Reserved.