throw new GFacException(e);
} catch (IOException e) {
throw new GFacException(e);
}
GFacProviderConfig s = null;
GFacProvider provider = null;
List<GFacProviderConfig> aClass = null;
String providerClassName = null;
try {
aClass = GFacConfiguration.getProviderConfig(handlerDoc,
Constants.XPATH_EXPR_APPLICATION_HANDLERS_START + applicationName + "']", Constants.GFAC_CONFIG_APPLICATION_NAME_ATTRIBUTE);
// This should be have a single element only.
if (aClass != null && !aClass.isEmpty()) {
s = aClass.get(0);
Class<? extends GFacProvider> aClass1 = Class.forName(s.getClassName()).asSubclass(GFacProvider.class);
provider = aClass1.newInstance();
//loading the provider properties
if(!aClass.isEmpty()){
provider.initProperties(aClass.get(0).getProperties());
}
}
// We give higher preference to applications specific provider if configured
if (provider == null) {
String hostClass = hostDescription.getType().getClass().getName();
providerClassName = GFacConfiguration.getAttributeValue(GFacConfiguration.getHandlerDoc(), Constants.XPATH_EXPR_PROVIDER_ON_HOST + hostClass + "']", Constants.GFAC_CONFIG_CLASS_ATTRIBUTE);
Class<? extends GFacProvider> aClass1 = Class.forName(providerClassName).asSubclass(GFacProvider.class);
provider = aClass1.newInstance();
//loading the provider properties
aClass = GFacConfiguration.getProviderConfig(GFacConfiguration.getHandlerDoc(), Constants.XPATH_EXPR_PROVIDER_HANDLERS_START +
providerClassName + "']", Constants.GFAC_CONFIG_APPLICATION_NAME_ATTRIBUTE);
if(!aClass.isEmpty()){
provider.initProperties(aClass.get(0).getProperties());
}
}
} catch (XPathExpressionException e) {
log.error("Error evaluating XPath expression"); //To change body of catch statement use File | Settings | File Templates.
throw new GFacException("Error evaluating XPath expression", e);