Announcement Announcement Module
Collapse
No announcement yet.
StaticPointcut not working on backing bean action method Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • StaticPointcut not working on backing bean action method

    I have a very strange problem. I intercept all of my jsf backing bean methods with static pointcut. I create the proxies by hand, i.e.

    A part of MyFactory.java
    Code:
    .
    .
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName){
          if(myPointcut.getClassFilter().matches(bean.getClass())){
                ProxyFactory pf = new ProxyFactory();
                pf.addAdvisor(advisor);
                pf.setTarget(bean);
                return pf.getProxy();
          }
          return bean;
    }
    .
    .
    (this is a spring bean that post processes my spring-jsf backing beans)

    If I directly refer to the bean using its name from the jspx page like:
    HTML Code:
    <ice:inputText value="#{myBean.filterText}" />
    then everything just goes fine.

    Bu if I indirectly referrence the bean like
    HTML Code:
    <ice:inputText value="#{activePageBean.selectedNode.filterText}" />
    then the original bean method is directly called instead of the proxied methods. and hence no interception occurs.

    I have an ice:tree component and for that tree the getIcon, getDisplayText methods are intercepted but for the rest, no method is intercepted.

    The bean is taken from FacesContext by code:
    Code:
    	DefaultMutableTreeNode rootTreeNode = (DefaultMutableTreeNode) getModel().getRoot();
    	.
    	.
    	ActivePageContentBean activePageBean = FacesUtils.getManagedBean("activeAyarlarPageBean", ActivePageContentBean.class);
    	FKDSPageContent fkdsPageContent = (FKDSPageContent) rootTreeNode.getUserObject();
    	.
    	.
    	BeanOne beanOne = FacesUtils.getManagedBean("beanOne", BeanOne.class);
    	beanOne.setNavigationSelection(activePageBean);
    	DefaultMutableTreeNode kullanicilarNode = new DefaultMutableTreeNode(beanOne);
    	beanOne.setWrapper(kullanicilarNode);
    	rootTreeNode.add(kullanicilarNode);
    FACES CONFIG:
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    
    <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
    	version="1.2">
    	<application>
    		<view-handler>com.icesoft.faces.facelets.D2DFaceletViewHandler</view-handler>
    	</application>
    	<application>
    		<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
    	</application>
    
    	<managed-bean>
    		<description>Manages render calls to the Faces Context.</description>
    		<managed-bean-name>rmanager</managed-bean-name>
    		<managed-bean-class>com.icesoft.faces.async.render.RenderManager</managed-bean-class>
    		<managed-bean-scope>application</managed-bean-scope>
    	</managed-bean>
    	<managed-bean>
    		<managed-bean-name>activePageBean</managed-bean-name>
    		<managed-bean-class>org.mami.pointcut.FKDSGorunumBean</managed-bean-class>
    		<managed-bean-scope>request</managed-bean-scope>
    		<managed-property>
    			<property-name>ayarlarTreeBean</property-name>
    			<value>#{ayarlarTreeBean}</value>
    		</managed-property>
    		<managed-property>
    			<property-name>gorunumPageContentBean</property-name>
    			<value>#{activeAyarlarPageBean}</value>
    		</managed-property>
    	</managed-bean>
    
    	<!-- Ayarlar gorunum aktif page -->
    	<managed-bean>
    		<managed-bean-name>activeAyarlarPageBean</managed-bean-name>
    		<managed-bean-class>org.mami.pointcut.ActivePageContentBean</managed-bean-class>
    		<managed-bean-scope>request</managed-bean-scope>
    	</managed-bean>
    
    	<managed-bean>
    		<managed-bean-name>ayarlarTreeBean</managed-bean-name>
    		<managed-bean-class>org.mami.pointcut.AyarlarTreeBean</managed-bean-class>
    		<managed-bean-scope>request</managed-bean-scope>
    		<managed-property>
    			<property-name>renderManager</property-name>
    			<value>#{rmanager}</value>
    		</managed-property>
    	</managed-bean>
    </faces-config>
    applicationcontext-xml
    HTML Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <b:beans xmlns="http://www.springframework.org/schema/security" xmlns:b="http://www.springframework.org/schema/beans"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                  http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.4.xsd"
    >
    
         <http auto-config="true" access-denied-page="/accessDenied.jsp">
    
              <intercept-url pattern="/inc/**" access="IS_AUTHENTICATED_REMEMBERED" />
              <form-login login-page="/login.jsp" default-target-url="/inc/fibermain.iface" always-use-default-target="true" />
              <logout logout-success-url="/index.jsp" />
              <remember-me key="myRememberKey" />
              <anonymous />
              <http-basic />
              <!--
                   Ayni kisi baska yerde oturum acinca var olan oturumu kapatmak icin exception-if-maximum-exceeded= "false"
                   olmasi lazim, eger bu deger true olsa, onceki session expire olmadan login yapilamaz
              -->
              <!--
    			<concurrent-session-control max-sessions="1"
    			exception-if-maximum-exceeded="false" />
    		-->
         </http>
         <authentication-provider>
              <password-encoder hash="md5" />
              <user-service>
                   <user name="rod" password="a564de63c2d0da68cf47586ee05984d7" authorities="ROLE_SUPERVISOR, ROLE_USER, ROLE_TELLER" />
                   <user name="dianne" password="65d15fe9156f9c4bbffd98085992a44e" authorities="ROLE_USER,ROLE_TELLER" />
                   <user name="scott" password="2b58af6dddbd072ed27ffc86725d7d3a" authorities="ROLE_USER" />
                   <user name="peter" password="22b5c9accc6e1ba628cedc63a72d57f8" authorities="ROLE_USER" />
              </user-service>
         </authentication-provider>
         <b:bean id="pointcutMap" class="org.mami.pointcut.PointcutMap" />
         <b:bean id="proxyFactory" class="org.mami.pointcut.MyFactory" />
         <bean id="beanOne" class="org.mami.pointcut.beans.BeanOne" scope="request" />
         <bean id="beanTwo" class="org.mami.pointcut.beans.BeanTwo" scope="request" />
    </b:beans>
    This may be about some phase or render manager considerations maybe facelets or the order or configuration of filters. I don't know.
    Any Idea about that?

    (I am using jsf, ice-faces 1.7.2, spring security-aspectjrt- aspectj weaver-cgilib running on JBOSS 4.3)
    Last edited by myildiz83; May 12th, 2009, 10:23 AM. Reason: The problem description changed

  • #2
    Solved

    The problem is that:
    I was calling activePageBean.setSelectedPanel(this) in the tree navigation code.

    Since this should be a proxy (which obviously is the original object) the outer class gets the access to original methods not proxy methods.

    As a result: USE the "this" property carefully when proxying objects!

    Comment

    Working...
    X