Issue
Can I make the spring service classes final? Is there any harm doing that? Nobody is going to extend the class. Is there any issue?
public final class MyService {
// Depedencies go here.
}
Solution
Don't make them final. If you use any AOP (including transaction support) on concrete classes, spring will use CGLIB to dynamically extend your class in order to make a proxy. And the requirement for CGLIB to work is to have your classes non-final. Otherwise an exception will be thrown.
Answered By - Bozho
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.