org.jboss.ws.api.util
Class ServiceLoader

java.lang.Object
  extended by org.jboss.ws.api.util.ServiceLoader

public final class ServiceLoader
extends Object

Load a service class of a given name using this ordered lookup procedure:

  1. If a resource file with the given name is found in META-INF/services/..., then its first line, if present, is used as the UTF-8 encoded name of the implementation class.
  2. If the ${java.home}/lib/jaxws.properties file exists and it is readable by the java.util.Properties.load(InputStream) method and it contains an entry whose key is the given name, then the value of that entry is used as the name of the implementation class.
  3. If a system property with the given name is defined, then its value is used as the name of the implementation class.
  4. Finally, a default implementation class name is used.

Since:
14-Dec-2006
Author:
Thomas Diesler, Alessio Soldano

Method Summary
static Object loadService(String propertyName, String defaultFactory)
          This method uses the algorithm below using the JAXWS Provider as an example.
static Object loadService(String propertyName, String defaultFactory, ClassLoader cl)
          This method uses the algorithm below using the JAXWS Provider as an example.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadService

public static Object loadService(String propertyName,
                                 String defaultFactory,
                                 ClassLoader cl)
This method uses the algorithm below using the JAXWS Provider as an example.
 1. If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then
 its first line, if present, is used as the UTF-8 encoded name of the implementation class.
 
 2. If the ${java.home}/lib/jaxws.properties file exists and it is readable by the 
 java.util.Properties.load(InputStream) method and it contains an entry whose key is 
 javax.xml.ws.spi.Provider, then the value of that entry is used as the name of the implementation class.
 
 3. If a system property with the name javax.xml.ws.spi.Provider is defined, then its value is used
 as the name of the implementation class.
 
 4. Finally, a default implementation class name is used.
 

Parameters:
propertyName - The property name for the service to resolve
defaultFactory - Default factory class name to be used when not able to resolve anything
cl - The classLoader to be used for loading resolved service
Returns:
A new instance of the required service

loadService

public static Object loadService(String propertyName,
                                 String defaultFactory)
This method uses the algorithm below using the JAXWS Provider as an example.
 1. If a resource with the name of META-INF/services/javax.xml.ws.spi.Provider exists, then
 its first line, if present, is used as the UTF-8 encoded name of the implementation class.
 
 2. If the ${java.home}/lib/jaxws.properties file exists and it is readable by the 
 java.util.Properties.load(InputStream) method and it contains an entry whose key is 
 javax.xml.ws.spi.Provider, then the value of that entry is used as the name of the implementation class.
 
 3. If a system property with the name javax.xml.ws.spi.Provider is defined, then its value is used
 as the name of the implementation class.
 
 4. Finally, a default implementation class name is used.
 
This is equivalent to calling loadService(String propertyName, String defaultFactory, ClassLoader cl) passing in the Thread.currentThread().getContextClassLoader().

Parameters:
propertyName - The property name for the service to resolve
defaultFactory - Default factory class name to be used when not able to resolve anything
Returns:
A new instance of the required service


Copyright © 2012 JBoss, by Red Hat. All Rights Reserved.