1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.eclipse.jetty.apache.jsp;
20
21 import java.io.IOException;
22 import java.net.URL;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.List;
26
27 import javax.servlet.ServletContext;
28
29 import org.apache.jasper.servlet.JasperInitializer;
30 import org.apache.jasper.servlet.TldPreScanned;
31 import org.apache.jasper.servlet.TldScanner;
32 import org.eclipse.jetty.util.log.Log;
33 import org.eclipse.jetty.util.log.Logger;
34 import org.xml.sax.SAXException;
35
36
37
38
39
40 public class JettyJasperInitializer extends JasperInitializer
41 {
42 private static final Logger LOG = Log.getLogger(JettyJasperInitializer.class);
43
44
45
46
47
48
49
50 private final class NullTldScanner extends TldScanner
51 {
52
53
54
55
56
57
58 private NullTldScanner(ServletContext context, boolean namespaceAware, boolean validation, boolean blockExternal)
59 {
60 super(context, namespaceAware, validation, blockExternal);
61 }
62
63
64
65
66 @Override
67 public void scan() throws IOException, SAXException
68 {
69 return;
70 }
71
72
73
74
75 @Override
76 public List<String> getListeners()
77 {
78 return Collections.emptyList();
79 }
80
81
82
83
84 @Override
85 public void scanJars()
86 {
87 return;
88 }
89 }
90
91
92
93
94
95
96
97 @Override
98 public TldScanner newTldScanner(ServletContext context, boolean namespaceAware, boolean validate, boolean blockExternal)
99 {
100 String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled");
101 if (tmp!=null && !tmp.equals("") && Boolean.valueOf(tmp))
102 {
103 if (LOG.isDebugEnabled()) LOG.debug("Jsp precompilation detected");
104 return new NullTldScanner(context, namespaceAware, validate, blockExternal);
105 }
106
107 Collection<URL> tldUrls = (Collection<URL>)context.getAttribute("org.eclipse.jetty.tlds");
108 if (tldUrls != null)
109 {
110 if (LOG.isDebugEnabled()) LOG.debug("Tld pre-scan detected");
111 return new TldPreScanned(context,namespaceAware,validate,blockExternal,tldUrls);
112 }
113
114 if (LOG.isDebugEnabled()) LOG.debug("Defaulting to jasper tld scanning");
115 return super.newTldScanner(context, namespaceAware, validate, blockExternal);
116 }
117
118
119 }