use of org.grails.core.exceptions.GrailsConfigurationException in project grails-core by grails.
the class DefaultGrailsPlugin method evaluatePluginScopes.
private void evaluatePluginScopes() {
// Damn I wish Java had closures
pluginScopes = evaluateIncludeExcludeProperty(SCOPES, new Closure(this) {
private static final long serialVersionUID = 1;
@Override
public Object call(Object arguments) {
final String scopeName = ((String) arguments).toUpperCase();
try {
return BuildScope.valueOf(scopeName);
} catch (IllegalArgumentException e) {
throw new GrailsConfigurationException("Plugin " + this + " specifies invalid scope [" + scopeName + "]");
}
}
});
pluginEnvs = evaluateIncludeExcludeProperty(ENVIRONMENTS, new Closure(this) {
private static final long serialVersionUID = 1;
@Override
public Object call(Object arguments) {
String envName = (String) arguments;
Environment env = Environment.getEnvironment(envName);
if (env != null)
return env.getName();
return arguments;
}
});
}
use of org.grails.core.exceptions.GrailsConfigurationException in project grails-core by grails.
the class ProfilingGrailsPluginManager method doDynamicMethods.
@Override
public void doDynamicMethods() {
long time = System.currentTimeMillis();
System.out.println("doWithDynamicMethods started");
checkInitialised();
// remove common meta classes just to be sure
MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
for (Class<?> COMMON_CLASS : COMMON_CLASSES) {
registry.removeMetaClass(COMMON_CLASS);
}
for (GrailsPlugin plugin : pluginList) {
if (plugin.supportsCurrentScopeAndEnvironment()) {
try {
long pluginTime = System.currentTimeMillis();
System.out.println("doWithDynamicMethods for plugin [" + plugin.getName() + "] started");
plugin.doWithDynamicMethods(applicationContext);
System.out.println("doWithDynamicMethods for plugin [" + plugin.getName() + "] took " + (System.currentTimeMillis() - pluginTime));
} catch (Throwable t) {
throw new GrailsConfigurationException("Error configuring dynamic methods for plugin " + plugin + ": " + t.getMessage(), t);
}
}
}
System.out.println("doWithDynamicMethods took " + (System.currentTimeMillis() - time));
}
use of org.grails.core.exceptions.GrailsConfigurationException in project grails-core by grails.
the class CorePluginFinder method loadCorePluginsFromResources.
@SuppressWarnings("rawtypes")
private void loadCorePluginsFromResources(Resource[] resources) throws IOException {
LOG.debug("Attempting to load [" + resources.length + "] core plugins");
try {
SAXParser saxParser = SpringIOUtils.newSAXParser();
for (Resource resource : resources) {
InputStream input = null;
try {
input = resource.getInputStream();
PluginHandler ph = new PluginHandler();
saxParser.parse(input, ph);
for (String pluginType : ph.pluginTypes) {
Class<?> pluginClass = attemptCorePluginClassLoad(pluginType);
if (pluginClass != null) {
addPlugin(pluginClass);
binaryDescriptors.put(pluginClass, new BinaryGrailsPluginDescriptor(resource, ph.pluginClasses));
}
}
} finally {
if (input != null) {
input.close();
}
}
}
} catch (ParserConfigurationException e) {
throw new GrailsConfigurationException("XML parsing error loading core plugins: " + e.getMessage(), e);
} catch (SAXException e) {
throw new GrailsConfigurationException("XML parsing error loading core plugins: " + e.getMessage(), e);
}
}
use of org.grails.core.exceptions.GrailsConfigurationException in project grails-core by grails.
the class DefaultGrailsPluginManager method doDynamicMethods.
@Override
public void doDynamicMethods() {
checkInitialised();
// remove common meta classes just to be sure
MetaClassRegistry registry = GroovySystem.getMetaClassRegistry();
for (Class<?> COMMON_CLASS : COMMON_CLASSES) {
registry.removeMetaClass(COMMON_CLASS);
}
for (GrailsPlugin plugin : pluginList) {
if (plugin.supportsCurrentScopeAndEnvironment()) {
try {
plugin.doWithDynamicMethods(applicationContext);
} catch (Throwable t) {
throw new GrailsConfigurationException("Error configuring dynamic methods for plugin " + plugin + ": " + t.getMessage(), t);
}
}
}
}
use of org.grails.core.exceptions.GrailsConfigurationException in project grails-core by grails.
the class DefaultGrailsApplication method addArtefact.
/**
* Adds an artefact of the given type for the given GrailsClass.
*
* @param artefactType The type of the artefact as defined by a ArtefactHandler instance
* @param artefactGrailsClass A GrailsClass instance that matches the type defined by the ArtefactHandler
* @return The GrailsClass if successful or null if it couldn't be added
* @throws GrailsConfigurationException If the specified GrailsClass is not the same as the type defined by the ArtefactHandler
* @see grails.core.ArtefactHandler
*/
public GrailsClass addArtefact(String artefactType, GrailsClass artefactGrailsClass) {
ArtefactHandler handler = artefactHandlersByName.get(artefactType);
if (handler.isArtefactGrailsClass(artefactGrailsClass)) {
// Store the GrailsClass in cache
DefaultArtefactInfo info = getArtefactInfo(artefactType, true);
info.addGrailsClass(artefactGrailsClass);
info.updateComplete();
initializeArtefacts(artefactType);
return artefactGrailsClass;
}
throw new GrailsConfigurationException("Cannot add " + artefactType + " class [" + artefactGrailsClass + "]. It is not a " + artefactType + "!");
}
Aggregations