Java Reference
In-Depth Information
import com.ensode.cdiintro.stereotype.NamedSessionScoped;
import java.io.Serializable;
@NamedSessionScoped
public class StereotypeClient implements Serializable {
private String property1;
private String property2;
public String getProperty1() {
return property1;
}
public void setProperty1(String property1) {
this.property1 = property1;
}
public String getProperty2() {
return property2;
}
public void setProperty2(String property2) {
this.property2 = property2;
}
}
We annotated the
StereotypeClient
class with our
NamedSessionScoped
stereotype,
which is equivalent to using the
@Named
and
@SessionScoped
annotations.
Interceptor binding types
One of the advantages of EJBs is that they allow us to easily perform
aspect-oriented
programming
(
AOP
) via interceptors. CDI allows us to write interceptor binding
types; this lets us bind interceptors to beans and the beans do not have to depend
on the interceptor directly. Interceptor binding types are annotations that are
themselves annotated with
@InterceptorBinding
.
Creating an interceptor binding type in NetBeans involves creating a new file,
selecting the
Contexts and Dependency Injection
category, and selecting the
Interceptor Binding Type
file type.