/*
* 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 (c) 1999 by Sun Microsystems, Inc.
* All rights reserved.
*
*/
// ServiceStoreFactory.java: Factory for creating ServiceStore objects.
// Author: James Kempf
// Created On: Fri Apr 17 12:14:12 1998
// Last Modified By: James Kempf
// Last Modified On: Mon Jan 4 15:26:34 1999
// Update Count: 34
//
/**
* The ServiceStoreFactory provides a way to obtain a ServiceStore
* object. The exact implementation will depend on how the
* a connection to an LDAP server, or a persistent object
* database.
*
* @author James Kempf
*/
"com.sun.slp.ServiceStoreInMemory";
"sun.net.slp.serviceStoreClass";
// Comment characters for deserialization.
// Character for URL list separator.
// Identifies scopes pseudo-attribute.
/**
* Return the ServiceStore for the SLP agent.
*
* @return An object supporting the ServiceStore interface.
* @exception ServiceLocationException Thrown
* if the ServiceStore object can't be
* created or if the
* class implementing the ServiceStore required
* a network connnection (for example, an LDAP
* server) and the connection couldn't be made.
*/
throws ServiceLocationException {
}
// Create the appropriate ServiceStore object from the property.
private static ServiceStore
throws ServiceLocationException {
try {
} catch (ClassNotFoundException ex) {
throw
"ssf_no_class",
new Object[] {storeClassName});
}
try {
} catch (InstantiationException ex) {
throw
"ssf_inst_ex",
new Object[] {
ex.getMessage()});
} catch (IllegalAccessException ex) {
throw
"ssf_ill_ex",
new Object[] {
ex.getMessage()});
} catch (ClassCastException ex) {
throw
"ssf_class_cast",
new Object[] {storeClassName});
}
return store;
}
/**
* Deserialize a service store from the open stream.
*
* @param is The object input stream for the service store.
* @return ServiceStore deserialized from the stream.
* @exception ServiceLocationException If anything goes
* wrong with the deserialization.
*/
throws ServiceLocationException {
try {
} catch (IOException ex) {
throw
"ssf_io_deser",
}
return ss;
}
// Read the service store in the standard format from the input
throws IOException, ServiceLocationException {
int linecount = 0;
int scopeLinenum = 0;
// Parse input file until no bytes left.
linecount++;
// Skip any empty lines at this level.
continue;
}
// If initial character is "#" or ";", ignore the line.
// It's a comment. Also if the line is empty.
if (cc == COMMENT_CHAR1 ||
cc == COMMENT_CHAR2) {
continue;
}
// At this level, the line must be a URL registration,
// with format:
//
// service-url ", " language ", " lifetime [ ", " type ]
//
//
// We allow arbitrary whitespace around commas.
if (tk.hasMoreTokens()) {
if (tk.hasMoreTokens()) {
if (tk.hasMoreTokens()) {
if (tk.hasMoreTokens()) {
if (tk.hasMoreTokens()) {
// should be nothing more on the line.
}
}
}
}
}
// Check for errors.
throw
"ssf_not_valid_url",
}
// Create the service: URL.
try {
// If lifetime is maximum, then set to LIFETIME_PERMANENT.
}
// Check if it's OK for this service URL.
if (utype.isServiceURL()) {
new Object[] {
surl,
utype});
} else {
if (!t.isServiceURL() &&
url.setServiceType(t);
}
}
}
} catch (NumberFormatException ex) {
throw
"ssf_not_valid_lifetime",
new Object[] {
} catch (IllegalArgumentException ex) {
throw
"ssf_syntax_err",
new Object[] {
}
// Get attributes. Format should be:
//
// attr-line = attr-assign | keyword
// attr-assign = attr-id "=" attrval-list
// keyword = attr-id
// attrval-list = attrval | attrval ", " attrval-list
boolean firstLine = true;
try {
linecount++;
// Empty line indicates we're done with attributes.
break;
}
// Format the line for creating. Check whether it's a
// keyword or not.
}
// Create the attribute from the string.
new ServiceLocationAttribute(line, false);
// If this is the scope attribute, save until later.
if (firstLine) {
firstLine = false;
continue; // do NOT save as a regular attribute.
}
}
ht,
false);
}
} catch (ServiceLocationException e) {
// tack on the line count
throw e;
}
// Use scopes we've been configured with if none.
} else {
try {
// Unescape scope strings.
// Validate, lower case scope names.
} catch (ServiceLocationException e) {
throw e;
}
}
// We've got the attributes, the service URL, scope, and
// locale, so add a record. Note that any crypto is
// added when the registration is actually done.
// Create a CSrvReg for forwarding
}
}
// Write the service store in the standard format to the output
// stream.
throws IOException, ServiceLocationException {
while (recs.hasMoreElements()) {
// Compose the registration line.
// Put out the service type and naming authority if the
// URL is not a service URL.
}
// Write out line.
// Zero line buffer.
// Insert a scope attribute, if the scope isn't simply "DEFAULT".
scopes),
0);
}
// Write out the attributes.
for (i = 0; i < n; i++) {
false));
// Add the escaped values.
for (j = 0; j < m; j++) {
if (j > 0) {
}
}
}
// Zero out string buffer.
}
// End of registration.
}
}
}