ASF Bugzilla – Attachment 37867 Details for
Bug 65124
Inefficient generated JSP code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Sample plug-in for <c:set .../>
CoreSetPlugin.java (text/plain), 2.59 KB, created by
Mark Thomas
on 2021-05-18 16:23:12 UTC
(
hide
)
Description:
Sample plug-in for <c:set .../>
Filename:
MIME Type:
Creator:
Mark Thomas
Created:
2021-05-18 16:23:12 UTC
Size:
2.59 KB
patch
obsolete
>/* >* Licensed to the Apache Software Foundation (ASF) under one or more >* contributor license agreements. See the NOTICE file distributed with >* this work for additional information regarding copyright ownership. >* The ASF licenses this file to You under the Apache License, Version 2.0 >* (the "License"); you may not use this file except in compliance with >* the License. You may obtain a copy of the License at >* >* http://www.apache.org/licenses/LICENSE-2.0 >* >* Unless required by applicable law or agreed to in writing, software >* distributed under the License is distributed on an "AS IS" BASIS, >* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >* See the License for the specific language governing permissions and >* limitations under the License. >*/ >package jsp2.examples.plugins; > >import org.apache.jasper.compiler.tagplugin.TagPlugin; >import org.apache.jasper.compiler.tagplugin.TagPluginContext; > >/** > * Tag plug-in implementation intended to demonstrate a simple optimisation case > * based on the requirements described in > * <a href="https://bz.apache.org/bugzilla/show_bug.cgi?id=65124">bug 65124</a>. > */ >public class CoreSetPlugin implements TagPlugin { > > @Override > public void doTag(TagPluginContext ctxt) { > if (!ctxt.isAttributeSpecified("value")) { > // Value is defined in tag body. > // Don't optimise > ctxt.dontUseTagPlugin(); > return; > } > > if (ctxt.isAttributeSpecified("target") || ctxt.isAttributeSpecified("property")) { > // Attempting to set a property on an object > // Don't optimise > ctxt.dontUseTagPlugin(); > return; > } > > if (!ctxt.isAttributeSpecified("var")) { > // No target variable defined > // Don't optimise > ctxt.dontUseTagPlugin(); > return; > } > > if (ctxt.isAttributeSpecified("scope")) { > // TODO - we can easily parse this rather than only support the default. > ctxt.dontUseTagPlugin(); > return; > } > > ctxt.generateJavaSource("pageContext.setAttribute("); > if (ctxt.isConstantAttribute("var")) { > ctxt.generateJavaSource("\"" + ctxt.getConstantAttribute("var") + "\""); > } else { > ctxt.generateAttribute("var"); > } > ctxt.generateJavaSource(", "); > if (ctxt.isConstantAttribute("value")) { > ctxt.generateJavaSource("\"" + ctxt.getConstantAttribute("value") + "\""); > } else { > ctxt.generateAttribute("value"); > } > ctxt.generateJavaSource(", 1);"); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 65124
:
37726
| 37867