📄 profile.java
字号:
/* * 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> * <?xml version="1.0" encoding="utf-8" standalone="no"?> * * <!-- * <!DOCTYPE xsd:schema SYSTEM "http://www.w3c.org/2001/XMLSchema.dtd"> * --> * * <xsd:schema xmlns:jxta="http://www.jxta.org/net/jxta/ext/config" * xmlns:xsd="http://www.w3c.org/2001/XMLSchema.dtd"> * * <xsd:annotation> * <xsd:documentation xml:lang="en"> * JXTA Configuration * * see http://www.jxta.org for more info. * </xsd:documentation> * </xsd:annotation> * * <xsd:complexType name="jxta"> * <xsd:sequence> * <xsd:element name="peer" type="jxta:Peer" minOccurs="1" maxOccurs="1"/> * <xsd:element name="network" type="jxta:Network" minOccurs="1" * maxOccurs="1"/> * <xsd:element name="transport" type="jxta:Transport" minOccurs="1" * maxOccurs="1"/> * <xsd:element name="service" type="jxta:Service" minOccurs="1" * maxOccurs="1"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:complexType name="Peer"> * <xsd:attribute name="name" type="xsd:string" use="optional"/> * <xsd:attribute name="id" type="jxta:PeerID" use="optional"/> * <xsd:attribute name="descriptor" type="xsd:string" use="optional"/> * <xsd:attribute name="home" type="xsd:anyURI" use="optional" * default="file://${user.home}/.jxta"/> * <xsd:attribute name="trace" type="jxta:Trace" use="optional" * default="user default"/> * <xsd:sequence> * <xsd:element name="description" type="jxta:Description" minOccurs="0" * maxOccurs="unbounded"/> * <xsd:element name="security" type="jxta:Security" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="rootCert" type="jxta:RootCert" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="proxy" type="jxta:ProxyAddress" minOccurs="0" * maxOccurs="1"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:complexType name="Network"> * <xsd:attribute name="id" type="xsd:string" use="xxx"/> * <xsd:attribute name="name" type="xsd:string" use="optional"/> * <xsd:attribute name="description" type="xsd:string" use="optional"/> * <xsd:sequence> * <xsd:element name="rendezVous" type="jxta:RendezVous" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="relays" type="jxta:Relays" minOccurs="0" maxOccurs="1"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:complexType name="Transport"> * <xsd:sequence> * <xsd:element name="tcp" type="Tcp" minOccurs="0" maxOccurs="unbounded"/> * <xsd:element name="http" type="Http" minOccurs="0" maxOccurs="unbounded"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:complexType name="Service"> * <xsd:sequence> * <xsd:element name="rendezVous" type="jxta:RendezVousService" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="relay" type="jxta:RelayService" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="endpoint" type="jxta:EndpointService" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="proxy" type="jxta:ProxyService" minOccurs="0" * maxOccurs="1"/> * </xsd:sequence> * * <xsd:complextType name="Configuration"> * <xsd:sequence> * <xsd:element name="optimizer" type="jxta:Optimizer" minOccurs="0" * maxOccurs="unbounded"/> * <xsd:element name="validator" type="jxta:Validator" minOccurs="0" * maxOccurs="unbounded"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:simpleType name="Trace"> * <xsd:restriction base="xsd:string"> * <xsd:enumeration value="error"/> * <xsd:enumeration value="warn"/> * <xsd:enumeration value="info"/> * <xsd:enumeration value="debug"/> * <xsd:enumeration value="user default"/> * </xsd:restriction> * </xsd:simpleType> * * <xsd:complextType name="Description"> * <xsd:all> * </xsd:all> * </xsd:complextType> * * <xsd:complexType name="Security"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="true"/> * <xsd:attribute name="principal" type="xsd:string" use="required"/> * </xsd:complexType> * * <xsd:complexType name="RootCert"> * <xsd:simpleContext> * <xsd:extension base="xsd:string"> * <xsd:attribute name="address" type="xsd:anyURI" use="optional"/> * </xsd:extension> * </xsd:simpleContext> * </xsd:complexType> * * <xsd:complexType name="ProxyAddress"> * <xsd:simpleContent> * <xsd:extension base="xsd:anyURI"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="false"/> * </xsd:extension> * </xsd:simpleContent> * </xsd:complexType> * * <xsd:complexType name="RendezVous"> * <xsd:attribute name="bootstrap" type="xsd:anyURI" use="optional"/> * <xsd:attribute name="discovery" type="xsd:boolean" use="optional" * default="true"/> * <xsd:element name="address" type="jxta:Address" minOccurs="0" * maxOccurs="unbounded" default="://"/> * </xsd:complexType> * * <xsd:complexType name="Relays"> * <xsd:attribute name="bootstrap" type="xsd:anyURI" use="optional"/> * <xsd:attribute name="discovery" type="xsd:boolean" use="optional" * default="true"/> * <xsd:element name="address" type="jxta:Address" minOccurs="0" * maxOccurs="unbounded" default="//:"/> * </xsd:complexType> * * <xsd:element name="Address" type="xsd:anyURI" * <!-- * <xsd:attribute name="isDirect" type="xsd:boolean" use="optional" * default="true"/> * --> * </> * * <xsd:complexType name="Tcp"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="true"/> * <xsd:attribute name="mode" type="xsd:boolean" use="optional" * default="auto"/> * <xsd:sequence> * <xsd:element name="incoming" type="jxta:TransportEndpoint" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="outgoing" type="jxta:TransportEndpoint" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="TcpAddress" type="TcpAddress" minOccurs="0" * maxOccurs="unbounded"/> * <xsd:element name="publicAddress" type="jxta:PublicAddress" minOccurs="0" * maxOccurs="unbounded" default="http://:"/> * <xsd:element name="proxy" type="jxta:ProxyAddress" minOccurs="0" * maxOccurs="1"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:complexType name="Http"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="true"/> * <xsd:sequence> * <xsd:element name="incoming" type="jxta:TransportEndpoint" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="outgoing" type="jxta:TransportEndpoint" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="address" type="jxta:TransportAddress" minOccurs="0" * maxOccurs="unbounded" default="http://:"/> * <xsd:element name="publicAddress" type="jxta:PublicAddress" minOccurs="0" * maxOccurs="unbounded" default="http://:"/> * <xsd:element name="proxy" type="jxta:ProxyAddress" minOccurs="0" * maxOccurs="1"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:complexType name="TransportEndpoint"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="false"/> * </xsd:complexType> * * <xsd:complexType name="TcpAddress"> * <xsd:simpleContent> * <xsd:extension bae="xsd:anyURI"> * <xsd:attribute name="range" type="xsd:integer"> * <xsd:restrictive> * <xsd:minInclusive value="0"/> * <xsd:maxInclusive value="65535"/> * </xsd:restrictive> * </xsd:attribute> * <xsd:sequence> * <xsd:element name="multicast" type="jxta:MulticastAddress" * minOccurs="0" maxOccurs="unbounded"/> * </xsd:sequence> * </xsd:extension> * </xsd:simpleContent> * </xsd:complexType> * * <xsd:complexType name="TransportAddress"> * <xsd:simpleContent> * <xsd:extension base="xsd:anyURI"> * <xsd:attribute name="range" type="xsd:integer"> * <xsd:restrictive> * <xsd:minInclusive value="0"/> * <xsd:maxInclusive value="65535"/> * </xsd:restrictive> * </xsd:attribute> * </xsd:extension> * </xsd:simpleContent> * </xsd:complexType> * * <xsd:complextType name="MulticastAddress"> * <xsd:simpleContent> * <xsd:extension base="xsd:anyURI"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="true"/> * <xsd:attribute name="size" type="xsd:nonNegativeInteger" use="optional" * default="16384"/> * </xsd:extension> * </xsd:simpleContent> * </xsd:complextType> * * <xsd:complexType name="PublicAddress"> * <xsd:attribute name="exclusive" type="xsd:boolean" use="optional" * default="false"/> * </xsd:complexType> * * <xsd:complexType name="RendezVousService"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="false"/> * <xsd:attribute name="mode" type="xsd:boolean" use="optional" * default="client"/> * <xsd:sequence> * <xsd:element name="autoStart" type="jxta:AutoStart" minOccurs="0" * maxOccurs="1" default="0"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:complexType name="RelayService"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="false"/> * <xsd:attribute name="queueSize" type="xsd:nonNegativeInterger" * use="optional" default="100"/> * <xsd:sequence> * <xsd:element name="incoming" type="jxta:ServiceEndpoint" minOccurs="0" * maxOccurs="1"/> * <xsd:element name="outgoing" type="jxta:ServiceEndpoint" minOccurs="0" * maxOccurs="1"/> * </xsd:sequence> * </xsd:complexType> * * <xsd:complexType name="EndpointService"> * <xsd:attribute name="queueSize" type="xsd:positiveInteger" use="optional" * default="20"/> * </xsd:complexType> * * <xsd:complexType name="ProxyService"> * <xsd:simpleContent> * <xsd:extension base="xsd:anyURI"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="false"/> * </xsd:extension> * </xsd:simpleContent> * </xsd:complexType> * * <xsd:element name="AutoStart"> * <xsd:simpleContent> * <xsd:extension base="nonNegativeInteger"> * <xsd:attribute name="enabled" type="xsd:boolean" use="optional" * default="false"/> *
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -