org.jvnet.hk2.component
Class Habitat

java.lang.Object
  extended by org.jvnet.hk2.component.Habitat
All Implemented Interfaces:
ServiceLocator, BaseServiceLocator, SimpleServiceLocator

Deprecated.

@Deprecated
public class Habitat
extends Object
implements ServiceLocator, SimpleServiceLocator

A set of templates that constitute a world of objects.

Author:
Kohsuke Kawaguchi, Jerome Dochez

Constructor Summary
Habitat()
          Deprecated.  
Habitat(Habitat parent, String name)
          Deprecated.  
Habitat(ServiceLocator delegate)
          Deprecated.  
 
Method Summary
 void add(Inhabitant<?> i)
          Deprecated. Adds a new inhabitant.
<T> void
addComponent(T component)
          Deprecated. Add an already instantiated component to this manager.
 void addIndex(Inhabitant<?> i, String index, String name)
          Deprecated. Adds a new index to look up the given inhabitant.
protected  void addIndex(Inhabitant<?> i, String index, String name, boolean notify)
          Deprecated.  
<T> T
create(Class<T> createMe)
          Deprecated. This method will analyze the given class, and create it if can.
<U> U
createAndInitialize(Class<U> createMe)
          Deprecated. This method creates, injects and post-constructs an object with the given class.
<T> Collection<T>
getAllByContract(Class<T> contractType)
          Deprecated. Gets all the inhabitants registered under the given Contract.
<T> Collection<T>
getAllByContract(String contractType)
          Deprecated.  
<T> Collection<T>
getAllByType(Class<T> implType)
          Deprecated. Gets the object of the given type.
 List<ServiceHandle<?>> getAllServiceHandles(Annotation qualifier, Annotation... qualifiers)
          Deprecated. Gets service handles that can be used to get and destroy the returned services
 List<ServiceHandle<?>> getAllServiceHandles(Filter searchCriteria)
          Deprecated. Gets a service handle that can be used to get and destroy the returned service.
 List<ServiceHandle<?>> getAllServiceHandles(Type contractOrImpl, Annotation... qualifiers)
          Deprecated. Gets service handles that can be used to get and destroy the returned services
<T> List<T>
getAllServices(Annotation qualifier, Annotation... qualifiers)
          Deprecated. Gets the all the services from this locator that has the given qualifier or qualifiers
 List<?> getAllServices(Filter searchCriteria)
          Deprecated. Gets the all the services from this locator that implements this contract or has this implementation
<T> List<T>
getAllServices(Type contractOrImpl, Annotation... qualifiers)
          Deprecated. Gets the all the services from this locator that implements this contract or has this implementation
 ActiveDescriptor<?> getBestDescriptor(Filter filter)
          Deprecated. Gets the descriptor that best matches this filter, taking ranking and service id into account
<T> T
getByContract(Class<T> contractType)
          Deprecated. Gets the object that has the given contract.
<T> T
getByContract(String contractType)
          Deprecated.  
<T> T
getByType(Class<T> implType)
          Deprecated. Gets the object of the given type.
<T> T
getByType(String implType)
          Deprecated. Gets the object of the given type.
<T> T
getComponent(Class<T> clazz)
          Deprecated. Obtains a reference to the component inside the manager.
<T> T
getComponent(Class<T> contract, String name)
          Deprecated. Loads a component that implements the given contract and has the given name.
<T> T
getComponent(String fullQualifiedName, String name)
          Deprecated. Analogous to the following:
 List<ActiveDescriptor<?>> getDescriptors(Filter filter)
          Deprecated. Gets the list of descriptors that match the given filter
<T> Inhabitant<T>
getInhabitant(Class<T> contract, String name)
          Deprecated. Gets a lazy reference to the component.
<T> Inhabitant<T>
getInhabitant(Type type, String name)
          Deprecated.  
 Inhabitant<?> getInhabitantByAnnotation(Class<? extends Annotation> contract, String name)
          Deprecated. Gets the inhabitant that has the given contract annotation and the given name.
 Inhabitant<?> getInhabitantByContract(String typeName)
          Deprecated. Get the first inhabitant by contract
 Inhabitant getInhabitantByContract(String fullyQualifiedName, String name)
          Deprecated.  
<T> Inhabitant<T>
getInhabitantByType(Class<T> implType)
          Deprecated. Gets a lazy reference to the component.
 Inhabitant<?> getInhabitantByType(String fullyQualifiedClassName)
          Deprecated.  
<T> Inhabitant<T>
getInhabitantByType(Type implType)
          Deprecated.  
<T> Collection<Inhabitant<? extends T>>
getInhabitants(Class<T> type)
          Deprecated. Gets all the inhabitants for a spcial contract.
<T> Iterable<Inhabitant<? extends T>>
getInhabitants(Class<T> contract, String name)
          Deprecated. Gets all the inhabitants that has the given contract and the given name

This method defers the actual instantiation of the component until Inhabitant.get() is invoked.

 Iterable<Inhabitant<?>> getInhabitantsByAnnotation(Class<? extends Annotation> contract, String name)
          Deprecated. Gets all the inhabitants that has the given contract annotation and the given name.
 Collection<Inhabitant<?>> getInhabitantsByContract(String fullyQualifiedClassName)
          Deprecated.  
<T> Collection<Inhabitant<T>>
getInhabitantsByContract(Type contract)
          Deprecated. Gets all the inhabitants that has the given contract.
<T> Collection<Inhabitant<T>>
getInhabitantsByType(Class<T> implType)
          Deprecated. Gets all the inhabitants that has the given implementation type.
 Collection<Inhabitant<?>> getInhabitantsByType(String fullyQualifiedClassName)
          Deprecated. Gets all the inhabitants that has the given implementation type name.
 ActiveDescriptor<?> getInjecteeDescriptor(Injectee injectee)
          Deprecated. This method will first find a descriptor for this injectee, and then reify that descriptor.
 long getLocatorId()
          Deprecated. This returns the unique locator ID for this locator.
 String getName()
          Deprecated. Returns the name of this ServiceLocator
<T> Inhabitant<T>
getProvider(Type type, String name)
          Deprecated. Gets an inhabitant from its type and optionally name
<T> T
getService(ActiveDescriptor<T> activeDescriptor, ServiceHandle<?> root)
          Deprecated. This method should be called by code getting injectee's on behalf of some root object.
<T> T
getService(Type contractOrImpl, Annotation... qualifiers)
          Deprecated. Gets the best service from this locator that implements this contract or has this implementation
<T> T
getService(Type contractOrImpl, String name, Annotation... qualifiers)
          Deprecated. Gets the best service from this locator that implements this contract or has this implementation and has the given name
<T> ServiceHandle<T>
getServiceHandle(ActiveDescriptor<T> activeDescriptor)
          Deprecated. Gets a service handle that can be used to get and destroy the returned service.
<T> ServiceHandle<T>
getServiceHandle(ActiveDescriptor<T> activeDescriptor, Injectee injectee)
          Deprecated. Gets a service handle that can be used to get and destroy the returned service.
<T> ServiceHandle<T>
getServiceHandle(Type contractOrImpl, Annotation... qualifiers)
          Deprecated. Gets a service handle that can be used to get and destroy the returned service.
<T> ServiceHandle<T>
getServiceHandle(Type contractOrImpl, String name, Annotation... qualifiers)
          Deprecated. Gets a service handle that can be used to get and destroy the returned service
protected static Long getServiceRanking(Inhabitant<?> i, boolean wantNonNull)
          Deprecated.  
 void initialized()
          Deprecated. FOR INTERNAL USE ONLY
<T> T
inject(Class<T> type)
          Deprecated. Instantiate the passed type and injects all the org.jvnet.hk2.annotations.Inject annotated fields and methods
 void inject(Object object)
          Deprecated. This will analyze the given object and inject into its fields and methods.
 boolean isInitialized()
          Deprecated.  
 void postConstruct(Object postConstructMe)
          Deprecated. This will analyze the given object and call the postConstruct method.
 void preDestroy(Object preDestroyMe)
          Deprecated. This will analyze the given object and call the preDestroy method.
 ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor)
          Deprecated. Converts a descriptor to an ActiveDescriptor.
 ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor, Injectee injectee)
          Deprecated. Converts a descriptor to an ActiveDescriptor.
 boolean remove(Inhabitant<?> inhabitant)
          Deprecated. Removes an inhabitant
 boolean removeAllByType(Class<?> type)
          Deprecated. Removes all inhabitants for a particular type
 boolean removeIndex(String index, Object serviceOrInhabitant)
          Deprecated. Removes a Contracted service
 boolean removeIndex(String index, String name)
          Deprecated. Removes a NamedInhabitant for a specific contract
 void shutdown()
          Deprecated. This method will shutdown every service associated with this ServiceLocator.
 String toString()
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Habitat

public Habitat()
Deprecated. 

Habitat

public Habitat(ServiceLocator delegate)
Deprecated. 

Habitat

public Habitat(Habitat parent,
               String name)
Deprecated. 
Method Detail

removeAllByType

public boolean removeAllByType(Class<?> type)
Deprecated. 
Removes all inhabitants for a particular type

Parameters:
type - of the component
Returns:
true if any inhabitants were removed

add

public void add(Inhabitant<?> i)
Deprecated. 
Adds a new inhabitant.

See Inhabitants for typical ways to create Inhabitants.


addIndex

public void addIndex(Inhabitant<?> i,
                     String index,
                     String name)
Deprecated. 
Adds a new index to look up the given inhabitant.

Parameters:
index - Primary index name, such as contract FQCN.
name - Name that identifies the inhabitant among other inhabitants in the same index. Can be null for unnamed inhabitants.

addIndex

protected void addIndex(Inhabitant<?> i,
                        String index,
                        String name,
                        boolean notify)
Deprecated. 

getServiceRanking

protected static Long getServiceRanking(Inhabitant<?> i,
                                        boolean wantNonNull)
Deprecated. 

remove

public boolean remove(Inhabitant<?> inhabitant)
Deprecated. 
Removes an inhabitant

Parameters:
inhabitant - inhabitant to be removed

removeIndex

public boolean removeIndex(String index,
                           String name)
Deprecated. 
Removes a NamedInhabitant for a specific contract

Parameters:
index - contract name
name - instance name
Returns:
true if the removal was successful

removeIndex

public boolean removeIndex(String index,
                           Object serviceOrInhabitant)
Deprecated. 
Removes a Contracted service

Parameters:
index - the contract name
serviceOrInhabitant - the service instance, or an Inhabitant instance

initialized

public void initialized()
Deprecated. 
FOR INTERNAL USE ONLY


isInitialized

public boolean isInitialized()
Deprecated. 

getAllByContract

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

Specified by:
getAllByContract in interface BaseServiceLocator
Returns:
can be empty but never null.

getAllByContract

public <T> Collection<T> getAllByContract(String contractType)
Deprecated. 
Specified by:
getAllByContract in interface BaseServiceLocator

getAllByType

public <T> Collection<T> getAllByType(Class<T> implType)
Deprecated. 
Gets the object of the given type.

Returns:
can be empty but never null.

addComponent

public <T> void addComponent(T component)
                  throws ComponentException
Deprecated. 
Add an already instantiated component to this manager. The component has been instantiated by external code, however dependency injection, PostConstruct invocation and dependency extraction will be performed on this instance before it is store in the relevant scope's resource manager.

Parameters:
component - component instance
Throws:
ComponentException - if the passed object is not an HK2 component or injection/extraction failed.

getComponent

public <T> T getComponent(Class<T> clazz)
               throws ComponentException
Deprecated. 
Obtains a reference to the component inside the manager.

This is the "new Foo()" equivalent in the IoC world.

Depending on the Scope of the component, a new instance might be created, or an existing instance might be returned.

Specified by:
getComponent in interface BaseServiceLocator
Returns:
non-null.
Throws:
ComponentException - If failed to obtain a requested instance. In practice, failure only happens when we try to create a new instance of the component.

getComponent

public <T> T getComponent(Class<T> contract,
                          String name)
               throws ComponentException
Deprecated. 
Description copied from interface: BaseServiceLocator
Loads a component that implements the given contract and has the given name.

Specified by:
getComponent in interface BaseServiceLocator
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

public <T> T getComponent(String fullQualifiedName,
                          String name)
Deprecated. 
Description copied from interface: BaseServiceLocator
Analogous to the following:
 getComponent(contractClass.getName(), name);
 

Specified by:
getComponent in interface BaseServiceLocator
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.

getInhabitant

public <T> Inhabitant<T> getInhabitant(Class<T> contract,
                                       String name)
                            throws ComponentException
Deprecated. 
Gets a lazy reference to the component.

This method defers the actual instantiation of the component until Inhabitant.get() is invoked.

Returns:
null if no such component is found.
Throws:
ComponentException

getInhabitant

public <T> Inhabitant<T> getInhabitant(Type type,
                                       String name)
Deprecated. 

getInhabitantByType

public <T> Inhabitant<T> getInhabitantByType(Class<T> implType)
Deprecated. 
Gets a lazy reference to the component.

This method defers the actual instantiation of the component until Inhabitant.get() is invoked.

Returns:
null if no such component is found.

getInhabitantByType

public <T> Inhabitant<T> getInhabitantByType(Type implType)
Deprecated. 

getInhabitantByType

public Inhabitant<?> getInhabitantByType(String fullyQualifiedClassName)
Deprecated. 

getInhabitantByAnnotation

public Inhabitant<?> getInhabitantByAnnotation(Class<? extends Annotation> contract,
                                               String name)
                                        throws ComponentException
Deprecated. 
Gets the inhabitant that has the given contract annotation and the given name.

This method defers the actual instantiation of the component until Inhabitant.get() is invoked.

Returns:
null if no such component is found.
Throws:
ComponentException

getInhabitants

public <T> Collection<Inhabitant<? extends T>> getInhabitants(Class<T> type)
Deprecated. 
Gets all the inhabitants for a spcial contract. FOR COMPATIBILITY REASONS

Type Parameters:
T - the parameterized type
Parameters:
type - the contract type
Returns:

getInhabitantsByContract

public <T> Collection<Inhabitant<T>> getInhabitantsByContract(Type contract)
                                                   throws ComponentException
Deprecated. 
Gets all the inhabitants that has the given contract.

Specified by:
getInhabitantsByContract in interface SimpleServiceLocator
Throws:
ComponentException

inject

public <T> T inject(Class<T> type)
Deprecated. 
Instantiate the passed type and injects all the org.jvnet.hk2.annotations.Inject annotated fields and methods

Type Parameters:
T - type of the requested instance
Parameters:
type - class of the requested instance
Returns:
the instantiated and injected instance

getInhabitantsByType

public <T> Collection<Inhabitant<T>> getInhabitantsByType(Class<T> implType)
                                               throws ComponentException
Deprecated. 
Gets all the inhabitants that has the given implementation type.

Specified by:
getInhabitantsByType in interface SimpleServiceLocator
Throws:
ComponentException

getInhabitantsByType

public Collection<Inhabitant<?>> getInhabitantsByType(String fullyQualifiedClassName)
Deprecated. 
Gets all the inhabitants that has the given implementation type name.

Specified by:
getInhabitantsByType in interface SimpleServiceLocator

getInhabitantByContract

public Inhabitant<?> getInhabitantByContract(String typeName)
Deprecated. 
Get the first inhabitant by contract

Parameters:
typeName - fullyQualifiedClassName
Returns:

getInhabitantsByContract

public Collection<Inhabitant<?>> getInhabitantsByContract(String fullyQualifiedClassName)
Deprecated. 
Specified by:
getInhabitantsByContract in interface SimpleServiceLocator

getInhabitantByContract

public Inhabitant getInhabitantByContract(String fullyQualifiedName,
                                          String name)
Deprecated. 

getInhabitants

public <T> Iterable<Inhabitant<? extends T>> getInhabitants(Class<T> contract,
                                                            String name)
                                                 throws ComponentException
Deprecated. 
Gets all the inhabitants that has the given contract and the given name

This method defers the actual instantiation of the component until Inhabitant.get() is invoked.

Returns:
Can be empty but never null.
Throws:
ComponentException

getInhabitantsByAnnotation

public Iterable<Inhabitant<?>> getInhabitantsByAnnotation(Class<? extends Annotation> contract,
                                                          String name)
                                                   throws ComponentException
Deprecated. 
Gets all the inhabitants that has the given contract annotation and the given name.

This method defers the actual instantiation of the component until Inhabitant.get() is invoked.

Returns:
Can be empty but never null.
Throws:
ComponentException

getByType

public <T> T getByType(Class<T> implType)
Deprecated. 
Description copied from interface: BaseServiceLocator
Gets the object of the given type.

Specified by:
getByType in interface BaseServiceLocator
Returns:
null if not found.

getByType

public <T> T getByType(String implType)
Deprecated. 
Description copied from interface: BaseServiceLocator
Gets the object of the given type.

Specified by:
getByType in interface BaseServiceLocator
Returns:
null if not found.

getProvider

public <T> Inhabitant<T> getProvider(Type type,
                                     String name)
Deprecated. 
Description copied from interface: SimpleServiceLocator
Gets an inhabitant from its type and optionally name

Specified by:
getProvider in interface SimpleServiceLocator
Parameters:
type - requested inhabitant type
name - optional name

getByContract

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

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

Specified by:
getByContract in interface BaseServiceLocator

getByContract

public <T> T getByContract(String contractType)
Deprecated. 
Specified by:
getByContract in interface BaseServiceLocator

getService

public <T> T getService(Type contractOrImpl,
                        Annotation... qualifiers)
             throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets the best service from this locator that implements this contract or has this implementation

Use this method only if destroying the service is not important

Specified by:
getService in interface ServiceLocator
Parameters:
contractOrImpl - May not be null, and is the contract or concrete implementation to get the best instance of
qualifiers - The set of qualifiers that must match this service definition
Returns:
An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract
Throws:
MultiException - if there was an error during service creation

getService

public <T> T getService(Type contractOrImpl,
                        String name,
                        Annotation... qualifiers)
             throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets the best service from this locator that implements this contract or has this implementation and has the given name

Use this method only if destroying the service is not important

Specified by:
getService in interface ServiceLocator
Parameters:
contractOrImpl - May not be null, and is the contract or concrete implementation to get the best instance of
name - May not be null, and is the name of the implementation to be returned
qualifiers - The set of qualifiers that must match this service definition
Returns:
An instance of the contract or impl. May return null if there is no provider that provides the given implementation or contract
Throws:
MultiException - if there was an error during service creation

getAllServices

public <T> List<T> getAllServices(Type contractOrImpl,
                                  Annotation... qualifiers)
                       throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets the all the services from this locator that implements this contract or has this implementation

Use this method only if destroying the service is not important

Specified by:
getAllServices in interface ServiceLocator
Parameters:
contractOrImpl - May not be null, and is the contract or concrete implementation to get the best instance of
qualifiers - The set of qualifiers that must match this service definition
Returns:
A list of services implementing this contract or concrete implementation. May not return null, but may return an empty list
Throws:
MultiException - if there was an error during service creation

getAllServices

public List<?> getAllServices(Filter searchCriteria)
                       throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets the all the services from this locator that implements this contract or has this implementation

Use this method only if destroying the service is not important

This method should also be used with care to avoid classloading a large number of services

Specified by:
getAllServices in interface ServiceLocator
Parameters:
searchCriteria - The returned service will match the Filter (in other words, searchCriteria.matches returns true). May not be null
Returns:
A list of services matching this filter. May not return null, but may return an empty list
Throws:
MultiException - if there was an error during service creation

getServiceHandle

public <T> ServiceHandle<T> getServiceHandle(Type contractOrImpl,
                                             Annotation... qualifiers)
                                  throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets a service handle that can be used to get and destroy the returned service. If a service, and all per lookup services must be destroyed then this method should be used to destroy the object

It is assumed that this method is called by the top level code. All injection points created because of this invocation must use the getServiceHandle(ActiveDescriptor, ServiceHandle) method to retrieve objects, so that they can be destroyed in the proper sequence

Specified by:
getServiceHandle in interface ServiceLocator
Parameters:
contractOrImpl - May not be null, and is the contract or concrete implementation to get the best instance of
qualifiers - The set of qualifiers that must match this service definition
Returns:
Will return root as a convenience
Throws:
MultiException - if there was an error during service creation

getServiceHandle

public <T> ServiceHandle<T> getServiceHandle(Type contractOrImpl,
                                             String name,
                                             Annotation... qualifiers)
                                  throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets a service handle that can be used to get and destroy the returned service

Specified by:
getServiceHandle in interface ServiceLocator
Parameters:
contractOrImpl - May not be null, and is the contract or concrete implementation to get the best instance of
name - The name to use to further qualify the search (may be null)
qualifiers - The set of qualifiers that must match this service definition
Returns:
Will the service handle for the best service matching the given criteria, or null if no matching service could be found
Throws:
MultiException - if there was an error during service creation

getAllServiceHandles

public List<ServiceHandle<?>> getAllServiceHandles(Type contractOrImpl,
                                                   Annotation... qualifiers)
                                            throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets service handles that can be used to get and destroy the returned services

Specified by:
getAllServiceHandles in interface ServiceLocator
Parameters:
contractOrImpl - May not be null, and is the contract or concrete implementation to get the best instance of
qualifiers - The set of qualifiers that must match this service definition
Returns:
A non-null but possibly empty list of service handles matching the given criteria
Throws:
MultiException - if there was an error during service creation

getAllServiceHandles

public List<ServiceHandle<?>> getAllServiceHandles(Filter searchCriteria)
                                            throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets a service handle that can be used to get and destroy the returned service. If a service, and all per lookup services must be destroyed then this method should be used to destroy the object

It is assumed that this method is called by the top level code. All injection points created because of this invocation must use the getServiceHandle(ActiveDescriptor, ServiceHandle) method to retrieve objects, so that they can be destroyed in the proper sequence

Specified by:
getAllServiceHandles in interface ServiceLocator
Parameters:
searchCriteria - A filter to use when determining which services should apply
Returns:
A list of handles in ranked order that match the given filter
Throws:
MultiException - if there was an error during service creation

getDescriptors

public List<ActiveDescriptor<?>> getDescriptors(Filter filter)
Deprecated. 
Description copied from interface: ServiceLocator
Gets the list of descriptors that match the given filter

Specified by:
getDescriptors in interface ServiceLocator
Parameters:
filter - A filter to use when determining which services should apply
Returns:
A list of descriptors in ranked order that match the given filter

getBestDescriptor

public ActiveDescriptor<?> getBestDescriptor(Filter filter)
Deprecated. 
Description copied from interface: ServiceLocator
Gets the descriptor that best matches this filter, taking ranking and service id into account

Specified by:
getBestDescriptor in interface ServiceLocator
Parameters:
filter - The filter to use to retrieve the set of descriptors
Returns:
The best descriptor matching the filter, or null if there is no descriptor that matches the filter

reifyDescriptor

public ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor,
                                           Injectee injectee)
                                    throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Converts a descriptor to an ActiveDescriptor. Will use the registered HK2Loaders to perform this action

Specified by:
reifyDescriptor in interface ServiceLocator
Parameters:
descriptor - The descriptor to convert, may not be null
injectee - The injectee on behalf of whom this descriptor is being injected. May be null if the injectee is unknown
Returns:
The active descriptor as loaded with the first valid HK2Loader
Throws:
MultiException - if there were errors when loading or analyzing the class

reifyDescriptor

public ActiveDescriptor<?> reifyDescriptor(Descriptor descriptor)
                                    throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Converts a descriptor to an ActiveDescriptor. Will use the registered HK2Loaders to perform this action

Specified by:
reifyDescriptor in interface ServiceLocator
Parameters:
descriptor - The descriptor to convert, may not be null
Returns:
The active descriptor as loaded with the first valid HK2Loader
Throws:
MultiException - if there were errors when loading or analyzing the class

getInjecteeDescriptor

public ActiveDescriptor<?> getInjecteeDescriptor(Injectee injectee)
                                          throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
This method will first find a descriptor for this injectee, and then reify that descriptor. If multiple descriptors are found, they will be reified in ranking order until an ActiveDescriptor matching the Injectee is found.

Specified by:
getInjecteeDescriptor in interface ServiceLocator
Parameters:
injectee - the injection point for whom to find the ActiveDescriptor
Returns:
The active descriptor for this injection point
Throws:
MultiException - if there were errors when loading or analyzing the class

getServiceHandle

public <T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor,
                                             Injectee injectee)
                                  throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets a service handle that can be used to get and destroy the returned service. If a service, and all per lookup services must be destroyed then this method should be used to destroy the object

It is assumed that this method is called by the top level code. All injection points created because of this invocation must use the getServiceHandle(ActiveDescriptor, ServiceHandle) method to retrieve objects, so that they can be destroyed in the proper sequence

Specified by:
getServiceHandle in interface ServiceLocator
Parameters:
activeDescriptor - The service handle that can be used to get and destroy this service
injectee - The injectee on behalf of whom this descriptor is being injected. May be null if the injectee is unknown
Returns:
Will return root as a convenience
Throws:
MultiException - if there was an error during service creation

getServiceHandle

public <T> ServiceHandle<T> getServiceHandle(ActiveDescriptor<T> activeDescriptor)
                                  throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets a service handle that can be used to get and destroy the returned service. If a service, and all per lookup services must be destroyed then this method should be used to destroy the object

It is assumed that this method is called by the top level code. All injection points created because of this invocation must use the getServiceHandle(ActiveDescriptor, ServiceHandle) method to retrieve objects, so that they can be destroyed in the proper sequence

Specified by:
getServiceHandle in interface ServiceLocator
Parameters:
activeDescriptor - The service handle that can be used to get and destroy this service
Returns:
Will return root as a convenience
Throws:
MultiException - if there was an error during service creation

getService

public <T> T getService(ActiveDescriptor<T> activeDescriptor,
                        ServiceHandle<?> root)
             throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
This method should be called by code getting injectee's on behalf of some root object. In this way the objects associated with the root object can be destroyed in the proper sequence

Specified by:
getService in interface ServiceLocator
Parameters:
activeDescriptor - The descriptor whose service to create
root - The ultimate parent of this service creation. May be null
Returns:
The service matching this descriptor
Throws:
MultiException - if there was an error during service creation

getName

public String getName()
Deprecated. 
Description copied from interface: ServiceLocator
Returns the name of this ServiceLocator

Specified by:
getName in interface ServiceLocator
Returns:
The name of this ServiceLocator, will not return null

getLocatorId

public long getLocatorId()
Deprecated. 
Description copied from interface: ServiceLocator
This returns the unique locator ID for this locator. The locator ID will be assigned at the time of creation and must be a monotonacally increasing number (starting at zero)

Specified by:
getLocatorId in interface ServiceLocator
Returns:
The identifier for this service locator

shutdown

public void shutdown()
Deprecated. 
Description copied from interface: ServiceLocator
This method will shutdown every service associated with this ServiceLocator. Those services that have a preDestroy shall have their preDestroy called

Specified by:
shutdown in interface ServiceLocator

create

public <T> T create(Class<T> createMe)
Deprecated. 
Description copied from interface: ServiceLocator
This method will analyze the given class, and create it if can. The object created in this way will not be managed by HK2. It is the responsibility of the caller to ensure that any lifecycle this object has is honored

Specified by:
create in interface ServiceLocator
Parameters:
createMe - The class to create, may not be null
Returns:
An instance of the object

inject

public void inject(Object object)
Deprecated. 
Description copied from interface: ServiceLocator
This will analyze the given object and inject into its fields and methods. The object injected in this way will not be managed by HK2

Specified by:
inject in interface ServiceLocator
Parameters:
object - The object to be analyzed and injected into

postConstruct

public void postConstruct(Object postConstructMe)
Deprecated. 
Description copied from interface: ServiceLocator
This will analyze the given object and call the postConstruct method. The object given will not be managed by HK2

Specified by:
postConstruct in interface ServiceLocator
Parameters:
postConstructMe - The object to postConstruct

preDestroy

public void preDestroy(Object preDestroyMe)
Deprecated. 
Description copied from interface: ServiceLocator
This will analyze the given object and call the preDestroy method. The object given will not be managed by HK2

Specified by:
preDestroy in interface ServiceLocator
Parameters:
preDestroyMe - The object to preDestroy

createAndInitialize

public <U> U createAndInitialize(Class<U> createMe)
Deprecated. 
Description copied from interface: ServiceLocator
This method creates, injects and post-constructs an object with the given class. This is equivalent to calling the ServiceLocator.create(Class) method followed by the ServiceLocator.inject(Object) method followed by the ServiceLocator.postConstruct(Object) method.

The object created is not managed by the locator.

Specified by:
createAndInitialize in interface ServiceLocator
Parameters:
createMe - The non-null class to create this object from
Returns:
An instance of the object that has been created, injected and post constructed

getAllServices

public <T> List<T> getAllServices(Annotation qualifier,
                                  Annotation... qualifiers)
                       throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets the all the services from this locator that has the given qualifier or qualifiers

Use this method only if destroying the services is not important

Specified by:
getAllServices in interface ServiceLocator
Parameters:
qualifier - May not be null, and is a qualifier that must match the service definition
qualifiers - The set of qualifiers that must match this service definition
Returns:
A list of services implementing this contract or concrete implementation. May not return null, but may return an empty list
Throws:
MultiException - if there was an error during service creation

getAllServiceHandles

public List<ServiceHandle<?>> getAllServiceHandles(Annotation qualifier,
                                                   Annotation... qualifiers)
                                            throws MultiException
Deprecated. 
Description copied from interface: ServiceLocator
Gets service handles that can be used to get and destroy the returned services

Specified by:
getAllServiceHandles in interface ServiceLocator
Parameters:
qualifier - May not be null, and is a qualifier that must match the service definition
qualifiers - The set of qualifiers that must match this service definition
Returns:
A non-null but possibly empty list of service handles matching the given criteria
Throws:
MultiException - if there was an error during service creation

toString

public String toString()
Deprecated. 
Overrides:
toString in class Object


Copyright © 2013 Oracle Corporation. All Rights Reserved.