Books
in black and white
Main menu
Share a book About us Home
Books
Biology Business Chemistry Computers Culture Economics Fiction Games Guide History Management Mathematical Medicine Mental Fitnes Physics Psychology Scince Sport Technics
Ads

More Java Pitfalls Share Reactor - Daconta M,C.

Daconta M,C. More Java Pitfalls Share Reactor - Wiley publishing, 2003. - 476 p.
ISBN: 0-471-23751-5
Download (direct link): morejavapitfallssharereactor2003.pdf
Previous << 1 .. 71 72 73 74 75 76 < 77 > 78 79 80 81 82 83 .. 166 >> Next

33 pw write("<?xml version=\"1.0\"?>\n");
34 pw write("<TestPlan>\n");
35 pw write("<threadgroups>\n");
36 pw write("<ThreadGroup name=\"Thread Group " + topicIds[x] + "\"
37 numThreads=\"1\" rampUp=\"0\">");
38 pw write("<controllers>\n");
39 pw write("<LoopController
40 type=\"org.apache.jmeter.control.LoopController\"
41 name=\"Loop Controller\" iterations=\"1\">");
42 pw write("<configElements>\n");
43 pw write("</configElements>\n");
44 pw write("<controllers>\n");
45
46 for (int y=0; y < states.length; y++) {
Listing 23.3 generateTests.java (continued)
206 Item 23
47 pw.write("<HttpTestSample
48 type=\"org.apache.jmeter.protocol.http.control.HttpTestSample\"
49 name=\"Cache Test for" + states[y] +
50 "(id=" + topicIds[x] + ")" + "\" getImages=\"false\">\n");
51 pw.write("<defaultUrl>\n");
52 pw.write("<ConfigElement type=\"
53 org.apache.jmeter.protocol.http.config.MultipartUrlConfig\">
54 \n");
55 pw.write("<property name=\"port\">8080</property>\n");
56 pw.write("<property name=\"PROTOCOL\">http</property>\n");
57 pw.write("<property name=\"domain\">localhost</property>\n");
58 pw.write("<property name=\"arguments\">\n");
59 pw.write("<Arguments>\n");
60 pw.write("<argument name=\"state\"> " + states[y] +
61 "</argument>\n");
62 pw.write("<argument name=\"topicId\">" + topicIds[x] +
63 "</argument>\n");
64 pw.write("</Arguments>\n");
65 pw.write("</property>\n");
66 pw.write("<property name=\"path\">
67 /cachePage/home.jsp</property>\n");
68 pw.write("<property name=\"method\">GET</property>\n");
69 pw.write("</ConfigElement></defaultUrl>\n");
70 pw.write("<configElements>\n");
71 pw.write("</configElements>\n");
72 pw.write("<controllers>\n");
73 pw.write("</controllers>\n");
74 pw.write("</HttpTestSample>\n");
75 }
76
77 pw.write("</controllers>\n");
78 pw.write("</LoopController>\n");
79 pw.write("</controllers>\n");
80 pw.write("<timers>\n");
81 pw.write("<Timer type=\"org.apache.jmeter.timers.ConstantTimer\"
82 name=\"Constant Timer\">\n");
83 pw.write("<delay>1000</delay>\n");
84 pw.write("<range>0.0</range>\n");
85 pw.write("</Timer>\n");
86 pw.write("</timers>\n");
87 pw.write("<listeners>\n");
88 pw.write("</listeners>\n");
89 pw.write("</ThreadGroup>\n");
90 pw.write("</threadgroups>\n");
91 pw.write("<configElements>\n");
92 pw.write("</configElements>\n");
Listing 23.3 (continued)
Cache, It's Money 207
93 pw.write("</TestPlan>\n");
94 pw.close();
95 System.out.println("Finished writing: " + topicIds[x]);
96 }
97 }
98 }
99 }
Listing 23.3 (continued)
Figure 23.3 demonstrates what occurs in our Web application when we use the JMe-ter test scripts to cache our database queries. These scripts ping the database with the query operations indicated by the number 1 in the figure and cache the pages to the cache repository so that future database queries hit the cached scripts as indicated by the number 2.
In the end, our scripts allowed us to cache our entire site and reduce query result times, which pleased our customer. Additionally, the knowledge we acquired from our JMeter implementation allowed us to engage our test personnel earlier in our next program, which facilitated our integration efforts between our front-end and database developers.
In all Web development efforts, it is paramount that developers pay some consideration to the implementation of a caching strategy so that pertinent data can be delivered in a timely fashion and database server overloads can be avoided. If your site serves up document artifacts that don't change regularly, it will serve you well. Consider that at the JavaOne 2002 Conference there was significant discussion of the JCACHE specification (JSR 107), whose purpose is to standardize caching of Java objects. Feature enhancements with existing tag libraries like OSCache, along with new implementations like JCACHE, will continue to produce faster Web page response times and make Web content queries a much more pleasant experience.
Figure 23.3 Cache architecture.
208 Item 24
Item 24: JSP Design Errors
The evolution of Web applications followed two different paths: scripts and compiled executables. Servlets provided a strong improvement on the compiled code examples but suffered their own limitations in terms of presentation. The arrival of JSP caused many people to use them as self-compiling scripts. They saw the flexibility of script programming combined with the power of compiled code. Unfortunately, this can cause significant problems in maintenance, reuse, and flexibility.
My development team was assigned a task of building a Web-based workflow system that persisted information to a conventional relational database. Having built systems like this with a few different technologies, including most recently a servlet implementation of a similar system, we were eager to try JSP to eliminate our endless println statements, as well as eliminate the fundamental maintenance nightmare of trying to maintain HTML code inside our servlets.
Previous << 1 .. 71 72 73 74 75 76 < 77 > 78 79 80 81 82 83 .. 166 >> Next