Search in sources :

Example 1 with ModuleXMLConfigurationFileParser

use of com.sun.enterprise.config.modularity.parser.ModuleXMLConfigurationFileParser 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;
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) ConfigBeanDefaultValue(com.sun.enterprise.config.modularity.customization.ConfigBeanDefaultValue) XMLStreamException(javax.xml.stream.XMLStreamException) ModuleXMLConfigurationFileParser(com.sun.enterprise.config.modularity.parser.ModuleXMLConfigurationFileParser) LocalStringManager(com.sun.enterprise.util.LocalStringManager) CustomConfiguration(com.sun.enterprise.config.modularity.annotation.CustomConfiguration) Method(java.lang.reflect.Method) IOException(java.io.IOException) PropertyVetoException(java.beans.PropertyVetoException) XMLStreamException(javax.xml.stream.XMLStreamException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException)

Aggregations

CustomConfiguration (com.sun.enterprise.config.modularity.annotation.CustomConfiguration)1 ConfigBeanDefaultValue (com.sun.enterprise.config.modularity.customization.ConfigBeanDefaultValue)1 ModuleXMLConfigurationFileParser (com.sun.enterprise.config.modularity.parser.ModuleXMLConfigurationFileParser)1 LocalStringManager (com.sun.enterprise.util.LocalStringManager)1 LocalStringManagerImpl (com.sun.enterprise.util.LocalStringManagerImpl)1 PropertyVetoException (java.beans.PropertyVetoException)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 XMLStreamException (javax.xml.stream.XMLStreamException)1