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

📄 peergroupfactory.java

📁 jxta_src_2.41b jxta 2.41b 最新版源码 from www.jxta.org
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* * 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 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. * ==================================================================== * * 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: PeerGroupFactory.java,v 1.58 2006/07/06 19:49:32 bondolo Exp $ */package net.jxta.peergroup;import java.lang.reflect.Constructor;import java.io.File;import java.net.URI;import java.net.URLConnection;import java.util.ResourceBundle;import java.util.PropertyResourceBundle;import java.io.IOException;import java.lang.reflect.InvocationTargetException;import java.util.MissingResourceException;import org.apache.log4j.Logger;import org.apache.log4j.Level;import net.jxta.document.MimeMediaType;import net.jxta.document.StructuredDocumentFactory;import net.jxta.document.XMLDocument;import net.jxta.document.XMLElement;import net.jxta.peergroup.Configurator;import net.jxta.protocol.ConfigParams;import net.jxta.exception.ConfiguratorException;import net.jxta.exception.PeerGroupException;import net.jxta.exception.JxtaError;/** * A factory for instantiating the JXTA core peer groups. * * <p/>JXTA comes with two peergroup implementations: * * <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> * * <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> * *  @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. * *  @see net.jxta.peergroup.PeerGroup */public final class PeerGroupFactory {        /**     *  Log4J 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.     *     *  @deprecated Consider converting to use {@link WorldPeerGroupFactory#WorldPeerGroupFactory(Class,ConfigParams,URI)}.     *     *  @param c The Class which will be instantiated for the World Peer Group     **/    public static void setPlatformClass(Class c) {        worldGroupClass = c;    }        /**     *  Static Method to initialize the std peer group class.     *     *  @deprecated This method previously had no effect and has been removed with no alternatives.     *     *  @param c The Class which will be instantiated for most peer groups.     **/    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.     *     *  @deprecated Consider converting to use {@link NetPeerGroupFactory#NetPeerGroupFactory(ConfigParams,URI,ID,String,XMLElement)}     *  or {@link NetPeerGroupFactory#NetPeerGroupFactory(PeerGroup,ID,String,XMLElement)}.     *     *  @param desc The description which will be used for new net peer group instances.     **/    public static void setNetPGDesc(String desc) {        netPGDesc = desc;    }        /**     *  Sets 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)}.     *     *  @param name The name which will be used for new net peer group instances.     **/    public static void setNetPGName(String name) {        netPGName = name;    }        /**     *  Sets 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)}.     *     *  @param id The ID which will be used for new net peer group instances.     **/    public static void setNetPGID(PeerGroupID id) {        netPGID = id;    }        /**     *  Get the optional configurator class for the world peer group.     *     *  @deprecated Consider converting to use {@link NetPeerGroupFactory}.     *     *  @return Class configurator class     **/    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}.     *     * @deprecated Consider converting to use {@link NetPeerGroupFactory} and/or {@link WorldPeerGroupFactory}.     *     * @param c The {@code Class} to use as a configurator for the World Peer     * Group.     **/    public static void setConfiguratorClass(Class c) {                if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug( "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.     *     * @deprecated Consider converting to use {@link NetPeerGroupFactory} and/or {@link WorldPeerGroupFactory}.     * @see PeerGroup#getStoreHome()     *     * @return The location which will serve as the parent for all stored     * items used by JXTA.     **/    public static URI getStoreHome() {        if( null == storeHome ) {            // Establish the default store location via long established hackery.            String jxta_path = System.getProperty( "JXTA_HOME", ".jxta/" );            

⌨️ 快捷键说明

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