Top Description Methods
org.glassfish.hk2.api

public Interface IterableProvider<T>

extends Provider<T>, Iterable<T>
Type Parameters
<T>
The type of this IterableProvider
Imports
java.lang.annotation.Annotation, java.lang.reflect.Type, jakarta.inject.Provider

This object can be injected rather than Provider when it is desired to iterate over more than one returned instance of the type. This interface also has several methods which allow the user to further narrow down the selected services at runtime. It can also provide an Iterable of ServiceHandle for finer control of the lifecycle of services found

The iterator returned will be in ranked order (with DescriptorRank as primary key, largest rank first and ServiceID as secondary key, smallest id first)

Author
jwells

Method Summary

Modifier and TypeMethod and Description
public ServiceHandle<T>

Returns:

A ServiceHandle for the service, or null if there is currently no service definition available
getHandle
()

Rather than getting the service directly with get (in which case the returned service cannot be disposed of) this method will instead return a service handle for the current best service.

public int

Returns:

the size of the iterator that would be chosen
getSize
()

Returns the size of the iterator that would be returned

public Iterable<ServiceHandle<T>>

Returns:

An iterator of ServiceHandles for the set of services represtended by this IterableProvider
handleIterator
()

This version of iterator returns an iterator of ServiceHandles rather than returning the services (which then have no way to be properly destroyed)

public IterableProvider<T>

Returns:

An iterable provider further qualified with the given name
named
(String
The value field of the Named annotation parameter. Must not be null
name
)

Returns an IterableProvider that is further qualified with the given name

public <U> IterableProvider<U>

Returns:

An iterator restricted to only providing the given type
ofType
(Type
The type to restrict the returned iterator to
type
)

Returns an IterableProvider that is of the given type.

public IterableProvider<T>

Returns:

An iterator restricted with the given qualifiers
qualifiedWith
(Annotation...
The qualifiers to further restrict this iterator to
qualifiers
)

A set of qualifiers to further restrict this iterator to.

Inherited from jakarta.inject.Provider:
get
Inherited from java.lang.Iterable:
forEachiteratorspliterator

Method Detail

getHandleback to summary
public ServiceHandle<T> getHandle()

Rather than getting the service directly with get (in which case the returned service cannot be disposed of) this method will instead return a service handle for the current best service.

Returns:ServiceHandle<T>

A ServiceHandle for the service, or null if there is currently no service definition available

getSizeback to summary
public int getSize()

Returns the size of the iterator that would be returned

Returns:int

the size of the iterator that would be chosen

handleIteratorback to summary
public Iterable<ServiceHandle<T>> handleIterator()

This version of iterator returns an iterator of ServiceHandles rather than returning the services (which then have no way to be properly destroyed)

Returns:Iterable<ServiceHandle<T>>

An iterator of ServiceHandles for the set of services represtended by this IterableProvider

namedback to summary
public IterableProvider<T> named(String name)

Returns an IterableProvider that is further qualified with the given name

Parameters
name:String

The value field of the Named annotation parameter. Must not be null

Returns:IterableProvider<T>

An iterable provider further qualified with the given name

ofTypeback to summary
public <U> IterableProvider<U> ofType(Type type)

Returns an IterableProvider that is of the given type. This type must be one of the type safe contracts of the original iterator

Parameters
type:Type

The type to restrict the returned iterator to

Returns:IterableProvider<U>

An iterator restricted to only providing the given type

qualifiedWithback to summary
public IterableProvider<T> qualifiedWith(Annotation... qualifiers)

A set of qualifiers to further restrict this iterator to.

Parameters
qualifiers:Annotation[]

The qualifiers to further restrict this iterator to

Returns:IterableProvider<T>

An iterator restricted with the given qualifiers