Modify problem 8 from Chapter 7 so that whenever a client contacts the server, a time stamp is sent from the server to every client that has contacted it so far.

```
import java.rmi.*;

/**
* This is a remote interface for a Daytime server with
* callback.
* @author M. L. Liu
*/

public interface DaytimeServerInterface extends Remote {

public String getDaytime(DaytimeClientInterface daytimeClientObject )
throws java.rmi.RemoteException;
}
```

```
public interface DaytimeClientInterface
extends java.rmi.Remote{
// This remote method is invoked by a callback
// server to make a callback to an client which
// implements this interface.
// @param message - a string containing information for the
// client to process upon being called back.

public void notifyMe(String message)
throws java.rmi.RemoteException;

} // end interface
```


```

import java.rmi.*;

import java.rmi.server.*;

import java.util.Vector;

import java.util.Date;



/**

* This class implements the remote interface

* CallbackServerInterface.

* @author M. L. Liu

*/



public class DaytimeServerImpl extends UnicastRemoteObject

implements DaytimeServerInterface {



private Vector clientList;



public DaytimeServerImpl( ) throws RemoteException {

super( );

clientList = new Vector();

}



public String getDaytime(DaytimeClientInterface callbackClientObject )

throws java.rmi.RemoteException {

String timeStamp = (new Date( )).toString( );

doCallbacks(timeStamp);

registerForCallback(callbackClientObject );

return(timeStamp);

}



private synchronized void registerForCallback(

DaytimeClientInterface callbackClientObject)

throws java.rmi.RemoteException{

// store the callback object into the vector

if (!(clientList.contains(callbackClientObject)))

Computer Science & Information Technology

You might also like to view...

Which statement is a valid local variable declaration in Alice?

A. distanceToHorse = Double (1.0); B. Double distanceToHorse (1.0);  C. Double distanceToHorse = 1.0;  D. distanceToHorse (Double, 1.0); 

Computer Science & Information Technology

List at least eight different tasks a service desk staff member might have to perform during a typical day.

What will be an ideal response?

Computer Science & Information Technology

One way to get fired quickly is to brag over social media about a new marketing strategy before it has been publicly announced.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Critical Thinking Questions Case 8-1 ? You have been chosen to be a teaching assistant at your school. A student comes to you with questions about storage devices.  The student asks you which type of storage device is best to store the operating system and applications. You tell her that a(n) ______ is a good option.

A. SSD B. USB flash drive C. Memory card D. Optical disc

Computer Science & Information Technology