good point. This might also tangent the EJB EG.
Since EJB and CDI will imo grow together sooner or later, we should aim to really behave
the same.
LieGrue,
strub
--- On Mon, 5/16/11, Pete Muir <pmuir(a)redhat.com> wrote:
From: Pete Muir <pmuir(a)redhat.com>
Subject: Re: [cdi-dev] interceptor that return void, unclear in 1.0 specification, needs
clarification in 1.1
To: jpai(a)redhat.com
Cc: cdi-dev(a)lists.jboss.org
Date: Monday, May 16, 2011, 9:53 AM
As Jaikiran says it's up to the
Interceptors spec to decide whether to support void or not,
Rick, please take your feedback there (this is run by the
EJB EG).
We will fix the example in the spec of course :-)
BTW please remember to not set the fix version when
creating issues, and that the affects version is 1.0 :-)
On 16 May 2011, at 07:58, Jaikiran Pai wrote:
> The interceptors spec says this about @AroundInvoke
methods on interceptors:
>
> <quote>
> Around-invoke methods have the following signature:
>
> Object <METHOD>(InvocationContext) throws
Exception
>
> </quote>
>
> By the way, if Weld is failing silently, then I guess
it needs to be improved to throw an explicit error.
>
> -Jaikiran
> On Monday 16 May 2011 12:06 PM, Rick Hightower wrote:
>> The specification has an example in 9.5.1 that
returns a void. AspectJ/AspectWerks annotation allow this
(prior art).
>>
>>
>> Can interceptors return void? The specification
seem unclear on this. Well, it shows an example but there is
no further verbiage.
>>
>>
>> I get three different behaviors for this
interceptor:
>>
>> package org.cdi.advocacy.security;
>>
>>
>>
>> import javax.inject.Inject;
>> import javax.interceptor.AroundInvoke;
>> import javax.interceptor.Interceptor;
>> import javax.interceptor.InvocationContext;
>>
>> /**
>> * @author Richard Hightower
>> */
>> @Secure @Interceptor
>> public class SecurityAdvice {
>>
>> @Inject
>> private
SecurityService securityManager;
>>
>>
@AroundInvoke
>> public void
checkSecurity(InvocationContext joinPoint) throws Exception
{
>>
>>
System.out.println("In SecurityAdvice");
>>
>>
/* If the user is not logged in, don't let
them use this method */
>>
if(!securityManager.isLoggedIn()){
>>
throw new SecurityViolationException();
>>
}
>>
>>
/* Get the name of the method being
invoked. */
>>
String operationName =
joinPoint.getMethod().getName();
>>
/* Get the name of the object being
invoked. */
>>
String objectName =
joinPoint.getTarget().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();
>> }
>> }
>>
>> Weld does not recognize it because it returns
void. It fails silently.
>> Candi recognizes it and uses it.
>> OpenWebBeans throws an exception as follows:
>>
>>
>>
>>
org.apache.webbeans.exception.WebBeansConfigurationException:
@AroundInvoke annotated method : checkSecurity in class :
org.cdi.advocacy.security.SecurityAdvice must return Object
type
>> at
org.apache.webbeans.util.WebBeansUtil.checkAroundInvokeAnnotationCriterias(WebBeansUtil.java:1094)
>> at
org.apache.webbeans.util.WebBeansUtil.configureInterceptorMethods(WebBeansUtil.java:1241)
>> at
org.apache.webbeans.intercept.WebBeansInterceptorConfig.addMethodInterceptors(WebBeansInterceptorConfig.java:349)
>> at
org.apache.webbeans.intercept.WebBeansInterceptorConfig.configure(WebBeansInterceptorConfig.java:250)
>> at
org.apache.webbeans.config.DefinitionUtil.defineBeanInterceptorStack(DefinitionUtil.java:1058)
>> at
org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:365)
>> at
org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:326)
>> at
org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:179)
>> at
org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:123)
>> at
org.cdiadvocate.beancontainer.OpenWebBeansBeanContainer.doStart(OpenWebBeansBeanContainer.java:26)
>> at
org.cdiadvocate.beancontainer.AbstractBeanContainer.start(AbstractBeanContainer.java:111)
>> at
org.cdi.advocacy.AtmMain.<clinit>(AtmMain.java:25)
>> Exception in thread "main"
java.lang.ExceptionInInitializerError
>> Caused by:
org.cdiadvocate.beancontainer.BeanContainerInitializationException:
Unable to start BeanContainer : @AroundInvoke annotated
method : checkSecurity in class :
org.cdi.advocacy.security.SecurityAdvice must return Object
type
>> at
org.cdiadvocate.beancontainer.AbstractBeanContainer.start(AbstractBeanContainer.java:113)
>> at
org.cdi.advocacy.AtmMain.<clinit>(AtmMain.java:25)
>> Caused by:
org.apache.webbeans.exception.WebBeansConfigurationException:
@AroundInvoke annotated method : checkSecurity in class :
org.cdi.advocacy.security.SecurityAdvice must return Object
type
>> at
org.apache.webbeans.util.WebBeansUtil.checkAroundInvokeAnnotationCriterias(WebBeansUtil.java:1094)
>> at
org.apache.webbeans.util.WebBeansUtil.configureInterceptorMethods(WebBeansUtil.java:1241)
>> at
org.apache.webbeans.intercept.WebBeansInterceptorConfig.addMethodInterceptors(WebBeansInterceptorConfig.java:349)
>> at
org.apache.webbeans.intercept.WebBeansInterceptorConfig.configure(WebBeansInterceptorConfig.java:250)
>> at
org.apache.webbeans.config.DefinitionUtil.defineBeanInterceptorStack(DefinitionUtil.java:1058)
>> at
org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:365)
>> at
org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:326)
>> at
org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:179)
>> at
org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:123)
>> at
org.cdiadvocate.beancontainer.OpenWebBeansBeanContainer.doStart(OpenWebBeansBeanContainer.java:26)
>> at
org.cdiadvocate.beancontainer.AbstractBeanContainer.start(AbstractBeanContainer.java:111)
>> ... 1 more
>>
>> I think CDI 1.1 should clarify the behavior and I
think it should support return types of void.
>> --
>> Rick Hightower
>> (415) 968-9037
>> Profile
>>
>>
>>
>> _______________________________________________
>> cdi-dev mailing list
>>
>> cdi-dev(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/cdi-dev
>
> _______________________________________________
> cdi-dev mailing list
> cdi-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/cdi-dev
_______________________________________________
cdi-dev mailing list
cdi-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/cdi-dev