jsf 2 - Interceptors don't work with JSF managed beans? -


i decide try interceptors first interceptor binding annotation is

@inherited @interceptorbinding @target({type}) @retention(runtime) public @interface withlog {   // no parameters required   } 

and interceptor class is

@interceptor @withlog public class loginterceptor {    @aroundinvoke   private object logmethod(invocationcontext context) throws exception {     system.out.println("method " + context.getmethod().getname() +          " of class " + context.gettarget().getclass().getname() + " called.");     return context.proceed();   }    @postconstruct   private void construct(invocationcontext context) {     system.out.println("@postconstruct of " +          context.getmethod().getdeclaringclass().getname() + " started.");   } } 

so, want add simple logging jsf managed bean:

@managedbean(name = "departmentrootmb") @viewscoped @withlog public class departmentrootmb implements serializable {    long serialversionuid = 0l; // . . . properties, methods  } 

i read, enable interceptors need create beans.xml. created 1 in web-inf directory:

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"        xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"        xsi:schemalocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"        bean-discovery-mode="annotated">     <interceptors>         <class>ru.edu.pgtk.weducation.interceptors.loginterceptor</class>     </interceptors> </beans> 

i rebuild project , no effect. mistake? did wrong? use glassfish 4.1 standard components (weld, eclipselink, jsf 2.2.7)

thanks time , best regards.

interceptors don't work jsf managed beans?

correct.

replace jsf bean management facility cdi bean management facility.

in other words, replace @managedbean , friends @named , friends. jsf bean management facility on schedule deprecated in favor of cdi in future java ee version anyway. opportunity migrate can.

see also:


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -