|
|
|
I had the same reaction - but maybe choosing a different function name than enhance() would help.
After some additional discussions with someone who pointed out that it might be vital for an observer to have control whether it is invoked before or after the PostConstruct method in the target instance itself, I probably have to rename the existing tags since I don't want to end up with a tag named PostPostConstruct. ;-)
So probably we'll rather have [Init] [Destroy] for the object itself, and [PreConfigure] [PreInit] [PostInit] [PreDestroy] [PostDestroy] for the observer? You'll then have full control over execution order. I think most of the tag names are self-explanatory. [PreConfigure] would execute even before injections have been performed. |
|||||||||||||||||||||||||||||||||||||||
When I first read it, I was a little surprised by the reuse of the PostConstruct and PreDestroy metadata, since the developer now needs to read the metadata and method signature to infer the meaning, since in one case the object is the class instance and in the other it is the parameter. Having said that, I can't think of a better alternative off the top of my head and the rules are easy enough to grasp after a few moments of reflection.