Package org.xmldb.api.base
Interface ServiceProvider
-
- All Known Subinterfaces:
Collection
- All Known Implementing Classes:
ServiceProviderCache
public interface ServiceProviderTheServiceProviderinterface access to theServiceimplementation instances and is able to query for implemented ones.- Since:
- 2.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <S extends Service>
java.util.Optional<S>findService(java.lang.Class<S> serviceType)Returns optionalServiceinstance for the requestedserviceType.default <S extends Service>
SgetService(java.lang.Class<S> serviceType)Returns aServiceinstance for the requestedserviceType.<S extends Service>
booleanhasService(java.lang.Class<S> serviceType)Checks if a service of the given serviceType is available.
-
-
-
Method Detail
-
hasService
<S extends Service> boolean hasService(java.lang.Class<S> serviceType)
Checks if a service of the given serviceType is available. This method will returnfalsein case of the specified service can not be provided for any reason.- Returns:
trueif the given service type is supported,false otherwise- Since:
- 2.0
-
findService
<S extends Service> java.util.Optional<S> findService(java.lang.Class<S> serviceType)
Returns optionalServiceinstance for the requestedserviceType. If noServiceexists or can be provided an empty optional is returned.- Type Parameters:
S- the type of service- Parameters:
serviceType- the type of service to return- Returns:
- a optional instance of the given service type
- Since:
- 2.0
-
getService
default <S extends Service> S getService(java.lang.Class<S> serviceType) throws XMLDBException
Returns aServiceinstance for the requestedserviceType. If noServiceexists aXMLDBExceptionwithErrorCodes.NO_SUCH_SERVICEis thrown.- Type Parameters:
S- the type of service- Parameters:
serviceType- the type of service to return- Returns:
- a instance of the given service type
- Throws:
XMLDBException- with expected error codes.ErrorCodes.NO_SUCH_SERVICEif the service does not exist,ErrorCodes.VENDOR_ERRORfor any vendor specific errors that occur.ErrorCodes.COLLECTION_CLOSEDif theclosemethod has been called on theCollection- Since:
- 2.0
-
-