Methods Summary |
---|
private boolean | createRestoPipe()
try {
// Create my input pipe to listen for hungry peers
// requests
pipeIn = pipes.createInputPipe(myAdv);
} catch (Exception e) {
System.out.println(
"Could not initialize the Restaurant pipe" + e.getMessage());
return false;
}
return true;
|
private java.lang.String | friesPrice(java.lang.String size)
if (size.equals("small"))
return "$1.50";
if (size.equals("medium"))
return "2.50";
if (size.equals("large"))
return "3.00";
return "error";
|
public net.jxta.document.Advertisement | getImplAdvertisement()
return srvImpl;
|
public net.jxta.service.Service | getInterface() // Resolver pipe timeout
// Service objects are not manipulated directly to protect usage
//of the service. A Service interface is returned to access the service
return this;
|
public void | init(net.jxta.peergroup.PeerGroup group, net.jxta.id.ID assignedID, net.jxta.document.Advertisement impl)
// Save the RestoNet pointer, the pipe and the RestoPeer Service
restoNet = group;
srvImpl = (ModuleImplAdvertisement) impl;
System.out.println("Initialization RestoPeer Special Service: " +
srvImpl.getModuleSpecID());
// Extract the service pipe advertisement from the service
// module impl Advertisement. The client MUST use the same pipe
// advertisement to talk to the service. When the client
// discovers the peergroup advertisement, it will extract the
// pipe advertisement to create the connecting pipe by getting
// the module impl advertisement associated with the RestoPeer
// service.
System.out.println("Extract the pipe advertisement from the Service");
PipeAdvertisement pipeadv = null;
try {
// Extract the pipe adv from the Module impl param section
myAdv = (PipeAdvertisement)
AdvertisementFactory.newAdvertisement((TextElement)
srvImpl.getParam().getChildren().nextElement());
} catch (Exception e) {
System.out.println("failed to read/parse pipe advertisement");
e.printStackTrace();
System.exit(-1);
}
// Start the RestoPeer service loop thread to respond to Hungry peers
// fries requests. Start a new thread for processing all the
// requests
HandleFriesRequest peerRequest = new HandleFriesRequest();
peerRequest.start();
|
public int | startApp(java.lang.String[] args)
// nothing to do here
return 0;
|
public void | stopApp()
|