File tree Expand file tree Collapse file tree 5 files changed +33
-0
lines changed Expand file tree Collapse file tree 5 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 4
4
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5
5
// Uses remote object PerfectTime
6
6
// {ValidateByHand}
7
+ package remote ;
8
+
7
9
import java .rmi .registry .*;
8
10
9
11
public class DisplayPerfectTime {
Original file line number Diff line number Diff line change 3
3
// We make no guarantees that this code is fit for any purpose.
4
4
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5
5
// The PerfectTime remote interface
6
+ package remote ;
7
+
6
8
import java .rmi .*;
7
9
8
10
public interface PerfectTime extends Remote {
Original file line number Diff line number Diff line change 3
3
// We make no guarantees that this code is fit for any purpose.
4
4
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5
5
// Implementing the PerfectTime remote object
6
+ package remote ;
7
+
6
8
import java .rmi .RemoteException ;
7
9
8
10
public class PerfectTimeImpl implements PerfectTime {
Original file line number Diff line number Diff line change 4
4
// Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5
5
// Server for the PerfectTime remote object
6
6
// {ValidateByHand}
7
+ package remote ;
8
+
7
9
import java .rmi .registry .Registry ;
8
10
import java .rmi .registry .LocateRegistry ;
9
11
import java .rmi .RemoteException ;
Original file line number Diff line number Diff line change
1
+ // remote/tests/RMITests.java
2
+ // (c)2016 MindView LLC: see Copyright.txt
3
+ // We make no guarantees that this code is fit for any purpose.
4
+ // Visit http://mindviewinc.com/Books/OnJava/ for more book information.
5
+ package remote ;
6
+
7
+ import java .rmi .registry .*;
8
+
9
+ import org .junit .jupiter .api .*;
10
+ import org .junit .jupiter .api .TestInfo ;
11
+
12
+ public class RMITests {
13
+ @ Test
14
+ void test_remote_time () throws Exception {
15
+ LocateRegistry .createRegistry (1099 );
16
+ PerfectTimeServer timeServer = new PerfectTimeServer ();
17
+ timeServer .main (null );
18
+ Registry reg =
19
+ LocateRegistry .getRegistry ("localhost" );
20
+ PerfectTime pt =
21
+ (PerfectTime ) reg .lookup ("PerfectTime" );
22
+ for (int i = 0 ; i < 10 ; i ++)
23
+ System .out .println ("Time: " + pt .getPerfectTime ());
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments