use of com.sun.enterprise.config.modularity.annotation.CustomConfiguration in project Payara by payara.
the class ConfigModularityUtils method getDefaultConfigurations.
/**
* If exists, locate and return a URL to the configuration snippet for the given config bean class.
*
* @param configBeanClass the config bean type we want to check for its configuration snippet
* @return A url to the file or null of not exists
*/
public List<ConfigBeanDefaultValue> getDefaultConfigurations(Class configBeanClass, String runtimeType) {
// Determine if it is DAS or instance
CustomConfiguration c = (CustomConfiguration) configBeanClass.getAnnotation(CustomConfiguration.class);
List<ConfigBeanDefaultValue> defaults = Collections.emptyList();
if (c.usesOnTheFlyConfigGeneration()) {
Method m = getGetDefaultValuesMethod(configBeanClass);
if (m != null) {
try {
defaults = (List<ConfigBeanDefaultValue>) m.invoke(null, runtimeType);
} catch (Exception e) {
LogHelper.log(LOG, Level.INFO, cannotGetDefaultConfig, e, configBeanClass.getName());
}
}
} else {
// TODO properly handle the exceptions
LocalStringManager localStrings = new LocalStringManagerImpl(configBeanClass);
ModuleXMLConfigurationFileParser parser = new ModuleXMLConfigurationFileParser(localStrings);
try {
defaults = parser.parseServiceConfiguration(getConfigurationFileUrl(configBeanClass, c.baseConfigurationFileName(), runtimeType).openStream());
} catch (XMLStreamException e) {
LOG.log(Level.SEVERE, cannotParseDefaultDefaultConfig, e);
} catch (IOException e) {
LOG.log(Level.SEVERE, cannotParseDefaultDefaultConfig, e);
}
}
return defaults;
}
Aggregations