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/05/04 09:00:32 UTC
svn commit: r940753 - in /myfaces/extensions/scripting/trunk:
extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/scripting/loaders/java/jsr199/
extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extens...
Author: werpu
Date: Tue May 4 07:00:31 2010
New Revision: 940753
URL: http://svn.apache.org/viewvc?rev=940753&view=rev
Log:
https://issues.apache.org/jira/browse/EXTSCRIPT-128
Added:
myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SuppressExtValWarningStartupListener.java
Modified:
myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/scripting/loaders/java/jsr199/JSR199Compiler.java
myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/api/CompilerConst.java
myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/instantbean/HelloBean.java
myfaces/extensions/scripting/trunk/extscript-examples/pom.xml
Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/scripting/loaders/java/jsr199/JSR199Compiler.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/scripting/loaders/java/jsr199/JSR199Compiler.java?rev=940753&r1=940752&r2=940753&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/scripting/loaders/java/jsr199/JSR199Compiler.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/scripting/loaders/java/jsr199/JSR199Compiler.java Tue May 4 07:00:31 2010
@@ -121,8 +121,8 @@ public class JSR199Compiler implements o
getLog().info("[EXT-SCRIPTING] Doing a full recompile");
List<File> sourceFiles = FileUtils.fetchSourceFiles(WeavingContext.getConfiguration().getWhitelistedSourceDirs(ScriptingConst.ENGINE_TYPE_JSF_JAVA), CompilerConst.JAVA_WILDCARD);
- for(File sourceFile: sourceFiles) {
- if(!sourceFile.exists()) {
+ for (File sourceFile : sourceFiles) {
+ if (!sourceFile.exists()) {
getLog().log(Level.WARNING, "[EXT-SCRIPTING] Source file with path {0} does not exist it might cause an error in the compilation process", sourceFile.getAbsolutePath());
}
}
@@ -151,21 +151,42 @@ public class JSR199Compiler implements o
Logger log = Logger.getLogger(this.getClass().getName());
StringBuilder errors = new StringBuilder();
CompilationResult result = new CompilationResult("");
+ boolean hasError = false;
for (Diagnostic diagnostic : diagnosticCollector.getDiagnostics()) {
String error = createErrorMessage(diagnostic);
log.log(Level.WARNING, "[EXT-SCRIPTING] Compiler: {0}", error);
- result.getErrors().add(new CompilationResult.CompilationMessage(diagnostic.getLineNumber(), diagnostic.getMessage(Locale.getDefault())));
+
+ if (diagnostic.getKind().equals(Diagnostic.Kind.ERROR)) {
+ hasError = true;
+ result.getErrors().add(new CompilationResult.CompilationMessage(diagnostic.getLineNumber(), diagnostic.getMessage(Locale.getDefault())));
+ } else {
+ result.getWarnings().add(new CompilationResult.CompilationMessage(diagnostic.getLineNumber(), diagnostic.getMessage(Locale.getDefault())));
+ }
errors.append(error);
}
WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA, result);
-
- throw new ClassNotFoundException("Compile error of java file:" + errors.toString());
+ assertErrorFound(errors, hasError);
} else {
WeavingContext.setCompilationResult(ScriptingConst.ENGINE_TYPE_JSF_JAVA, new CompilationResult(""));
}
}
/**
+ * interruption of the compile flow should only
+ * happen if an error has ocurred otherwise we will proceed
+ * as expected
+ *
+ * @param errors the errors messages found
+ * @param hasError marker if an error was found or not
+ * @throws ClassNotFoundException in case of a compile error
+ */
+ private void assertErrorFound(StringBuilder errors, boolean hasError) throws ClassNotFoundException {
+ if (hasError) {
+ throw new ClassNotFoundException("Compile error of java file:" + errors.toString());
+ }
+ }
+
+ /**
* creates a standardized error message
*
* @param diagnostic the diagnostic of the compiler containing the error data
@@ -177,7 +198,17 @@ public class JSR199Compiler implements o
if (diagnostic == null) {
return retVal.toString();
}
- retVal.append(CompilerConst.STD_ERROR_HEAD);
+ if (diagnostic.getKind().equals(Diagnostic.Kind.ERROR)) {
+ retVal.append(CompilerConst.STD_ERROR_HEAD);
+ } else if (diagnostic.getKind().equals(Diagnostic.Kind.NOTE)) {
+ retVal.append(CompilerConst.STD_NOTE_HEAD);
+ } else if (diagnostic.getKind().equals(Diagnostic.Kind.WARNING)) {
+ retVal.append(CompilerConst.STD_WARN_HEAD);
+ } else if (diagnostic.getKind().equals(Diagnostic.Kind.MANDATORY_WARNING)) {
+ retVal.append(CompilerConst.STD_MANDATORY_WARN_HEAD);
+ } else if (diagnostic.getKind().equals(Diagnostic.Kind.OTHER)) {
+ retVal.append(CompilerConst.STD_OTHER_HEAD);
+ }
String message = diagnostic.getMessage(Locale.getDefault());
message = (message == null) ? "" : message;
retVal.append(message);
Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/api/CompilerConst.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/api/CompilerConst.java?rev=940753&r1=940752&r2=940753&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/api/CompilerConst.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/api/CompilerConst.java Tue May 4 07:00:31 2010
@@ -27,7 +27,11 @@ package org.apache.myfaces.extensions.sc
*/
public class CompilerConst {
- public static final String STD_ERROR_HEAD = "Java Compiler, Error on line: ";
+ public static final String STD_ERROR_HEAD = "Java Compiler, error on line: ";
+ public static final String STD_WARN_HEAD = "Java Compiler, warning on line: ";
+ public static final String STD_MANDATORY_WARN_HEAD = "Java Compiler, mandatory warning on line: ";
+ public static final String STD_OTHER_HEAD = "Java Compiler, other diagnostic on line: ";
+ public static final String STD_NOTE_HEAD = "Java Compiler, Info on line: ";
public static final String JC_CLASSPATH = "-cp";
public static final String JC_TARGET_PATH = "-d";
public static final String JC_SOURCEPATH = "-sourcepath";
Added: myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SuppressExtValWarningStartupListener.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SuppressExtValWarningStartupListener.java?rev=940753&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SuppressExtValWarningStartupListener.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/java/org/apache/myfaces/blank/SuppressExtValWarningStartupListener.java Tue May 4 07:00:31 2010
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2010 werpu2.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * under the License.
+ */
+
+package org.apache.myfaces.blank;
+
+import javax.faces.application.Application;
+import javax.faces.event.PostConstructApplicationEvent;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+
+/**
+ * A startup listener which suppresses
+ * the ext-val warning (which actually is a bug in ext-val)
+ * for version 2.0.3, is already reported and will be fixed in the
+ * long run
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+public class SuppressExtValWarningStartupListener implements SystemEventListener {
+ public boolean isListenerForSource(Object source) {
+ return source instanceof Application; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ public void processEvent(SystemEvent event) {
+ if (!event.getClass().equals(PostConstructApplicationEvent.class)) {
+ return;
+ }
+
+ //TODO disable the EXT-VAL warning
+ }
+
+}
Modified: myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/instantbean/HelloBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/instantbean/HelloBean.java?rev=940753&r1=940752&r2=940753&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/instantbean/HelloBean.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java/org/apache/myfaces/javaloader/instantbean/HelloBean.java Tue May 4 07:00:31 2010
@@ -21,6 +21,8 @@ package org.apache.myfaces.javaloader.in
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
+import java.util.LinkedList;
+import java.util.List;
/**
* @author Werner Punz (latest modification by $Author$)
@@ -32,10 +34,16 @@ import javax.faces.bean.SessionScoped;
public class HelloBean {
int cnt = 0;
+ //we deliberately make a warning here to cover warnings in our compiler interface
+ List testList = new LinkedList();
-
private String hello = "Hello world from an instant bean";
+ public HelloBean() {
+ //unchecked operation deliberately done
+ testList.add(hello);
+ }
+
private String addedMethod() {
return "you can add change and remove methods on the fly without any server restart";
}
Modified: myfaces/extensions/scripting/trunk/extscript-examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-examples/pom.xml?rev=940753&r1=940752&r2=940753&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-examples/pom.xml (original)
+++ myfaces/extensions/scripting/trunk/extscript-examples/pom.xml Tue May 4 07:00:31 2010
@@ -30,7 +30,7 @@
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.1</version>
+ <version>6.1.12</version>
<configuration>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">