2N/A/*
2N/A * CDDL HEADER START
2N/A *
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 *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
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 *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1999 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A *
2N/A */
2N/A
2N/A// URLAttributeVerifier.java: Parse a service template from a URL
2N/A// Author: James Kempf
2N/A// Created On: Mon Jun 23 11:52:04 1997
2N/A// Last Modified By: James Kempf
2N/A// Last Modified On: Thu Jun 11 13:24:03 1998
2N/A// Update Count: 22
2N/A//
2N/A
2N/Apackage com.sun.slp;
2N/A
2N/Aimport java.util.*;
2N/Aimport java.net.*;
2N/Aimport java.io.*;
2N/A
2N/A/**
2N/A * A URLAttributeVerifier object performs service template parsing from
2N/A * a URL. Most of the work is done by the superclass. This class
2N/A * takes care of opening the Reader on the URL.
2N/A *
2N/A * @author James Kempf
2N/A *
2N/A */
2N/A
2N/Aclass URLAttributeVerifier extends AttributeVerifier {
2N/A
2N/A /**
2N/A * Construct a URLAttributeVerifier for the file named in the parameter.
2N/A *
2N/A * @param url URL from which to read the template
2N/A * @exception ServiceLocationException Error code may be:
2N/A * SYSTEM_ERROR
2N/A * when the URL can't be opened or
2N/A * some other i/o error occurs.
2N/A * PARSE_ERROR
2N/A * if an error occurs during
2N/A * attribute parsing.
2N/A */
2N/A
2N/A URLAttributeVerifier(String url)
2N/A throws ServiceLocationException {
2N/A
2N/A super();
2N/A
2N/A initialize(url);
2N/A
2N/A }
2N/A
2N/A // Open a reader on the URL and initialize the attribute verifier.
2N/A
2N/A private void initialize(String urlName)
2N/A throws ServiceLocationException {
2N/A
2N/A InputStream is = null;
2N/A
2N/A try {
2N/A
2N/A // Open the URL.
2N/A
2N/A URL url = new URL(urlName);
2N/A
2N/A // Open an input stream on the URL.
2N/A
2N/A is = url.openStream();
2N/A
2N/A // Initialize the verifier, by parsing the file.
2N/A
2N/A super.initialize(new InputStreamReader(is));
2N/A
2N/A } catch (MalformedURLException ex) {
2N/A
2N/A throw
2N/A new ServiceLocationException(
2N/A ServiceLocationException.INTERNAL_SYSTEM_ERROR,
2N/A "invalid_url",
2N/A new Object[] {urlName});
2N/A
2N/A } catch (IOException ex) {
2N/A
2N/A throw
2N/A new ServiceLocationException(
2N/A ServiceLocationException.INTERNAL_SYSTEM_ERROR,
2N/A "url_ioexception",
2N/A new Object[] { urlName, ex.getMessage()});
2N/A
2N/A }
2N/A
2N/A try {
2N/A
2N/A is.close();
2N/A
2N/A } catch (IOException ex) {
2N/A
2N/A }
2N/A
2N/A }
2N/A}