Ideally, I think it can be called from anywhere because you are using ClassPathXmlApplicationContext:
Originally Posted by santyop
This is the definition of ClassPathXmlApplicationContext:
applicationContext = new ClassPathXmlApplicationContext("data-access-context.xml");
Standalone XML application context, taking the context definition files from the class path. Mainly useful for test harnesses, but also for application contexts embedded within JARs.
It also states:
This is a simple, one-stop shop convenience ApplicationContext. Consider using the GenericApplicationContext class in combination with an XmlBeanDefinitionReader for more flexible context setup.
so to answer you question, it can be used anywhere. You will feed the ClassPathXmlApplicationContext your application context file on the classpath. For myself, I used this factory in the same project as was my my master application-context file (which other context files linked to).