Announcement Announcement Module
No announcement yet.
Problems with CGLIB proxies calling protected methods from superclass Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with CGLIB proxies calling protected methods from superclass

    I am writing a JSF bean using the Spring annotations instead of JSF ones. The declaration of the bean is:

    @Scope(value=SpringScopes.JSF_VIEW, proxyMode=ScopedProxyMode.TARGET_CLASS)
    public class ListaTablaMaestraBean<ENTITY extends IBeanTablaMaestra> 
    	extends AbstractMantenimientoTablaBean<ENTITY, FiltroTablaMaestra> {
    The JSF_VIEW scope is the VIEW scope from JSF, and I took the implementation from Here

    Once the page is loaded I call to the method modificaEntidadActionListener of the superclass AbstractMantenimientoTablaBean from the XHTML code.

    protected abstract ENTITY recuperaEntidadModificar();
    public final void modificaEntidadActionListener(Long idElementoSeleccionado) {
    	if (isTienePermisoModificar()) {
    		this.idElementoSeleccionado = idElementoSeleccionado;
    		entity = recuperaEntidadModificar();
    	} else {
    The method modificaEntidadActionListener calls recuperaEntidadModificar() which is an abstract method implemented in the subclass. The problem is that the call to recuperaEntidadModificar() is made through a CGLIB proxy, and the method is executed in a different instance of the same class (which is annoying because field values are not initialized).

    To solve it, I just made an interface with all the public methods, and changed the proxy to standard java interfaces, but I'd prefer not to put interfaces in JSF beans.

    Is there any way to tell CGLIB not to intercept protected methods?