Compile time checks?

Splash Forums PrettyFaces Users Compile time checks?

This topic contains 5 replies, has 2 voices, and was last updated by  Robert 8 years, 4 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #24734


    Hey guys,

    how can I do compile-time checks of my prettyfaces annotations? Is there a jar file I can hook into the build process?
    I want to detect e.g., duplicated mapping ids early.



    No, there is nothing like this. What else would you like to check beside duplicated mappings? Detecting duplicated mappings at compile time doesn’t make much sense to me, because mappings could be contained in multiple JAR files and the compile time classpath could be different from the runtime classpath.



    I’d like to catch any error as early as possible. I just found the duplicated mappings problem, but if there are other bad configurations, I’d like to catch those as well.

    If I have a duplicated mapping I get an exception in the server log and navigation does not work at all (not only for the mapping in question). To detect this I need to deploy and either keep an eye on the server log or try to use the application. Both is manual work and inconvenient, especially on a CI server.

    I don’t mind if mappings can be in multiple jar or war files; as the programmer I know where my mappings are and I can point a checking program to the right files.

    Does that make sense?


    To be honest, I don’t consider duplicate mapping IDs as a problem users often run into. I almost think that this never happened to me before. I try to follow a naming schema that prevents conflicts. Something like “customerList”, “customerCreate”, “customerModify”, ….

    The only thing I could imagine that could perform such compile time checks would be a maven plugin or something like this. But I think this would be hard to implement, because you would have to duplicate much of the bootstrapping code of PrettyFaces to get the effective mapping ids (parsing pretty-config.xml and scanning for annotations).

    I for myself don’t see much of a benefit for such compile time checks. Especially there isn’t much beside duplicate mapping IDs that you can look for at compile time. But if you think this could be useful for you, we are always happy to get contributions. πŸ™‚


    Just another thought on this. If you really want to check for duplicate mapping IDs, what about creating an Arquillian test which packages your complete application to a WAR, deploys it and than checks if the container boots correctly. This way you have a simple JUnit test that checks if your application starts up correctly. Wouldn’t this fit your needs? This would even catch more errors like ambiguous dependencies of CDI beans etc.



    Thanks for your input.

    I guess I want to avoid copy & paste errors mostly… we have some URLs that use the same backing bean, like this:

    @com.ocpsoft.pretty.faces.annotation.URLMappings(mappings = {
            id = Node.MAPPING_RCPTS,
            pattern = Node.URL_PATTERN + "recipients/",
            viewId = Node.THE_PAGE),
            id = Node.MAPPING_DELIVERED,
            pattern = Node.URL_PATTERN + "delivered/",
            viewId = Node.THE_PAGE),
            id = Node.MAPPING_BOUNCED,
            pattern = Node.URL_PATTERN + "bounced/",
            viewId = Node.THE_PAGE)

    My experience with Arquillian is limited (and really bad)… guess I can give it another try.


Viewing 6 posts - 1 through 6 (of 6 total)

The forum ‘PrettyFaces Users’ is closed to new topics and replies.

Comments are closed.