org.jvnet.hk2.component
Interface BaseServiceLocator

All Known Subinterfaces:
SimpleServiceLocator
All Known Implementing Classes:
Habitat

public interface BaseServiceLocator

Provide a simple abstraction for getting services by contract or type.

Author:
Mason Taube

Method Summary
<T> Collection<T>
getAllByContract(Class<T> contractType)
          Gets all the inhabitants registered under the given Contract.
<T> Collection<T>
getAllByContract(String contractType)
           
<T> T
getByContract(Class<T> contractType)
          Gets the object that has the given contract.
<T> T
getByContract(String contractType)
           
<T> T
getByType(Class<T> implType)
          Gets the object of the given type.
<T> T
getByType(String implType)
          Gets the object of the given type.
<T> T
getComponent(Class<T> clazz)
           
<T> T
getComponent(Class<T> contract, String name)
          Loads a component that implements the given contract and has the given name.
<T> T
getComponent(String fullQualifiedName, String name)
          Analogous to the following:
 

Method Detail

getComponent

<T> T getComponent(Class<T> contract,
                   String name)
               throws ComponentException
Loads a component that implements the given contract and has the given name.

Parameters:
name - can be null, in which case it'll only match to the unnamed component.
Returns:
null if no such service exists.
Throws:
ComponentException

getComponent

<T> T getComponent(String fullQualifiedName,
                   String name)
Analogous to the following:
 getComponent(contractClass.getName(), name);
 

Parameters:
fullQualifiedName - the contract class name
name - can be null, in which case it'll only match to the unnamed component.
Returns:
null if no such service exists.

getComponent

<T> T getComponent(Class<T> clazz)
               throws ComponentException
Throws:
ComponentException

getByType

<T> T getByType(Class<T> implType)
Gets the object of the given type.

Returns:
null if not found.

getByType

<T> T getByType(String implType)
Gets the object of the given type.

Returns:
null if not found.

getByContract

<T> T getByContract(Class<T> contractType)
Gets the object that has the given contract.

If there are more than one of them, this method arbitrarily return one of them.


getByContract

<T> T getByContract(String contractType)

getAllByContract

<T> Collection<T> getAllByContract(Class<T> contractType)
Gets all the inhabitants registered under the given Contract. This is an example of heterogeneous type-safe container.

Returns:
can be empty but never null.

getAllByContract

<T> Collection<T> getAllByContract(String contractType)


Copyright © 2012 Oracle Corporation. All Rights Reserved.