I’m a little confused after all articles that I read. I don’t want to use additional services as I’ll need if I use Weld Framework instead of simple Spring qualifier in service layer. And I have one service which uses JavaMailSender. I just want to have ability use AOP in controller layer with JSF.
I got absolutely confused after reading about support JSR-229 and JSR-330 by Spring (even Spring 3)
Spring 3 And JSR-330 @Inject And @Named Example
Does it mean that I can do smth like that and don't lose posibility use Spring features like AOP ? (Yes, I think.)
import javax.inject.Inject;
import javax.inject.Named;
import java.io.Serializable;
@Named("newClientController")
@ViewScoped
public class NewClientController implements Serializable {
@Inject
private ClientService clientService;
////......
}
@Service
@Transactional
public class ClientService {
public ClientService(){
int i = 0;
}
@Autowired
@Qualifier("clientDAOMyBatis")
private ClientDAO clientDAO;
//....
}
I researched several days and found several groups of decisions
1) Bridge between Spring and CDI
https://stackoverflow.com/questions/5510144/cdi-bean-accessing-spring-beans Injecting a Spring bean using CDI @Inject
Prons:
- Simple decision
- Don't lose Spring features
Cons:
- They have doubtful reputation. (bugs !!!)
2) Use Spring @Component and create custom ViewScope for JSF http://blog.primefaces.org/?p=702
Prons:
- Simple decision
- Don't lose Spring features
Cons:
- Absent implementation of support for destruction callbacks.
3) Serializable Spring Bean (smth strange)
https://codereview.stackexchange.com/questions/23790/spring-autowiring-in-managed-beans-with-support-for-serialization-is-this-safe
Please, don't close this questions. I know that many related questions exist. Could you advice me some solution for that problem?
P.S. I use MyBatis which doesn't support JPA and Spring Java-based Configuration because I want to deploy this app in cloud.