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

📄 networkconfigurator.java

📁 JXTA&#8482 is a set of open, generalized peer-to-peer (P2P) protocols that allow any networked devi
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * HTTP Config Advertisement     */    protected transient HTTPAdv httpConfig;        /**     * Default HTTP transport state     */    protected transient boolean httpEnabled = true;        /**     *  Infrastructure Peer Group Configuration     */    protected transient PeerGroupConfigAdv infraPeerGroupConfig;        /**     * Creates NetworkConfigurator instance with default AD-HOC configuration     *     * @param storeHome the URI to persistent store     * @return NetworkConfigurator instance with default AD-HOC configuration     */    public static NetworkConfigurator newAdHocConfiguration(URI storeHome) {        return new NetworkConfigurator(ADHOC_NODE, storeHome);    }        /**     * Creates NetworkConfigurator instance with default Edge configuration     *     * @param storeHome the URI to persistent store     * @return NetworkConfigurator instance with default AD-HOC configuration     */    public static NetworkConfigurator newEdgeConfiguration(URI storeHome) {        return new NetworkConfigurator(EDGE_NODE, storeHome);    }        /**     * Creates NetworkConfigurator instance with default Rendezvous configuration     *     * @param storeHome the URI to persistent store     * @return NetworkConfigurator instance with default Rendezvous configuration     */    public static NetworkConfigurator newRdvConfiguration(URI storeHome) {        return new NetworkConfigurator(RDV_NODE, storeHome);    }        /**     * Creates NetworkConfigurator instance with default Relay configuration     *     * @param storeHome the URI to persistent store     * @return NetworkConfigurator instance with default Relay configuration     */    public static NetworkConfigurator newRelayConfiguration(URI storeHome) {        return new NetworkConfigurator(RELAY_NODE, storeHome);    }        /**     * Creates NetworkConfigurator instance with default Rendezvous configuration     *     * @param storeHome the URI to persistent store     * @return NetworkConfigurator instance with default Rendezvous configuration     */    public static NetworkConfigurator newRdvRelayConfiguration(URI storeHome) {        return new NetworkConfigurator(RDV_NODE | RELAY_SERVER, storeHome);    }        /**     * Creates NetworkConfigurator instance with default Proxy configuration     *     * @param storeHome the URI to persistent store     * @return NetworkConfigurator instance with defaultProxy configuration     */    public static NetworkConfigurator newProxyConfiguration(URI storeHome) {        return new NetworkConfigurator(PROXY_NODE, storeHome);    }        /**     * Creates NetworkConfigurator instance with default Rendezvous, Relay, Proxy configuration     *     * @param storeHome the URI to persistent store     * @return NetworkConfigurator instance with default Rendezvous, Relay, Proxy configuration     */    public static NetworkConfigurator newRdvRelayProxyConfiguration(URI storeHome) {        return new NetworkConfigurator(RDV_RELAY_PROXY_NODE, storeHome);    }        /**     * Creates the default NetworkConfigurator. The configuration is stored  with a default configuration mode of EDGE_NODE     */    public NetworkConfigurator() {        this(EDGE_NODE, new File(".jxta").toURI());    }        /**     * Creates a NetworkConfigurator with the default configuration of the     * specified mode. <p/>Valid modes include ADHOC_NODE, EDGE_NODE, RDV_NODE     * PROXY_NODE, RELAY_NODE, RDV_RELAY_PROXY_NODE, or any combination of     * specific configuration.<p/> e.g. RDV_NODE | HTTP_CLIENT     *     * @param mode      the new configuration mode     * @param storeHome the URI to persistent store     * @see #setMode     */    public NetworkConfigurator(int mode, URI storeHome) {        if (Logging.SHOW_FINE && LOG.isLoggable(Level.FINE)) {            LOG.fine("Creating a default configuration");        }                setStoreHome(storeHome);                httpConfig = createHttpAdv();        rdvConfig = createRdvConfigAdv();        relayConfig = createRelayConfigAdv();        proxyConfig = createProxyAdv();        tcpConfig = createTcpAdv();        infraPeerGroupConfig = createInfraConfigAdv();                setMode(mode);    }        /**     * Sets PlaformConfig Peer Description element     *     * @param description the peer description     */    public void setDescription(String description) {        this.description = description;    }        /**     * Set the current directory for configuration and cache persistent store     * <p/>(default is $CWD/.jxta)     * <p/>     * <dt>Simple example :</dt>     * <pre>     *  <code>     *   //Create an application home     *   File appHome = new File(System.getProperty("JXTA_HOME", ".cache"));     *   //Create an instance home under the application home     *   File instanceHome = new File(appHome, instanceName);     *   jxtaConfig.setHome(instanceHome);     *   </code>     * </pre>     *     * @param home the new home value     * @see #getHome     */    public void setHome(File home) {        this.storeHome = home.toURI();    }        /**     * Returns the current directory for configuration and cache persistent      * store. This is the same location as returned by {@link #getStoreHome()}     * which is more general than this method.     *     * @return Returns the current home directory     * @see #setHome     */    public File getHome() {        if( "file".equalsIgnoreCase(storeHome.getScheme())) {            return new File(storeHome);        } else {            throw new UnsupportedOperationException("Home location is not a file:// URI : " + storeHome );        }    }        /**     * Returns the location which will serve as the parent for all stored items     * used by JXTA.     *     * @return The location which will serve as the parent for all stored     *         items used by JXTA.     * @see net.jxta.peergroup.PeerGroup#getStoreHome()     */    public URI getStoreHome() {        return storeHome;    }        /**     * Sets the location which will serve as the parent for all stored items     * used by JXTA.     *     * @see net.jxta.peergroup.PeerGroup#getStoreHome()     */    public void setStoreHome(URI 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.");        }                // FIXME this should be removed when 1488 is committed        if (!"file".equalsIgnoreCase(newHome.getScheme())) {            throw new IllegalArgumentException("Only file based URI currently supported");        }                // Adds a terminating /        if (!newHome.toString().endsWith("/")) {            newHome = URI.create(newHome.toString() + "/");        }        storeHome = newHome;    }        /**     * Toggles HTTP transport state     *     * @param enabled if true, enables HTTP transport     */    public void setHttpEnabled(boolean enabled) {        this.httpEnabled = enabled;        if (!httpEnabled) {            httpConfig.setClientEnabled(false);            httpConfig.setServerEnabled(false);        }    }        /**     * Toggles the HTTP transport server (incoming) mode     *     * @param incoming toggles HTTP transport server mode     */    public void setHttpIncoming(boolean incoming) {        httpConfig.setServerEnabled(incoming);    }        /**     * Toggles the HTTP transport client (outgoing) mode     *     * @param outgoing toggles HTTP transport client mode     */    public void setHttpOutgoing(boolean outgoing) {        httpConfig.setClientEnabled(outgoing);    }        /**     * Sets the HTTP listening port (default 9901)     *     * @param port the new HTTP port value     */    public void setHttpPort(int port) {        httpConfig.setPort(port);    }        /**     * Sets the HTTP interface Address to bind the HTTP transport to     * <p/>e.g. "192.168.1.1"     *     * @param address the new address value     */    public void setHttpInterfaceAddress(String address) {        httpConfig.setInterfaceAddress(address);    }        /**     * Sets the HTTP JXTA Public Address     * e.g. "192.168.1.1:9700"     *     * @param address   the HTTP transport public address     * @param exclusive determines whether an address is advertised exclusively     */    public void setHttpPublicAddress(String address, boolean exclusive) {        httpConfig.setServer(address);        httpConfig.setPublicAddressOnly(exclusive);    }        /**     * Sets the ID which will be used for new net peer group instances.     * <p/>     * <p/>By Setting an alternate infrastructure PeerGroup ID (aka NetPeerGroup),     * it prevents heterogeneous infrastructure PeerGroups from intersecting.     * <p/>This is highly recommended practice for application deployment     *     * @param id the new infrastructure PeerGroupID as a string     * @see net.jxta.peergroup.PeerGroupFactory#setNetPGID     */    public void setInfrastructureID(ID id) {        if (id == null || id.equals(ID.nullID)) {            throw new IllegalArgumentException("PeerGroupID can not be null");        }        infraPeerGroupConfig.setPeerGroupID(id);    }        /**     * Sets the ID which will be used for new net peer group instances.     * <p/>     * <p/>By Setting an alternate infrastructure PeerGroup ID (aka NetPeerGroup),     * it prevents heterogeneous infrastructure PeerGroups from intersecting.     * <p/>This is highly recommended practice for application deployment     *     * @param idStr the new infrastructure PeerGroupID as a string     * @see net.jxta.peergroup.PeerGroupFactory#setNetPGID     */    public void setInfrastructureID(String idStr) {        if (idStr == null || idStr.length() == 0) {            throw new IllegalArgumentException("PeerGroupID string can not be empty or null");        }                PeerGroupID pgid = (PeerGroupID) ID.create(URI.create(idStr));        setInfrastructureID(pgid);    }        /**     * Gets the ID which will be used for new net peer group instances.     * <p/>     *     * @return the infrastructure PeerGroupID as a string     */    public String getInfrastructureIDStr() {        return infraPeerGroupConfig.getPeerGroupID().toString();    }        /**     * Sets the infrastructure PeerGroup name meta-data     *     * @param name the Infrastructure PeerGroup name     * @see net.jxta.peergroup.PeerGroupFactory#setNetPGName     */    public void setInfrastructureName(String name) {        infraPeerGroupConfig.setName(name);    }        /**     * Gets the infrastructure PeerGroup name meta-data     *     * @return the Infrastructure PeerGroup name     */    public String getInfrastructureName() {        return infraPeerGroupConfig.getName();    }        /**     * Sets the infrastructure PeerGroup description meta-data     *     * @param description the infrastructure PeerGroup description     * @see net.jxta.peergroup.PeerGroupFactory#setNetPGDesc     */    public void setInfrastructureDescriptionStr(String description) {        infraPeerGroupConfig.setDescription(description);    }        /**     * Returns the infrastructure PeerGroup description meta-data     *     * @return the infrastructure PeerGroup description meta-data     */    public String getInfrastructureDescriptionStr() {        return infraPeerGroupConfig.getDescription();    }        /**     * Sets the infrastructure PeerGroup description meta-data     *     * @param description the infrastructure PeerGroup description     * @see net.jxta.peergroup.PeerGroupFactory#setNetPGDesc     */    public void setInfrastructureDesc(XMLElement description) {        infraPeerGroupConfig.setDesc(description);    }        /**     * Sets the current node configuration mode.     * <p/>The default mode is EDGE, unless modified at construction time.     * A node configuration mode defined a preset configuration     * parameters based on a operating mode. i.e. an EDGE mode, enable     * client/server side tcp, multicast, client side http, RelayService     * client mode.     * <p/> Valid modes include EDGE, RDV_SERVER,     * RELAY_OFF, RELAY_CLIENT, RELAY_SERVER, PROXY_SERVER, or any combination     * of which.<p/> e.g. RDV_SERVER + RELAY_SERVER

⌨️ 快捷键说明

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