*/
public static GenericApplicationContext getSpringApplicationContext(AxisService axisService)
throws AxisFault {
GenericApplicationContext appContext;
Parameter appContextParameter = axisService.getParameter(SPRING_APPLICATION_CONTEXT);
Parameter contextLocationParam = axisService
.getParameter(SPRING_APPLICATION_CONTEXT_LOCATION);
// return the application context
if (appContextParameter != null) {
appContext = (GenericApplicationContext) appContextParameter.getValue();
// if the context is not found initialize a new one
} else {
appContext = new GenericApplicationContext();
ClassLoader serviceCL = axisService.getClassLoader();
appContext.setClassLoader(serviceCL);
ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(serviceCL);
XmlBeanDefinitionReader xbdr = new XmlBeanDefinitionReader(appContext);
// load the bean context file from the parameter
if (contextLocationParam != null) {
xbdr.loadBeanDefinitions(new ClassPathResource((String) contextLocationParam
.getValue()));
appContext.refresh();
AxisServiceGroup axisServiceGroup = axisService.getAxisServiceGroup();
Parameter springGroupCtxLocation = axisServiceGroup
.getParameter(SPRING_APPLICATION_CONTEXT_LOCATION);
// add the context to the service group or add it to the
// service
if (springGroupCtxLocation != null) {
axisServiceGroup.addParameter(new Parameter(SPRING_APPLICATION_CONTEXT,
appContext));
} else {
axisService.addParameter(new Parameter(SPRING_APPLICATION_CONTEXT,
appContext));
}
return appContext;
}
InputStream ctxFileInputStream = serviceCL
.getResourceAsStream(DeploymentConstants.META_INF + File.separator
+ axisService.getName() + "-application-context.xml");
// try for meta-inf
if (ctxFileInputStream == null) {
ctxFileInputStream = serviceCL.getResourceAsStream(DeploymentConstants.META_INF
.toLowerCase()
+ File.separator
+ axisService.getName()
+ "-application-context.xml");
}
// load the context file from meta-inf
if (ctxFileInputStream != null) {
xbdr.setValidationMode(XmlBeanDefinitionReader.VALIDATION_NONE);
xbdr.loadBeanDefinitions(new InputStreamResource(ctxFileInputStream));
appContext.refresh();
axisService.addParameter(new Parameter(SPRING_APPLICATION_CONTEXT, appContext));
return appContext;
} else {
throw new AxisFault("Spring context file cannot be located for AxisService");
}