You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/01/21 18:25:01 UTC
svn commit: r901783 -
/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java
Author: werpu
Date: Thu Jan 21 17:25:00 2010
New Revision: 901783
URL: http://svn.apache.org/viewvc?rev=901783&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-50
adding error message handling for the groovy compiler
Modified:
myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java
Modified: myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java?rev=901783&r1=901782&r2=901783&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java (original)
+++ myfaces/extensions/scripting/trunk/core/core/src/main/java/org/apache/myfaces/scripting/loaders/groovy/compiler/GroovyCompilerFacade.java Thu Jan 21 17:25:00 2010
@@ -23,8 +23,10 @@
import org.apache.myfaces.extensions.scripting.compiler.CompilationResult;
import org.apache.myfaces.extensions.scripting.compiler.GroovyCompiler;
import org.apache.myfaces.scripting.api.DynamicCompiler;
+import org.apache.myfaces.scripting.api.ScriptingConst;
import org.apache.myfaces.scripting.core.util.ClassUtils;
import org.apache.myfaces.scripting.core.util.FileUtils;
+import org.apache.myfaces.scripting.core.util.WeavingContext;
import org.apache.myfaces.scripting.loaders.groovy.compiler.GroovyContainerFileManager;
import org.apache.myfaces.scripting.loaders.java.RecompiledClassLoader;
import org.apache.myfaces.scripting.loaders.java.jdk5.ContainerFileManager;
@@ -59,36 +61,36 @@
String className = filePath.replaceAll(separator, ".");
className = ClassUtils.relativeFileToClassName(className);
- // try {
- //no need we do a full recompile at the beginning
- //CompilationResult result = compiler.compile(new File(sourceRoot), fileManager.getTempDir(), filePath, fileManager.getClassLoader());
-
- //displayMessages(result);
-
- //if (!result.hasErrors()) {
- fileManager.refreshClassloader();
- ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
- //we now quickly check for the groovy classloader being, set we cannot deal with instances here
-
- //TODO change the check as well for java
- if (!(oldClassLoader.equals(fileManager.getClassLoader()))) {
- try {
- RecompiledClassLoader classLoader = (RecompiledClassLoader) fileManager.getClassLoader();
- classLoader.setSourceRoot(sourceRoot);
- Thread.currentThread().setContextClassLoader(classLoader);
-
- //Not needed anymore due to change in the dynamic class detection system
- //ClassUtils.markAsDynamicJava(fileManager.getTempDir().getAbsolutePath(), className);
-
- return classLoader.loadClass(className);
- } finally {
- Thread.currentThread().setContextClassLoader(oldClassLoader);
- }
- }
- //} else {
- // log.error("Compiler errors");
- // displayMessages(result);
- //}
+ // try {
+ //no need we do a full recompile at the beginning
+ //CompilationResult result = compiler.compile(new File(sourceRoot), fileManager.getTempDir(), filePath, fileManager.getClassLoader());
+
+ //displayMessages(result);
+
+ //if (!result.hasErrors()) {
+ fileManager.refreshClassloader();
+ ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+ //we now quickly check for the groovy classloader being, set we cannot deal with instances here
+
+ //TODO change the check as well for java
+ if (!(oldClassLoader.equals(fileManager.getClassLoader()))) {
+ try {
+ RecompiledClassLoader classLoader = (RecompiledClassLoader) fileManager.getClassLoader();
+ classLoader.setSourceRoot(sourceRoot);
+ Thread.currentThread().setContextClassLoader(classLoader);
+
+ //Not needed anymore due to change in the dynamic class detection system
+ //ClassUtils.markAsDynamicJava(fileManager.getTempDir().getAbsolutePath(), className);
+
+ return classLoader.loadClass(className);
+ } finally {
+ Thread.currentThread().setContextClassLoader(oldClassLoader);
+ }
+ }
+ //} else {
+ // log.error("Compiler errors");
+ // displayMessages(result);
+ //}
//} catch (CompilationException e) {
// log.error(e);
@@ -115,11 +117,11 @@
private void displayMessages(CompilationResult result) {
for (CompilationResult.CompilationMessage error : result.getErrors()) {
- log.error(error.getLineNumber() + "-" + error.getMessage());
-
+ log.error("[EXT-SCRIPTING] Groovy compiler error:" + error.getLineNumber() + "-" + error.getMessage());
}
for (CompilationResult.CompilationMessage error : result.getWarnings()) {
- log.error(error.getMessage());
+ log.error("[EXT-SCRIPTING] Groovy compiler warning:" + error.getMessage());
}
+ WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_GROOVY, result);
}
}