Package javax.enterprise.inject

Java Dependency Injection annotations and exceptions.

See:
          Description

Interface Summary
Instance<T> Factory to create instances of a bean.
 

Exception Summary
AmbiguousResolutionException When an injection Manager.getInstance call cannot return a unique bean, it throws this exception.
CreationException When bean creation fails, the injection BeanManager will throw this exception.
IllegalProductException Exception during runtime for webbeans
InjectionException Exceptions occuring during injection will extend from this exception.
ResolutionException When bean creation fails, the injection BeanManager will throw this exception.
UnproxyableResolutionException When a bean cannot generate a proxy as required by the specification, the injection BeanManager will throw this exception.
UnsatisfiedResolutionException When no matching bean can be found for an injection point or a BeanManager.getReference, the BeanManager BeanManager will throw this exception.
 

Annotation Types Summary
Alternative Disables the bean from the initial discovery.
Any Binding injection representing any matching bean.
Default Default bean injection uses @Default as the injection point's @Qualifier.
Disposes Factory destruction methods are declared with the @Disposes annotation.
Model A standard @Stereotype
New New bean creation and injection uses the @New annotation as the @Qualifier for the injection point.
Produces Bean factory methods are declared with the @Produces annotation.
Specializes Bean factory methods are declared with the @Produces annotation.
Stereotype The @Stereotype annotation for web beans
Typed Allows specific type information for scanning.
 

Package javax.enterprise.inject Description

Java Dependency Injection annotations and exceptions. For programmatic access see javax.enterprise.inject.spi.

Example: injecting a servlet using a custom binding type

 package example;

 import example.MyBinding;
 import javax.servlet.*;
 import java.io.*;

 public class MyServlet extends GenericServlet {
   @MyBinding MyBean _bean;

   public void service(ServletRequest req, ServletResponse res)
     throws IOException
   {
     PrintWriter out = res.getWriter();

     out.println("my-bean: " + _bean);
   }
 }
 

Example: creating a custom binding type

 package example;

 import static java.lang.annotation.ElementType.*;
 import static java.lang.annotation.RetentionPolicy.Runtime;
 import java.lang.annotation.*;

 import javax.enterprise.inject.BindingType;

 @BindingType
 @Documented
 Target({TYPE, METHOD, FIELD, PARAMETER})
 Retention(RUNTIME)
 public @interface MyBinding {
 }
 

Example: configuring using a custom binding type

META-INF/beans.xml
 <Beans xmlns="urn:java:ee" xmlns:example="urn:java:example">

   <example:MyBean>
     <example:MyBinding/>
   </example:MyBean>

 </Beans>