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