Package org.jboss.ws.api.util
Class ServiceLoader
- java.lang.Object
-
- 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:- 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.
- If a system property with the given name is defined, then its value is used as the name of the implementation class.
- Finally, a default implementation class name is used.
- Since:
- 14-Dec-2006
- Author:
- Thomas Diesler, Alessio Soldano, Richard Opalka
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectloadService(String propertyName, String defaultFactory)This method uses the algorithm below using the JAXWS Provider as an example.static ObjectloadService(String propertyName, String defaultFactory, ClassLoader cl)This method uses the algorithm below using the JAXWS Provider as an example.
-
-
-
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/jakarta.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 jakarta.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 jakarta.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 resolvedefaultFactory- Default factory class name to be used when not able to resolve anythingcl- 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/jakarta.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 jakarta.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 jakarta.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 callingloadService(String propertyName, String defaultFactory, ClassLoader cl)passing in the Thread.currentThread().getContextClassLoader().- Parameters:
propertyName- The property name for the service to resolvedefaultFactory- Default factory class name to be used when not able to resolve anything- Returns:
- A new instance of the required service
-
-