-
1. Re: Spring MVC Example
splatch Mar 1, 2013 9:49 AM (in response to msduk)Hey Mark,
You may take a look on presentation from last year about integrating CDI with Spring. My thinking is that Spring bridges somehow CDI annotations into Spring context but it simply ignores custom extensions. In other words you may use CDI in very limited way.
-
2. Re: Spring MVC Example
msduk Mar 1, 2013 11:40 AM (in response to splatch)Hi thanks for the response. I had already read your presentation, very helpful.
<cdi:bean-manager/>
<cdi:bean-reference id="apiService" type="com.api.ApiService"/><!- remote ->
<cdi:bean-reference id="webServiceBean" type="com.web.WebServiceBean"/><!-- local ->
I found I was unable to wire any remote interface directly to the controller. However I can reference ApiService if it is injected into the local bean. Which seems odd to me.
@Service(WebService.class)
public class WebServiceBean implements WebService {
@Inject @Reference
ApiService apiService;
public String apiServiceMessage() {
return apiService.demoApi("hi");
}
>>>
@Controller
public class HomeController {
@Autowired <!-- works -->
WebServiceBean webServiceBean;
@Autowired <!-- doesn't work-->
ApiService apiService;
<!-- works -->
webServiceBean.apiServiceMessage()
I am guessing, as dont know a huge amount about Spring behind the scenes and even less about CDI, but the remote interfaces dont seem to be exposed by the bridge.
I dont know if anyone else has a better solution?