0 Replies Latest reply on Mar 19, 2008 7:44 PM by alesj

    AOP proxies and field injection

    alesj

      I've added org.jboss.test.microcontainer.beans.test.FieldAccessTestCase test.
      It checks how beans and field injection play when beans are aspectized.

      What I've already mentioned

      "alesj" wrote:
      "kabir.khan@jboss.com" wrote:
       if (o instanceof org.jboss.aop.proxy.container.AspectManaged)
       {
       //It is a proxy
       }
       else if (o instanceof org.jboss.aop.Advised)
       {
       //It is woven
       }
       else
       {
       //Plain class
       }
      


      Do we need such a check?
      e.g. JoinpointFactory
      // perhaps name param is too much
      boolean isFieldAccesible(Object target, String name);
      

      Where AOPJpF would do the above mentioned check, and BasicJpF just returned true.

      but got no response,
      is what this test also exposes.

      e.g. this is my simple bean
      public class AccessBean
      {
       public String pubString;
      
       public String getPubString()
       {
       return pubString;
       }
      }
      

      and I do field injection
       <bean name="public" class="org.jboss.test.microcontainer.beans.support.AccessBean" access-mode="ALL">
       <property name="pubString">foobar</property>
       </bean>
      

      but this is what could happen
       AccessBean pb = getBean("public", AccessBean.class);
       assertEquals("foobar", pb.pubString);
       AbstractTypeTestDelegate.Type type = getType("public");
       assertTrue(pb.getPubString() == null || type != AbstractTypeTestDelegate.Type.PROXY);
      

      pb.pubString != pb.getPubString() if pb ~ proxy

      Perhaps not knowing that my bean is gonna be matched by some pointcut, hence being aspectized, I'm using a mixture of direct public field access and getter. Expecting that using either is the same. Which is not the case here, as the example shows.

      Leave it as it is, or hack something to fail or at least produce a loud warning?