2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A// Author: James Kempf 2N/A// Created On: Mon May 11 13:46:02 1998 2N/A// Last Modified By: James Kempf 2N/A// Last Modified On: Mon Feb 22 15:47:37 1999 2N/A * DATable is an abstract class that provides the interface for DA 2N/A * and scope discovery. A variety of implementations are possible. 2N/A * The getDATable() method creates the right one from a subclass. 2N/A * @author James Kempf 2N/A // System property naming the DATable implementation class to use. 2N/A // SA only scopes property. 2N/A // Hashtable key for multicast scopes. 2N/A // Hashtable key for DA equivalence classes. 2N/A * A record for all DAs supporting exactly the same set of scopes. 2N/A * @author James Kempf 2N/A // The scopes supported. 2N/A * Return a hashtable containing two entries: 2N/A * MULTICAST_KEY - Vector of scopes from the incoming vector that are not 2N/A * supported by any known DA. 2N/A * UNICAST_KEY - Vector of DATable.DARecord objects containing 2N/A * equivalence classes of DAs that all support the same set of scopes. 2N/A * Only DAs supporting one or more scopes in the incoming vector 2N/A * Note that the equivalence classes don't necessarily mean that the 2N/A * set of scopes are mutually exclusive. For example, if DA1 supports 2N/A * scopes A, B, and C; and DA2 supports scopes C and D, then they 2N/A * are in separate equivalence classes even though they both support 2N/A * C. But if DA2 supports A, B, and C; then it is in the same equivalence 2N/A * @param scopes The scopes for which DAs are required. 2N/A * @return A Hashtable with the multicast scopes and DAAddresses. 2N/A * Remove a DA by address. 2N/A * @param address The host address of the DA. 2N/A * @param scopes The scopes. 2N/A * @return True if removed, false if not. 2N/A * Return a vector of scopes that the SA or UA client should use. 2N/A * Note that if no DAs are around, SA adverts must be used to 2N/A * find SAs. We must sort through the returned DAs and apply 2N/A * the scope prioritization algorithm to them. 2N/A * @return Vector of scopes for the SA or UA client to use. 2N/A // First, get the DA addresses v.s. scopes table from the DAtable. 2N/A // This will also include DA addresses from the configuration file, 2N/A // if any. We don't filter on any scopes, since we want all of 2N/A // them. We are only interested in v2 scopes here. 2N/A // Go through the equivalence classes and pull out scopes. 2N/A for (i =
0; i < n; i++) {
2N/A for (j =
0; j < m; j++) {
2N/A // Unicast scopes take precedence over multicast scopes, 2N/A // so insert them at the beginning of the vector. 2N/A * Get the right DA table implementation. The property 2N/A * sun.net.slp.DATableClass determines the class. 2N/A * @return The DATable object for this process' SLP requests. 2N/A // Return it right up front if we have it. 2N/A // Link and instantiate it. 2N/A // Link and instantiate the class in the property. 2N/A // Get the property. 2N/A // Link the class and instantiate the object. 2N/A "no_da_table_class",
2N/A "instantiation_exception",
2N/A // We won't reach this point, since the assertions will capture 2N/A // any errors and kill the program. 2N/A // Utility functions for DA filtering and handling scopes. 2N/A // Filter scopes, removing any not on the filter list if inVector is 2N/A // false and removing any in the filter list if inVector is true. 2N/A // Null or empty filter vector means that all should be accepted. 2N/A // Add a new address to the equivalence class. 2N/A // Create the InetAddress object. 2N/A // Go through the existing vector. 2N/A for (j =
0; j < m; j++) {
2N/A // Make a new record if not equivalent. 2N/A // Add to record. Optimize, by putting the local address at the 2N/A // beginning of the vector. 2N/A * Validate the scope names. We check that they are all strings, 2N/A * that none are the empty string. In addition, we collate to 2N/A * remove duplicates, and lower case. 2N/A // Check for empty vector. 2N/A // Check for all strings and none empty. 2N/A "non_string_element",
2N/A // Lower case, trim. 2N/A // Squeeze out spaces. 2N/A // Add a single embedded whitespace for each group found. 2N/A // If it wasn't already seen, put it into the hashtable. 2N/A * Must decrement the index 'i' otherwise the next iteration 2N/A * around the loop will miss the element immediately after 2N/A * the element removed. 2N/A * WARNING: Do not use 'i' again until the loop has 2N/A * iterated as it may, after decrementing,