本文整理汇总了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);
}
}