javax.enterprise.inject
Interface Instance<T>

All Superinterfaces:
java.lang.Iterable<T>, Provider<T>
All Known Implementing Classes:
InstanceImpl

public interface Instance<T>
extends Provider<T>, java.lang.Iterable<T>

Factory to create instances of a bean.

Example: injecting and using Instance

 package example;

 import javax.enterprise.inject.*;
 import javax.servlet.*;

 public class MyServlet extends GenericServlet {
  @Obtains @Instance<MyBean> _beanFactory;

  public void service(ServletRequest req, ServletResponse res)
  {
    MyBean bean = _beanFactory.get();
  }
 }
 

See Also:
javax.event.Event

Method Summary
 boolean isAmbiguous()
          Test if there are multiple beans that match the instance.
 boolean isUnsatisfied()
          Test if there are any beans that match the instance.
 Instance<T> select(java.lang.annotation.Annotation... qualifiers)
          Restricts the instance given a set of qualifiers
<U extends T>
Instance<U>
select(java.lang.Class<U> subtype, java.lang.annotation.Annotation... qualifiers)
          Restricts the instance to a subtype and bindings.
<U extends T>
Instance<U>
select(TypeLiteral<U> subtype, java.lang.annotation.Annotation... qualifiers)
          Restricts the instance to a subtype and bindings.
 
Methods inherited from interface javax.inject.Provider
get
 
Methods inherited from interface java.lang.Iterable
iterator
 

Method Detail

select

Instance<T> select(java.lang.annotation.Annotation... qualifiers)
Restricts the instance given a set of qualifiers


select

<U extends T> Instance<U> select(java.lang.Class<U> subtype,
                                 java.lang.annotation.Annotation... qualifiers)
Restricts the instance to a subtype and bindings.


select

<U extends T> Instance<U> select(TypeLiteral<U> subtype,
                                 java.lang.annotation.Annotation... qualifiers)
Restricts the instance to a subtype and bindings.


isUnsatisfied

boolean isUnsatisfied()
Test if there are any beans that match the instance.


isAmbiguous

boolean isAmbiguous()
Test if there are multiple beans that match the instance.