|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
@Deprecated public interface ServiceLocator<T>
A ServiceLocator provides runtime access to a particular service in HK2.
At any point in time, one can get theProvider
s that qualify
to the locator query by calling the super class methods.
There are two variations of ServiceLocators. The first type
is when a ServiceLocator is produced by methods like
Services#byType(Class)
and Services#byType(String)
.
In HK2, services "byType" represent a concrete class type lacking
any contract level abstraction of that concrete class as shown in
this example:
@Service public class Example { ... }Services "byType" are either present or they are not. This is because a service "byType" is a concrete class declaration as shown in the example above. Example.class will either be present in the
HK2
service registry or it will not. In another words, there
is no further way to abstractly locate Example.class when it
is being sought by its type.
The methods #getProvider() and {@link #get()}
represent access to the singleton if the service "byType" exists in
the HK2 service registry. If the service component does not exist then
these methods will return null. In this situation, {@link #all()} will
return an empty collection. Otherwise {@link #all} will return a
singleton collection.
The second variation of ServiceLocator is that it forms the
super interface for {@link ContractLocator} and is produced by methods
like {@link Services#forContract(Class)} and
{@link Services#forContract(String)}.
Unlike "byType" where there can either be zero or one manifestation of
a qualifying service, a {@link ContractLocator} can represent many
service instances in the HK2 service registry. In this case, the
methods {@link #getProvider()} and {@link #get()} represent
the "best qualifying" service matching the locator criteria.
See {@link ContractLocator} for more detail.
ContractLocator
Method Summary |
---|
Methods inherited from interface org.glassfish.hk2.Providers |
---|
all, get, getByType, getProvider |
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |