* accepts either qualified or unqualified service names.
*
* @pre service_name != null
*/
static public Frame composeQuery(String service_name) {
VinciFrame query = new VinciFrame();
query.fadd(TransportConstants.COMMAND_KEY, VNSConstants.RESOLVE_COMMAND);
int start = service_name.indexOf('[');
if (start != -1) {
// qualified service name ... must parse out qualifications
int end = service_name.indexOf(']', start);
if (end != -1) {
String qualifications = service_name.substring(start + 1, end);
query.fadd(VNSConstants.SERVICE_KEY, service_name.substring(0, start));
StringTokenizer tokenizer = new StringTokenizer(qualifications, ",");
if (tokenizer.hasMoreTokens()) {
query.fadd(VNSConstants.LEVEL_KEY, tokenizer.nextToken());
if (tokenizer.hasMoreTokens()) {
query.fadd(VNSConstants.HOST_KEY, tokenizer.nextToken());
if (tokenizer.hasMoreTokens()) {
query.fadd(VNSConstants.INSTANCE_KEY, tokenizer.nextToken());
}
}
}
return query;
}
}
int at = service_name.indexOf('@');
if (at == -1) {
query.fadd(VNSConstants.SERVICE_KEY, service_name);
} else {
query.fadd(VNSConstants.SERVICE_KEY, service_name.substring(0, at));
}
return query;
}