?? jiniagentservice.java
字號(hào):
// These classes form the basis of the RMI support
import java.rmi.RemoteException;
import java.rmi.RMISecurityManager;
import java.rmi.server.UnicastRemoteObject;
import java.io.IOException;
// We will require a number of Jini classes to support our Jini service
import net.jini.core.discovery.LookupLocator;
import net.jini.core.lookup.ServiceID;
import net.jini.discovery.DiscoveryGroupManagement;
import net.jini.discovery.LookupDiscoveryManager;
import net.jini.lookup.JoinManager;
import net.jini.lookup.ServiceIDListener;
//
// Extend the UnicastRemoteObject to create a non-activatable Jini service.
//
public class JiniAgentService extends UnicastRemoteObject
implements Agent
{
// The LookupDiscoveryManager you are using to find (request) LUSs
private LookupDiscoveryManager lookupDiscMgr;
// The lookup locator array that contains specific LUSs
private LookupLocator locators[];
// The groups array that contains specific groups, no groups, or all groups
private String groups[] = DiscoveryGroupManagement.ALL_GROUPS;
// The manager for joining LUSs
private JoinManager joiner = null;
// ServiceID returned from the lookup registration process
private ServiceID serviceID = null;
//
// Add an init method to your constructor to do initialization specific to Jini.
//
public JiniAgentService() throws IOException {
// call the UnicastRemoteObject to export the object
super();
// Initialize the Jini service
init();
}
// Create a discovery manager by passing parameters
// to discover all LUSes within the multicast radius.
// Do this by specifying ALL_GROUPS and null parameters.
private void init() throws IOException {
try {
lookupDiscMgr = new LookupDiscoveryManager(groups, locators, null);
} catch (IOException e) {
System.err.println("Problem starting discovery");
e.printStackTrace();
throw new IOException("Problem starting discovery:" +
e.getLocalizedMessage());
}
/* Register this service with any configured LUSes */
if (serviceID == null) {
// First instance ... need service id
joiner = new JoinManager(
this, // service object
null, // service attributes
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -