use of org.apache.sling.scripting.jsp.jasper.runtime.AnnotationProcessor in project sling by apache.
the class JspServletWrapper method destroy.
/**
* Destroy this wrapper
* @param deleteGeneratedFiles Should generated files be deleted as well?
*/
public void destroy(final boolean deleteGeneratedFiles) {
if (this.isTagFile) {
if (log.isDebugEnabled()) {
log.debug("Destroying tagfile " + jspUri);
}
this.tagFileClass = null;
if (deleteGeneratedFiles) {
if (log.isDebugEnabled()) {
log.debug("Deleting generated files for tagfile " + jspUri);
}
this.ctxt.getRuntimeContext().getIOProvider().delete(this.getDependencyFilePath());
}
} else {
if (log.isDebugEnabled()) {
log.debug("Destroying servlet " + jspUri);
}
if (theServlet != null) {
if (deleteGeneratedFiles) {
if (log.isDebugEnabled()) {
log.debug("Deleting generated files for servlet " + jspUri);
}
final String name;
if (isTagFile) {
name = this.ctxt.getTagInfo().getTagClassName();
} else {
name = this.ctxt.getServletPackageName() + "." + this.ctxt.getServletClassName();
}
final String path = ":/" + name.replace('.', '/') + ".class";
this.ctxt.getRuntimeContext().getIOProvider().delete(path);
this.ctxt.getRuntimeContext().getIOProvider().delete(this.getDependencyFilePath());
final org.apache.sling.scripting.jsp.jasper.compiler.Compiler c = this.ctxt.getCompiler();
if (c != null) {
c.removeGeneratedFiles();
}
}
theServlet.destroy();
AnnotationProcessor annotationProcessor = (AnnotationProcessor) config.getServletContext().getAttribute(AnnotationProcessor.class.getName());
if (annotationProcessor != null) {
try {
annotationProcessor.preDestroy(theServlet);
} catch (Exception e) {
// Log any exception, since it can't be passed along
log.error(Localizer.getMessage("jsp.error.file.not.found", e.getMessage()), e);
}
}
theServlet = null;
}
}
}
use of org.apache.sling.scripting.jsp.jasper.runtime.AnnotationProcessor in project sling by apache.
the class JspServletWrapper method loadServlet.
@SuppressWarnings("unchecked")
private Servlet loadServlet() throws ServletException, IOException {
Servlet servlet = null;
try {
if (log.isDebugEnabled()) {
log.debug("Loading servlet " + jspUri);
}
servlet = (Servlet) ctxt.load().newInstance();
AnnotationProcessor annotationProcessor = (AnnotationProcessor) config.getServletContext().getAttribute(AnnotationProcessor.class.getName());
if (annotationProcessor != null) {
annotationProcessor.processAnnotations(servlet);
annotationProcessor.postConstruct(servlet);
}
// update dependents
final List<String> oldDeps = this.dependents;
if (servlet != null && servlet instanceof JspSourceDependent) {
this.dependents = (List<String>) ((JspSourceDependent) servlet).getDependants();
if (this.dependents == null) {
this.dependents = Collections.EMPTY_LIST;
}
this.ctxt.getRuntimeContext().addJspDependencies(this, this.dependents);
}
if (!equals(oldDeps, this.dependents)) {
this.persistDependencies();
}
} catch (final IllegalAccessException e) {
throw new JasperException(e);
} catch (final InstantiationException e) {
throw new JasperException(e);
} catch (final Exception e) {
throw new JasperException(e);
}
servlet.init(config);
return servlet;
}
Aggregations