@param key The key of the attribute we are looking for in the connection @return <tt>true</tt> if this connection contains the attribute with the specified <tt>key</tt>.
Returns the value of the user-defined attribute of this connection.
Returns the value of user defined attribute associated with the specified key. If there's no such attribute, the specified default value is associated with the specified key, and the default value is returned. This method is same with the following code except that the operation is performed atomically. <pre> if (containsAttribute(key)) { return getAttribute(key); } else { setAttribute(key, defaultValue); return defaultValue; } </pre>
@return the set of keys of all user-defined attributes.
@return the EventHandler which handles this connection.
@return <tt>true</tt> if this connection is active.
@return <tt>true</tt> if and only if this connection is being closed (but not disconnected yet) or is closed.
@return <tt>true</tt> if this connection is connected with remote peer.
@return <tt>true</tt> if the connection has started and initialized a SslEngine, <tt>false</tt> if the connection is not yet secured (the handshake is not completed) or if SSL is not set for this connection, or if SSL is not even an option.
Removes a user-defined attribute with the specified key.
Removes a user defined attribute with the specified key if the current attribute value is equal to the specified value. This method is same with the following code except that the operation is performed atomically. <pre> if (containsAttribute(key) && getAttribute(key).equals(value)) { removeAttribute(key); return true; } else { return false; } </pre>
Replaces a user defined attribute with the specified key if the value of the attribute is equals to the specified old value. This method is same with the following code except that the operation is performed atomically. <pre> if (containsAttribute(key) && getAttribute(key).equals(oldValue)) { setAttribute(key, newValue); return true; } else { return false; } </pre>
Sets a user-defined attribute.
Sets a user defined attribute without a value. This is useful when you just want to put a 'mark' attribute. Its value is set to {@link bool#TRUE}.
Sets a user defined attribute if the attribute with the specified key is not set yet. This method is same with the following code except that the operation is performed atomically. <pre> if (containsAttribute(key)) { return getAttribute(key); } else { return setAttribute(key, value); } </pre>
Sets a user defined attribute without a value if the attribute with the specified key is not set yet. This is useful when you just want to put a 'mark' attribute. Its value is set to {@link bool#TRUE}. This method is same with the following code except that the operation is performed atomically. <pre> if (containsAttribute(key)) { return getAttribute(key); // might not always be bool.TRUE. } else { return setAttribute(key); } </pre>
Writes the specified <code>message</code> to remote peer. This operation is asynchronous; {@link IoHandler#messageSent(Connection,Object)} will be invoked when the message is actually sent to remote peer. You can also wait for the returned {@link WriteFuture} if you want to wait for the message actually written.
<p> A handle which represents connection between two end-points regardless of transport types. </p> <p> {@link Connection} provides user-defined attributes. User-defined attributes are application-specific data which are associated with a connection. It often contains objects that represents the state of a higher-level protocol and becomes a way to exchange data between filters and handlers. </p> <h3>Adjusting Transport Type Specific Properties</h3> <p> You can simply downcast the connection to an appropriate subclass. </p> <h3>Thread Safety</h3> <p> {@link Connection} is thread-safe. But please note that performing more than one {@link #write(Object)} calls at the same time will cause the {@link IoFilter#filterWrite(IoFilter.NextFilter,Connection,WriteRequest)} to be executed simultaneously, and therefore you have to make sure the {@link IoFilter} implementations you're using are thread-safe, too. </p> <h3>Equality of Connections</h3> TODO : The getId() method is totally wrong. We can't base a method which is designed to create a unique ID on the hashCode method. {@link Object#equals(Object)} and {@link Object#hashCode()} shall not be overriden to the default behavior that is defined in {@link Object}.
@author <a href="http://mina.apache.org">Apache MINA Project</a>