org.qi4j.api.service.importer
Class ServiceSelectorImporter<T>
java.lang.Object
org.qi4j.api.service.importer.ServiceSelectorImporter<T>
- All Implemented Interfaces:
- ServiceImporter<T>
public final class ServiceSelectorImporter<T>
- extends java.lang.Object
- implements ServiceImporter<T>
If several services are available with a given type, and you want to constrain
the current module to use a specific one, then use this importer. Specify a
Specification<ServiceReference<T>> criteria as meta-info for the service, which will be applied
to the list of available services, and the first match will be chosen.
This importer will avoid selecting itself, as could be possible if the ServiceQualifier.first()
filter is used.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ServiceSelectorImporter
public ServiceSelectorImporter()
importService
public T importService(ImportedServiceDescriptor serviceDescriptor)
throws ServiceImporterException
- Description copied from interface:
ServiceImporter
- Imports an instance of the service type described in the service descriptor.
- Specified by:
importService
in interface ServiceImporter<T>
- Parameters:
serviceDescriptor
- The service descriptor.
- Returns:
- The imported service instance.
- Throws:
ServiceImporterException
- if import failed.
isAvailable
public boolean isAvailable(T instance)
- Description copied from interface:
ServiceImporter
- Ask if the service is available or not.
- Specified by:
isAvailable
in interface ServiceImporter<T>
- Parameters:
instance
- the instance to be checked
- Returns:
- true if the service is available, false if not