Uploaded image for project: 'CDI Specification Issues'
  1. CDI Specification Issues
  2. CDI-224

Support Decoration of no interface beans


      According to CDI 1.0 Spec:

      "Decorators may be associated with any managed bean that is not itself an interceptor or decorator or with any EJB session bean."

      "The set of decorated types of a decorator includes all bean types of the managed bean which are Java interfaces, except for java.io.Serializable. The decorator bean class and its superclasses are not decorated types of the decorator."

      Both CDI and EJB support No interface beans, but for some reason Decorators only work on methods from a Interface. While Interceptors on the other hand work fine with Classes.

      I can see no technical reason to why Decorators should only work on Interfaces since all Proxies etc should already be in place.

      import javax.decorator.Decorator;
      import javax.decorator.Delegate;
      import javax.enterprise.inject.Any;
      import javax.inject.Inject;
      import junit.framework.Assert;
      import org.jboss.arquillian.container.test.api.Deployment;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.spec.WebArchive;
      import org.jboss.shrinkwrap.impl.BeansXml;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      public class DecoratesClassTestCase {
      	public static WebArchive create() {
      		return ShrinkWrap.create(WebArchive.class)
      						new BeansXml().decorators(BusinessDecorator.class), "beans.xml");
      	public void shouldBeAbleToDecorate(BusinessObject business) throws Exception {
      		Assert.assertEquals("Decorated Test", business.send("Test"));
      	public static abstract class BusinessDecorator extends BusinessObject {
      		@Inject @Delegate @Any
      		private BusinessObject delegate;
      		public String send(String msg) {
      			return "Decorated " + delegate.send(msg);
      	public static class BusinessObject {
      		public String send(String msg) {
      			return msg;

            asabotdu@redhat.com Antoine Sabot-Durand (Inactive)
            aslak@redhat.com Aslak Knutsen
            0 Vote for this issue
            7 Start watching this issue