Author: musachy
Date: Mon Aug 10 16:13:32 2009
New Revision: 802841
URL: http://svn.apache.org/viewvc?rev=802841&view=rev
Log:
Fix tests
Modified:
struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java
Modified:
struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java
URL:
http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java?rev=802841&r1=802840&r2=802841&view=diff
==============================================================================
---
struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java
(original)
+++
struts/sandbox/trunk/struts2-jsp-plugin/src/main/java/org/apache/struts2/JSPLoader.java
Mon Aug 10 16:13:32 2009
@@ -22,11 +22,14 @@
import com.opensymphony.xwork2.util.finder.ClassLoaderInterfaceDelegate;
import com.opensymphony.xwork2.util.finder.UrlSet;
+import com.opensymphony.xwork2.util.finder.ClassLoaderInterface;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
import com.opensymphony.xwork2.util.URLUtil;
+import com.opensymphony.xwork2.ActionContext;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.xwork.StringUtils;
+import org.apache.commons.lang.xwork.ObjectUtils;
import org.apache.struts2.compiler.MemoryClassLoader;
import org.apache.struts2.compiler.MemoryJavaFileObject;
import org.apache.struts2.jasper.JasperException;
@@ -63,6 +66,10 @@
public Servlet load(String location) throws Exception {
location = StringUtils.substringBeforeLast(location, "?");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Compiling JSP [#0]", location);
+ }
+
//use Jasper to compile the JSP into java code
JspC jspC = compileJSP(location);
String source = jspC.getSourceCode();
@@ -99,9 +106,11 @@
/**
* Compiles the given source code into java bytecode
- *
*/
private void compileJava(String className, final String source,
Set<String> extraClassPath) throws IOException {
+ if (LOG.isTraceEnabled())
+ LOG.trace("Compiling [#0], source: [#1]", className, source);
+
JavaCompiler compiler =
ToolProvider.getSystemJavaCompiler();
@@ -197,9 +206,13 @@
return jspC;
}
- private ClassLoaderInterfaceDelegate getClassLoaderInterface() {
- //TODO: get this from context so OSGI works
- return new
ClassLoaderInterfaceDelegate(Thread.currentThread().getContextClassLoader());
+ private ClassLoaderInterface getClassLoaderInterface() {
+ ClassLoaderInterface classLoaderInterface = null;
+ ActionContext ctx = ActionContext.getContext();
+ if (ctx != null)
+ classLoaderInterface = (ClassLoaderInterface)
ctx.get(ClassLoaderInterface.CLASS_LOADER_INTERFACE);
+
+ return (ClassLoaderInterface)
ObjectUtils.defaultIfNull(classLoaderInterface, new
ClassLoaderInterfaceDelegate(JSPLoader.class.getClassLoader()));
}
private static URI toURI(String name) {