01.02.2013 Views

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

disaster recovery<br />

What went wrong?<br />

How did this happen?<br />

What would you do?<br />

186 Chapter 6<br />

Something’s clearly gone wrong. Below is some code we compiled on our machine<br />

and the same section <strong>of</strong> code from the demo machine. See if you can figure out what<br />

happened.<br />

public class RemoteReader implements Runnable {<br />

boolean[] checkboxState = null;<br />

String nameToShow = null;<br />

Object obj = null;<br />

public void run() {<br />

try {<br />

while((obj=in.readObject()) != null) {<br />

System.out.println("got an object from server");<br />

System.out.println(obj.getClass());<br />

String nameToShow = (String) obj;<br />

checkboxState = (boolean[]) in.readObject();<br />

if (nameToShow.equals(POKE_START_SEQUENCE)) {<br />

playPoke();<br />

nameToShow = "Hey! Pay attention.";<br />

}<br />

otherSeqsMap.put(nameToShow, checkboxState);<br />

listVector.add(nameToShow);<br />

incomingList.setListData(listVector);<br />

} // close while<br />

} catch (Exception ex) { ex.printStackTrace(); }<br />

} // close run<br />

Here’s the code from<br />

our machine—it worked<br />

fine when we ran it.<br />

And here’s the<br />

code on the demo<br />

server—the code<br />

that tanked.<br />

public class RemoteReader implements Runnable {<br />

boolean[] checkboxState = null;<br />

String nameToShow = null;<br />

Object obj = null;<br />

public void run() {<br />

try {<br />

while ((obj = in.readObject()) != null) {<br />

System.out.println("got an object from server");<br />

System.out.println(obj.getClass());<br />

String nameToShow = (String) obj;<br />

checkboxState = (boolean[]) in.readObject();<br />

if (nameToShow.equals(PICTURE_START_SEQUENCE)) {<br />

receiveJPEG();<br />

}<br />

else {<br />

otherSeqsMap.put(nameToShow, checkboxState);<br />

listVector.add(nameToShow);<br />

incomingList.setListData(listVector);<br />

}<br />

} // close while<br />

} catch (Exception ex) {<br />

ex.printStackTrace();<br />

}<br />

} // close run<br />

Download at WoweBook.Com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!