7 Replies Latest reply on Aug 27, 2007 7:38 PM by swd847

    Custom annotation scanner

    swd847

      Would it be possible to add a scanner for custom annotations into seam?
      I am thinking something along the lines of:

      1) Define the annotations that we are interested in in a configuration file, as well as the application scope context variables that they are to be loaded into.

      2) When the component scanner runs it also looks for these class level annotations, and loads the class names into a list.

      3) These lists are then saved to the application scope.

      Application scoped components could then use these lists to set up any infrastructure that uses these classes.

        • 1. Re: Custom annotation scanner
          matt.drees

          There's actually a jira feature request for that: http://jira.jboss.com/jira/browse/JBSEAM-1342

          I'd like it, too, but it might not come for a little while.

          • 2. Re: Custom annotation scanner
            swd847

            I might be prepared to work on it, as I have a use for it, but I would need confirmation on how people would want it to work.
            The JIRA issue seems to just be about making the Scanner class public, so it is possible to write custom scanners.
            I was thinking of re-using the seam scanner to reduce startup times. I was thinking the configuration would be something like:

            <scannerconfig>
             <annotations>
             <annotation class="com.custom.Annotation" variable="customAnnotationList" />
             </annotations>
             <files>
             <file pattern="*.customdata.xml" variable="customFileList" />
             </files>
            </scannerconfig>
            




            • 3. Re: Custom annotation scanner
              pmuir

              My design would be something similar to the data binder meta annotations (the JIRA issue probably has a misleading description, its actually about the ability to reuse the scanner).

              • 4. Re: Custom annotation scanner
                matt.drees

                Pete, do you know if there are any plans to let the scanner find files, too (as swd847 is suggesting)?

                • 5. Re: Custom annotation scanner
                  pmuir

                  Sorry, I wasn't thinking there at all. Of course, it wouldn't be like the DataBinder stuff at all. Anyway, its an interesting idea to have it scan files as well, can you add a comment to the issue? atm I'm not sure how to best configure which files to scan (we don't want another configuration file).

                  • 6. Re: Custom annotation scanner
                    christian.bauer

                    The wiki has several use cases as well and I've been experimenting with different metamodels and ways of scanning/constructing/registering this data so it is conveniently available at runtime. I'm not convinced yet I found the best approach but there is definitely a need for a more generic "registry" feature in Seam.

                    • 7. Re: Custom annotation scanner
                      swd847

                      There does not seam to be a logical place to put it at the moment, other than components.xml, which would not really work.


                      The wiki has several use cases as well and I've been experimenting with different metamodels and ways of scanning/constructing/registering this data so it is conveniently available at runtime. I'm not convinced yet I found the best approach but there is definitely a need for a more generic "registry" feature in Seam.


                      What would be the benefit of a generic registry over application scoped components?