use of grails.core.ArtefactHandler in project grails-core by grails.
the class AbstractGrailsApplication method configChanged.
@Override
public void configChanged() {
updateFlatConfig();
final ArtefactHandler[] handlers = getArtefactHandlers();
if (handlers != null) {
for (ArtefactHandler handler : handlers) {
if (handler instanceof GrailsConfigurationAware) {
((GrailsConfigurationAware) handler).setConfiguration(config);
}
}
}
}
use of grails.core.ArtefactHandler in project grails-core by grails.
the class BootStrapArtefactHandlerTests method testIsBootStrapClass.
public void testIsBootStrapClass() {
GroovyClassLoader gcl = new GroovyClassLoader();
Class<?> c = gcl.parseClass("class TestBootStrap { }\n");
ArtefactHandler handler = new BootstrapArtefactHandler();
assertTrue(handler.isArtefact(c));
}
use of grails.core.ArtefactHandler in project grails-core by grails.
the class ControllerArtefactHandlerTests method testIsControllerClass.
public void testIsControllerClass() {
GroovyClassLoader gcl = new GroovyClassLoader();
Class<?> c = gcl.parseClass("class TestController { }\n");
ArtefactHandler handler = new ControllerArtefactHandler();
assertTrue(handler.isArtefact(c));
}
use of grails.core.ArtefactHandler in project grails-core by grails.
the class AbstractGrailsPluginManager method informOfClassChange.
public void informOfClassChange(Class<?> aClass) {
if (aClass == null || application == null) {
return;
}
ArtefactHandler handler = application.getArtefactType(aClass);
if (handler == null) {
return;
}
String pluginName = handler.getPluginName();
if (pluginName == null) {
return;
}
GrailsPlugin plugin = getGrailsPlugin(pluginName);
if (plugin != null) {
if (!plugin.isEnabled(applicationContext.getEnvironment().getActiveProfiles()))
return;
plugin.notifyOfEvent(GrailsPlugin.EVENT_ON_CHANGE, aClass);
} else {
String classNameAsPath = aClass.getName().replace('.', File.separatorChar);
String groovyClass = classNameAsPath + ".groovy";
String javaClass = classNameAsPath + ".java";
for (GrailsPlugin grailsPlugin : pluginList) {
List<WatchPattern> watchPatterns = grailsPlugin.getWatchedResourcePatterns();
if (watchPatterns != null) {
for (WatchPattern watchPattern : watchPatterns) {
File parent = watchPattern.getDirectory();
String extension = watchPattern.getExtension();
if (parent != null && extension != null) {
File f = new File(parent, groovyClass);
if (f.exists() && f.getName().endsWith(extension)) {
grailsPlugin.notifyOfEvent(GrailsPlugin.EVENT_ON_CHANGE, aClass);
} else {
f = new File(parent, javaClass);
if (f.exists() && f.getName().endsWith(extension)) {
grailsPlugin.notifyOfEvent(GrailsPlugin.EVENT_ON_CHANGE, aClass);
}
}
}
}
}
}
}
}
Aggregations