Concurrent Programming with Java
Lab Manual, Version 1.0, F. Astha Ekadiyanto,
2002.
Lab 2: Building Application
Setting neighboring Rbs is a little bit more complex than registering Rbs to Msc. In order to set the Rbs neighbors, first of all we should be able to access both of the neighboring Rbs from the Msc. This can be done by executing the findRbs(String) method in the Msc.
This demonstration will set "RBS-1" and "RBS-2" as neighbors. The rest of directly neighboring RBS is left for you to try them individually. First of all, search the RBS-1 instance/object in the Msc using the findRbs(String) method.
Since you have registered "RBS-1" the result should be an object reference. When you click on the "object reference" in the list, the Inspect and Get button will be enabled. Use Get to get the reference into the Object Panel of BlueJ. Perform the same process to Get the object reference of "RBS-2". You should have an RBS-2 registered in Msc first to be able to do so. If not, then the result will be a null. Finally, in the Object Panel, you will see that besides Msc_1, there are two more instances namely result (representing RBS-1) and result_2 (representing RBS-2),
Now you are ready to set both Rbs as neighbors. There are two ways to set these two as neighbors. The first one is by accessing the addNeighbor(Rbs) method from each of the Rbs objects and passing the reference of the other Rbs object as argument. The other way is by using the setNeighboring(Rbs,Rbs) static method in the Msc Class. Static methods can be accessed from the Msc Class definition and not from the Msc object.
Passing the two Rbs reference into the setNeighboring(Rbs,Rbs) method will set both Rbs as neighbors.
To check whether the process is successful, access the showNeighbors(Rbs) static method from the Msc Class. Select one of the Rbs, namely the result_2 for instance.
The result of executing the showNeighbors(Rbs) static method from the Msc Class will be the list of all the registered neighbors to the "RBS-2" which is currently only consists of "RBS-1" .
You could register all the neighboring Rbs using the same way.