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

📄 peergroupfactory.java

📁 JXTA&#8482 is a set of open, generalized peer-to-peer (P2P) protocols that allow any networked devi
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            jxta_home.mkdirs();            URI defaultHome = jxta_home.toURI();            return defaultHome;        }        return storeHome;    }    /**     * Set the location which will serve as the parent for all stored items used by JXTA.     *     * @param newHome The absolute URI location which will serve as the parent     *                for all stored items used by JXTA. Currently this must be a non-opaque URI.     *                May also be {@code null} to restore the default value.     * @deprecated Consider converting to use {@link NetPeerGroupFactory} and/or {@link WorldPeerGroupFactory}.     */    @Deprecated    public static void setStoreHome(URI newHome) {        if (null != newHome) {            // Fail if the URI is not absolute.            if (!newHome.isAbsolute()) {                throw new IllegalArgumentException("Only absolute URIs accepted for store home location.");            }            // Fail if the URI is Opaque.            if (newHome.isOpaque()) {                throw new IllegalArgumentException("Only hierarchical URIs accepted for store home location.");            }            // Add a trailing slash if necessary.             if (!newHome.toString().endsWith("/")) {                newHome = URI.create(newHome.toString() + "/");            }        }        storeHome = newHome;    }    /**     * Static Method to create a new peer group instance.     * <p/>     * After being created the init() method needs to be called, and     * the startApp() method may be called, at the invoker's discretion.     *     * @return PeerGroup instance of a new PeerGroup     * @deprecated This method was previously unused and has been removed with no alternatives. (it wasn't useful)     */    @Deprecated    public static PeerGroup newPeerGroup() {        throw new UnsupportedOperationException("This feature has been removed. (sorry)");    }    /**     * Instantiates the World (Platform) Peer Group and can also optionally     * (re)configure the world peer group before instantiation using the     * configurator specified via {@link #setConfiguratorClass(Class)}.     * <p/>     * Only one instance of  the World Peer Group may be created within the     * context of the {@code PeerGroupFactory}'s class loader. Invoking this     * method amounts to creating an instance of JXTA.     * <p/>     * The {@link PeerGroup#init(PeerGroup,ID,Advertisement)} method is     * called automatically. The {@link PeerGroup#startApp(String[])} method     * is left for the invoker to call if appropriate.     *     * @return PeerGroup The World Peer Group instance.     * @throws JxtaError Thrown for all checked Exceptions which occur during     *                   construction of the World Peer Group.     * @deprecated Consider converting to use {@link WorldPeerGroupFactory#WorldPeerGroupFactory()}.     */    @Deprecated    public static PeerGroup newPlatform() {        Class c = PeerGroupFactory.getConfiguratorClass();        if (null == c) {            c = NULL_CONFIGURATOR;        }        Configurator configurator;        try {            Constructor config_constructor = c.getConstructor(URI.class);            configurator = (Configurator) config_constructor.newInstance(getStoreHome());        } catch (InvocationTargetException ie) {            LOG.log(Level.SEVERE, "Uninstantiatable configurator: " + c, ie);            throw new JxtaError("Uninstantiatable configurator: " + c, ie);        } catch (NoSuchMethodException ie) {            LOG.log(Level.SEVERE, "Uninstantiatable configurator: " + c, ie);            throw new JxtaError("Uninstantiatable configurator: " + c, ie);        } catch (InstantiationException ie) {            LOG.log(Level.SEVERE, "Uninstantiatable configurator: " + c, ie);            throw new JxtaError("Uninstantiatable configurator: " + c, ie);        } catch (IllegalAccessException iae) {            LOG.log(Level.SEVERE, "can\'t instantiate configurator: " + c, iae);            throw new JxtaError("Can't instantiate configurator: " + c, iae);        } catch (ClassCastException cce) {            LOG.log(Level.SEVERE, "Not a Configurator :" + c, cce);            throw new JxtaError("Not a Configurator :" + c, cce);        }        ConfigParams pc;        try {            pc = configurator.getConfigParams();        } catch (ConfiguratorException cce) {            LOG.log(Level.SEVERE, "Could not retrieve configuration", cce);            throw new JxtaError("Could not retrieve configuration", cce);        }        try {            WorldPeerGroupFactory wpgf;            if (null == worldGroupClass) {                wpgf = new WorldPeerGroupFactory(pc, getStoreHome());            } else {                wpgf = new WorldPeerGroupFactory(worldGroupClass, pc, getStoreHome());            }            configurator.setConfigParams(pc);            configurator.save();            // Forget about the configurator            configurator = null;            return wpgf.getInterface();        } catch (RuntimeException e) {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "newPlatform failed", e);            }            // rethrow            throw e;        } catch (Exception e) {            // should be all other checked exceptions            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "newPlatform failed", e);            }            // Simplify exception scheme for caller: any sort of problem wrapped            // in a PeerGroupException.            throw new JxtaError("newPlatform failed", e);        } catch (Error e) {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "newPlatform failed", e);            }            // rethrow            throw e;        }    }    /**     * Instantiates the net peer group using the provided parent peer group.     *     * @param ppg The parent group.     * @return PeerGroup The default netPeerGroup     * @throws PeerGroupException For failures in constructing the Net Peer Group.     * @deprecated Consider converting to use {@link NetPeerGroupFactory#NetPeerGroupFactory(PeerGroup,ID,String,XMLElement)}.     */    @Deprecated    public static PeerGroup newNetPeerGroup(PeerGroup ppg) throws PeerGroupException {        try {            NetPeerGroupFactory npgf;            NetPeerGroupFactory.NetGroupTunables tunables;            if (null == netPGID) {                // Determine net peer group configuration parameters if they                // have not already been set.                tunables = new NetPeerGroupFactory.NetGroupTunables(ResourceBundle.getBundle("net.jxta.impl.config")                        ,                        new NetPeerGroupFactory.NetGroupTunables());                // load overides from "${JXTA_HOME}config.properties".                URI configPropertiesLocation = getStoreHome().resolve("config.properties");                try {                    URLConnection configProperties = configPropertiesLocation.toURL().openConnection();                    ResourceBundle rsrcs = new PropertyResourceBundle(configProperties.getInputStream());                    tunables = new NetPeerGroupFactory.NetGroupTunables(rsrcs, tunables);                    if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {                        LOG.fine("Loaded defaults from " + rsrcs);                    }                } catch (MissingResourceException ignored) {                    ;                } catch (IOException ignored) {                    ;                } catch (Exception ignored) {                    ;                }            } else {                tunables = new NetPeerGroupFactory.NetGroupTunables(netPGID, netPGName                        ,                        (XMLDocument) StructuredDocumentFactory.newStructuredDocument(MimeMediaType.XMLUTF8, "desc", netPGDesc));            }            npgf = new NetPeerGroupFactory(ppg, tunables.id, tunables.name, tunables.desc);            PeerGroup newPg = npgf.getInterface();            return newPg;        } catch (PeerGroupException failed) {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "newNetPeerGroup failed", failed);            }            // rethrow            throw failed;        } catch (RuntimeException e) {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "newNetPeerGroup failed", e);            }            // rethrow            throw e;        } catch (Exception e) {            // should be all other checked exceptions            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "newNetPeerGroup failed", e);            }            // Simplify exception scheme for caller: any sort of problem wrapped            // in a PeerGroupException.            throw new PeerGroupException("newNetPeerGroup failed", e);        } catch (Error e) {            if (Logging.SHOW_SEVERE && LOG.isLoggable(Level.SEVERE)) {                LOG.log(Level.SEVERE, "newNetPeerGroup failed", e);            }            // rethrow            throw e;        }    }    /**     * Instantiates the World Peer Group and then instantiates the Net Peer     * Group. This simplifies the method by which applications can start JXTA.     *     * @return The newly instantiated Net Peer Group.     * @deprecated Consider converting to use {@link NetPeerGroupFactory#NetPeerGroupFactory()}     *             or preferably one of the other {@code NetPeerGroupFactory} constructors.     */    @Deprecated    public static PeerGroup newNetPeerGroup() throws PeerGroupException {        // get/create the World Peer Group.        PeerGroup wpg = getWorldPeerGroup();        try {            PeerGroup npg = newNetPeerGroup(wpg);            return npg;        } finally {            wpg.unref();        }    }    /**     * Retrieves or constructs a new World Peer Group instance suitable for     * use as the parent for Net Peer Group instances. This implementation     * makes an important trade-off worth noting; it will use an existing     * world peer group instance if available and ignore any changes which have     * been made to the static configuration methods provided by this class.     *     * @return The World Peer Group.     * @throws PeerGroupException For failures in recovering the World Peer Group.     */    private static PeerGroup getWorldPeerGroup() throws PeerGroupException {        synchronized (PeerGroup.globalRegistry) {            PeerGroup result = PeerGroup.globalRegistry.lookupInstance(PeerGroupID.worldPeerGroupID);            if (null != result) {                return result;            }            return newPlatform();        }    }}

⌨️ 快捷键说明

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