You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@openwebbeans.apache.org by Xinglie Zheng <zh...@gmail.com> on 2012/06/26 21:59:52 UTC

Interceptor doesn't

I am using OpenWebbeans with Struts 1.2 framework in Weblogic 11g.  I added
an interceptor for security check.  But when I debug in Eclipse,  the
breakpoint at interceptor was never reached.  Following is my code:


@InterceptorBinding
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Secure {
 @Nonbinding int[] allowedUserRole() default {};
}


//Struts action class
public final class EditUserInfoAction extends Action {
 @Secure(allowedUserRole={1,2})
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
......
        }


//Interceptor class
@Secure
@Interceptor
public class ACLInterceptor {
@AroundInvoke
public Object manageACL(InvocationContext ctx) throws Exception {
......
         }


manageACL() method was never invoked.   I really appreciate your help.

Re: Interceptor doesn't

Posted by Rafael Pestano <rm...@yahoo.com.br>.
Hi Xinglie,

As far as i know(correct if im wrong, i do not have experience with Struts) a Strut Action has its own lifecycle which is different than a CDI bean, so to make it be a cdi bean you should create an extension and transform all Struts beans/actions into CDI beans by creating a javax.enterprise.inject.spi.Bean and implementing all its methods and register it into CDI. 

Basically you will observe to a processAnnotatedType(@Observes ProcessAnnotatedType<StrutsAction> pat)  to gather all struts beans.

Later in afterBeanDiscovery event you  will create the javax.enterprise.inject.spi.Bean for each Struts bean you gathered.

You should look at this weld chapter about portable extensions: http://docs.jboss.org/weld/reference/latest/en-US/html/extend.html.

Also take a look at Struts CDI plugin http://struts.apache.org/2.3.3/docs/cdi-plugin.html maybe it saves you from creating the extension.

Maybe someone experiencied in Struts(also in CDI ;) )  could  give a more detailed answer. 

I hope it helps 



Att, 

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS
http://code.google.com/p/jsf-conventions-framework/
http://rpestano.wordpress.com
http://twitter.com/realpestano



________________________________
De: Xinglie Zheng <zh...@gmail.com>
Para: user@openwebbeans.apache.org; Rafael Pestano <rm...@yahoo.com.br> 
Enviadas: Terça-feira, 26 de Junho de 2012 21:40
Assunto: Re: Interceptor doesn't


Hi Rafael,

I think almost all Java class is a CDI bean.  Do I need to do extra declaration for making a Java class into CDI bean?

Regards,
Xinglie Zheng 


On Tue, Jun 26, 2012 at 4:19 PM, Rafael Pestano <rm...@yahoo.com.br> wrote:

Hi Xinglie Zheng,
>
>you added your struts Action  as a CDI bean in an extension? otherwise i think OWB cant intercept a non CDI.
>
>
>Att,
>
>Rafael M. Pestano
>
>Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
>Graduando em Ciência da Computação UFRGS
>http://code.google.com/p/jsf-conventions-framework/
>http://rpestano.wordpress.com
>http://twitter.com/realpestano
>
>
>
>________________________________
>De: Xinglie Zheng <zh...@gmail.com>
>Para: user@openwebbeans.apache.org
>Enviadas: Terça-feira, 26 de Junho de 2012 16:59
>Assunto: Interceptor doesn't
>
>
>
>I am using OpenWebbeans with Struts 1.2 framework in Weblogic 11g.  I added an interceptor for security check.  But when I debug in Eclipse,  the breakpoint at interceptor was never reached.  Following is my code:
>
>
>
>@InterceptorBinding
>@Target({ElementType.METHOD, ElementType.TYPE})
>@Retention(RetentionPolicy.RUNTIME)
>public @interface Secure {
>@Nonbinding int[] allowedUserRole() default {};
>}
>
>
>//Struts action class
>public final class EditUserInfoAction extends Action {
>@Secure(allowedUserRole={1,2})
>public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
>HttpServletResponse response) throws IOException, ServletException {
>......
>        }
>
>
>//Interceptor class
>@Secure
>@Interceptor
>public class ACLInterceptor {
>@AroundInvoke
>public Object manageACL(InvocationContext ctx) throws Exception {
>......
>         }
>
>
>manageACL() method was never invoked.   I really appreciate your help. 
> 

Re: Interceptor doesn't

Posted by Xinglie Zheng <zh...@gmail.com>.
Hi Rafael,

I think almost all Java class is a CDI bean.  Do I need to do extra
declaration for making a Java class into CDI bean?

Regards,
Xinglie Zheng

On Tue, Jun 26, 2012 at 4:19 PM, Rafael Pestano <rm...@yahoo.com.br>wrote:

> Hi Xinglie Zheng,
>
> you added your struts Action  as a CDI bean in an extension? otherwise i
> think OWB cant intercept a non CDI.
>
>
> Att,
>
> Rafael M. Pestano
>
> Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
> Graduando em Ciência da Computação UFRGS
> http://code.google.com/p/jsf-conventions-framework/
> http://rpestano.wordpress.com
> http://twitter.com/realpestano
>
>
>
> ________________________________
> De: Xinglie Zheng <zh...@gmail.com>
> Para: user@openwebbeans.apache.org
> Enviadas: Terça-feira, 26 de Junho de 2012 16:59
> Assunto: Interceptor doesn't
>
>
> I am using OpenWebbeans with Struts 1.2 framework in Weblogic 11g.  I
> added an interceptor for security check.  But when I debug in Eclipse,  the
> breakpoint at interceptor was never reached.  Following is my code:
>
>
>
> @InterceptorBinding
> @Target({ElementType.METHOD, ElementType.TYPE})
> @Retention(RetentionPolicy.RUNTIME)
> public @interface Secure {
> @Nonbinding int[] allowedUserRole() default {};
> }
>
>
> //Struts action class
> public final class EditUserInfoAction extends Action {
> @Secure(allowedUserRole={1,2})
> public ActionForward execute(ActionMapping mapping, ActionForm form,
> HttpServletRequest request,
> HttpServletResponse response) throws IOException, ServletException {
> ......
>         }
>
>
> //Interceptor class
> @Secure
> @Interceptor
> public class ACLInterceptor {
> @AroundInvoke
> public Object manageACL(InvocationContext ctx) throws Exception {
> ......
>          }
>
>
> manageACL() method was never invoked.   I really appreciate your help.
>

Re: Interceptor doesn't

Posted by Rafael Pestano <rm...@yahoo.com.br>.
Hi Xinglie Zheng,

you added your struts Action  as a CDI bean in an extension? otherwise i think OWB cant intercept a non CDI.


Att, 

Rafael M. Pestano

Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
Graduando em Ciência da Computação UFRGS
http://code.google.com/p/jsf-conventions-framework/
http://rpestano.wordpress.com
http://twitter.com/realpestano



________________________________
De: Xinglie Zheng <zh...@gmail.com>
Para: user@openwebbeans.apache.org 
Enviadas: Terça-feira, 26 de Junho de 2012 16:59
Assunto: Interceptor doesn't


I am using OpenWebbeans with Struts 1.2 framework in Weblogic 11g.  I added an interceptor for security check.  But when I debug in Eclipse,  the breakpoint at interceptor was never reached.  Following is my code:



@InterceptorBinding
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface Secure {
@Nonbinding int[] allowedUserRole() default {};
}


//Struts action class
public final class EditUserInfoAction extends Action {
@Secure(allowedUserRole={1,2})
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
......
        }


//Interceptor class
@Secure
@Interceptor
public class ACLInterceptor {
@AroundInvoke
public Object manageACL(InvocationContext ctx) throws Exception {
......
         }


manageACL() method was never invoked.   I really appreciate your help.