📄 connectqosdata.java
字号:
* @return Are we a cluster? */ public boolean isClusterNode() { return this.clusterNode.getValue(); } /** * @return The isClusterNode flag object */ public PropBoolean getClusterNodeProp() { return this.clusterNode; } /** * @return refreshSession is true if the client automatically notifies xmlBlaster that it is alive * and the login session is extended */ public final boolean getRefreshSession() { return this.refreshSession.getValue(); } /** * @param refreshSession true: The client automatically notifies xmlBlaster that it is alive * and the login session is extended */ public final void setRefreshSession(boolean refreshSession) { this.refreshSession.setValue(refreshSession); } /** * @return The isClusterNode flag object */ public PropBoolean getRefreshSessionProp() { return this.refreshSession; } /** * @param Set if we allow multiple updates for the same message if we have subscribed multiple times to it. */ public void setDuplicateUpdates(boolean duplicateUpdates) { this.duplicateUpdates.setValue(duplicateUpdates); } /** * @return true if we allow multiple updates for the same message if we have subscribed multiple times to it. */ public boolean duplicateUpdates() { return this.duplicateUpdates.getValue(); } /** */ public PropBoolean duplicateUpdatesProp() { return this.duplicateUpdates; } /** * Used for ConnetReturnQos only: If reconnected==true a client has reconnected to an existing session */ public void setReconnected(boolean reconnected) { this.reconnected.setValue(reconnected); } /** * Used for ConnetReturnQos only. * @return true A client has reconnected to an existing session */ public boolean isReconnected() { return this.reconnected.getValue(); } /** */ public PropBoolean getReconnectedProp() { return this.reconnected; } public void addAddress(Address address) { ClientQueueProperty prop = new ClientQueueProperty(glob, this.nodeId.toString()); // Use default queue properties for this xmlBlaster access address prop.setAddress(address); addClientQueueProperty(prop, true); } /** * Add an address to which we want to connect, with all the configured parameters. * <p /> * @param address An object containing the protocol (e.g. EMAIL) the address (e.g. hugo@welfare.org) and the connection properties */ public void setAddress(Address address) { ClientQueueProperty prop = new ClientQueueProperty(glob, this.nodeId.toString()); // Use default queue properties for this xmlBlaster access address prop.setAddress(address); addClientQueueProperty(prop); } /** * The current connection address and properties of the xmlBlaster server * we want connect to. * @return never null */ public Address getAddress() { ClientQueueProperty[] props = getClientQueuePropertyArr(); Address adr = null; for (int i=0; i<props.length; i++) { adr = props[i].getCurrentAddress(); if (getDefaultType().equals(adr.getType())) { return adr; } } if (adr == null) { log.severe("Internal error, can't access address instance in queue"); throw new IllegalArgumentException(ME + ": Internal error, can't access address instance in queue"); } return adr; } /** * Try to find the default protocol address as configured for clients * @return Never null */ private String getDefaultType() { if (this.defaultType == null) { synchronized (this) { if (this.defaultType == null) { Address def = new Address(glob); this.defaultType = def.getType(); if (this.defaultType == null) { this.defaultType = "SOCKET"; } } } } return this.defaultType; } /** * The connection address and properties of the xmlBlaster server * we want connect to. * @return never null */ public Address[] getAddresses() { ClientQueueProperty[] props = getClientQueuePropertyArr(); ArrayList list = new ArrayList(); for (int i=0; i<props.length; i++) { AddressBase[] adrs = props[i].getAddresses(); for (int j=0; j<adrs.length; j++) { list.add(adrs[j]); } } return (Address[])list.toArray(new Address[list.size()]); } /** * Adds a queue description. * This allows to set all supported attributes of a client side queue and an address to reach xmlBlaster * @param prop The property object of the client side queue which shall be established. * @return false if not accepted * @see org.xmlBlaster.util.qos.address.Address */ public boolean addClientQueueProperty(ClientQueueProperty prop) { return addClientQueueProperty(prop, false); } private boolean addClientQueueProperty(ClientQueueProperty prop, boolean allowMultiAddress) { if (prop == null) return false; // We use a list to allow in future mutliple addresses if (!allowMultiAddress && this.clientQueuePropertyList.size() > 0) { Address addr = prop.getCurrentAddress(); log.warning("Clients side load balancing is not implemented, we ignore the additional address" + ((addr==null) ? "" : " '"+addr.toString()+"'")); //Thread.currentThread().dumpStack(); return false; } this.clientQueuePropertyList.add(prop); return true; } /** * The current used (or the default) queue property * @return Never null */ public ClientQueueProperty getClientQueueProperty() { ClientQueueProperty[] props = getClientQueuePropertyArr(); for (int i=0; i<props.length; i++) { Address[] arr = (Address[])props[i].getAddresses(); for (int j=0; j<arr.length; j++) { if (getDefaultType().equals(arr[j].getType())) { return props[i]; } } } return props[0]; } /** * @return never null */ private ClientQueueProperty createClientQueueProperty() { if (this.clientQueuePropertyList.size() < 1) { if (log.isLoggable(Level.FINE)) log.fine("Creating default server address instance"); //setAddress(glob.getBootstrapAddress()); setAddress(new Address(glob)); } if (this.clientQueuePropertyList.size() < 1) { log.severe("Internal error, can't access address instance"); throw new IllegalArgumentException(ME + ": Internal error, can't access address instance"); } return (ClientQueueProperty)this.clientQueuePropertyList.get(0); } public boolean hasAddress() { if (this.clientQueuePropertyList.size() > 0) return true; return false; } /** * At least one entry is delivered */ public ClientQueueProperty[] getClientQueuePropertyArr() { if (this.clientQueuePropertyList.size() < 1) { createClientQueueProperty(); // force creation } return (ClientQueueProperty[])this.clientQueuePropertyList.toArray(new ClientQueueProperty[this.clientQueuePropertyList.size()]); } /** * Does the given address belong to this client connection setup? */ public boolean contains(Address other) { if (other == null) return false; ClientQueueProperty[] props = getClientQueuePropertyArr(); for (int i=0; i<props.length; i++) { if (props[i].contains(other)) { return true; } } return false; } /** * Usually done on server side as the server is not interested in it */ public void eraseClientQueueProperty() { this.clientQueuePropertyList.clear(); } /** * Add a callback address where to send the message * <p /> * Creates a default CbQueueProperty object to hold the callback address argument.<br /> * @param callback An object containing the protocol (e.g. EMAIL) and the address (e.g. hugo@welfare.org) */ public void addCallbackAddress(CallbackAddress callback) { // Use default queue properties for this callback address CbQueueProperty prop = getSessionCbQueueProperty(); prop.setCallbackAddress(callback); } /** * Access the currently used callback address. * @return can be null */ public CallbackAddress getCurrentCallbackAddress() { CbQueueProperty prop = getSessionCbQueueProperty(); // never null return prop.getCurrentCallbackAddress(); } /** * @return the login credentials or null if not set */ public I_SecurityQos getSecurityQos() { return this.securityQos; } /** * Return the type of the referenced security plugin. * <p/> * @return The type or null if not known */ public String getClientPluginType() { try { return getClientPlugin().getType(); } catch (Exception e) { return null; } } /** * Return the version of the referenced security plugin. * <p/> * @return The version or null if not known */ public String getClientPluginVersion() { try { return getClientPlugin().getVersion(); } catch (Exception e) { return null; } } /** * @return The user ID or "NoLoginName" if not known */ public String getUserId() { I_SecurityQos securityQos = getSecurityQos(); if (securityQos==null) return "NoLoginName"; else return securityQos.getUserId(); } /** * Returns the connection state directly after the connect() method returns (client side only). * @return Usually ConnectionStateEnum.ALIVE or ConnectionStateEnum.POLLING */ public ConnectionStateEnum getInitialConnectionState() { return this.initialConnectionState; } /** * Set the connection state directly after the connect() (client side only). */ public void setInitialConnectionState(ConnectionStateEnum initialConnectionState) { this.initialConnectionState = initialConnectionState; } /** * The number of bytes of stringified qos */ public int size() { return this.toXml().length(); } /** * Unique id of the xmlBlaster server (or a client), changes on each restart. * If 'node/heron' is restarted, the instanceId changes. * @return nodeId + timestamp, '/node/heron/instanceId/33470080380' */ public String getInstanceId() { return this.serverInstanceId; } /** * Unique id of the xmlBlaster server (or a client), changes on each restart. * If 'node/heron' is restarted, the instanceId changes. * @param instanceId e.g. '/node/heron/instanceId/33470080380' */ public void setInstanceId(String instanceId) { this.serverInstanceId = instanceId; } /** * Converts the data into a valid XML ASCII string. * @return An XML ASCII string */ public String toString() { return toXml(); } /** * Dump state of this object into a XML ASCII string. */ public String toXml() { return toXml((String)null); } /** * Dump state of this object into a XML ASCII string. * <br> * @param extraOffset indenting of tags for nice output * @return internal state of the connect QoS as a XML ASCII string */ public String toXml(String extraOffset) { return toXml(extraOffset, (Properties)null); } public String toXml(String extraOffset, Properties props) { return this.factory.writeObject(this, extraOffset, props); } public String toXml(String extraOffset, boolean forceReadable) { Properties props = null; if (forceReadable) { props = new Properties(); props.put(Constants.TOXML_FORCEREADABLE, ""+forceReadable); } return this.factory.writeObject(this, extraOffset, props); } /** * Returns a shallow clone, you can change safely all basic or immutable types * like boolean, String, int. * Currently TopicProperty and RouteInfo is not cloned (so don't change it) */ public Object clone() { log.severe("clone() is not tested"); ConnectQosData newOne = null; newOne = (ConnectQosData)super.clone(); synchronized(this) { newOne.ptpAllowed = (PropBoolean)this.ptpAllowed.clone(); newOne.clusterNode = (PropBoolean)this.clusterNode.clone(); newOne.refreshSession = (PropBoolean)this.refreshSession.clone(); newOne.duplicateUpdates = (PropBoolean)this.duplicateUpdates.clone(); newOne.reconnected = (PropBoolean)this.reconnected.clone(); //newOne.sessionQos = (SessionQos)this.sessionQos.clone(); //newOne.securityQos = (I_SecurityQos)this.securityQos.clone(); newOne.serverRefVec = this.serverRefVec; newOne.nodeId = this.nodeId; } return newOne; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -