Sponsored Link •
ServiceRegistrarproxy to the service provider
ServiceRegistrarproxy to the client
RemoteException) in interface
Create a batch file that starts up the servers that you'll need to have running for the rest of the problems.
The first thing your batch file should do is set some environment variables:
set JINI_HOME=d:\jini1_0_1 set JDK_HOME=d:\jdk1.3 set YOUR_HOST=123.456.123.456 set YOUR_PORT=8080Just set the first two variables to the appropriate directories on your local disk. Set the
YOUR_HOSTvariable to your actual IP address, not 127.0.0.1 and not any DNS-style host name. The best way to ensure that other nodes on the network can find your web server is to point to it with an IP address in quad form.
The next thing you'll need to do is start a web server that will serve up files from the lookup service (reggie), transaction manager (mahalo), and javaspace (outrigger). Something like this should work. (The second and third lines should be one line.)
echo Launching web server for reggie, mahalo, and outrigger... start %JDK_HOME%\bin\java -jar %JINI_HOME%\lib\tools.jar -port %YOUR_PORT% -dir %JINI_HOME%\lib -verboseAt this point, you may wish to test your batch script. Once you get the web server to indeed pop up in a DOS box, attempt to request the URL
http://127.0.0.1:8080/reggie-dl.jarvia a web browser.
The reggie server runs in the RMI Activation Daemon (RMID), so the next thing your batch script should
do is start RMID. Before starting RMID, you should clear out its logs. (RMID keeps state between
crashes and shutdowns, so that once registered with RMID, remote objects are always available until
explicitly removed. RMID's places its logs in a subdirectory (called
log) of the
directory in which you start RMID. The following command should delete the logs:
del log\Logfile.* del log\Snapshot.* del log\Version_Number rmdir logOnce the logs are deleted, you can start RMID:
start %JDK_HOME%\bin\rmid -J-Djava.security.policy=policy.all -J-Djava.rmi.server.logCalls=trueStarting in 1.3, RMID requires a policy file. You can just use the
policy.allfile for these exercises. Try running your batch file again to make sure RMID gets started OK. To stop RMID once you get it going, type the following into any DOS box:
Modify your batch script once again, so that after RMID gets going, your batch script fires up the Jini lookup service. Before starting the lookup service, you'll want to remove its log files:
del reggie_log\Logfile.* del reggie_log\Snapshot.* del reggie_log\Version_Number rmdir reggie_log
Then start reggie (all one line):
%JDK_HOME%\bin\java -Djava.security.policy=%JINI_HOME%/example/lookup/policy.all -jar %JINI_HOME%/lib/reggie.jar http://%YOUR_HOST%:%YOUR_PORT%/reggie-dl.jar %JINI_HOME%/example/lookup/policy.all reggie_log public
Test your script once again, to make sure the lookup service registers itself successfully with RMID. This will take a while, perhaps a minute or so. If the lookup service throws back some exceptions at you, you may need to insert some kind of pause between starting RMID and starting reggie. RMID takes a few seconds to sort itself out and mentally prepare to accept activatable objects like those offered by reggie.
To generate a prompt in DOS that will wait for you to hit return, you could use this:
mkdir delmedir del delmedir\*.* rmdir delmedir
Modify your batch script yet again, this time to start a transaction manager. Like the lookup service, the transaction manager will operate as an activatable object in RMID. Before starting the transaction manager, you'll want to remove its log files:
del mahalo_log\JoinAdminLog\*.* del mahalo_log\Version rmdir mahalo_log\JoinAdminLog rmdir mahalo_log
Then start mahalo (all one line):
%JDK_HOME%\bin\java -Dcom.sun.jini.mahalo.managerName=TransactionManager -Djava.security.policy=%JINI_HOME%/example/lookup/policy.all -jar %JINI_HOME%/lib/mahalo.jar http://%YOUR_HOST%:%YOUR_PORT%/mahalo-dl.jar %JINI_HOME%/example/lookup/policy.all SOME_ABSOLUTE_PATH\mahalo_log public
Make sure you replace
"SOME_ABSOLUTE_PATH" with the absolute path
to your working directory, the directory in which you run your batch script.
Test your script once again, to make sure the transaction manager gets going successfully.
Unfortunately, you've almost come to the end of all this fun and exciting batch file writing, so make sure you savor the joy of this last step. The only server left to start is the JavaSpace. Because we'll be using the non-persistent version of outrigger, you don't even have to clean up any log files. Just start the space:
%JDK_HOME%\bin\java -Dcom.sun.jini.outrigger.spaceName=YOUR_NAME_HERE -Djava.security.policy=%JINI_HOME%/example/lookup/policy.all -Djava.rmi.server.codebase=http://%YOUR_HOST%:%YOUR_PORT%/outrigger-dl.jar -jar %JINI_HOME%/lib/transient-outrigger.jar public
Please substitute your name in place of
"YOUR_NAME_HERE" when starting the space. (Any name will
actually work, so long as it is unique in the class room, so feel free to be creative.)
Test your batch script one last time, to make sure JavaSpaces gets going correctly. When the script is done, the DOS box in which you actually run the script will end up being the JavaSpace server.
RuntimeInfra/ex1 directory, run
lsd.bat, which will do
a "directory" of the lookup service running on port 4160 of your computer. Make sure you see
at least three services running in your lookup service, the lookup service itself (reggie always
registers its own service with itself), the transaction manager, and the JavaSpace. You may see
lots more, because everyone else in the room testing their batch files will be starting these
services as well, and they will attempt to register themselves in your lookup service too.