Constructor.
(ServletWriter out, Compiler compiler)
| 3360 | * Constructor. |
| 3361 | */ |
| 3362 | Generator(ServletWriter out, Compiler compiler) throws JasperException { |
| 3363 | this.out = out; |
| 3364 | methodsBuffered = new ArrayList<>(); |
| 3365 | charArrayBuffer = null; |
| 3366 | err = compiler.getErrorDispatcher(); |
| 3367 | ctxt = compiler.getCompilationContext(); |
| 3368 | fragmentHelperClass = new FragmentHelperClass("Helper"); |
| 3369 | pageInfo = compiler.getPageInfo(); |
| 3370 | |
| 3371 | ELInterpreter elInterpreter = null; |
| 3372 | try { |
| 3373 | elInterpreter = ELInterpreterFactory.getELInterpreter(compiler.getCompilationContext().getServletContext()); |
| 3374 | } catch (Exception e) { |
| 3375 | err.jspError("jsp.error.el_interpreter_class.instantiation", e.getMessage()); |
| 3376 | } |
| 3377 | this.elInterpreter = elInterpreter; |
| 3378 | |
| 3379 | StringInterpreter stringInterpreter = null; |
| 3380 | try { |
| 3381 | stringInterpreter = |
| 3382 | StringInterpreterFactory.getStringInterpreter(compiler.getCompilationContext().getServletContext()); |
| 3383 | } catch (Exception e) { |
| 3384 | err.jspError("jsp.error.string_interpreter_class.instantiation", e.getMessage()); |
| 3385 | } |
| 3386 | this.stringInterpreter = stringInterpreter; |
| 3387 | |
| 3388 | /* |
| 3389 | * Temporary hack. If a JSP page uses the "extends" attribute of the page directive, the _jspInit() method of |
| 3390 | * the generated servlet class will not be called (it is only called for those generated servlets that extend |
| 3391 | * HttpJspBase, the default), causing the tag handler pools not to be initialized and resulting in a NPE. The |
| 3392 | * JSP spec needs to clarify whether containers can override init() and destroy(). For now, we just disable tag |
| 3393 | * pooling for pages that use "extends". |
| 3394 | */ |
| 3395 | if (pageInfo.getExtends(false) == null || ctxt.getOptions().getPoolTagsWithExtends()) { |
| 3396 | isPoolingEnabled = ctxt.getOptions().isPoolingEnabled(); |
| 3397 | } else { |
| 3398 | isPoolingEnabled = false; |
| 3399 | } |
| 3400 | beanInfo = pageInfo.getBeanRepository(); |
| 3401 | varInfoNames = pageInfo.getVarInfoNames(); |
| 3402 | breakAtLF = ctxt.getOptions().getMappedFile(); |
| 3403 | if (isPoolingEnabled) { |
| 3404 | tagHandlerPoolNames = new ArrayList<>(); |
| 3405 | } else { |
| 3406 | tagHandlerPoolNames = null; |
| 3407 | } |
| 3408 | timestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| 3409 | timestampFormat.setTimeZone(TimeZone.getTimeZone("UTC")); |
| 3410 | String nonstandardOptionsList = ctxt.getOptions().getUseNonstandardTagOptimizations(); |
| 3411 | if (nonstandardOptionsList == null) { |
| 3412 | nonstandardCustomTagNames = Collections.emptySet(); |
| 3413 | } else { |
| 3414 | nonstandardCustomTagNames = new HashSet<>(Arrays.asList(nonstandardOptionsList.split(","))); |
| 3415 | } |
| 3416 | } |
| 3417 | |
| 3418 | /** |
| 3419 | * The main entry for Generator. |
nothing calls this directly
no test coverage detected