Enabling a decorator
As with interceptors, all decorators are disabled by default, so we need to enable our decorator within the beans.xml
file of a bean archive:
<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"> <decorators> <class>org.cdibook.chapter6.PasswordMonitorDecorator</class> </decorators> </beans>
Note
Activation of a decorator within beans.xml
will activate it for all beans within the same archive only.
Get JBoss Weld CDI for Java Platform now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.