I have two spring configuration files and I specify them in my web.xml as shown below.
web.xml snippet
..
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/classes/domain-context.xml WEB-INF/classes/client-ws.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
..
From my domain object I have to call the web service client and to get the link to the web service client I do this:
ApplicationContext context = new ClassPathXmlApplicationContext("client-ws.xml");
ProductServiceClient client = (ProductServiceClient) context.getBean("productClient");
..
client.find(prodID);
..
However, I have concerns that finding the client-ws.xml file and getting a link to the ProductServiceClient bean is inefficient. I was thinking of getting it using WebApplicationContextUtils. However, I do not want my domain objects to depend on ServletContext (web / control layer object), because WebApplicationContextUtils depends on ServletContext. What is the best way to get a spring bean reference on indoor units?
Thank!