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

📄 configurator.java

📁 JXTA源文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * @deprecated Constructors specifying 'principal' are deprecated.     *     * @param   name        peer name     * @param  description  peer description     * @param   principal   peer principal     * @param   password    peer password     */        public Configurator(String name, String description, String principal,        String password) {        this(Env.JXTA_HOME.toURI(), name, description, principal, password);    }        /**     * Constructor whereby one can specify an alternative JXTA persistence directory,     * peer name, description, principal and password with which to establish the     * initial context.      *     * @param  home         JXTA persistence directory destination     * @param  name         peer name     * @param  description  peer description     * @param  password     peer password     */        public Configurator(URI home, String name, String description, String password) {        this(home, name, description, name, password );            }            /**     * Constructor whereby one can specify an alternative JXTA persistence directory,     * peer name, description, principal and password with which to establish the     * initial context.      *     * @deprecated Constructors specifying 'principal' are deprecated.     *     * @param  home         JXTA persistence directory destination     * @param  name         peer name     * @param  description  peer description     * @param  principal    peer principal     * @param  password     peer password     */        public Configurator(URI home, String name, String description,        String principal, String password) {//        init(home, Profile.SEED, name, description, principal, password);        try {            init(home, null, name, description, principal, password);        } catch( ConfiguratorException badConfig ) {            throw new UndeclaredThrowableException( badConfig, "Configuration Failure" );        }    }            /**     * Constructor whereby one can provide an alternative {@code Profile} with     * the specified configuration preferences with which to establish the initial     * context.     *     * @param   profile     the provided {@code Profile}     */        public Configurator(Profile profile) {        this(Env.JXTA_HOME.toURI(), profile);    }        /**     * Constructor whereby one can specify an alternative JXTA persistence directory     * and {@code Profile} with which to establish the initial context.     *     * @param   home    JXTA persistence directory destination     * @param   profile the provided {@code Profile}     */        public Configurator(URI home, Profile profile) {        try {            init(home, profile, null, null, null, null);        } catch( ConfiguratorException badConfig ) {            throw new UndeclaredThrowableException( badConfig, "Configuration Failure" );        }    }        /**     * Constructor whereby one can specify a {@link net.jxta.impl.protocol.PlatformConfig}     * to establish the initial context.     *     * @param   config  {@link net.jxta.impl.protocol.PlatformConfig} configuration     */        public Configurator(PlatformConfig config) {        this(Env.JXTA_HOME.toURI(), config);    }    /**     * Constructor whereby one can specify a JXTA persistence directory and     * {@link net.jxta.impl.protocol.PlatformConfig} to establish the initial     * context.     *     * @param   home    JXTA persistence directory destination     * @param   config  {@code net.jxta.impl.protocol.PlatformConfig} configuration     */        public Configurator(URI home, PlatformConfig config) {        setJxtaHome(home);        try {        process(config);        } catch( ConfiguratorException badConfig ) {            throw new UndeclaredThrowableException( badConfig, "Configuration Failure" );        }    }        /**     * Accessor for the JXTA persistence directory.     *     * @return      the configuration JXTA persistence directory     */        public URI getJxtaHome() {        return this.home;    }        /**     * {@inheritDoc}     */        public ConfigParams load()    throws ConfiguratorException {        return load(new File(toFile(getJxtaHome()), Env.PLATFORM_CONFIG));    }        /**     * {@inheritDoc}     */        public PlatformConfig load(File loadFile)    throws ConfiguratorException {        if (LOG.isEnabledFor(Level.DEBUG)) {            LOG.debug("Reading Platform Config from : " +            loadFile.getAbsolutePath());        }                PlatformConfig pc = null;        FileInputStream advStream = null;                try {            advStream = new FileInputStream(loadFile);            Reader advReader = new InputStreamReader(advStream, "UTF-8");                        pc = (PlatformConfig)AdvertisementFactory.newAdvertisement(MimeMediaType.XMLUTF8,                advReader);                        if (LOG.isEnabledFor(Level.DEBUG)) {                LOG.debug("Recovered Platform Config from : " +                    loadFile.getAbsolutePath());            }        } catch (FileNotFoundException e) {            if (LOG.isEnabledFor(Level.DEBUG)) {                LOG.debug("Platform Config not found : " +                    loadFile.getAbsolutePath());            }        } catch (Exception e) {            if (LOG.isEnabledFor(Level.WARN)) {                LOG.warn("Failed to Recover '" + loadFile.getAbsolutePath() +                    "' due to : ", e);            }                        try {                // delete that bad file.                loadFile.delete();            } catch (Exception ex1) {                LOG.fatal("Could not remove bad Configuration file", ex1);                                throw new ConfiguratorException( "Could not remove '" +                    loadFile.getAbsolutePath() +                    "'. Remove it by hand before retrying", ex1);            }                        throw new ConfiguratorException("Failed to Recover PlatformConfig", e);        } finally {            try {                if (advStream != null) {                    advStream.close();                }                                advStream = null;            } catch (Exception ignored) {            }        }                return pc;    }                /**     * Accessor to the confguration descriptor.     *     * @return      the configuration descriptor.     */        public String getDescriptor() {        return this.descriptor;    }        /**     * Specify the configuration descriptor.     *     * @param   descriptor  configuration descriptor     */        public void setDescriptor(String descriptor) {        this.descriptor = descriptor;    }        /**     * Accessor to the peer name.     *     * @return      the peer name.     */        public String getName() {        return this.peerName;    }        /**     * Specify the peer name.     *     * @param   name    the peer name.     */        public void setName(String name) {        this.peerName = (name != null && name.trim().length() > 0 ?            name.trim() : null);    }        /**     * Accessor to the peer description.     *     * @return      the peer description.     */        public String getDescription() {        String d = getDescriptor();                d = d != null ? d.trim() : d;                String postfix = "";                if (d != null &&            d.length() > 0 &&            this.peerDescription != null) {            String s = SPACE + PARENTHESIS_OPEN + d + PARENTHESIS_CLOSE;                        if (this.peerDescription.indexOf(s) == -1) {                postfix = s;            }        }                return this.peerDescription + postfix;    }        /**     * Specify the peer description.     *     * @param   description     the peer description.     */        public void setDescription(String description) {        this.peerDescription = (description != null &&            description.trim().length() > 0 ?                description.trim() : null);    }        /**     * Accessor to the <a href="http://logging.apache.org/log4">jLog4J</a> level.     *     * @return      the log level.     */        public Trace getTrace() {        return this.trace;    }        /**     * Specify the <a href="http://logging.apache.org/log4j">Log4J</a> level.     *     * @param   trace   the log level.     */        public void setTrace(Trace trace) {        if (trace != null) {            this.trace = trace;        }    }        /**     * Accessor to the {@link net.jxta.peer.PeerID}.     *     * @return      the {@link net.jxta.peer.PeerID}     */        public PeerID getPeerId() {        return this.peerId;    }        /**     * Specify the {@link net.jxta.peer.PeerID}.     *      * <p>Unspecified {@link net.jxta.peer.PeerID} will be generated by the     * JXTA Platform upon startup.     *     * @param   peerId  the {@link net.jxta.peer.PeerID}     */        public void setPeerId(PeerID peerId) {        this.peerId = peerId;    }        /**     * Accessor to the {@link net.jxta.rendezvous.RendezVousService} enabler which     * indicates as to whether or not the to be configured JXTA instance is to     * provision the {@link net.jxta.rendezvous.RendezVousService}.     *     * @return      {@link net.jxta.rendezvous.RendezVousService} enabler     */        public boolean isRendezVous() {        return RdvConfigAdv.RendezVousConfiguration.RENDEZVOUS ==            this.rdvConfig.getConfiguration();    }        /**     * Specify the {@link net.jxta.rendezvous.RendezVousService} enabler.     *     * @deprecated          see #setRendezvousConfigrationMode     * @param   isEnabled   {@link net.jxta.rendezvous.RendezVousService} enabler     */        public void setRendezVous(boolean isEnabled) {        this.rdvConfig.setConfiguration(isEnabled ?            RdvConfigAdv.RendezVousConfiguration.RENDEZVOUS :            RdvConfigAdv.RendezVousConfiguration.EDGE);    }        /**     * Accessor for the RendezVous configuration mode.     *     * @return      configuration mode     */        public String getRendezVousConfigurationMode() {        return this.rdvConfig.getConfiguration().toString();    }        /**     * Specify the RendezVous configuration mode.     *     * @param   configurationMode        configuration mode     */        public void setRendezVousConfigurationMode(String configurationMode) {        configurationMode = configurationMode != null ?            configurationMode.trim() : configurationMode;                if (configurationMode != null) {            configurationMode = configurationMode.replaceAll(SPACE_REGEX,                EMPTY_SPACE);        }                RdvConfigAdv.RendezVousConfiguration rc = null;                for (Iterator ci = Default.RENDEZVOUS_CONFIGURATION_MODES.iterator();            rc == null && ci.hasNext(); ) {            RdvConfigAdv.RendezVousConfiguration c =                (RdvConfigAdv.RendezVousConfiguration)ci.next();                        if (c.toString().replaceAll(SPACE_REGEX, EMPTY_STRING).                equalsIgnoreCase(configurationMode)) {                rc = c;            }        }                if (rc != null) {            this.rdvConfig.setConfiguration(rc);        }    }        /**     * Accessor to the configured RendezVous addresses in the form of {@link java.net.URI}.     *     * @return      RendezVous as a {@link java.util.List} of {@link java.net.URI}     */        public List getRendezVous() {        return new ArrayList(Arrays.asList(rdvConfig.getSeedRendezvous()));    }        /**     * Clears and resets the RendezVous address.     *     * @param       rendezVous              RendezVous address     * @throws      ConfiguratorException   {@link net.jxta.exception.ConfiguratorException}     *                                      chained list of configuration errors     */        public void setRendezVous(URI rendezVous)    throws ConfiguratorException {        setRendezVous(Collections.singletonList(rendezVous));    }    

⌨️ 快捷键说明

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