⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 profile.java

📁 jxta_src_2.41b jxta 2.41b 最新版源码 from www.jxta.org
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* *  Copyright (c) 2001 Sun Microsystems, Inc.  All rights *  reserved. * *  Redistribution and use in source and binary forms, with or without *  modification, are permitted provided that the following conditions *  are met: * *  1. Redistributions of source code must retain the above copyright *  notice, this list of conditions and the following disclaimer. * *  2. Redistributions in binary form must reproduce the above copyright *  notice, this list of conditions and the following disclaimer in *  the documentation and/or other materials provided with the *  distribution. * *  3. The end-user documentation included with the redistribution, *  if any, must include the following acknowledgment: *  "This product includes software developed by the *  Sun Microsystems, Inc. for Project JXTA." *  Alternately, this acknowledgment may appear in the software itself, *  if and wherever such third-party acknowledgments normally appear. * *  4. The names "Sun", "Sun Microsystems, Inc.", "JXTA" and "Project JXTA" *  must not be used to endorse or promote products derived from this *  software without prior written permission. For written *  permission, please contact Project JXTA at http://www.jxta.org. * *  5. Products derived from this software may not be called "JXTA", *  nor may "JXTA" appear in their name, without prior written *  permission of Sun. * *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *  DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF *  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT *  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF *  SUCH DAMAGE. *  ==================================================================== * *  This software consists of voluntary contributions made by many *  individuals on behalf of Project JXTA.  For more *  information on Project JXTA, please see *  <http://www.jxta.org/>. * *  This license is based on the BSD license adopted by the Apache Foundation. * *  $Id: Profile.java,v 1.32 2006/06/08 04:31:08 gonzo Exp $ */package net.jxta.ext.config;import java.io.IOException;import java.net.MalformedURLException;import java.net.URI;import java.net.URL;import java.util.HashMap;import java.util.Iterator;import java.io.InputStream;import org.apache.log4j.Level;import org.apache.log4j.Logger;/** * Provides a means to declaratively manage {@link net.jxta.ext.config.Configurator} processes by * quantifing varying configuration classes into common domains in the form of * "profiles." * * <p>A series of profile presets exist including: * * <ul> *  <li>{@link net.jxta.ext.config.Profile#EDGE} - primarily a service consumer</li> *  <li>{@link net.jxta.ext.config.Profile#SUPER} - primarily a service provisioner</li> *  <li>{@link net.jxta.ext.config.Profile#ADHOC} - primarily useful for 0 configuration service consumers</li> *  <li>{@link net.jxta.ext.config.Profile#LOCAL} - primarily useful for development</li> *  <li>{@link net.jxta.ext.config.Profile#DEFAULT} - equivalent to {@link net.jxta.ext.config.Profile#EDGE}</li> * </ul> * * <p>Most of the included profiles include subtle variations. Further, one can * construct entirely new profiles that support specific application requirements. * * <p>All addresses are of the form {@link java.net.URI}. Addresses that do not * specify scheme information will be defaulted accordingly to the respective * context. Partial {@link java.net.URI} addresses will be templated with the * respective context such as the local IP address, etc. *  * <p>At times it is desirable to specify non-static data within a Profile. As * such, profiles support <b>macros</b> that take the form <b>${macro-id}</b> * where the value "macro-id" is used to specify a distinct system property, the * results of which is evaluated as follows: * * <pre> *   String macro = System.getProperty("macro-id"); * </pre> * * <p>In addition to supporting any application specified system property the * following macros are built in as they are often required: * * <table cellpadding="2" cellspacing="2" border="0"> * <tr> * <td>host.any</td> * <td>represents the IPv4 or IPv6 "Any/All" address (e.g. 0.0.0.0, ::)</td> * </tr> * <tr> * <td>host.local</td> * <td>represents the IPV4 or IPv6 "loopback" address (e.g. 127.0.0.1, ::1)</td> * </tr> * <tr> * <td>java.io.tmpdir</td> * <td>represents the default temp file path in the form of a {@link java.net.URI}</td> * </tr> * <tr> * <td>java.home</td> * <td>represents the JVM installation directory in the form of a {@link java.netURI}</td> * </tr> * <tr> * <td>user.dir</td> * <td>represents the user's current working directory in the form of a {@link java.net.URI}</td> * </tr> * <tr> * <td>user.home</td> * <td>represends the user's home directory in the form of a {@link java.net.URI}</td> * </tr> * </table> *  * <p>All fields have backing defaults enabling one to specify only the required * overrides in order to construct complete configuration profiles. *  * <p>Following is a (as of yet unvalidated) Profile DTD: *  * <pre> * &lt;?xml version="1.0" encoding="utf-8" standalone="no"?&gt; * * &lt;!-- * &lt;!DOCTYPE xsd:schema SYSTEM "http://www.w3c.org/2001/XMLSchema.dtd"&gt; * --&gt; * * &lt;xsd:schema xmlns:jxta="http://www.jxta.org/net/jxta/ext/config" *   xmlns:xsd="http://www.w3c.org/2001/XMLSchema.dtd"&gt; * *   &lt;xsd:annotation&gt; *     &lt;xsd:documentation xml:lang="en"&gt; *     JXTA Configuration * *     see http://www.jxta.org for more info. *     &lt;/xsd:documentation&gt; *   &lt;/xsd:annotation&gt; * *   &lt;xsd:complexType name="jxta"&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="peer" type="jxta:Peer" minOccurs="1" maxOccurs="1"/&gt; *       &lt;xsd:element name="network" type="jxta:Network" minOccurs="1" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="transport" type="jxta:Transport" minOccurs="1" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="service" type="jxta:Service" minOccurs="1" *         maxOccurs="1"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="Peer"&gt; *     &lt;xsd:attribute name="name" type="xsd:string" use="optional"/&gt; *     &lt;xsd:attribute name="id" type="jxta:PeerID" use="optional"/&gt; *     &lt;xsd:attribute name="descriptor" type="xsd:string" use="optional"/&gt; *     &lt;xsd:attribute name="home" type="xsd:anyURI" use="optional" *       default="file://${user.home}/.jxta"/&gt; *     &lt;xsd:attribute name="trace" type="jxta:Trace" use="optional" *       default="user default"/&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="description" type="jxta:Description" minOccurs="0" *         maxOccurs="unbounded"/&gt; *       &lt;xsd:element name="security" type="jxta:Security" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="rootCert" type="jxta:RootCert" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="proxy" type="jxta:ProxyAddress" minOccurs="0" *         maxOccurs="1"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="Network"&gt; *     &lt;xsd:attribute name="id" type="xsd:string" use="xxx"/&gt; *     &lt;xsd:attribute name="name" type="xsd:string" use="optional"/&gt; *     &lt;xsd:attribute name="description" type="xsd:string" use="optional"/&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="rendezVous" type="jxta:RendezVous" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="relays" type="jxta:Relays" minOccurs="0" maxOccurs="1"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="Transport"&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="tcp" type="Tcp" minOccurs="0" maxOccurs="unbounded"/&gt; *       &lt;xsd:element name="http" type="Http" minOccurs="0" maxOccurs="unbounded"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="Service"&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="rendezVous" type="jxta:RendezVousService" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="relay" type="jxta:RelayService" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="endpoint" type="jxta:EndpointService" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="proxy" type="jxta:ProxyService" minOccurs="0" *         maxOccurs="1"/&gt; *     &lt;/xsd:sequence&gt; * *   &lt;xsd:complextType name="Configuration"&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="optimizer" type="jxta:Optimizer" minOccurs="0" *         maxOccurs="unbounded"/&gt; *       &lt;xsd:element name="validator" type="jxta:Validator" minOccurs="0" *         maxOccurs="unbounded"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:simpleType name="Trace"&gt; *     &lt;xsd:restriction base="xsd:string"&gt; *       &lt;xsd:enumeration value="error"/&gt; *       &lt;xsd:enumeration value="warn"/&gt; *       &lt;xsd:enumeration value="info"/&gt; *       &lt;xsd:enumeration value="debug"/&gt; *       &lt;xsd:enumeration value="user default"/&gt; *     &lt;/xsd:restriction&gt; *   &lt;/xsd:simpleType&gt; * *   &lt;xsd:complextType name="Description"&gt; *     &lt;xsd:all&gt; *     &lt;/xsd:all&gt; *   &lt;/xsd:complextType&gt; * *   &lt;xsd:complexType name="Security"&gt; *     &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *       default="true"/&gt; *     &lt;xsd:attribute name="principal" type="xsd:string" use="required"/&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="RootCert"&gt; *     &lt;xsd:simpleContext&gt; *       &lt;xsd:extension base="xsd:string"&gt; *         &lt;xsd:attribute name="address" type="xsd:anyURI" use="optional"/&gt; *       &lt;/xsd:extension&gt; *     &lt;/xsd:simpleContext&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="ProxyAddress"&gt; *     &lt;xsd:simpleContent&gt; *       &lt;xsd:extension base="xsd:anyURI"&gt; *         &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *           default="false"/&gt; *       &lt;/xsd:extension&gt; *     &lt;/xsd:simpleContent&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="RendezVous"&gt; *     &lt;xsd:attribute name="bootstrap" type="xsd:anyURI" use="optional"/&gt; *     &lt;xsd:attribute name="discovery" type="xsd:boolean" use="optional" *       default="true"/&gt; *     &lt;xsd:element name="address" type="jxta:Address" minOccurs="0" *       maxOccurs="unbounded" default="://"/&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="Relays"&gt; *     &lt;xsd:attribute name="bootstrap" type="xsd:anyURI" use="optional"/&gt; *     &lt;xsd:attribute name="discovery" type="xsd:boolean" use="optional" *       default="true"/&gt; *     &lt;xsd:element name="address" type="jxta:Address" minOccurs="0" *       maxOccurs="unbounded" default="//:"/&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:element name="Address" type="xsd:anyURI" *   <!-- *     &lt;xsd:attribute name="isDirect" type="xsd:boolean" use="optional" *       default="true"/&gt; *   --> *   &lt;/&gt; * *   &lt;xsd:complexType name="Tcp"&gt; *     &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *       default="true"/&gt; *     &lt;xsd:attribute name="mode" type="xsd:boolean" use="optional" *       default="auto"/&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="incoming" type="jxta:TransportEndpoint" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="outgoing" type="jxta:TransportEndpoint" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="TcpAddress" type="TcpAddress" minOccurs="0" *         maxOccurs="unbounded"/&gt; *       &lt;xsd:element name="publicAddress" type="jxta:PublicAddress" minOccurs="0" *         maxOccurs="unbounded" default="http://:"/&gt; *       &lt;xsd:element name="proxy" type="jxta:ProxyAddress" minOccurs="0" *         maxOccurs="1"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="Http"&gt; *     &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *       default="true"/&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="incoming" type="jxta:TransportEndpoint" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="outgoing" type="jxta:TransportEndpoint" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="address" type="jxta:TransportAddress" minOccurs="0" *         maxOccurs="unbounded" default="http://:"/&gt; *       &lt;xsd:element name="publicAddress" type="jxta:PublicAddress" minOccurs="0" *         maxOccurs="unbounded" default="http://:"/&gt; *       &lt;xsd:element name="proxy" type="jxta:ProxyAddress" minOccurs="0" *         maxOccurs="1"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="TransportEndpoint"&gt; *     &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *       default="false"/&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="TcpAddress"&gt; *       &lt;xsd:simpleContent&gt; *       &lt;xsd:extension bae="xsd:anyURI"&gt; *         &lt;xsd:attribute name="range" type="xsd:integer"&gt; *           &lt;xsd:restrictive&gt; *             &lt;xsd:minInclusive value="0"/&gt; *             &lt;xsd:maxInclusive value="65535"/&gt; *           &lt;/xsd:restrictive&gt; *         &lt;/xsd:attribute&gt; *         &lt;xsd:sequence&gt; *           &lt;xsd:element name="multicast" type="jxta:MulticastAddress" *             minOccurs="0" maxOccurs="unbounded"/&gt; *         &lt;/xsd:sequence&gt; *       &lt;/xsd:extension&gt; *     &lt;/xsd:simpleContent&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="TransportAddress"&gt; *     &lt;xsd:simpleContent&gt; *       &lt;xsd:extension base="xsd:anyURI"&gt; *         &lt;xsd:attribute name="range" type="xsd:integer"&gt; *           &lt;xsd:restrictive&gt; *             &lt;xsd:minInclusive value="0"/&gt; *             &lt;xsd:maxInclusive value="65535"/&gt; *           &lt;/xsd:restrictive&gt; *         &lt;/xsd:attribute&gt; *       &lt;/xsd:extension&gt; *     &lt;/xsd:simpleContent&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complextType name="MulticastAddress"&gt; *     &lt;xsd:simpleContent&gt; *       &lt;xsd:extension base="xsd:anyURI"&gt; *         &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *           default="true"/&gt; *         &lt;xsd:attribute name="size" type="xsd:nonNegativeInteger" use="optional" *           default="16384"/&gt; *         &lt;/xsd:extension&gt; *       &lt;/xsd:simpleContent&gt; *   &lt;/xsd:complextType&gt; * *   &lt;xsd:complexType name="PublicAddress"&gt; *     &lt;xsd:attribute name="exclusive" type="xsd:boolean" use="optional" *       default="false"/&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="RendezVousService"&gt; *     &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *       default="false"/&gt; *     &lt;xsd:attribute name="mode" type="xsd:boolean" use="optional" *       default="client"/&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="autoStart" type="jxta:AutoStart" minOccurs="0" *         maxOccurs="1" default="0"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="RelayService"&gt; *     &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *       default="false"/&gt; *     &lt;xsd:attribute name="queueSize" type="xsd:nonNegativeInterger" *       use="optional" default="100"/&gt; *     &lt;xsd:sequence&gt; *       &lt;xsd:element name="incoming" type="jxta:ServiceEndpoint" minOccurs="0" *         maxOccurs="1"/&gt; *       &lt;xsd:element name="outgoing" type="jxta:ServiceEndpoint" minOccurs="0" *         maxOccurs="1"/&gt; *     &lt;/xsd:sequence&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="EndpointService"&gt; *     &lt;xsd:attribute name="queueSize" type="xsd:positiveInteger" use="optional" *       default="20"/&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:complexType name="ProxyService"&gt; *     &lt;xsd:simpleContent&gt; *       &lt;xsd:extension base="xsd:anyURI"&gt; *        &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *          default="false"/&gt; *       &lt;/xsd:extension&gt; *     &lt;/xsd:simpleContent&gt; *   &lt;/xsd:complexType&gt; * *   &lt;xsd:element name="AutoStart"&gt; *     &lt;xsd:simpleContent&gt; *       &lt;xsd:extension base="nonNegativeInteger"&gt; *         &lt;xsd:attribute name="enabled" type="xsd:boolean" use="optional" *           default="false"/&gt; *

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -