use of grails.plugins.GrailsPlugin 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);
}
}
}
}
}
use of grails.plugins.GrailsPlugin in project grails-core by grails.
the class AbstractGrailsPluginManager method doRuntimeConfiguration.
/**
* Base implementation that will perform runtime configuration for the specified plugin name.
*/
public void doRuntimeConfiguration(String pluginName, RuntimeSpringConfiguration springConfig) {
checkInitialised();
GrailsPlugin plugin = getGrailsPlugin(pluginName);
if (plugin == null) {
throw new PluginException("Plugin [" + pluginName + "] not found");
}
if (!plugin.supportsCurrentScopeAndEnvironment()) {
return;
}
if (!plugin.isEnabled(applicationContext.getEnvironment().getActiveProfiles()))
return;
String[] dependencyNames = plugin.getDependencyNames();
doRuntimeConfigurationForDependencies(dependencyNames, springConfig);
String[] loadAfters = plugin.getLoadAfterNames();
for (String name : loadAfters) {
GrailsPlugin current = getGrailsPlugin(name);
if (current != null) {
current.doWithRuntimeConfiguration(springConfig);
}
}
plugin.doWithRuntimeConfiguration(springConfig);
}
use of grails.plugins.GrailsPlugin in project grails-core by grails.
the class BasePluginFilter method buildExplicitlyNamedList.
/**
* Returns the sublist of the supplied set who are explicitly named, either
* as included or excluded plugins
*
* @return a sublist containing the elements of the original list
* corresponding with the explicitlyNamed items as passed into the
* constructor
*/
private void buildExplicitlyNamedList() {
for (GrailsPlugin plugin : originalPlugins) {
// find explicitly included plugins
String name = plugin.getName();
if (suppliedNames.contains(name)) {
explicitlyNamedPlugins.add(plugin);
addedNames.add(name);
}
}
}
use of grails.plugins.GrailsPlugin in project grails-core by grails.
the class BasePluginFilter method buildDerivedPluginList.
/**
* Builds list of <code>GrailsPlugins</code> which are derived from the
* <code>explicitlyNamedPlugins</code> through a dependency relationship
*/
private void buildDerivedPluginList() {
// find their dependencies
for (int i = 0; i < explicitlyNamedPlugins.size(); i++) {
GrailsPlugin plugin = explicitlyNamedPlugins.get(i);
// recursively add in plugin dependencies
addPluginDependencies(derivedPlugins, plugin);
}
}
use of grails.plugins.GrailsPlugin in project grails-core by grails.
the class DefaultGroovyPageLocator method findPageInBinding.
public GroovyPageScriptSource findPageInBinding(String pluginName, String uri, TemplateVariableBinding binding) {
GroovyPageScriptSource scriptSource = null;
String contextPath = resolveContextPath(pluginName, uri, binding);
String fullURI = GrailsResourceUtils.appendPiecesForUri(contextPath, uri);
if (pluginManager != null) {
GrailsPlugin grailsPlugin = pluginManager.getGrailsPlugin(pluginName);
if (grailsPlugin instanceof BinaryGrailsPlugin) {
BinaryGrailsPlugin binaryGrailsPlugin = (BinaryGrailsPlugin) grailsPlugin;
File projectDirectory = binaryGrailsPlugin.getProjectDirectory();
if (projectDirectory != null) {
File f = new File(projectDirectory, GrailsResourceUtils.VIEWS_DIR_PATH + uri);
if (f.exists()) {
scriptSource = new GroovyPageResourceScriptSource(uri, new FileSystemResource(f));
}
} else {
scriptSource = resolveViewInBinaryPlugin(binaryGrailsPlugin, uri);
}
}
}
if (scriptSource == null) {
scriptSource = findPageInBinding(fullURI, binding);
}
if (scriptSource == null) {
scriptSource = findResourceScriptSource(uri);
}
//last effort to resolve and force name of plugin to use camel case
if (scriptSource == null) {
contextPath = resolveContextPath(pluginName, uri, binding, true);
scriptSource = findPageInBinding(GrailsResourceUtils.appendPiecesForUri(contextPath, uri), binding);
}
return scriptSource;
}
Aggregations