📄 httpadv.java
字号:
if (0 == value.length()) { return false; } if (tag.equals(ProtocolTag)) { setProtocol(value); return true; } if (tag.equals(IntfAddrTag)) { setInterfaceAddress(value); return true; } if (tag.equals(ConfModeTag)) { setConfigMode(value); return true; } if (tag.equals(PortTag)) { setPort(Integer.parseInt(value.trim())); return true; } if (tag.equals(ProxyTag)) { proxy = value; return true; } if (tag.equals(ServerTag)) { server = value; return true; } return false; } /** * {@inheritDoc} * <p/> * <p/><emphasis>NB</emphasis>: we do not try to enforce dependency rules * such as Proxy only when router, because we want to convey the complete * configuration, even items corresponding to not currently enabled * features. HttpTransport will gracefully disregard items that have * no use in the current context. */ @Override public Document getDocument(MimeMediaType encodeAs) { if (serverEnabled && (0 == listenPort)) { throw new IllegalStateException("Dynmaic port selection not supported with incoming connections."); } if ((listenPort < -1) || (listenPort > 65535)) { throw new IllegalStateException("Illegal Listen Port Value"); } if (!Arrays.asList(CONFIGMODES).contains(configMode)) { throw new IllegalStateException("Unsupported configuration mode."); } // XXX 20050118 bondolo Some versions apparently don't initialize this field. Eventually make it required. if (null == getProtocol()) { setProtocol("http"); } StructuredDocument adv = (StructuredDocument) super.getDocument(encodeAs); if (adv instanceof Attributable) { // Only one flag for now. Easy. if (publicAddressOnly) { ((Attributable) adv).addAttribute(FlagsTag, PublicAddressOnlyAttr); } } Element e1 = adv.createElement(ProtocolTag, getProtocol()); adv.appendChild(e1); if (null != getInterfaceAddress()) { Element e2 = adv.createElement(IntfAddrTag, getInterfaceAddress()); adv.appendChild(e2); } Element e3 = adv.createElement(ConfModeTag, getConfigMode()); adv.appendChild(e3); Element e4 = adv.createElement(PortTag, Integer.toString(getPort())); adv.appendChild(e4); Element ext; if (proxy != null) { ext = adv.createElement(ProxyTag, proxy); adv.appendChild(ext); } // If disabled, say it; otherwise it is assumed on. In published // advs, we only keep data for items that are ON, so we do not // have to clutter them with the flag. if (!proxyEnabled) { ext = adv.createElement(ProxyOffTag); adv.appendChild(ext); } if (server != null) { ext = adv.createElement(ServerTag, server); adv.appendChild(ext); } // If disabled, say it; otherwise it is assumed on. In published // advs, we only keep data for items that are ON, so we do not // have to clutter them with the flag. if (!serverEnabled) { ext = adv.createElement(ServerOffTag); adv.appendChild(ext); } // If disabled, say it; otherwise it is assumed on. In published // advs, we only keep data for items that are ON, so we do not // have to clutter them with the flag. if (!clientEnabled) { ext = adv.createElement(ClientOffTag); adv.appendChild(ext); } return adv; } /** * Returns the interfaceAddr. That is, the ip of the IF to which to bind * locally created sockets. * * @return string The address. */ public String getInterfaceAddress() { return interfaceAddress; } /** * Sets the interfaceAddr. That is, the ip of the IF to which to bind * locally created sockets. * * @param address The address */ public void setInterfaceAddress(String address) { this.interfaceAddress = address; } public boolean getPublicAddressOnly() { return publicAddressOnly; } public void setPublicAddressOnly(boolean only) { publicAddressOnly = only; } /** * returns the config mode. That is, how the user prefers to configure * the interface address: "auto", "manual" * * @return string config mode */ public String getConfigMode() { return configMode; } /** * set the config mode. That is, how the user prefers to configure * the interface address: "auto", "manual" * <p/> * This is just a pure config item. It is never in published advs. The TCP * transport strips it when it initializes. * * @param mode Can be "auto", "manual" other settings will act as the default * which is "auto". */ public void setConfigMode(String mode) { if (!Arrays.asList(CONFIGMODES).contains(mode)) { throw new IllegalArgumentException("Unsupported configuration mode."); } configMode = mode; } /** * Returns the port number to which server sockets are locally bound. * * @return String the port */ public int getPort() { return listenPort; } /** * Sets the port number to which server sockets are locally bound. * * @param newPort the port */ public void setPort(int newPort) { listenPort = newPort; } /** * @return the proxy string * @deprecated This has been deprecated. Set your proxy directly with the JVM */ @Deprecated public String getProxy() { return proxy; } public String getServer() { return server; } /** * @return true if proxy enabled * @deprecated This has been deprecated. Set your proxy directly with the JVM */ @Deprecated public boolean isProxyEnabled() { return proxyEnabled; } public boolean isServerEnabled() { return serverEnabled; } public boolean isClientEnabled() { return clientEnabled; } // If one of proxy, server, or router is cleared, the corresponding // enabled flag should be false (the opposite is not true). /** * @param name the proxy string * @deprecated This has been deprecated. Set your proxy directly with the JVM */ @Deprecated public void setProxy(String name) { proxy = name; if (name == null) { proxyEnabled = false; } } public void setServer(String name) { server = name; } /** * @param enabled true if proxy is enabled * @deprecated This has been deprecated. Set your proxy directly with the JVM */ @Deprecated public void setProxyEnabled(boolean enabled) { proxyEnabled = enabled; } public void setServerEnabled(boolean enabled) { serverEnabled = enabled; } public void setClientEnabled(boolean enabled) { clientEnabled = enabled; } /** * {@inheritDoc} */ @Override public String[] getIndexFields() { return INDEXFIELDS; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -