Ok... I missed that. There is still an example that shows a void return type interceptor and there is some prior art along these lines. So I guess I am still, asking that this be a feature request for CDI 1.1.<br><br><div>
<a href="https://issues.jboss.org/browse/CDI-130">https://issues.jboss.org/browse/CDI-130</a></div><div><br></div><div>This works in Spring:</div><div><br></div><div><meta charset="utf-8"><span class="Apple-style-span" style="font-family: Times; font-size: medium; "><pre>
package com.arcmind.springquickstart.security;



import org.aspectj.lang.ProceedingJoinPoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @author Richard Hightower
 */
@Component
public class SecurityAdvice {
        
        @Autowired(required=true)
        @Qualifier (&quot;manager&quot;)
        private SecurityService securityManager;

        public void checkSecurity(ProceedingJoinPoint joinPoint) throws Throwable {
                
            /* If the user is not logged in, don&#39;t let them use this method */
            if(!securityManager.isLoggedIn()){            
                throw new SecurityViolationException();
            }

            /* Get the name of the method being invoked. */
            String operationName = joinPoint.getSignature().getName();
            /* Get the name of the object being invoked. */
            String objectName = joinPoint.getThis().getClass().getName();


           /*
            * Invoke the method or next Interceptor in the list,
            * if the current user is allowed.
            */
            if (!securityManager.isAllowed(objectName, operationName)){
                throw new SecurityViolationException();
            }
        
            joinPoint.proceed();
        }
        

        /**
         * @return Returns the manager.
         */
        public SecurityService getSecurityManager() {
                return securityManager;
        }
        /**
         * @param manager The manager to set.
         */
        public void setSecurityManager(SecurityService manager) {
                this.securityManager = manager;
        }
        
}</pre></span></div><div><br><div class="gmail_quote">On Sun, May 15, 2011 at 11:58 PM, Jaikiran Pai <span dir="ltr">&lt;<a href="mailto:jpai@redhat.com">jpai@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


  
    
    
  
  <div text="#000000" bgcolor="#ffffff">
    <tt>The interceptors spec says this about @AroundInvoke methods on
      interceptors:<br>
      <br>
      &lt;quote&gt;<br>
      Around-invoke methods have the following signature:<br>
      <br>
      Object &lt;METHOD&gt;(InvocationContext) throws Exception<br>
      <br>
      &lt;/quote&gt;<br>
      <br>
      By the way, if Weld is failing silently, then I guess it needs to
      be improved to throw an explicit error.<br>
      <br>
      -Jaikiran<div><div></div><div class="h5"><br>
      On Monday 16 May 2011 12:06 PM, Rick Hightower wrote:</div></div></tt>
    <blockquote type="cite"><div><div></div><div class="h5">
      <div>
        
        <tt><span style="font-family:Helvetica;font-size:12px">The specification has an
            example in 9.5.1 that returns a void. AspectJ/AspectWerks
            annotation allow this (prior art).</span></tt></div>
      <div><tt><span style="font-family:Helvetica;font-size:12px"><br>
          </span></tt></div>
      <div><tt><font><span style="font-size:12px"><br>
            </span></font></tt></div>
      <tt>
        Can interceptors return void? The specification seem unclear on
        this. Well, it shows an example but there is no further
        verbiage.</tt>
      <div><tt><br>
        </tt>
        <div><tt><br>
          </tt></div>
        <div>
          
          
          
          
          
          
          <p><tt>I get three different behaviors for this
              interceptor:</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><span>package</span>
              org.cdi.advocacy.security;</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><span>import</span>
              javax.inject.Inject;</tt></p>
          <p><tt><span>import</span>
              javax.interceptor.AroundInvoke;</tt></p>
          <p><tt><span>import</span>
              javax.interceptor.Interceptor;</tt></p>
          <p><tt><span>import</span>
              javax.interceptor.InvocationContext;</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt>/**</tt></p>
          <p><tt> * <span>@author</span> <span>Richard</span> <span>Hightower</span></tt></p>
          <p><tt> */</tt></p>
          <p><tt>@Secure<span> </span>@Interceptor</tt></p>
          <p><tt><span>public</span> <span>class</span> SecurityAdvice {</tt></p>
          <p><tt>        </tt></p>
          <p><tt>        <span>@Inject</span></tt></p>
          <p><tt>        <span>private</span>
              SecurityService <span>securityManager</span>;</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><span>        </span>@AroundInvoke</tt></p>
          <p><tt>        <span>public</span> <span>void</span> checkSecurity(InvocationContext
              joinPoint) <span>throws</span> Exception {</tt></p>
          <p><tt>        <span> </span></tt></p>
          <p><tt>        <span> </span>System.<span>out</span>.println(<span>&quot;In
                SecurityAdvice&quot;</span>);</tt></p>
          <p><tt>                </tt></p>
          <p><tt><span>            </span>/* If
              the user is not logged in, don&#39;t let them use this method
              */</tt></p>
          <p><tt>            <span>if</span>(!<span>securityManager</span>.isLoggedIn()){        
                 </tt></p>
          <p><tt>                <span>throw</span>
              <span>new</span> SecurityViolationException();</tt></p>
          <p><tt>            }</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><span>            </span>/* Get
              the name of the method being invoked. */</tt></p>
          <p><tt>            String operationName =
              joinPoint.getMethod().getName();</tt></p>
          <p><tt><span>            </span>/* Get
              the name of the object being invoked. */</tt></p>
          <p><tt>            String objectName =
              joinPoint.getTarget().getClass().getName();</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt>           <span>/*</span></tt></p>
          <p><tt>            * Invoke the method or next <span>Interceptor</span> in the list,</tt></p>
          <p><tt>            * if the current user is
              allowed.</tt></p>
          <p><tt>            */</tt></p>
          <p><tt>            <span>if</span> (!<span>securityManager</span>.isAllowed(objectName,
              operationName)){</tt></p>
          <p><tt>                <span>throw</span>
              <span>new</span> SecurityViolationException();</tt></p>
          <p><tt>            }</tt></p>
          <p><tt>        </tt></p>
          <p><tt>            joinPoint.proceed();</tt></p>
          <p><tt>        }</tt></p>
          <p><tt>}</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt>Weld does not recognize it because it
              returns void. It fails silently.</tt></p>
          <p><tt>Candi recognizes it and uses it.</tt></p>
          <p><tt>OpenWebBeans throws an exception as follows:</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt><span>org.apache.webbeans.exception.WebBeansConfigurationException</span>:
              @AroundInvoke annotated method : checkSecurity in class :
              org.cdi.advocacy.security.SecurityAdvice must return
              Object type</tt></p>
          <p><tt><span> </span>at
org.apache.webbeans.util.WebBeansUtil.checkAroundInvokeAnnotationCriterias(<span>WebBeansUtil.java:1094</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.util.WebBeansUtil.configureInterceptorMethods(<span>WebBeansUtil.java:1241</span>)</tt></p>
          <p><tt><span> </span>at
org.apache.webbeans.intercept.WebBeansInterceptorConfig.addMethodInterceptors(<span>WebBeansInterceptorConfig.java:349</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.intercept.WebBeansInterceptorConfig.configure(<span>WebBeansInterceptorConfig.java:250</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.config.DefinitionUtil.defineBeanInterceptorStack(<span>DefinitionUtil.java:1058</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.config.BeansDeployer.validate(<span>BeansDeployer.java:365</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(<span>BeansDeployer.java:326</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.config.BeansDeployer.deploy(<span>BeansDeployer.java:179</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(<span>AbstractLifeCycle.java:123</span>)</tt></p>
          <p><tt><span> </span>at
              org.cdiadvocate.beancontainer.OpenWebBeansBeanContainer.doStart(<span>OpenWebBeansBeanContainer.java:26</span>)</tt></p>
          <p><tt><span> </span>at
              org.cdiadvocate.beancontainer.AbstractBeanContainer.start(<span>AbstractBeanContainer.java:111</span>)</tt></p>
          <p><tt><span> </span>at
              org.cdi.advocacy.AtmMain.&lt;clinit&gt;(<span>AtmMain.java:25</span>)</tt></p>
          <p><tt>Exception in thread &quot;main&quot;
              java.lang.ExceptionInInitializerError</tt></p>
          <p><tt>Caused by: <span>org.cdiadvocate.beancontainer.BeanContainerInitializationException</span>:
              Unable to start BeanContainer : @AroundInvoke annotated
              method : checkSecurity in class :
              org.cdi.advocacy.security.SecurityAdvice must return
              Object type</tt></p>
          <p><tt><span> </span>at
              org.cdiadvocate.beancontainer.AbstractBeanContainer.start(<span>AbstractBeanContainer.java:113</span>)</tt></p>
          <p><tt><span> </span>at
              org.cdi.advocacy.AtmMain.&lt;clinit&gt;(<span>AtmMain.java:25</span>)</tt></p>
          <p><tt>Caused by: <span>org.apache.webbeans.exception.WebBeansConfigurationException</span>:
              @AroundInvoke annotated method : checkSecurity in class :
              org.cdi.advocacy.security.SecurityAdvice must return
              Object type</tt></p>
          <p><tt><span> </span>at
org.apache.webbeans.util.WebBeansUtil.checkAroundInvokeAnnotationCriterias(<span>WebBeansUtil.java:1094</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.util.WebBeansUtil.configureInterceptorMethods(<span>WebBeansUtil.java:1241</span>)</tt></p>
          <p><tt><span> </span>at
org.apache.webbeans.intercept.WebBeansInterceptorConfig.addMethodInterceptors(<span>WebBeansInterceptorConfig.java:349</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.intercept.WebBeansInterceptorConfig.configure(<span>WebBeansInterceptorConfig.java:250</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.config.DefinitionUtil.defineBeanInterceptorStack(<span>DefinitionUtil.java:1058</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.config.BeansDeployer.validate(<span>BeansDeployer.java:365</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(<span>BeansDeployer.java:326</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.config.BeansDeployer.deploy(<span>BeansDeployer.java:179</span>)</tt></p>
          <p><tt><span> </span>at
              org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(<span>AbstractLifeCycle.java:123</span>)</tt></p>
          <p><tt><span> </span>at
              org.cdiadvocate.beancontainer.OpenWebBeansBeanContainer.doStart(<span>OpenWebBeansBeanContainer.java:26</span>)</tt></p>
          <p><tt><span> </span>at
              org.cdiadvocate.beancontainer.AbstractBeanContainer.start(<span>AbstractBeanContainer.java:111</span>)</tt></p>
          <p><tt><span> </span>... 1
              more</tt></p>
          <p><tt><br>
            </tt></p>
          <p><tt>I think CDI 1.1 should clarify the behavior
              and I think it should support return types of void.</tt></p>
          <tt>-- <br>
            <b>Rick Hightower</b><br>
            <a href="tel:%28415%29%20968-9037" value="+14159689037" target="_blank">(415) 968-9037</a> <br>
            <a href="http://www.google.com/profiles/RichardHightower" target="_blank">Profile</a> <br>
            <br>
          </tt>
        </div>
      </div>
      </div></div><pre><tt>
</tt><fieldset></fieldset><tt>
_______________________________________________
cdi-dev mailing list
<a href="mailto:cdi-dev@lists.jboss.org" target="_blank">cdi-dev@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a>
</tt></pre>
    </blockquote>
    <tt><br>
    </tt>
  </div>

<br>_______________________________________________<br>
cdi-dev mailing list<br>
<a href="mailto:cdi-dev@lists.jboss.org">cdi-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/cdi-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/cdi-dev</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><b>Rick Hightower</b><br>(415) 968-9037 <br><a href="http://www.google.com/profiles/RichardHightower" target="_blank">Profile</a> <br><br>
</div>