use of grails.artefact.Enhanced in project grails-core by grails.
the class GrailsClassUtils method hasBeenEnhancedForFeature.
/**
* Checks to see if a class is marked with @grails.artefact.Enhanced and if the enhancedFor
* attribute of the annotation contains a specific feature name
*
* @param controllerClass The class to inspect
* @param featureName The name of a feature to check for
* @return true if controllerClass is marked with Enhanced and the enhancedFor attribute includes featureName, otherwise returns false
* @see Enhanced
* @see Enhanced#enhancedFor()
*/
public static Boolean hasBeenEnhancedForFeature(final Class<?> controllerClass, final String featureName) {
boolean hasBeenEnhanced = false;
final Enhanced enhancedAnnotation = controllerClass.getAnnotation(Enhanced.class);
if (enhancedAnnotation != null) {
final String[] enhancedFor = enhancedAnnotation.enhancedFor();
if (enhancedFor != null) {
hasBeenEnhanced = GrailsArrayUtils.contains(enhancedFor, featureName);
}
}
return hasBeenEnhanced;
}
use of grails.artefact.Enhanced 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