org.glassfish.hk2
Interface Provider<T>

All Known Subinterfaces:
Creator<T>, Inhabitant<T>, ManagedComponentProvider<T>
All Known Implementing Classes:
AbstractCreatorImpl, AbstractCreatorInhabitantImpl, AbstractInhabitantImpl, ConfigBean, ConstructorCreator, CreatorImpl, Dom, EventPublishingInhabitant, ExistingSingletonInhabitant, InhabitantImpl, LazyInhabitant, ScopedInhabitant

Deprecated.

@Deprecated
public interface Provider<T>

Similar to the Factory contract, providing a means to access the class type instance. The scope of the instances produces by the provider is determined by the implementation (e.g., singleton, per lookup, etc).

Bindings represent something that is registered in Services whereas a Provider provides the runtime services for the given registered Binding entry in the correct context appropriate for the caller.

Author:
Jerome Dochez, Jeff Trent, Mason Taube
See Also:
ManagedComponentProvider

Method Summary
 T get()
          Deprecated. The system calls this method to obtain a reference to the component/service.
 Collection<Annotation> getAnnotations()
          Deprecated. The collection of annotations for this type.
<U> U
getByType(Class<U> type)
          Deprecated. Obtain a reference to the associated component/service.
 boolean isActive()
          Deprecated. Returns true if the component has been instantiated.
 Class<? extends T> type()
          Deprecated. The class type of the implementation.
 

Method Detail

get

T get()
      throws ComponentException
Deprecated. 
The system calls this method to obtain a reference to the component/service.

Returns:
null is a valid return value. This is useful when a factory primarily does a look-up and it fails to find the specified component, yet you don't want that by itself to be an error. If the injection wants a non-null value (i.e., @Inject(optional=false)).
Throws:
ComponentException - If the factory failed to get/create an instance and would like to propagate the error to the caller.

getByType

<U> U getByType(Class<U> type)
Deprecated. 
Obtain a reference to the associated component/service. The given type may be used by the provider to obtain and return a proxy rather than the actual component.

Parameters:
type - the required type of the returned object
Returns:
the component or a suitable proxy of the given type
Throws:
ClassCastException - if the component is not an instance of the given type
ComponentException - if this provider failed to get or create an instance of the component

type

Class<? extends T> type()
Deprecated. 
The class type of the implementation. it is responsible also for determining how (i.e., which loader) to use.

The class type for what the Factory actually produces.

Note that there is some cost to this call during the first invocation since it needs to perform classloading. Care should therefore be exercised accordingly.

Returns:
the class type for what this Provider produces, or null only in the case where the Provider is a facade to a user defined factory that

getAnnotations

Collection<Annotation> getAnnotations()
Deprecated. 
The collection of annotations for this type. Note that this may not be the same as the annotations on the type().

Returns:
a non-null collection of annotation classes for this provider type.

isActive

boolean isActive()
Deprecated. 
Returns true if the component has been instantiated.

Returns:
true if the component is active.


Copyright © 2013 Oracle Corporation. All Rights Reserved.