Initializer for the Jasper JSP Engine.
| 38 | * Initializer for the Jasper JSP Engine. |
| 39 | */ |
| 40 | public class JasperInitializer implements ServletContainerInitializer { |
| 41 | |
| 42 | /** |
| 43 | * Constructs a new JasperInitializer. |
| 44 | */ |
| 45 | public JasperInitializer() { |
| 46 | } |
| 47 | |
| 48 | private static final String MSG = "org.apache.jasper.servlet.JasperInitializer"; |
| 49 | private final Log log = LogFactory.getLog(JasperInitializer.class); // must not be static |
| 50 | |
| 51 | /* |
| 52 | * Preload classes required at runtime by a JSP servlet so that we don't get a defineClassInPackage security |
| 53 | * exception. |
| 54 | */ |
| 55 | static { |
| 56 | JspFactoryImpl factory = new JspFactoryImpl(); |
| 57 | if (JspFactory.getDefaultFactory() == null) { |
| 58 | JspFactory.setDefaultFactory(factory); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public void onStartup(Set<Class<?>> types, ServletContext context) throws ServletException { |
| 64 | if (log.isDebugEnabled()) { |
| 65 | log.debug(Localizer.getMessage(MSG + ".onStartup", context.getServletContextName())); |
| 66 | } |
| 67 | |
| 68 | // Set up a simple default Instance Manager |
| 69 | if (context.getAttribute(InstanceManager.class.getName()) == null) { |
| 70 | context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager()); |
| 71 | } |
| 72 | |
| 73 | boolean validate = Boolean.parseBoolean(context.getInitParameter(Constants.XML_VALIDATION_TLD_INIT_PARAM)); |
| 74 | String blockExternalString = context.getInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM); |
| 75 | boolean blockExternal; |
| 76 | if (blockExternalString == null) { |
| 77 | blockExternal = true; |
| 78 | } else { |
| 79 | blockExternal = Boolean.parseBoolean(blockExternalString); |
| 80 | } |
| 81 | |
| 82 | // scan the application for TLDs |
| 83 | TldScanner scanner = newTldScanner(context, true, validate, blockExternal); |
| 84 | try { |
| 85 | scanner.scan(); |
| 86 | } catch (IOException | SAXException e) { |
| 87 | throw new ServletException(e); |
| 88 | } |
| 89 | |
| 90 | // add any listeners defined in TLDs |
| 91 | for (String listener : scanner.getListeners()) { |
| 92 | context.addListener(listener); |
| 93 | } |
| 94 | |
| 95 | context.setAttribute(TldCache.SERVLET_CONTEXT_ATTRIBUTE_NAME, |
| 96 | new TldCache(context, scanner.getUriTldResourcePathMap(), scanner.getTldResourcePathTaglibXmlMap())); |
| 97 |
nothing calls this directly
no test coverage detected