Results 1 to 2 of 2

Thread: Purpose of @RooBeanInfo?

  1. #1
    Join Date
    Jun 2009
    Posts
    3

    Question Purpose of @RooBeanInfo?

    After I found the @RooBeanInfo annotation, I tested it with a simple class:

    Code:
    @RooJavaBean
    @RooToString
    public class Item{
      @NotNull
      private String type;
    
      public String getFoo() {
        return "";
      }
    
      public void setFoo(String s) {
      }
    }
    I was expecting an auto-generated BeanInfo class, in the vein of @RooJavaBean, but that didn't happen. Digging around in the addon-beaninfo sourcecode didn't enlighten me neither.

    Could I have some information about the purpose of this annotation and the corresponding Roo plugin?

    Cheers, Andreas

  2. #2
    Join Date
    Mar 2008
    Location
    Sydney, AU
    Posts
    974

    Default

    Hi Andreas,

    The @RooJavaBean annotation will trigger the creation of a Item_Roo_JavaBean.aj file when needed. @RooJavaBean in this case could take care of creating accessors and mutators for private fields defined in the Item.java class. In your case it will create a fully working getType() and a setType() methods as per JavaBean sec.

    Internally the @RooJavaBean annotation will also trigger the creation of a BeanInfoMetadata object which provides metadata information about this bean. This is more interesting for add-on development as the add-on might need to know about accessors, mutators, field names and types, etc which this bean exposes.

    If you want to take a look at the BeanInfoMetadata for curiosity you can type this command in the shell:

    Code:
    roo> metadata for type -type your.package.Item
    This command will list all available metadata for the Item type and if you look closely you will see BeanInfoMetadata among them.

    I believe Ben is planning to write a blog post explaining the metadata system in a little more detail.

    -Stefan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •