Java: getter/setter methods
开发者_运维知识库How are a bean's getter methods invoked and set in various frameworks? is it only through reflections?
Yes, most frameworks use reflections for that, with assumed requirement that you must use a proper getter / setter naming convention (getXXX and setXXX, or isXXX and setXXX for boolean property).
Performance may be an issue, but unless you benchmark your application and find reflections to be a major bottleneck, I would advise against premature optimization, and use reflections as the simplest solution. With that said, you may want to look at this article on replacing reflections with code generation:
http://www.ibm.com/developerworks/java/library/j-dyn0610/
精彩评论