📄 nodeinfo.java
字号:
* @return true if ok, false on error */ public final boolean startElement(String uri, String localName, String name, StringBuffer character, Attributes attrs) { // log.info(ME, "startElement: name=" + name + " character='" + character.toString() + "'"); if (name.equalsIgnoreCase(MethodName.CONNECT.getMethodName())) { // "connect" inConnectQos = true; this.connectQosSaxFactory = new ConnectQosSaxFactory(this.remoteGlob); this.connectQosSaxFactory.setConnectQosData(getConnectQosData()); return true; } if (inConnectQos) { this.connectQosSaxFactory.startElement(uri, localName, name, character, attrs); return true; } //========= The rest is deprecated: /* "info" is deprecated as it only contains address specific informations New is "connect" -> now we can specify all connection details */ if (!inConnectQos && name.equalsIgnoreCase("info")) { inInfo = true; //this.connectQosData = new ConnectQosData(this.remoteGlob, this.nodeId); return true; } if (inAddress) { // delegate internal tags if (tmpAddress == null) return false; tmpAddress.startElement(uri, localName, name, character, attrs); return true; } if (inInfo && name.equalsIgnoreCase("address")) { inAddress = true; String type = (attrs != null) ? attrs.getValue("type") : null; tmpAddress = new Address(this.remoteGlob, type, getId()); tmpAddress.startElement(uri, localName, name, character, attrs); log.warning("Using <address> markup is deprecated, please use connectQos markup"); return true; } if (inInfo && name.equalsIgnoreCase("callback")) { inCallback = true; tmpCbAddress = new CallbackAddress(this.remoteGlob); tmpCbAddress.startElement(uri, localName, name, character, attrs); log.warning("Using <callback> markup is deprecated, please use connectQos markup"); return true; } return false; } /** * Handle SAX parsed end element */ public final void endElement(String uri, String localName, String name, StringBuffer character) throws SAXException { try { if (inConnectQos) { // delegate to connectQosSaxFactory ... if (name.equalsIgnoreCase(MethodName.CONNECT.getMethodName())) { // "connect" inConnectQos = false; character.setLength(0); this.connectQosData = this.connectQosSaxFactory.getConnectQosData(); this.connectQosSaxFactory = null; postInitialize(); } else { this.connectQosSaxFactory.endElement(uri, localName, name, character); } return; } //======== all the rest is deprecated: if (inInfo && inAddress) { // delegate address internal tags tmpAddress.endElement(uri, localName, name, character); if (name.equalsIgnoreCase("address")) { inAddress = false; addAddress(tmpAddress); } return; } if (inInfo && inCallback) { // delegate address internal tags tmpCbAddress.endElement(uri, localName, name, character); if (name.equalsIgnoreCase("callback")) { inCallback = false; addCbAddress(tmpCbAddress); } return; } if (inInfo && name.equalsIgnoreCase("info")) { ConnectQosData data = getConnectQosData(); if (!data.hasAddress()) { log.severe("Can't connect to node '" + getId() + "', address is null"); throw new XmlBlasterException(this.remoteGlob, ErrorCode.USER_CONFIGURATION, ME, "Can't connect to node '" + getId() + "', address is null"); } // TODO: Change this "/1" to use a SessionName instance: data.setUserId(this.remoteGlob.getId() + "/1"); // the login name, e.g. "heron/1" // The password is from the environment -passwd or more specific -passwd[heron] postInitialize(); } } catch(XmlBlasterException e) { throw new SAXException("Cluster node configuration parse error", e); } finally { character.setLength(0); } return; } /** * Create a more or less unique sessionId. * <p /> * see Authenticate.java createSessionId() for a discussion */ private String createCbSessionId() throws XmlBlasterException { try { String ip = this.remoteGlob.getLocalIP(); java.util.Random ran = new java.util.Random(); StringBuffer buf = new StringBuffer(512); buf.append(Constants.SESSIONID_PREFIX).append(ip).append("-").append(this.remoteGlob.getId()).append("-"); buf.append(System.currentTimeMillis()).append("-").append(ran.nextInt()).append("-").append((counter++)); String sessionId = buf.toString(); if (log.isLoggable(Level.FINE)) log.fine("Created callback sessionId='" + sessionId + "'"); return sessionId; } catch (Exception e) { String text = "Can't generate a unique callback sessionId: " + e.toString(); log.severe(text); throw new XmlBlasterException(this.remoteGlob, ErrorCode.USER_SECURITY_AUTHENTICATION_ACCESSDENIED, ME, text); } } /** * Dump state of this object into a XML ASCII string. */ public final String toXml() { return toXml((String)null, (Properties)null); } /** * Dump state of this object into a XML ASCII string. * @param extraOffset indenting of tags for nice output */ public final String toXml(String extraOffset, Properties props) { StringBuffer sb = new StringBuffer(512); if (extraOffset == null) extraOffset = ""; String offset = Constants.OFFSET + extraOffset; sb.append(offset).append("<").append(MethodName.CONNECT.getMethodName()).append(">"); sb.append(getConnectQosData().toXml(extraOffset + Constants.INDENT)); sb.append(offset).append("</").append(MethodName.CONNECT.getMethodName()).append(">"); DisconnectQos dis = getDisconnectQos(); if (dis != null) { sb.append(offset).append("<").append(MethodName.DISCONNECT.getMethodName()).append(">"); sb.append(dis.toXml(extraOffset + Constants.INDENT, props)); sb.append(offset).append("</").append(MethodName.DISCONNECT.getMethodName()).append(">"); } /* sb.append(offset).append("<info>"); if (this.connectQosData != null) { AddressBase[] arr = this.connectQosData.getAddresses(); for (int i=0; i<arr.length; i++) { sb.append(arr[i].toXml(extraOffset + Constants.INDENT)); } } if (cbAddressMap != null && cbAddressMap.size() > 0) { Iterator it = cbAddressMap.values().iterator(); while (it.hasNext()) { CallbackAddress info = (CallbackAddress)it.next(); sb.append(info.toXml(extraOffset + Constants.INDENT)); } } if (getBackupnodeMap() != null && getBackupnodeMap().size() > 0) { Iterator it = getBackupnodeMap().values().iterator(); sb.append(offset).append(" <backupnode>"); while (it.hasNext()) { NodeId info = (NodeId)it.next(); sb.append(offset).append(" <clusternode id='").append(info.getId()).append("'/>"); } sb.append(offset).append(" </backupnode>"); } sb.append(offset).append("</info>"); */ return sb.toString(); } /** * @return Returns the disconnectQos. */ public DisconnectQos getDisconnectQos() { return this.disconnectQos; } /** * @param disconnectQos The disconnectQos to set. */ public void setDisconnectQos(DisconnectQos disconnectQos) { this.disconnectQos = disconnectQos; } /** * @return Returns the remoteGlob. */ public org.xmlBlaster.util.Global getRemoteGlob() { return this.remoteGlob; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -