|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Locator
This contract provides the starting point for querying HK2's
backing service registry either by contract (e.g., classes
annotated with @Contract) or by concrete service type
(e.g., classes annotated with @Service).
Typically, DI is used to wire services together. Hk2 internals
uses the Locator to resolve services used with
@Inject during normal dependency injection.
The Locator interface can also be used for programmatic
resolution of services. Note, however, that it is recommended
for most developers to avoid programmatic service resolution,
and to instead rely upon DI wherever possible.
| Method Summary | ||
|---|---|---|
|
byType(Class<U> type)
Retrieve a service locator via a concrete service class type. |
|
ServiceLocator<?> |
byType(String typeName)
See forContract(Class), with the exception that the
type is provided as a string instead of a class instance. |
|
|
forContract(Class<U> contract)
Retrieve a service locator via a contract class. |
|
ContractLocator<?> |
forContract(String contractName)
See forContract(Class), with the exception that the
type is provided as a string instead of a class instance. |
|
|
forContract(TypeLiteral<U> typeLiteral)
See forContract(Class), with the exception that the
type is a TypeLiteral, a parameterized type. |
|
| Method Detail |
|---|
<U> ContractLocator<U> forContract(Class<U> contract)
// ExampleContract is an example of a contract type
@Contract
public interface ExampleContract {
}
@Service
public class Example implements ExampleContract {
}
contract - the contract class
ContractLocator<?> forContract(String contractName)
forContract(Class), with the exception that the
type is provided as a string instead of a class instance.
contractName - the contract class type name
<U> ContractLocator<U> forContract(TypeLiteral<U> typeLiteral)
forContract(Class), with the exception that the
type is a TypeLiteral, a parameterized type.
typeLiteral - the parameterized contract type literal name
<U> ServiceLocator<U> byType(Class<U> type)
// Example is an example of a service type
@Service
public class Example ... {
}
type - the service class type
ServiceLocator<?> byType(String typeName)
forContract(Class), with the exception that the
type is provided as a string instead of a class instance.
typeName - the service class type name
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||