📄 apa.htm
字号:
must be made thread-safe.<BR> <B><BR> 2</B>. Instead of using <TT>oneway</TT> methods to notify clients of updates, can you think of another way to efficiently send update messages to clients? (Hint: Multithreading could come in handy here.)<BR> Launching a new thread to send each client update messages significantly enhances the efficiency of non-<TT>oneway</TT> message delivery. This is because, rather than require a single thread to wait for each client response before delivering the next message, each thread can block while waiting for a response from its respective client.</DL><H3><A NAME="Heading25"></A><FONT COLOR="#000077">Exercises</FONT></H3><DL> <DD><B>1</B>. It was noted earlier in the chapter that no facility currently exists to cancel the automatic account update service. Provide an IDL method signature for such an operation. Don't forget to include appropriate exceptions, if any.<BR> The method signature, which would be added to the <TT>Bank</TT> interface, should resemble the following:<BR> <FONT COLOR="#0066FF"><TT><BR> void cancelUpdateService(in Account account)</TT><BR> <TT>raises (InvalidAccountException);</TT></FONT></DL><PRE></PRE><DL> <DD>The <TT>InvalidAccountException</TT> would be raised if the <TT>Account</TT> does not belong to the <TT>Bank</TT> on which the operation was called. Optionally, you would either raise this exception or ignore the operation if it were called on an <TT>Account</TT> that was already subscribed to this service.<BR> <B><BR> 2</B>. Implement the account update cancellation method from exercise 1.<BR> The complete implementation is not given here, but the following pseudocode provides the general algorithm:<BR> <FONT COLOR="#0066FF"><TT>void cancelUpdateService(Account account) {</TT><BR> <TT>if (account does not belong to this Bank) {</TT><BR> <TT>throw InvalidAccountException;</TT><BR> <TT>}</TT><BR> <TT>if (account is already subscribed to the auto update service) {</TT><BR> <TT>throw InvalidAccountException;</TT><BR> <TT>}</TT><BR> <TT>(otherwise)</TT><BR> <TT>remove the account from list of Accounts subscribed to the auto</TT><BR> <TT>update service</TT><BR> <TT>}</TT></FONT></DL><PRE></PRE><H2><A NAME="Heading26"></A><FONT COLOR="#000077">Day 10: Learning About CORBA DesignIssues</FONT></H2><H3><A NAME="Heading27"></A><FONT COLOR="#000077">Quiz</FONT></H3><DL> <DD><B>1</B>. What is the major issue associated with mixing client and server functionality in a single-threaded CORBA application?<BR> Depending on what the application is doing, mixing client and server functionality in a single-threaded application introduces the potential for deadlock to occur.<BR> <B><BR> 2</B>. How can the use of reference counting in a CORBA application lead to problems?<BR> When an application component crashes, none of the reference counts for the objects it referenced will be decremented. Consequently, those objects might not be destroyed when they should be.<BR> <B><BR> 3</B>. Which version of X11 (the X Window System) would be required to safely run multithreaded X-based applications?<BR> X11R6.1 or later is necessary to safely run multithreaded applications. Earlier versions don't have thread-safe libraries.<BR> <B><BR> 4</B>. Why is the capability to pass objects by value sometimes useful?<BR> If an application component intends to perform a number of operations on an object, it is often more efficient to use a local copy of that object rather than make numerous method invocations on a remote object.<BR> <B><BR> 5</B>. Why is it usually inadvisable to use the Exclusive <TT>oneway</TT> Call design pattern introduced earlier in this chapter?<BR> Because <TT>oneway</TT> methods are unreliable, the Exclusive <TT>oneway</TT> Call design pattern is difficult to implement for situations in which reliable message delivery is required.</DL><H2><A NAME="Heading28"></A><FONT COLOR="#000077">Day 11: Using the Dynamic InvocationInterface (DII)</FONT></H2><H3><A NAME="Heading29"></A><FONT COLOR="#000077">Quiz</FONT></H3><DL> <DD><B>1. Would you expect DII to be useful to most CORBA application developers? Why or why not?</B><BR> As emphasized numerous times in this chapter, DII will probably not be useful to most CORBA application developers. This is primarily because, for most applications, the interfaces are almost always known at compile time anyway. Also, DII adds a great deal of complexity that developers are well advised to avoid altogether.<BR> <B><BR> 2. What are the advantages of DII over static method invocation?<BR> </B>DII has two advantages over static method invocation: the flexibility for a client to invoke operations on interfaces that were unknown at the time the client was compiled, and the ability to use one of several options for obtaining the return result from a remote method invocation.<BR> <B><BR> 3. What are the disadvantages of DII compared to static method invocation?<BR> </B>The disadvantages to using DII are its complexity, its lack of static-type-checking ability, the additional overhead incurred by its call mechanism, and the overhead associated with interface discovery.</DL><H2><A NAME="Heading30"></A><FONT COLOR="#000077">Day 12: Exploring CORBAservicesand CORBAfacilities</FONT></H2><H3><A NAME="Heading31"></A><FONT COLOR="#000077">Quiz</FONT></H3><DL> <DD><B>1</B>. Who defines the specifications for CORBAservices and CORBAfacilities?<BR> The specifications for CORBAservices and CORBAfacilities are defined by the Object Management Group (OMG).<BR> <B><BR> 2</B>. Who provides the implementations for CORBAservices and CORBAfacilities?<BR> The implementations for CORBAservices and CORBAfacilities are provided by the vendors themselves. The OMG does not provide their implementations, only their specifications.<BR> <B><BR> 3</B>. What CORBAservices and/or CORBAfacilities, if any, must a vendor provide with an ORB product in order to be considered CORBA 2 compliant?<BR> No CORBAservices or CORBAfacilities implementations are required from a vendor for CORBA 2 compliance. Compliance is determined by a product's ORB capabilities alone.<BR> <B><BR> 4</B>. Why are vertical market facilities useful?<BR> Vertical market facilities are useful because they can enhance interoperability between applications within a particular industry. In addition, they can facilitate the sharing of data between companies within an industry.</DL><H3><A NAME="Heading32"></A><FONT COLOR="#000077">Exercises</FONT></H3><DL> <DD><B>1</B>. Provide an overview of how the Object Trader Service could be used to replace the <TT>BankServer</TT> in the sample <TT>Bank</TT> application.<BR> In the sample <TT>Bank</TT> application, the <TT>BankServer</TT> component exists solely to allow other application components to locate <TT>Bank</TT>s and <TT>ATM</TT>s. As it turns out, locating objects by type is precisely the capability provided by the Trader Service. Rather than locate and register with a <TT>BankServer</TT> component, <TT>Bank</TT>s and <TT>ATM</TT>s could instead register with the Trader Service. These components would subsequently be available to other application components--namely, <TT>Customer</TT>s--that could locate the components through the same Trader Service. Thus, the functionality of the <TT>BankServer</TT> component is effectively replaced.<BR> <B><BR> 2</B>. Describe how the Event Service could be used within the <TT>Bank</TT> application. (Hint: Consider the automatic account update feature added on Day 9.) What would be the benefit of using this approach?<BR> Currently, the automatic account update feature requires the <TT>Bank</TT> to iterate through its <TT>Account</TT>s that are subscribed to the update service. The <TT>Bank</TT> invokes a callback method on each of the <TT>Customer</TT>s who are associated with those <TT>Account</TT>s. Using the Event Service, the <TT>Bank</TT> could become a publisher of <TT>Account</TT> balance update events to which <TT>Customer</TT>s could subscribe. The benefit of this approach is that it eliminates the complexity of delivering update messages to <TT>Customer</TT>s in the <TT>Bank</TT> application; the details of message delivery are shifted to the Event Service.<BR> <B><BR> 3</B>. (Extra Credit) If you have any products available to you that implement one or more CORBAservices, try to integrate the functionality provided by a service of your choice with the sample <TT>Bank</TT> application. (See the section of this chapter labeled "Choosing CORBAservices" to determine which services might integrate well with the sample application.) Because of the numerous possibilities available to you, no answer is provided for this exercise.</DL><H2><A NAME="Heading33"></A><FONT COLOR="#000077">Day 13: Developing for the InternetUsing CORBA and Java</FONT></H2><H3><A NAME="Heading34"></A><FONT COLOR="#000077">Quiz</FONT></H3><DL> <DD><B>1. What IDL construct resembles Java's <TT>package</TT>?<BR> </B>The Java <TT>package</TT> is very similar to the IDL <TT>module</TT>.<BR> <B><BR> 2. What is an advantage of Java Remote Method Invocation (RMI) over CORBA? Of CORBA over RMI?</B><BR> One advantage of RMI over CORBA is that RMI allows objects to be passed by value. Some advantages of CORBA over RMI are language independence and robustness.<BR> <B><BR> 3. Why might a developer want to use Java to develop a CORBA application?<BR> </B>Java's portability makes it especially attractive for developing CORBA client applications that might be required to run on a variety of platforms.</DL><H2><A NAME="Heading35"></A><FONT COLOR="#000077">Day 14: Web-Enabling the Bank Examplewith Java</FONT></H2><H3><A NAME="Heading36"></A><FONT COLOR="#000077">Quiz</FONT></H3><DL> <DD><B>1</B>. Why might it be advantageous to deploy a CORBA client as a Java applet?<BR> Two potential advantages for using Java applets for CORBA clients are the Java language's portability and the applet's simplified deployment mechanism through Web browsers.<BR> <B><BR> 2</B>. Why is it useful for browsers to include built-in CORBA-related classes (for example, Netscape's Communicator includes Visigenic's VisiBroker for Java runtime)?<BR> Because the classes required for CORBA connectivity are included with the browser, they do not have to be downloaded with the applet each time the applet is downloaded, thus reducing the download time required.<BR> <B><BR> 3</B>. What is a potential disadvantage to the bundling scheme described in question 2?<BR> A possible disadvantage to this scheme is that the CORBA classes provided with the browser might become outdated, thus requiring new versions of the classes to be downloaded with the applet anyway.</DL><H3><A NAME="Heading37"></A><FONT COLOR="#000077">Exercise</FONT></H3><P>Extend the <TT>BankApplet</TT> to do even more cool stuff. For example, you mightadd tabbed panels to display the <TT>Account</TT>s belonging to a particular <TT>Customer</TT>.Or, you might extend the applet to allow multiple <TT>Customer</TT>s to be associatedwith an <TT>Account</TT> and extend the <TT>Account</TT> information correspondinglyto show all the <TT>Customer</TT>s associated with a given <TT>Account</TT>. (Becausethis is an open-ended exercise, no answer is given.)</P><CENTER><P><HR><A HREF="../ch14/ch14.htm"><IMG SRC="../button/previous.gif" WIDTH="128" HEIGHT="28"ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="../apb/apb.htm"><IMGSRC="../button/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"BORDER="0"></A><A HREF="../index.htm"><IMG SRC="../button/contents.gif" WIDTH="128"HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> <BR><BR><BR><IMG SRC="../button/corp.gif" WIDTH="284" HEIGHT="45" ALIGN="BOTTOM" ALT="Macmillan Computer Publishing USA"BORDER="0"></P><P>© <A HREF="../copy.htm">Copyright</A>, Macmillan Computer Publishing. Allrights reserved.</CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -