Skip to content

Commit 2fdf6fa

Browse files
author
Jan Luehe
committed
Reviewed by: kchung svn path=/trunk/; revision=1230
1 parent 83edab8 commit 2fdf6fa

File tree

3 files changed

+18
-38
lines changed

3 files changed

+18
-38
lines changed

impl/src/main/java/org/apache/jasper/compiler/Generator.java

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,16 +2290,12 @@ private void generateCustomStart(
22902290
out.print(tagHandlerClassName);
22912291
out.println(".class);");
22922292
} else {
2293-
out.print("new ");
2293+
out.print("(_jspx_resourceInjector != null) ? ");
2294+
out.print("_jspx_resourceInjector.createTagHandlerInstance(");
2295+
out.print(tagHandlerClassName);
2296+
out.print(".class) : new ");
22942297
out.print(tagHandlerClassName);
22952298
out.println("();");
2296-
out.printil("if (_jspx_resourceInjector != null) {");
2297-
out.pushIndent();
2298-
out.printin("_jspx_resourceInjector.inject(");
2299-
out.print(tagHandlerVar);
2300-
out.printil(");");
2301-
out.popIndent();
2302-
out.printil("}");
23032299
}
23042300

23052301
generateSetters(n, tagHandlerVar, handlerInfo, false);
@@ -2519,18 +2515,13 @@ private void generateCustomDoTag(
25192515
out.print(" ");
25202516
out.print(tagHandlerVar);
25212517
out.print(" = ");
2522-
out.print("new ");
2518+
out.print("(_jspx_resourceInjector != null) ? ");
2519+
out.print("_jspx_resourceInjector.createTagHandlerInstance(");
2520+
out.print(tagHandlerClassName);
2521+
out.print(".class) : new ");
25232522
out.print(tagHandlerClassName);
25242523
out.println("();");
25252524

2526-
out.printil("if (_jspx_resourceInjector != null) {");
2527-
out.pushIndent();
2528-
out.printin("_jspx_resourceInjector.inject(");
2529-
out.print(tagHandlerVar);
2530-
out.printil(");");
2531-
out.popIndent();
2532-
out.printil("}");
2533-
25342525
generateSetters(n, tagHandlerVar, handlerInfo, true);
25352526

25362527
// Set the body

impl/src/main/java/org/apache/jasper/runtime/TagHandlerPool.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,11 @@ public Tag get(Class handlerClass) throws JspException {
160160
// wait for us to construct a tag for this thread.
161161
Tag tagHandler = null;
162162
try {
163-
tagHandler = (Tag) handlerClass.newInstance();
164163
if (resourceInjector != null) {
165-
resourceInjector.inject(tagHandler);
164+
tagHandler = (Tag) resourceInjector.createTagHandlerInstance(
165+
handlerClass);
166+
} else {
167+
tagHandler = (Tag) handlerClass.newInstance();
166168
}
167169
} catch (Exception e) {
168170
throw new JspException(e.getMessage(), e);

impl/src/main/java/org/glassfish/jsp/api/ResourceInjector.java

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
package org.glassfish.jsp.api;
3838

39-
import javax.servlet.ServletContext;
4039
import javax.servlet.jsp.tagext.JspTag;
4140

4241
/**
@@ -47,27 +46,15 @@
4746
public interface ResourceInjector {
4847

4948
/**
50-
* Associates this ResourceInjector with the component environment of the
51-
* given servlet context.
49+
* Instantiates and injects the given tag handler class.
5250
*
53-
* @param servletContext The servlet context
54-
*/
55-
public void setContext(ServletContext servletContext);
56-
57-
58-
/**
59-
* Injects the injectable resources from the component environment
60-
* associated with this ResourceInjector into the given tag handler
61-
* instance.
62-
*
63-
* <p>Any @PostConstruct methods on the class (and super-classes)
64-
* of the instance will be invoked after injection.
65-
*
66-
* @param handler The tag handler instance to be injected
51+
* @param clazz the tag handler class to be instantiated and injected
6752
*
68-
* @throws Exception if an error occurs during injection
53+
* @throws Exception if an error has occurred during instantiation or
54+
* injection
6955
*/
70-
public void inject(JspTag handler) throws Exception;
56+
public <T extends JspTag> T createTagHandlerInstance(Class<T> clazz)
57+
throws Exception;
7158

7259
/**
7360
* Invokes any @PreDestroy methods defined on the instance's class

0 commit comments

Comments
 (0)