Announcement Announcement Module
Collapse
No announcement yet.
How to enforce bean naming standards? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to enforce bean naming standards?

    I'm working on a large-scale project with many developers creating bean xml files. To avoid naming collisions, we have a naming convention in place.

    I'm looking for a way to validate the naming conventions are being followed. Does anybody know of an easy way to do this? I've looked at the lifecycle methods and other tooling around the beanfactory & app context, but haven't found a fit.

    Our standard is something like: all bean names must equal the jar name in which the bean is defined. For example, in myservice.jar, all bean names must begin with "myservice".

  • #2
    Sounds like that's what a "BeanPostProcessor" is for. You can have it called on every bean creation.

    Comment


    • #3
      Originally posted by dkarr View Post
      Sounds like that's what a "BeanPostProcessor" is for. You can have it called on every bean creation.
      Yes, that does sound close. I'd need to know what file path the bean definition was loaded from. Correct me if I'm wrong, but BeanPostProcessor doesn't provide that info.

      Comment


      • #4
        Originally posted by easternwahoo View Post
        Yes, that does sound close. I'd need to know what file path the bean definition was loaded from. Correct me if I'm wrong, but BeanPostProcessor doesn't provide that info.
        I'm pretty sure you're right.

        In that case, you'll probably have to implement a completely different approach. I would suggest you implement build-time verification, instead of load-time verification. If I had to do that, I would utilize the Ant "XMLTask" task library, which allows easy iteration of xpath search results on XML files.

        Comment

        Working...
        X