com.vaadin.flow.di.
Interface Lookup
-
All Known Implementing Classes:
public interface Lookup
Provides a way to discover services used by Flow (SPI). Dependency injection frameworks can provide an implementation that manages instances according to the conventions of that framework.
This is similar to the
Instantiator
class but aLookup
instance is available even before aVaadinService
instance is created (and as a consequence there is no yet anInstantiator
instance).The
Lookup
instance and theVaadinContext
has one to one mapping and is available even before aDeploymentConfiguration
( andVaadinServlet
) is created. So this is kind of a singleton for a Web Application. As a consequence it provides and may return only web app singleton services.This is the code which one may use to get the
Lookup
instance:VaadinContext context = ...; Lookup lookup = context.getAttribute(Lookup.class);
This SPI is mostly for internal framework usage since
Instantiator
provides all required services for the application developer.Since:
Author:
Vaadin Ltd
See Also:
-
-
Method Summary
All Methods Modifier and Type Method and Description <T> T
lookup(Class<T> serviceClass)
Lookup for a service of the given type.
<T> Collection<T>
lookupAll(Class<T> serviceClass)
Lookup for all services by the provided
serviceClass
.
-
-
-
Method Detail
-
lookup
<T> T lookup(Class<T> serviceClass)
Lookup for a service of the given type.
The
serviceClass
is usually an interface (though it doesn't have to be) and the returned value is some implementation of this interface.Type Parameters:
T
- a service typeParameters:
serviceClass
- a service SPI classReturns:
a service which implements the
serviceClass
, may benull
if no services are registered for this SPISee Also:
-
lookupAll
<T> Collection<T> lookupAll(Class<T> serviceClass)
Lookup for all services by the provided
serviceClass
.The
serviceClass
is usually an interface class (though it doesn't have to be) and the returned value is all implementations of this interface.Type Parameters:
T
- a service typeParameters:
serviceClass
- a service SPI classReturns:
all services which implement the
serviceClass
, if no services found an empty list is returned (sonull
is not returned)
-
-