use of groovy.util.ConfigObject in project grails-core by grails.
the class AbstractGrailsPluginManager method informOfClassChange.
public void informOfClassChange(File file, @SuppressWarnings("rawtypes") Class cls) {
if (file.getName().equals(CONFIG_FILE)) {
ConfigSlurper configSlurper = getConfigSlurper(application);
ConfigObject c;
try {
c = configSlurper.parse(file.toURI().toURL());
application.getConfig().merge(c);
final Map flat = c.flatten();
application.getConfig().merge(flat);
application.configChanged();
informPluginsOfConfigChange();
} catch (Exception e) {
// ignore
LOG.debug("Error in changing Config", e);
}
} else {
if (cls != null) {
MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
registry.removeMetaClass(cls);
ExpandoMetaClass newMc = new ExpandoMetaClass(cls, true, true);
newMc.initialize();
registry.setMetaClass(cls, newMc);
Enhanced en = AnnotationUtils.findAnnotation(cls, Enhanced.class);
if (en != null) {
Class<?>[] mixinClasses = en.mixins();
if (mixinClasses != null) {
DefaultGroovyMethods.mixin(newMc, mixinClasses);
}
}
}
for (GrailsPlugin grailsPlugin : pluginList) {
if (grailsPlugin.hasInterestInChange(file.getAbsolutePath())) {
try {
if (cls == null) {
grailsPlugin.notifyOfEvent(GrailsPlugin.EVENT_ON_CHANGE, new FileSystemResource(file));
} else {
grailsPlugin.notifyOfEvent(GrailsPlugin.EVENT_ON_CHANGE, cls);
}
Environment.setCurrentReloadError(null);
} catch (Exception e) {
LOG.error("Plugin " + grailsPlugin + " could not reload changes to file [" + file + "]: " + e.getMessage(), e);
Environment.setCurrentReloadError(e);
}
}
}
}
}
Aggregations