* configuration and assuming that the appropriate subject is in effect.
*/
static void mainAsSubject(Configuration config) throws Exception {
/* Get the service discovery manager, for discovering other services */
ServiceDiscoveryManager serviceDiscovery;
try {
serviceDiscovery = (ServiceDiscoveryManager) config.getEntry(
"com.sun.jini.example.hello.Client", "serviceDiscovery",
ServiceDiscoveryManager.class);
} catch (NoSuchEntryException e) {
/* Default to search in the public group */
serviceDiscovery = new ServiceDiscoveryManager(
new LookupDiscovery(new String[] { "" }, config),
null, config);
}
/* Retrieve the server proxy preparer from the configuration */
ProxyPreparer preparer = (ProxyPreparer) config.getEntry(
"com.sun.jini.example.hello.Client",
"preparer", ProxyPreparer.class, new BasicProxyPreparer());
/* Create the filter to pass to the SDM for proxy preparation */
ServiceItemFilter filter = new ProxyPreparerFilter(preparer);
/* Look up the remote server (SDM performs proxy preparation) */
ServiceItem serviceItem = serviceDiscovery.lookup(
new ServiceTemplate(null, new Class[] { Hello.class }, null),
filter, Long.MAX_VALUE);
Hello server = (Hello) serviceItem.service;
/* Use the server */