Class ServiceRegistry<K,S>
- java.lang.Object
-
- org.eclipse.rdf4j.common.lang.service.ServiceRegistry<K,S>
-
- Direct Known Subclasses:
DatatypeHandlerRegistry,FileFormatServiceRegistry,FunctionRegistry,LanguageHandlerRegistry,QueryParserRegistry,RepositoryRegistry,SailRegistry,TransactionSettingRegistry,TupleFunctionRegistry
public abstract class ServiceRegistry<K,S> extends Object
A registry that stores services by some key. Upon initialization, the registry searches for service description files at META-INF/services/<service class name> and initializes itself accordingly.- Author:
- Arjohn Kampman
- See Also:
ServiceRegistry
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedServiceRegistry(Class<S> serviceClass)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Optional<S>add(S service)Adds a service to the registry.Optional<S>get(K key)Gets the service for the specified key, if any.Collection<S>getAll()Gets all registered services.protected abstract KgetKey(S service)Gets the key for the specified service.Set<K>getKeys()Gets the set of registered keys.booleanhas(K key)Checks whether a service for the specified key is available.voidremove(S service)Removes a service from the registry.
-
-
-
Method Detail
-
add
public Optional<S> add(S service)
Adds a service to the registry. Any service that is currently registered for the same key (as specified bygetKey(Object)) will be replaced with the new service.- Parameters:
service- The service that should be added to the registry.- Returns:
- The previous service that was registered for the same key, or
Optional.empty()if there was no such service.
-
remove
public void remove(S service)
Removes a service from the registry.- Parameters:
service- The service be removed from the registry.
-
get
public Optional<S> get(K key)
Gets the service for the specified key, if any.- Parameters:
key- The key identifying which service to get.- Returns:
- The service for the specified key, or
Optional.empty()if no such service is avaiable.
-
has
public boolean has(K key)
Checks whether a service for the specified key is available.- Parameters:
key- The key identifying which service to search for.- Returns:
- true if a service for the specific key is available, false otherwise.
-
getAll
public Collection<S> getAll()
Gets all registered services.- Returns:
- An unmodifiable collection containing all registered servivces.
-
getKeys
public Set<K> getKeys()
Gets the set of registered keys.- Returns:
- An unmodifiable set containing all registered keys.
-
-