Java Reference
In-Depth Information
side. We've stubbed out all but two of these methods for the sake of space. The
remaining two MBeanServer methods are used to test the connector later. Exam-
ine the listing; the discussion follows.
Listing 9.6
JINIConnectorClient.java
package jmxbook.ch9;
import javax.management.*;
import java.rmi.*;
import java.util.*;
import net.jini.discovery.*;
import net.jini.core.lookup.*;
import net.jini.lookup.*;
import java.io.*;
public class JINIConnectorClient
implements DiscoveryListener, MBeanServer
{
private ServiceTemplate template = null;
private LookupDiscovery reg = null;
private JINIConnector server =null;
public JINIConnectorClient()
{
System.setSecurityManager( new RMISecurityManager() );
Class[] cls = { JINIConnector.class };
template = new ServiceTemplate( null, cls, null );
try
{
reg = new LookupDiscovery( new String[] { "" } );
reg.addDiscoveryListener( this );
B
Begin search
for Jini service
while( server == null )
Thread.sleep( 1000 );
}
catch( Exception e )
{
e.printStackTrace();
}
}
C
Implemenent
listener callback
public void discovered( DiscoveryEvent event )
{
if( server != null )
return;
ServiceRegistrar[] lookups = event.getRegistrars();
try
{
ServiceMatches items = lookups[0].lookup( template,
Search WWH ::




Custom Search