Methods Summary |
---|
public JavacErrorDetail[] | compile(java.lang.String className, Node.Nodes pageNodes)
// Start capturing the System.err output for this thread
SystemLogHandler.setThread();
javac.setEncoding(javaEncoding);
// Initialize sourcepath
Path srcPath = new Path(project);
srcPath.setLocation(options.getScratchDir());
javac.setSrcdir(srcPath);
info.append(" srcDir=" + srcPath + "\n" );
info.append(" work dir=" + options.getScratchDir() + "\n");
// Build includes path
PatternSet.NameEntry includes = javac.createInclude();
includes.setName(ctxt.getJavaPath());
info.append(" include="+ ctxt.getJavaPath() + "\n" );
BuildException be = null;
StringBuffer errorReport = new StringBuffer();
String errorCapture = null;
if (ctxt.getOptions().getFork()) {
try {
javac.execute();
} catch (BuildException e) {
be = e;
log.error( "Javac exception ", e);
log.error( "Env: " + info.toString());
}
errorReport.append(logger.getReport());
// Stop capturing the System.err output for this thread
errorCapture = SystemLogHandler.unsetThread();
} else {
errorReport.append(logger.getReport());
errorCapture = SystemLogHandler.unsetThread();
// Capture the current thread
if (errorCapture != null) {
errorReport.append(lineSeparator);
errorReport.append(errorCapture);
}
JavacObj javacObj = new JavacObj(javac);
synchronized(javacObj) {
threadPool.execute(javacObj);
// Wait for the thread to complete
try {
javacObj.wait();
} catch (InterruptedException e) {
;
}
}
be = javacObj.getException();
if (be != null) {
log.error( "Javac exception ", be);
log.error( "Env: " + info.toString());
}
errorReport.append(logger.getReport());
errorCapture = javacObj.getErrorCapture();
}
if (errorCapture != null) {
errorReport.append(lineSeparator);
errorReport.append(errorCapture);
}
JavacErrorDetail[] javacErrors = null;
if (be != null) {
try {
String errorReportString = errorReport.toString();
javacErrors = ErrorDispatcher.parseJavacMessage(
pageNodes, errorReportString, javaFileName);
} catch (IOException ex) {
throw new JasperException(ex);
}
}
return javacErrors;
|
public void | doJavaFile(boolean keep)
if (!keep) {
File javaFile = new File(javaFileName);
javaFile.delete();
}
|
public long | getClassLastModified()
File classFile = new File(ctxt.getClassFileName());
return classFile.lastModified();
|
public java.io.Writer | getJavaWriter(java.lang.String javaFileName, java.lang.String javaEncoding)
this.javaFileName = javaFileName;
info.append("Compile: javaFileName=" + javaFileName + "\n" );
this.javaEncoding = javaEncoding;
Writer writer = null;
try {
writer = new OutputStreamWriter(
new FileOutputStream(javaFileName), javaEncoding);
} catch (UnsupportedEncodingException ex) {
errDispatcher.jspError("jsp.error.needAlternateJavaEncoding",
javaEncoding);
} catch (IOException ex) {
errDispatcher.jspError("jsp.error.unableToCreateOutputWriter",
javaFileName, ex);
}
return writer;
|
private org.apache.tools.ant.Project | getProject()
if( project!=null ) return project;
// Initializing project
project = new Project();
logger = new JasperAntLogger();
logger.setOutputPrintStream(System.out);
logger.setErrorPrintStream(System.err);
logger.setMessageOutputLevel(Project.MSG_INFO);
project.addBuildListener( logger);
if (System.getProperty("catalina.home") != null) {
project.setBasedir( System.getProperty("catalina.home"));
}
if( options.getCompiler() != null ) {
if( log.isDebugEnabled() )
log.debug("Compiler " + options.getCompiler() );
project.setProperty("build.compiler", options.getCompiler() );
}
project.init();
return project;
|
public void | init(org.apache.jasper.JspCompilationContext ctxt, ErrorDispatcher errDispatcher, boolean suppressLogging)
this.ctxt = ctxt;
this.errDispatcher = errDispatcher;
options = ctxt.getOptions();
log = suppressLogging?
new com.sun.org.apache.commons.logging.impl.NoOpLog():
com.sun.org.apache.commons.logging.LogFactory.getLog(
AntJavaCompiler.class);
getProject();
javac = (Javac) project.createTask("javac");
javac.setFork(options.getFork());
// Set the Java compiler to use
if (options.getCompiler() != null) {
javac.setCompiler(options.getCompiler());
}
startThreadPool();
|
public void | saveClassFile(java.lang.String className, java.lang.String classFileName)
// class files are alwyas saved.
|
public void | setClassPath(java.util.List cpath)
Path path = new Path(project);
for (File file: cpath) {
path.setLocation(file);
info.append(" cp=" + file + "\n");
}
javac.setClasspath(path);
|
public void | setDebug(boolean debug)
javac.setDebug(debug);
javac.setOptimize(!debug);
|
public void | setExtdirs(java.lang.String exts)
Path extdirs = new Path(project);
extdirs.setPath(exts);
javac.setExtdirs(extdirs);
info.append(" extdirs=" + exts+ "\n");
|
public void | setSourceVM(java.lang.String sourceVM)
javac.setSource(sourceVM);
info.append(" compilerSourceVM=" + sourceVM + "\n");
|
public void | setTargetVM(java.lang.String targetVM)
javac.setTarget(targetVM);
info.append(" compilerTargetVM=" + targetVM + "\n");
|
public static void | shutdownThreadPool()
if (threadPool != null) {
threadPool.shutdown();
}
|
public static void | startThreadPool()
if (threadPool == null) {
threadPool = Executors.newCachedThreadPool(threadFactory);
}
|