xref: /illumos-gate/usr/src/lib/libslp/javalib/com/sun/slp/ServiceLocationManager.java (revision 9a70fc3be3b1e966bf78825cdb8d509963a6f0a1)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*9a70fc3bSMark J. Nelson  * Common Development and Distribution License (the "License").
6*9a70fc3bSMark J. Nelson  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate  * Copyright (c) 1999 by Sun Microsystems, Inc.
237c478bd9Sstevel@tonic-gate  * All rights reserved.
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
27*9a70fc3bSMark J. Nelson //  ServiceLocationManager.java : The service locator object.
287c478bd9Sstevel@tonic-gate //  Author:           Erik Guttman
297c478bd9Sstevel@tonic-gate //
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate package com.sun.slp;
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate import java.util.*;
347c478bd9Sstevel@tonic-gate import java.io.*;
357c478bd9Sstevel@tonic-gate import java.lang.reflect.*;
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /**
387c478bd9Sstevel@tonic-gate  * The ServiceLocationManager class provides entry to SLP services.
397c478bd9Sstevel@tonic-gate  * The ServiceLocationManager class uses static methods
407c478bd9Sstevel@tonic-gate  * to provide objects encapsulating the connection with the Service
417c478bd9Sstevel@tonic-gate  * Location facility. In addition, it provides access to known
427c478bd9Sstevel@tonic-gate  * scopes.
437c478bd9Sstevel@tonic-gate  *
447c478bd9Sstevel@tonic-gate  * @author Erik Guttman
457c478bd9Sstevel@tonic-gate  *
467c478bd9Sstevel@tonic-gate  */
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate abstract public class ServiceLocationManager extends Object {
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate     // Properties.
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate     protected static DATable dat = null;
537c478bd9Sstevel@tonic-gate     protected static SLPConfig config = null;
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate     protected static Hashtable locators = new Hashtable();
567c478bd9Sstevel@tonic-gate     protected static Hashtable advertisers = new Hashtable();
577c478bd9Sstevel@tonic-gate     protected static Class locatorClass = null;
587c478bd9Sstevel@tonic-gate     protected static Class advertiserClass = null;
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate     // Public interface
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate     /**
637c478bd9Sstevel@tonic-gate      * The property accessor for the Locator object. If user agent
647c478bd9Sstevel@tonic-gate      * functionality is not available, returns null.
657c478bd9Sstevel@tonic-gate      *
667c478bd9Sstevel@tonic-gate      * @param locale The Locale of the Locator object. Use null for default.
677c478bd9Sstevel@tonic-gate      * @return The Locator object.
687c478bd9Sstevel@tonic-gate      * @exception ServiceLocationException Thrown if the locator can't
697c478bd9Sstevel@tonic-gate      *					  be created.
707c478bd9Sstevel@tonic-gate      *
717c478bd9Sstevel@tonic-gate      */
727c478bd9Sstevel@tonic-gate 
getLocator(Locale locale)737c478bd9Sstevel@tonic-gate     public static Locator getLocator(Locale locale)
747c478bd9Sstevel@tonic-gate 	throws ServiceLocationException
757c478bd9Sstevel@tonic-gate     {
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate 	if (locale == null) {
787c478bd9Sstevel@tonic-gate 	    locale = config.getLocale();
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate 	}
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate 	String lang = locale.getLanguage();
837c478bd9Sstevel@tonic-gate 	Locator locator = (Locator)locators.get(lang);
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate 	if (locator == null) {
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate 	    if (locatorClass == null) {
887c478bd9Sstevel@tonic-gate 		String className =
897c478bd9Sstevel@tonic-gate 		    System.getProperty("sun.net.slp.LocatorImpl");
907c478bd9Sstevel@tonic-gate 		if (className == null) {
917c478bd9Sstevel@tonic-gate 		    className = "com.sun.slp.UARequester";
927c478bd9Sstevel@tonic-gate 		}
937c478bd9Sstevel@tonic-gate 		locatorClass = getClass(className);
947c478bd9Sstevel@tonic-gate 	    }
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate 	    locator = (Locator)getInstance(locatorClass, locale);
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate 	    if (locator != null) {
997c478bd9Sstevel@tonic-gate 		locators.put(lang, locator);
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate 	    }
1027c478bd9Sstevel@tonic-gate 	}
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	return locator;
1057c478bd9Sstevel@tonic-gate     }
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate     /**
1087c478bd9Sstevel@tonic-gate      * The property accessor for the Advertiser object. If service agent
1097c478bd9Sstevel@tonic-gate      * functionality is not available, returns null.
1107c478bd9Sstevel@tonic-gate      *
1117c478bd9Sstevel@tonic-gate      * @param locale The Locale of the Advertiser object. Use null for default.
1127c478bd9Sstevel@tonic-gate      * @return The Advertiser object.
1137c478bd9Sstevel@tonic-gate      * @exception ServiceLocationException Thrown if the locator can't
1147c478bd9Sstevel@tonic-gate      *					  be created.
1157c478bd9Sstevel@tonic-gate      *
1167c478bd9Sstevel@tonic-gate      */
1177c478bd9Sstevel@tonic-gate 
getAdvertiser(Locale locale)1187c478bd9Sstevel@tonic-gate     public static Advertiser getAdvertiser(Locale locale)
1197c478bd9Sstevel@tonic-gate 	throws ServiceLocationException {
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate 	if (locale == null) {
1227c478bd9Sstevel@tonic-gate 	    locale = config.getLocale();
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 	}
1257c478bd9Sstevel@tonic-gate 
1267c478bd9Sstevel@tonic-gate 	String lang = locale.getLanguage();
1277c478bd9Sstevel@tonic-gate 	Advertiser advertiser = (Advertiser)advertisers.get(lang);
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 	if (advertiser == null) {
1307c478bd9Sstevel@tonic-gate 
1317c478bd9Sstevel@tonic-gate 	    if (advertiserClass == null) {
1327c478bd9Sstevel@tonic-gate 		String className =
1337c478bd9Sstevel@tonic-gate 		    System.getProperty("sun.net.slp.AdvertiserImpl");
1347c478bd9Sstevel@tonic-gate 		if (className == null) {
1357c478bd9Sstevel@tonic-gate 		    className = "com.sun.slp.SARequester";
1367c478bd9Sstevel@tonic-gate 		}
1377c478bd9Sstevel@tonic-gate 		advertiserClass = getClass(className);
1387c478bd9Sstevel@tonic-gate 	    }
1397c478bd9Sstevel@tonic-gate 
1407c478bd9Sstevel@tonic-gate 	    advertiser = (Advertiser)getInstance(advertiserClass, locale);
1417c478bd9Sstevel@tonic-gate 
1427c478bd9Sstevel@tonic-gate 	    if (advertiser != null) {
1437c478bd9Sstevel@tonic-gate 		advertisers.put(lang, advertiser);
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate 	    }
1467c478bd9Sstevel@tonic-gate 	}
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate 	return advertiser;
1497c478bd9Sstevel@tonic-gate     }
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate     /**
1527c478bd9Sstevel@tonic-gate      * Returns a vector of known scope names.  It will include any
1537c478bd9Sstevel@tonic-gate      * scopes defined in the configuration file and ensure that the
1547c478bd9Sstevel@tonic-gate      * <i>order</i> of those scope strings is kept in the list of
1557c478bd9Sstevel@tonic-gate      * scopes which is returned. This method enforces the constraint
1567c478bd9Sstevel@tonic-gate      * that the default scope is returned if no other is available.
1577c478bd9Sstevel@tonic-gate      *
1587c478bd9Sstevel@tonic-gate      * @param typeHint Type to look for if SA advertisment required.
1597c478bd9Sstevel@tonic-gate      * @return Vector containing Strings with scope names.
1607c478bd9Sstevel@tonic-gate      */
1617c478bd9Sstevel@tonic-gate 
findScopes()1627c478bd9Sstevel@tonic-gate     public static synchronized Vector findScopes()
1637c478bd9Sstevel@tonic-gate 	throws ServiceLocationException {
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate 	Vector accessableScopes = null;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate 	// For the UA, return configured scopes if we have them.
1687c478bd9Sstevel@tonic-gate 
1697c478bd9Sstevel@tonic-gate 	accessableScopes = config.getConfiguredScopes();
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 	// If no configured scopes, get discovered scopes from
1727c478bd9Sstevel@tonic-gate 	//  DA table.
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 	if (accessableScopes.size() <= 0) {
1757c478bd9Sstevel@tonic-gate 	    accessableScopes = dat.findScopes();
1767c478bd9Sstevel@tonic-gate 
1777c478bd9Sstevel@tonic-gate 	    // If still none, perform SA discovery.
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate 	    if (accessableScopes.size() <= 0) {
1807c478bd9Sstevel@tonic-gate 		accessableScopes = performSADiscovery();
1817c478bd9Sstevel@tonic-gate 
1827c478bd9Sstevel@tonic-gate 		// If still none, then return default scope. The client won`t
1837c478bd9Sstevel@tonic-gate 		//  be able to contact anyone because there`s nobody out there.
1847c478bd9Sstevel@tonic-gate 
1857c478bd9Sstevel@tonic-gate 		if (accessableScopes.size() <= 0) {
1867c478bd9Sstevel@tonic-gate 		    accessableScopes.addElement(Defaults.DEFAULT_SCOPE);
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate 		}
1897c478bd9Sstevel@tonic-gate 	    }
1907c478bd9Sstevel@tonic-gate 	}
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 	return accessableScopes;
1937c478bd9Sstevel@tonic-gate     }
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate     /**
1967c478bd9Sstevel@tonic-gate      * Returns the maximum across all DAs of the min-refresh-interval
1977c478bd9Sstevel@tonic-gate      * attribute.  This value satisfies the advertised refresh interval
1987c478bd9Sstevel@tonic-gate      * bounds for all DAs, and, if used by the SA, assures that no
1997c478bd9Sstevel@tonic-gate      * refresh registration will be rejected.  If no DA advertises a
2007c478bd9Sstevel@tonic-gate      * min-refresh-interval attribute, a value of 0 is returned.
2017c478bd9Sstevel@tonic-gate      *
2027c478bd9Sstevel@tonic-gate      * @return The maximum min-refresh-interval attribute value.
2037c478bd9Sstevel@tonic-gate      */
2047c478bd9Sstevel@tonic-gate 
getRefreshInterval()2057c478bd9Sstevel@tonic-gate     public static int getRefreshInterval() throws ServiceLocationException {
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 	// Get the min-refresh-interval attribute values for all DA's from
2087c478bd9Sstevel@tonic-gate 	//  the server.
2097c478bd9Sstevel@tonic-gate 
2107c478bd9Sstevel@tonic-gate 	Vector tags = new Vector();
2117c478bd9Sstevel@tonic-gate 	tags.addElement(Defaults.MIN_REFRESH_INTERVAL_ATTR_ID);
2127c478bd9Sstevel@tonic-gate 
2137c478bd9Sstevel@tonic-gate 	// We don't simply do Locator.findAttributes() here because we
2147c478bd9Sstevel@tonic-gate 	//  need to contact the SA server directly.
2157c478bd9Sstevel@tonic-gate 
2167c478bd9Sstevel@tonic-gate 	Vector saOnlyScopes = config.getSAOnlyScopes();
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate 	CAttrMsg msg = new CAttrMsg(Defaults.locale,
2197c478bd9Sstevel@tonic-gate 				    Defaults.SUN_DA_SERVICE_TYPE,
2207c478bd9Sstevel@tonic-gate 				    saOnlyScopes,
2217c478bd9Sstevel@tonic-gate 				    tags);
2227c478bd9Sstevel@tonic-gate 
2237c478bd9Sstevel@tonic-gate 	// Send it down the pipe to the IPC process. It's a bad bug
2247c478bd9Sstevel@tonic-gate 	//  if the reply comes back as not a CAttrMsg.
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate 	CAttrMsg rply =
2277c478bd9Sstevel@tonic-gate 	    (CAttrMsg)Transact.transactTCPMsg(config.getLoopback(), msg, true);
2287c478bd9Sstevel@tonic-gate 
2297c478bd9Sstevel@tonic-gate 	// Check error code.
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate 	if (rply == null ||
2327c478bd9Sstevel@tonic-gate 	    rply.getErrorCode() != ServiceLocationException.OK) {
2337c478bd9Sstevel@tonic-gate 	    short errCode =
2347c478bd9Sstevel@tonic-gate 		(rply == null ?
2357c478bd9Sstevel@tonic-gate 		 ServiceLocationException.INTERNAL_SYSTEM_ERROR :
2367c478bd9Sstevel@tonic-gate 		 rply.getErrorCode());
2377c478bd9Sstevel@tonic-gate 	    throw
2387c478bd9Sstevel@tonic-gate 		new ServiceLocationException(errCode,
2397c478bd9Sstevel@tonic-gate 					     "loopback_error",
2407c478bd9Sstevel@tonic-gate 					     new Object[] {
2417c478bd9Sstevel@tonic-gate 		    new Short(errCode)});
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate 	}
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate 	// Sort through the attribute values to determine reply.
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 	int ri = 0;
2487c478bd9Sstevel@tonic-gate 	Vector attrs = rply.attrList;
2497c478bd9Sstevel@tonic-gate 	ServiceLocationAttribute attr =
2507c478bd9Sstevel@tonic-gate 	    (attrs.size() > 0 ?
2517c478bd9Sstevel@tonic-gate 	    (ServiceLocationAttribute)attrs.elementAt(0):
2527c478bd9Sstevel@tonic-gate 	    null);
2537c478bd9Sstevel@tonic-gate 	Vector values = (attr != null ? attr.getValues():new Vector());
2547c478bd9Sstevel@tonic-gate 	int i, n = values.size();
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate 	for (i = 0; i < n; i++) {
2577c478bd9Sstevel@tonic-gate 	    Integer mri = (Integer)values.elementAt(i);
2587c478bd9Sstevel@tonic-gate 	    int mriv = mri.intValue();
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate 	    if (mriv > ri) {
2617c478bd9Sstevel@tonic-gate 		ri = mriv;
2627c478bd9Sstevel@tonic-gate 
2637c478bd9Sstevel@tonic-gate 	    }
2647c478bd9Sstevel@tonic-gate 	}
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate 	return ri;
2677c478bd9Sstevel@tonic-gate     }
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate     //
2707c478bd9Sstevel@tonic-gate     // Private implementation.
2717c478bd9Sstevel@tonic-gate     //
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate     // Return the requested class, or null if it can't be found.
2747c478bd9Sstevel@tonic-gate 
getClass(String name)2757c478bd9Sstevel@tonic-gate     private static Class getClass(String name) {
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate 	Class ret = null;
2787c478bd9Sstevel@tonic-gate 
2797c478bd9Sstevel@tonic-gate 	try {
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate 	    ret = Class.forName(name);
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate 	} catch (ClassNotFoundException ex) {
2847c478bd9Sstevel@tonic-gate 
2857c478bd9Sstevel@tonic-gate 	}
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate 	return ret;
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate     }
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate     // Return an instance from the class.
2927c478bd9Sstevel@tonic-gate 
getInstance(Class cobj, Locale locale)2937c478bd9Sstevel@tonic-gate     private static Object getInstance(Class cobj, Locale locale) {
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate 	Object ret = null;
2967c478bd9Sstevel@tonic-gate 
2977c478bd9Sstevel@tonic-gate 	if (cobj != null) {
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate 	    try {
3007c478bd9Sstevel@tonic-gate 		Class[] paramClasses = {locale.getClass()};
3017c478bd9Sstevel@tonic-gate 
3027c478bd9Sstevel@tonic-gate 		Constructor con = cobj.getDeclaredConstructor(paramClasses);
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate 		Object[] params = {locale};
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate 		ret = con.newInstance(params);
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 	    } catch (InstantiationException ex) {
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate 	    } catch (IllegalAccessException ex) {
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate 	    } catch (InvocationTargetException ex) {
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate 	    } catch (NoSuchMethodException ex) {
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate 	    }
3177c478bd9Sstevel@tonic-gate 	}
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate 	return ret;
3207c478bd9Sstevel@tonic-gate     }
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate     // Perform SA discovery, since no DA scopes found.
3237c478bd9Sstevel@tonic-gate 
performSADiscovery()3247c478bd9Sstevel@tonic-gate     private static Vector performSADiscovery()
3257c478bd9Sstevel@tonic-gate 	throws ServiceLocationException {
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate 	// Get type hint if any.
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate 	Vector hint = config.getTypeHint();
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate 	// Format query.
3327c478bd9Sstevel@tonic-gate 
3337c478bd9Sstevel@tonic-gate 	StringBuffer buf = new StringBuffer();
3347c478bd9Sstevel@tonic-gate 	int i, n = hint.size();
3357c478bd9Sstevel@tonic-gate 
3367c478bd9Sstevel@tonic-gate 	for (i = 0; i < n; i++) {
3377c478bd9Sstevel@tonic-gate 	    buf.append("(");
3387c478bd9Sstevel@tonic-gate 	    buf.append(Defaults.SERVICE_TYPE_ATTR_ID);
3397c478bd9Sstevel@tonic-gate 	    buf.append("=");
3407c478bd9Sstevel@tonic-gate 	    buf.append(hint.elementAt(i).toString());
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate 	}
3437c478bd9Sstevel@tonic-gate 
3447c478bd9Sstevel@tonic-gate 	// Add logical disjunction if more than one element.
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate 	if (i > 1) {
3477c478bd9Sstevel@tonic-gate 	    buf.insert(0, "(|");
3487c478bd9Sstevel@tonic-gate 	    buf.append(")");
3497c478bd9Sstevel@tonic-gate 	}
3507c478bd9Sstevel@tonic-gate 
3517c478bd9Sstevel@tonic-gate 	// Form SA discovery request.
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate 	CSrvMsg rqst = new CSrvMsg(config.getLocale(),
3547c478bd9Sstevel@tonic-gate 				   Defaults.SA_SERVICE_TYPE,
3557c478bd9Sstevel@tonic-gate 				   new Vector(),    // seeking scopes...
3567c478bd9Sstevel@tonic-gate 				   buf.toString());
3577c478bd9Sstevel@tonic-gate 
3587c478bd9Sstevel@tonic-gate 	// Transact the advert request.
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate 	Vector scopes =
3617c478bd9Sstevel@tonic-gate 	    Transact.transactActiveAdvertRequest(Defaults.SA_SERVICE_TYPE,
3627c478bd9Sstevel@tonic-gate 						 rqst,
3637c478bd9Sstevel@tonic-gate 						 null);
3647c478bd9Sstevel@tonic-gate 						// DA table not needed...
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate 	return scopes;
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate     }
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate     // Initialize SLPConfig and DATable.
3717c478bd9Sstevel@tonic-gate 
3727c478bd9Sstevel@tonic-gate     static {
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate 	if (config == null) {
3757c478bd9Sstevel@tonic-gate 	    config = SLPConfig.getSLPConfig();
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate 	}
3787c478bd9Sstevel@tonic-gate 
3797c478bd9Sstevel@tonic-gate 	if (dat == null) {
3807c478bd9Sstevel@tonic-gate 	    dat = DATable.getDATable();
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 	}
3837c478bd9Sstevel@tonic-gate     }
3847c478bd9Sstevel@tonic-gate }
385