I have two service beans called PowerUserManager
and SimpleUserManager
. Both @Service
annotated classes have about 20% of the code in common.
I've built an inheritance tree with a common abstract class (BaseUserManager
) to reduce redundancy between the two classes.
BaseUserManager
|
---------------
| |
PowerUserManager SimpleUserManager
Then in my @Controller
or whatever client class, I use the @Autowired
annotation to inject both PowerUserManager
and SimpleUserManager
and I use one of them depending on the instance of the User I'm dealing with.
I'm not comfortable using inheritance to factorize code especially in the service layer. Do you Spring fellows see a better way to do this ?