4 Replies Latest reply on Aug 14, 2005 3:00 PM by Ryan McDonough

    My JavaBean Aspect

    Ryan McDonough Newbie

      I've been working on an aspect for the past month where I could make a simple POJO, with just getters and setters, be able to support bound properties. These POJOs needed to be proper JavaBeans so that I could use them with the JGoodies Binding framework. Using JBoss AOP, I was able create a JavaBean Aspect so that any POJO could automagically work with the framework. I put an article, along with some code, up on my web site here:

      http://www.damnhandy.com/?page_id=17

      Any feedback on this would be greatly appreciated.

      Ryan-

        • 1. Re: My JavaBean Aspect
          Joep Wijers Newbie

          Hi,

          I am interested in applying your idea.
          Only, I quickly tried the sample eclipse project on your site and found that JGoodies throws an exception; it uses reflection to check that method addPropertyChangeListener exists, and it doesn't
          Maybe something is missing in the sample?

          thx,
          Joep

          • 2. Re: My JavaBean Aspect
            Ryan McDonough Newbie

            Joep,

            If you get the exception stating that the bean does not support bound properties, then the Aspect is not being applied. When the aspect is applied, JGoodies will see that the bean does have the methods it's looking for. I design the aspect to work with the way JGoodies verifies that the bean supports bound properties.

            How did you execute the example? Did you use the ant task or did you try and execute it from within Eclipse? If you're running the test class as a Java Application from within Eclipse, you'll need add a few VM params so that the aspects are applied at loadtime. You need to add:

            -javaagent:/path/to/jboss/jboss-aop-jdk50.jar
            -Djboss.aop.class.path=/path/to/compiled aspect jar or class folder
            

            or
            -Djboss.aop.path=/path/to/jboss-aop.xml
            


            Let me know if this helps any.

            Ryan-


            • 3. Re: My JavaBean Aspect
              Joep Wijers Newbie

              Hi Ryan,

              Yes this helps. Thanks for waking me up ;-)


              How did you execute the example? Did you use the ant task or did you try and execute it from within Eclipse? If you're running the test class as a Java Application from within Eclipse, you'll need add a few VM params so that the aspects are applied at loadtime.

              I am indeed running from Eclipse.
              I added these VM args and then it worked as expected:
              -javaagent:${project_loc}/lib/jboss-aop-jdk50.jar
              -Djboss.aop.path=${project_loc}/jboss-aop.xml
              


              I like it! I am considering to applying this approach; not just for bound properties but also other generic services I may want to mix in.

              Thanks,

              Joep

              • 4. Re: My JavaBean Aspect
                Ryan McDonough Newbie

                Awesome! Glad it worked out for you. In hind sight, it probably took me about as much time to figure out how to create an aspect using Introductions as it would have for me to code property change support into each class. But now that it's built, I can use it on just about anything going forward. It's still got a few rough edges, but I'm wokring on 'em. Let me know if you see anything that could be changed/made better, etc.

                Ryan-