org.jvnet.hk2.component
Interface SimpleServiceLocator

All Known Implementing Classes:
Habitat

public interface SimpleServiceLocator

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

Author:
Jerome Dochez, Jeff Trent

Method Summary
<T> T
getByType(java.lang.Class<T> implType)
          Gets the object of the given type.
<T> T
getByType(java.lang.String implType)
          Gets the object of the given type.
<T> T
getComponent(java.lang.Class<T> contract, java.lang.String name)
          Loads a component that implements the given contract and has the given name.
<T> T
getComponent(java.lang.String fullQualifiedName, java.lang.String name)
          Analogous to the following:
 

Method Detail

getComponent

<T> T getComponent(java.lang.Class<T> contract,
                   java.lang.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(java.lang.String fullQualifiedName,
                   java.lang.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.

getByType

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

Returns:
null if not found.

getByType

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

Returns:
null if not found.


Copyright © 2011 Oracle Corporation. All Rights Reserved.