kinman 2003/11/05 10:31:34 Modified: jasper2/src/share/org/apache/jasper/compiler Generator.java Log: - A smal performance improvement: instantiate the bean object with its constructor, if "class" attribute is specified in usebean, instead of going thru java.beans.Beans.instantiate(). Revision Changes Path 1.215 +35 -31 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java Index: Generator.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/Generator.java,v retrieving revision 1.214 retrieving revision 1.215 diff -u -r1.214 -r1.215 --- Generator.java 20 Oct 2003 21:07:46 -0000 1.214 +++ Generator.java 5 Nov 2003 18:31:34 -0000 1.215 @@ -1259,37 +1259,41 @@ className = attributeValue(beanName, false, String.class); } + out.printil("try {"); + out.pushIndent(); + out.printin(name); + out.print(" = ("); + out.print(type); + out.print(") java.beans.Beans.instantiate("); + out.print("this.getClass().getClassLoader(), "); + out.print(className); + out.println(");"); + out.popIndent(); + /* + * Note: Beans.instantiate throws ClassNotFoundException + * if the bean class is abstract. + */ + out.printil("} catch (ClassNotFoundException exc) {"); + out.pushIndent(); + out.printil( + "throw new InstantiationException(exc.getMessage());"); + out.popIndent(); + out.printil("} catch (Exception exc) {"); + out.pushIndent(); + out.printin("throw new ServletException("); + out.print("\"Cannot create bean of class \" + "); + out.print(className); + out.println(", exc);"); + out.popIndent(); + out.printil("}"); // close of try } else { // Implies klass is not null - className = quote(klass); + // Generate codes to instantiate the bean class + out.printin(name); + out.print(" = new "); + out.print(klass); + out.println("();"); } - out.printil("try {"); - out.pushIndent(); - out.printin(name); - out.print(" = ("); - out.print(type); - out.print(") java.beans.Beans.instantiate("); - out.print("this.getClass().getClassLoader(), "); - out.print(className); - out.println(");"); - out.popIndent(); - /* - * Note: Beans.instantiate throws ClassNotFoundException - * if the bean class is abstract. - */ - out.printil("} catch (ClassNotFoundException exc) {"); - out.pushIndent(); - out.printil( - "throw new InstantiationException(exc.getMessage());"); - out.popIndent(); - out.printil("} catch (Exception exc) {"); - out.pushIndent(); - out.printin("throw new ServletException("); - out.print("\"Cannot create bean of class \" + "); - out.print(className); - out.println(", exc);"); - out.popIndent(); - out.printil("}"); // close of try /* * Set attribute for bean in the specified scope */
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]