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 .. 120 121 122 123 124 125 < 126 > 127 128 129 130 131 132 .. 166 >> Next

07 */
08
09 public interface SOAPHandler extends javax ejb.EJBLocalObject
10 {
12 /**
13 * This method converts the parameter into the response
16 */
17
18 String convert(String param);
20 }
Listing 39.6 SOAPHandler (local)
There is something important to understand about this configuration. Since the servlet and EJBs need to be run in the process space, they need to be able to have each other in the same context. To accomplish this, you should place any Web
348 Item 40
components that use the local interfaces in the same EAR (Enterprise ARchive) as the classes that implement them.
So, should you always use local interfaces? Not necessarily. There is really one major thing to consider: Are your Web container and EJB container running in the same process, or should they be? This all depends on your individual architecture, but here are some thoughts to consider:
¦¦ Do you need separate processes for the Web container and the EJB container? Most people believe that in order to load-balance the Web servers, they must be kept separate from the EJB servers. This is untrue; in fact, it is likely that clustering multiple "combined" application servers will provide just as good, if not better, results.
¦¦ Is the EJB container going to be a resource burden on the Web container, since they are running in the same process? If your architecture is light on EJBs and heavy on Web components, perhaps they should be refactored out of the equation. A Web tier solution may be best.
This example is done to illustrate a point about using local interfaces for Enterprise JavaBeans. The example itself is quite helpful, but it is sure to become moot with the release of J2EE 1.4. In this release, JAX-RPC will become another communication protocol for interacting with EJB containers, like RMI is right now. Also, JAXM will become another protocol for interacting with the Java Message Service. These enhancements will make the Web services protocols just another transparent mechanism for communicating with the Java 2 Enterprise Edition.
Item 40: Image Obsession
Java has been enormously successful on the server side, largely tracking with the rise of the Internet and distributed computing. This has given rise to many, many thin clients. One of the biggest issues in thin clients is trying to deliver more expressive user interfaces. This was the idea behind XWindows—a big, powerful machine generates user interface components for thin clients.
A classic example in Web interfaces is to dynamically generate images. We built a graphical reporting tool that generated images using the open-source JFreeChart package (http://www.object-refinery.com/jfreechart/) and the open-source Cewolf custom tag library (http://cewolf.sourceforge.net/).
Our application generates a pie chart showing the percentages of Web browser usage on this particular site. We developed this application on our Windows development boxes. Listing 40.1 is what it looks like both in code (simplified, see the Cewolf docs for more information) and on the screen.
01: Ô & rtf p dP V = t r 0 mpo 1 java.util.*" %>
02: <%@page = t r 0 mpo 1 ’de.laures.cewolf.*" %>
03: e g a p @ % < = t r 0 mpo 1 ’com.jrefinery.data.*" %>
04:
Listing 40.1 Example code
Image Obsession 349
05 <%@ taglib uri="http://cewolf.sourceforge.net/taglib/cewolf.tld" 2
prefix="cewolf" %>
06
07 <%
08 class DatasetProducerlmpl implements DatasetProducer {
09 private Object obj;
10
11 public DatasetProducerImpl(Object obj) {
12 this.obj = obj;
13 }
14
15 public Object produceDataset(HashMap params) throws 2
DatasetProduceException {
16 return obj;
17 }
18 }
19 %>
20
21 <html>
22 <head>
23 <title>Browser Graph</title>
24 </head>
25
26 <body>
27 <%
28 try {
29
30 DefaultPieDataset pieData = new DefaultPieDataset();
31 pieData.setValue("Internet Explorer", new Integer(23405));
32 pieData.setValue("Netscape", new Integer(12313));
33 pieData.setValue("Mozilla", new Integer(11202));
34 pieData.setValue("Opera", new Integer(1333));
35
36 DatasetProducer pieProducer = new DatasetProducerlmpl(pieData) ;
37 pageContext.setAttribute("browserPie", pieProducer, 2
PageContext.APPLICATION_SCOPE);
38
39 %>
40
41 <center>
42 <h1>Usage of Site by Browser</h1>
43 </center>
44 <p>&nbsp;
45 <table border="0" cellpadding="2" align="center">
46 <tr>
47 <td colspan="2">
48 <cewolf:chart
49 id="browserPieChart"
50 title="Browser Usage"
Listing 40.1 (continued)
350 Item 40
51 renderer="servlet/chart"
52 width="400" height="300"
53 type="pie"
54 antialias="true">
55 <cewolf:data>
56 <cewolf:producer id="browserPie" />
57 </cewolf:data>
58 </cewolf:chart>
59 </td>
60 </tr>
61 </table>
62 <P>
63 <%
64
65 } catch (Exception e) {
66 e.printStackTrace();
67 }
68
69 %>
70
71 </body>
72 </html>
Listing 40.1 (continued)
Figure 40.1 shows our beautiful graph, easy to build and deploy. At this point, we start thinking that it cannot be this easy, so then we deploy our Web application on our production Solaris machine.
Previous << 1 .. 120 121 122 123 124 125 < 126 > 127 128 129 130 131 132 .. 166 >> Next