Search in sources :

Example 6 with ArtefactHandler

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);
            }
        }
    }
}
Also used : GrailsConfigurationAware(grails.core.support.GrailsConfigurationAware) ArtefactHandler(grails.core.ArtefactHandler)

Example 7 with ArtefactHandler

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));
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) BootstrapArtefactHandler(org.grails.web.servlet.boostrap.BootstrapArtefactHandler) ArtefactHandler(grails.core.ArtefactHandler) BootstrapArtefactHandler(org.grails.web.servlet.boostrap.BootstrapArtefactHandler)

Example 8 with ArtefactHandler

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));
}
Also used : GroovyClassLoader(groovy.lang.GroovyClassLoader) ControllerArtefactHandler(org.grails.core.artefact.ControllerArtefactHandler) ArtefactHandler(grails.core.ArtefactHandler) ControllerArtefactHandler(org.grails.core.artefact.ControllerArtefactHandler)

Example 9 with ArtefactHandler

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);
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : WatchPattern(org.grails.plugins.support.WatchPattern) GrailsPlugin(grails.plugins.GrailsPlugin) ArtefactHandler(grails.core.ArtefactHandler) File(java.io.File)

Aggregations

ArtefactHandler (grails.core.ArtefactHandler)9 GroovyClassLoader (groovy.lang.GroovyClassLoader)7 DomainClassArtefactHandler (org.grails.core.artefact.DomainClassArtefactHandler)3 CodecArtefactHandler (org.grails.commons.CodecArtefactHandler)2 GrailsConfigurationAware (grails.core.support.GrailsConfigurationAware)1 GrailsPlugin (grails.plugins.GrailsPlugin)1 File (java.io.File)1 ControllerArtefactHandler (org.grails.core.artefact.ControllerArtefactHandler)1 ServiceArtefactHandler (org.grails.core.artefact.ServiceArtefactHandler)1 TagLibArtefactHandler (org.grails.core.artefact.TagLibArtefactHandler)1 WatchPattern (org.grails.plugins.support.WatchPattern)1 BootstrapArtefactHandler (org.grails.web.servlet.boostrap.BootstrapArtefactHandler)1