You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Charlie Dobbie <cf...@gmail.com> on 2008/11/21 14:25:09 UTC

Thank you for wicketstuff-annotation!

I recently encountered the wicketstuff-annotation project, and now mount all
my pages via annotations.  Thank you for this project!  Gets a lot of Page
configuration out of the Application subclass and back to where it should
be.

After seeing the mount scanner, I was very pleased to note that the same
approach would solve another issue I have.  In my Application subclass I
always have a list of annotated Hibernate classes that need to be added to
the AnnotationConfiguration.  While in heavy development, I'm adding new
domain objects all the time, and frequently forget to add them to this list,
adding up to lots of minor frustrations.  But not any more - using the
MatchingResources class from wicketstuff-annotations, seven lines of code
solved that one for good:

        MatchingResources resources = new
MatchingResources("classpath*:uk/co/mypackagestructure/data/**/*.class");
        List<Class<? extends Annotation>> hibernateClasses = new
ArrayList<Class<? extends Annotation>>();
        hibernateClasses.add(Entity.class);
        hibernateClasses.add(MappedSuperclass.class);
        for(Class<? extends Annotation> hibernateClass : hibernateClasses) {
            for(Class<?> c : resources.getAnnotatedMatches(hibernateClass))
{
                config.addAnnotatedClass(c);
            }
        }

Hurrah!


Charlie.