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 of the following is a software honeypot solution?

A) Snort B) Specter C) Cisco Firepower 4100 series D) Cisco Firepower 9000 series

Computer Science & Information Technology

Which of the following functions evaluates whether a value has been entered into a field?

A. IsEmpty B. IsVoid C. IsNull D. Null

Computer Science & Information Technology