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 public class JettyJasperInitializer extends JasperInitializer
40 {
41 private static final Logger LOG = Log.getLogger(JettyJasperInitializer.class);
42
43
44
45
46
47
48
49 private final class NullTldScanner extends TldScanner
50 {
51
52
53
54
55
56
57 private NullTldScanner(ServletContext context, boolean namespaceAware, boolean validation, boolean blockExternal)
58 {
59 super(context, namespaceAware, validation, blockExternal);
60 }
61
62
63
64
65 @Override
66 public void scan() throws IOException, SAXException
67 {
68 return;
69 }
70
71
72
73
74 @Override
75 public List<String> getListeners()
76 {
77 return Collections.emptyList();
78 }
79
80
81
82
83 @Override
84 public void scanJars()
85 {
86 return;
87 }
88 }
89
90
91
92
93
94 @Override
95 public TldScanner newTldScanner(ServletContext context, boolean namespaceAware, boolean validate, boolean blockExternal)
96 {
97 String tmp = context.getInitParameter("org.eclipse.jetty.jsp.precompiled");
98 if (tmp!=null && !tmp.equals("") && Boolean.valueOf(tmp))
99 {
100 if (LOG.isDebugEnabled()) LOG.debug("Jsp precompilation detected");
101 return new NullTldScanner(context, namespaceAware, validate, blockExternal);
102 }
103
104 Collection<URL> tldUrls = (Collection<URL>)context.getAttribute("org.eclipse.jetty.tlds");
105 if (tldUrls != null)
106 {
107 if (LOG.isDebugEnabled()) LOG.debug("Tld pre-scan detected");
108 return new TldPreScanned(context,namespaceAware,validate,blockExternal,tldUrls);
109 }
110
111 if (LOG.isDebugEnabled()) LOG.debug("Defaulting to jasper tld scanning");
112 return super.newTldScanner(context, namespaceAware, validate, blockExternal);
113 }
114
115
116 }