本文整理匯總了Java中net.jini.discovery.DiscoveryGroupManagement類的典型用法代碼示例。如果您正苦於以下問題:Java DiscoveryGroupManagement類的具體用法?Java DiscoveryGroupManagement怎麽用?Java DiscoveryGroupManagement使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DiscoveryGroupManagement類屬於net.jini.discovery包,在下文中一共展示了DiscoveryGroupManagement類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLookupGroups
import net.jini.discovery.DiscoveryGroupManagement; //導入依賴的package包/類
/**
* Returns the Jini Lookup Service groups for this environment.
*
* @return an array of group names
*/
public static String[] getLookupGroups() {
String groups = null;
if(props!=null)
groups = props.getProperty(P_GROUPS);
if (groups == null || groups.length() == 0)
return DiscoveryGroupManagement.ALL_GROUPS;
return toArray(groups);
}
示例2: execute
import net.jini.discovery.DiscoveryGroupManagement; //導入依賴的package包/類
public void execute(String... args) throws Throwable {
out = NetworkShell.getShellOutputStream();
WhitespaceTokenizer myTk = NetworkShell.getShellTokenizer();
// pass in a clone of list - command may modify it
@SuppressWarnings("unchecked")
ArrayList<ServiceRegistrar> registrars = new ArrayList<ServiceRegistrar>(NetworkShell
.getRegistrars());
int numTokens = myTk.countTokens();
String[] groups = null; // matches all
String next = myTk.nextToken();
if (next.indexOf("-") != 0) {
if (numTokens == 1) {
if (next.indexOf(",") > 0) {
groups = NetworkShell.toArray(next, ",");
} else {
groups = new String[] { next };
}
} else {
String[] tg = getGroupArray(myTk, numTokens - 1);
groups = new String[numTokens];
groups[0] = next;
System.arraycopy(tg, 0, groups, 1, numTokens - 1);
}
for (int j = 0; j < groups.length; j++) {
if (groups[j].equalsIgnoreCase("all")) {
groups = DiscoveryGroupManagement.ALL_GROUPS;
break;
}
}
NetworkShell.setGroups(groups);
NetworkShell.getDisco().terminate();
NetworkShell.getRegistrars().clear();
DiscoCmd.selectedRegistrar = 0;
NetworkShell.setLookupDiscovery(groups);
} else if (next.equals("-r")) {
int myIdx = Integer.parseInt(myTk.nextToken());
if (numTokens == 2) {
groups = NetworkShell.getGroups();
} else if (numTokens > 2) {
groups = getGroupArray(myTk, numTokens - 2);
}
if ((myIdx < registrars.size()) && (myIdx >= 0)) {
ServiceRegistrar myReg = (ServiceRegistrar) registrars
.get(myIdx);
if (myReg != null) {
setGroups(myReg, myIdx, groups);
}
}
} else {
out.println(COMMAND_USAGE);
}
}