java/rmi server main - the java/rmi client will first have to install a security manager before doing any remote calls. you do this by making a call to system.setsecuritymanager(). we then create the java/rmi server object with the call
stockmarketimpl stockmarketimpl = new stockmarketimpl("nasdaq");
and remain there till we are shut down.
dcom - notice that we have not provided a main program for our dcom server implementation. the java support in internet explorer runs as an in-process server, and in-process servers cannot normally be remoted using the windows nt 4.0 distributed com (dcom). however, it is possible to launch a "surrogate" .exe in its own process that then loads the in-process server. this surrogate can then be remoted using dcom, in effect allowing the in-process server to be remoted.you can use javareg's /surrogate option to support remote access to a com class implemented in java. when first registering the class, specify the /surrogate option on the command line. for example:
javareg /register /class:stockmarket /clsid:{fe19e681-508b-11d2-a187-000000000000} /surrogate
this adds a localserver32 key to the registry in addition to the usual inprocserver32 key. the command line under the localserver32 key specifies javareg with the /surrogate but without the /register option.
hkey_classes_root
clsid
{bc4c0ab3-5a45-11d2-99c5-00a02414c655}
inprocserver32 = msjava.dll
localserver32 = javareg /clsid:{bc4c0ab3-5a45-11d2-99c5-00a02414c655} /surrogate
this causes javareg to act as the surrogate itself. when a remote client requests services from the com class that you've implemented using java, javareg is invoked. javareg then loads the java support in internet explorer with the specified java class. (this means that when distributing your java program, your installation program must install javareg along with the java class.) you can remove the localserver32 key by rerunning javareg with the /class option, specifying the same class name, but without the /clsid or /surrogate options
javareg /register /class:stockmarket
| dcom - registry file |
| regedit4 [hkey_classes_root\clsid\{bc4c0ab3-5a45-11d2-99c5-00a02414c655}] @="java class: stockmarket" "appid"="{bc4c0ab3-5a45-11d2-99c5-00a02414c655}" [hkey_classes_root\clsid\{bc4c0ab3-5a45-11d2-99c5-00a02414c655}\inprocserver32] @="msjava.dll" "threadingmodel"="both" "javaclass"="stockmarket" [hkey_classes_root\clsid\{bc4c0ab3-5a45-11d2-99c5-00a02414c655}\localserver32] @="javareg /clsid:{bc4c0ab3-5a45-11d2-99c5-00a02414c655} /surrogate" [hkey_classes_root\clsid\{bc4c0ab3-5a45-11d2-99c5-00a02414c655}\implemented categories] [hkey_classes_root\clsid\{bc4c0ab3-5a45-11d2-99c5-00a02414c655}\implemented categories\{be0975f0-bbdd-11cf-97df-00aa001f73c1}] [hkey_classes_root\appid\{bc4c0ab3-5a45-11d2-99c5-00a02414c655}] @="java class: stockmarket" |
| file : stockmarket.reg |