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

📄 peergroupfactory.java

📁 JXTA&#8482 is a set of open, generalized peer-to-peer (P2P) protocols that allow any networked devi
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 2001-2007 Sun Microsystems, Inc.  All rights reserved. *   *  The Sun Project JXTA(TM) Software License *   *  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 Sun Microsystems, Inc. for JXTA(TM) technology."  *     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 SUN  *  MICROSYSTEMS 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. *   *  JXTA is a registered trademark of Sun Microsystems, Inc. in the United  *  States and other countries. *   *  Please see the license information page at : *  <http://www.jxta.org/project/www/license.html> for instructions on use of  *  the license in source files. *   *  ==================================================================== *   *  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.  */package net.jxta.peergroup;import net.jxta.document.Advertisement;import net.jxta.document.MimeMediaType;import net.jxta.document.StructuredDocumentFactory;import net.jxta.document.XMLDocument;import net.jxta.document.XMLElement;import net.jxta.exception.ConfiguratorException;import net.jxta.exception.JxtaError;import net.jxta.exception.PeerGroupException;import net.jxta.id.ID;import net.jxta.logging.Logging;import net.jxta.protocol.ConfigParams;import java.io.File;import java.io.IOException;import java.lang.reflect.Constructor;import java.lang.reflect.InvocationTargetException;import java.net.URI;import java.net.URLConnection;import java.util.MissingResourceException;import java.util.PropertyResourceBundle;import java.util.ResourceBundle;import java.util.logging.Level;import java.util.logging.Logger;/** * A factory for instantiating the JXTA core peer groups. * <p/> * JXTA comes with two peergroup implementations: * <p/> * <dl> * <DT><strong>Platform</strong></DT> * <DD>Implements the world peer group. Every peer starts by instantiating this * peer group and then other peer groups are instantiated as needed. The World * Peer Group's ID is invariant. * <p/> * The world peer group provides the minimum core services needed to find * and instantiate other groups on a peer. The <strong>Platform</strong> * implementation will assign a new ID to the peer, if it does not already have * one.</DD> * <p/> * <DT><strong>StdPeergroup</strong></DT> * <DD>This is currently used to implement all other kinds of peer groups. * The first such peer group that it is instantiated after starting is known as * <em>The Net Peer Group</em>. When the <strong>Platform</strong> starts it may * optionally search for <em>The Net Peer Group</em> on the local network and, * if found, instantiate it. Otherwise a default built-in configuration of * <em>The Net Peer Group</em> is instantiated. * <p/> * A non-default configuration of <em>The Net Peer Group</em> may be set-up * by the administrator in charge of the network domain inside which the peer * is starting. <em>The Net Peer Group</em> is discovered via the Discovery * protocol. Many such groups may be configured by an administrator.<br> * <p/> * <strong>StdPeergroup</strong> may also be used to implement User-defined * peer groups--Users can create new peer groups which use their own set of * customized services.</DD> * </dl> * * @see net.jxta.peergroup.PeerGroup * @deprecated This factory has been deprecated in favour of {@link WorldPeerGroupFactory} *             and {@link NetPeerGroupFactory}. See the deprecations for the individual *             methods for the specific replacements/alternatives provided by the new *             factory classes. */@Deprecatedpublic final class PeerGroupFactory {    /**     * Logger     */    private final static transient Logger LOG = Logger.getLogger(PeerGroupFactory.class.getName());    /**     * Constant for specifying no configurator. This configurator provides no     * configuration actions but does ensure that a valid configuration exists     * at the specified location.     */    public final static Class NULL_CONFIGURATOR = net.jxta.impl.peergroup.NullConfigurator.class;    /**     * Constant for specifying the default configurator. Currently this is the     * familiar AWT-based dialogue but in future is likely to become the     * UI-less automatic configurator.     */    public final static Class DEFAULT_CONFIGURATOR = net.jxta.impl.peergroup.DefaultConfigurator.class;    /**     * The class which will be instantiated as the World Peer Group.     */    private static Class worldGroupClass = null;    /**     * The ID of the network peer group.     */    private static PeerGroupID netPGID = null;    /**     * The name of the network peer group.     */    private static String netPGName = null;    /**     * The description of the network peer group.     */    private static String netPGDesc = null;    /**     * The class which will be instantiated to configure the World Peer     * Group.     */    private static Class configurator = DEFAULT_CONFIGURATOR;    /**     * the location which will serve as the parent for all stored items used     * by JXTA.     */    private static URI storeHome = null;    /**     * Static Method to initialize the world peer group class.     *     * @param c The Class which will be instantiated for the World Peer Group     * @deprecated Consider converting to use {@link WorldPeerGroupFactory#WorldPeerGroupFactory(Class,ConfigParams,URI)}.     */    @Deprecated    public static void setPlatformClass(Class c) {        worldGroupClass = c;    }    /**     * Static Method to initialize the std peer group class.     *     * @param c The Class which will be instantiated for most peer groups.     * @deprecated This method previously had no effect and has been removed with no alternatives.     */    @Deprecated    public static void setStdPeerGroupClass(Class c) {        throw new UnsupportedOperationException("This feature has been removed. (sorry)");    }    /**     * Sets the description which will be used for new net peer group instances.     *     * @param desc The description which will be used for new net peer group instances.     * @deprecated Consider converting to use {@link NetPeerGroupFactory#NetPeerGroupFactory(ConfigParams,URI,ID,String,XMLElement)}     *             or {@link NetPeerGroupFactory#NetPeerGroupFactory(PeerGroup,ID,String,XMLElement)}.     */    @Deprecated    public static void setNetPGDesc(String desc) {        netPGDesc = desc;    }    /**     * Sets the name which will be used for new net peer group instances.     *     * @param name The name which will be used for new net peer group instances.     * @deprecated Consider converting to use {@link NetPeerGroupFactory#NetPeerGroupFactory(ConfigParams,URI,ID,String,XMLElement)}     *             or {@link NetPeerGroupFactory#NetPeerGroupFactory(PeerGroup,ID,String,XMLElement)}.     */    @Deprecated    public static void setNetPGName(String name) {        netPGName = name;    }    /**     * Sets the ID which will be used for new net peer group instances.     *     * @param id The ID which will be used for new net peer group instances.     * @deprecated Consider converting to use {@link NetPeerGroupFactory#NetPeerGroupFactory(ConfigParams,URI,ID,String,XMLElement)}     *             or {@link NetPeerGroupFactory#NetPeerGroupFactory(PeerGroup,ID,String,XMLElement)}.     */    @Deprecated    public static void setNetPGID(PeerGroupID id) {        netPGID = id;    }    /**     * Get the optional configurator class for the world peer group.     *     * @return Class configurator class     * @deprecated Consider converting to use {@link NetPeerGroupFactory}.     */    @Deprecated    public static Class getConfiguratorClass() {        return configurator;    }    /**     * Set the optional configurator class for the World Peer Group. If present     * an instance of this class will be used to generate/update the     * configuration parameters for the World Peer Group whenever     * {@code newPlatform()} is invoked.     * <p/>     * All configuration actions for the World Peer Group may be completely     * disabled by specify {@code null} as the configurator class. The default     * configuration class is always initialized to {@code DEFAULT_CONFIGURATOR}.     *     * @param c The {@code Class} to use as a configurator for the World Peer     *          Group.     * @deprecated Consider converting to use {@link NetPeerGroupFactory} and/or {@link WorldPeerGroupFactory}.     */    @Deprecated    public static void setConfiguratorClass(Class c) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Setting configurator class to : " + c);        }        configurator = c;    }    /**     * Returns the location which will serve as the parent for all stored items     * used by JXTA. This method is intended for use by PeerGroup implementations     * and is not intended for use by applications. Applications and services     * should use the PeerGroup method with the same name.     *     * @return The location which will serve as the parent for all stored     *         items used by JXTA.     * @see PeerGroup#getStoreHome()     * @deprecated Consider converting to use {@link NetPeerGroupFactory} and/or {@link WorldPeerGroupFactory}.     */    @Deprecated    public static URI getStoreHome() {        if (null == storeHome) {            // Establish the default store location via long established hackery.            String jxta_path = System.getProperty("JXTA_HOME", ".jxta/");            File jxta_home = new File(jxta_path);

⌨️ 快捷键说明

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