java - Limiting Dependency on Spring Without Losing Power of Framework -
simplified architecture of web projects
war
- spring dependency injection (most use xml)
jar
- dao
- domain
the problem: spring 3 , 2.5+ annotations building repositories , services has become easier wire together. however, because @service
conceptually belongs in jar far more war, , auto-wired repositories, , transactional classes, do. how people work it's expected not have "spring dependencies" in actual jar classes, i've found in multiple companies goal.
obviously know cannot remove spring dependencies if want use annotations , transactions, since spring classes, there best practice people use limit liability if there changes spring, or there projects use older spring versions in war included in jar?
i'm assuming must common problem, if not, please ask , elaborate
annotation based dependency injection (very convenient) violation of separation of concerns. dependency describe result of this. if avoid should wiring in separate package (i.e. not use annotations dependency injection).
it possible wire based on own custom annotations. depending on how far willing go can improve things leave single spring dependency (your extending annotation) or remove dependencies altogether. still violates soc, less dependency on spring.
usually find either living downsides of annotations, or living without them (using java config or plain old xml) maintainable options. custom annotations maintenance burden.
Comments
Post a Comment