Wildfire 3.2.4 Javadoc

org.jivesoftware.wildfire.net
Class VirtualConnection

java.lang.Object
  extended by org.jivesoftware.wildfire.net.VirtualConnection
All Implemented Interfaces:
Connection
Direct Known Subclasses:
ClientSessionConnection, HttpSession.HttpVirtualConnection

public abstract class VirtualConnection
extends Object
implements Connection

Abstract implementation of the Connection interface that models abstract connections. Abstract connections are connections that don't have a physical connection counterpart. Instead they can be seen as conceptual or just 'abstract' connections.

Default values and common behavior of virtual connections are modeled in this class. Subclasses should just need to specify how packets are delivered and what means closing the connection.

Author:
Gaston Dombiak

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.jivesoftware.wildfire.Connection
Connection.CompressionPolicy, Connection.TLSPolicy
 
Field Summary
protected  Session session
           
 
Constructor Summary
VirtualConnection()
           
 
Method Summary
 void close()
          Closes the session, the virtual connection and notifies listeners that the connection has been closed.
abstract  void closeVirtualConnection()
          Closes the virtual connection.
 Connection.CompressionPolicy getCompressionPolicy()
          Returns whether compression is optional or is disabled.
 String getLanguage()
          Returns the language code that should be used for this connection (e.g.
 int getMajorXMPPVersion()
          Returns the major version of XMPP being used by this connection (major_version.minor_version.
 int getMinorXMPPVersion()
          Returns the minor version of XMPP being used by this connection (major_version.minor_version.
 PacketDeliverer getPacketDeliverer()
          Returns the packet deliverer to use when delivering a packet over the socket fails.
 Connection.TLSPolicy getTlsPolicy()
          Returns whether TLS is mandatory, optional or is disabled.
 void init(Session session)
          Initializes the connection with it's owning session.
 boolean isClosed()
          Returns true if the connection/session is closed.
 boolean isCompressed()
          Returns true if the connection is using compression.
 boolean isFlashClient()
          Returns true if the connected client is a flash client.
 boolean isSecure()
          Returns true if this connection is secure.
 void registerCloseListener(ConnectionCloseListener listener, Object handbackMessage)
          Registers a listener for close event notification.
 void removeCloseListener(ConnectionCloseListener listener)
          Removes a registered close event listener.
 void setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
          Sets whether compression is enabled or is disabled.
 void setFlashClient(boolean flashClient)
          Sets whether the connected client is a flash client.
 void setLanaguage(String language)
          Sets the language code that should be used for this connection (e.g.
 void setTlsPolicy(Connection.TLSPolicy tlsPolicy)
          Sets whether TLS is mandatory, optional or is disabled.
 void setXMPPVersion(int majorVersion, int minorVersion)
          Sets the XMPP version information.
 void startCompression()
          Start using compression for this connection.
 void startTLS(boolean clientMode, String remoteServer)
          Secures the plain connection by negotiating TLS with the client.
 boolean validate()
          Verifies that the connection is still live.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jivesoftware.wildfire.Connection
deliver, deliverRawText, getInetAddress, systemShutdown
 

Field Detail

session

protected Session session
Constructor Detail

VirtualConnection

public VirtualConnection()
Method Detail

getLanguage

public String getLanguage()
Description copied from interface: Connection
Returns the language code that should be used for this connection (e.g. "en").

Specified by:
getLanguage in interface Connection
Returns:
the language code for the connection.

getMajorXMPPVersion

public int getMajorXMPPVersion()
Description copied from interface: Connection
Returns the major version of XMPP being used by this connection (major_version.minor_version. In most cases, the version should be "1.0". However, older clients using the "Jabber" protocol do not set a version. In that case, the version is "0.0".

Specified by:
getMajorXMPPVersion in interface Connection
Returns:
the major XMPP version being used by this connection.

getMinorXMPPVersion

public int getMinorXMPPVersion()
Description copied from interface: Connection
Returns the minor version of XMPP being used by this connection (major_version.minor_version. In most cases, the version should be "1.0". However, older clients using the "Jabber" protocol do not set a version. In that case, the version is "0.0".

Specified by:
getMinorXMPPVersion in interface Connection
Returns:
the minor XMPP version being used by this connection.

isClosed

public boolean isClosed()
Description copied from interface: Connection
Returns true if the connection/session is closed.

Specified by:
isClosed in interface Connection
Returns:
true if the connection is closed.

getCompressionPolicy

public Connection.CompressionPolicy getCompressionPolicy()
Description copied from interface: Connection
Returns whether compression is optional or is disabled.

Specified by:
getCompressionPolicy in interface Connection
Returns:
whether compression is optional or is disabled.

getTlsPolicy

public Connection.TLSPolicy getTlsPolicy()
Description copied from interface: Connection
Returns whether TLS is mandatory, optional or is disabled. When TLS is mandatory clients are required to secure their connections or otherwise their connections will be closed. On the other hand, when TLS is disabled clients are not allowed to secure their connections using TLS. Their connections will be closed if they try to secure the connection. in this last case.

Specified by:
getTlsPolicy in interface Connection
Returns:
whether TLS is mandatory, optional or is disabled.

isCompressed

public boolean isCompressed()
Description copied from interface: Connection
Returns true if the connection is using compression.

Specified by:
isCompressed in interface Connection
Returns:
true if the connection is using compression.

isFlashClient

public boolean isFlashClient()
Description copied from interface: Connection
Returns true if the connected client is a flash client. Flash clients need to receive a special character (i.e. \0) at the end of each xml packet. Flash clients may send the character \0 in incoming packets and may start a connection using another openning tag such as: "flash:client".

Specified by:
isFlashClient in interface Connection
Returns:
true if the connected client is a flash client.

setFlashClient

public void setFlashClient(boolean flashClient)
Description copied from interface: Connection
Sets whether the connected client is a flash client. Flash clients need to receive a special character (i.e. \0) at the end of each xml packet. Flash clients may send the character \0 in incoming packets and may start a connection using another openning tag such as: "flash:client".

Specified by:
setFlashClient in interface Connection
Parameters:
flashClient - true if the if the connection is a flash client.

setXMPPVersion

public void setXMPPVersion(int majorVersion,
                           int minorVersion)
Description copied from interface: Connection
Sets the XMPP version information. In most cases, the version should be "1.0". However, older clients using the "Jabber" protocol do not set a version. In that case, the version is "0.0".

Specified by:
setXMPPVersion in interface Connection
Parameters:
majorVersion - the major version.
minorVersion - the minor version.

setLanaguage

public void setLanaguage(String language)
Description copied from interface: Connection
Sets the language code that should be used for this connection (e.g. "en").

Specified by:
setLanaguage in interface Connection
Parameters:
language - the language code.

setCompressionPolicy

public void setCompressionPolicy(Connection.CompressionPolicy compressionPolicy)
Description copied from interface: Connection
Sets whether compression is enabled or is disabled.

Specified by:
setCompressionPolicy in interface Connection
Parameters:
compressionPolicy - whether Compression is enabled or is disabled.

setTlsPolicy

public void setTlsPolicy(Connection.TLSPolicy tlsPolicy)
Description copied from interface: Connection
Sets whether TLS is mandatory, optional or is disabled. When TLS is mandatory clients are required to secure their connections or otherwise their connections will be closed. On the other hand, when TLS is disabled clients are not allowed to secure their connections using TLS. Their connections will be closed if they try to secure the connection. in this last case.

Specified by:
setTlsPolicy in interface Connection
Parameters:
tlsPolicy - whether TLS is mandatory, optional or is disabled.

getPacketDeliverer

public PacketDeliverer getPacketDeliverer()
Description copied from interface: Connection
Returns the packet deliverer to use when delivering a packet over the socket fails. The packet deliverer will retry to send the packet using some other connection, will store the packet offline for later retrieval or will just drop it.

Specified by:
getPacketDeliverer in interface Connection
Returns:
the packet deliverer to use when delivering a packet over the socket fails.

startTLS

public void startTLS(boolean clientMode,
                     String remoteServer)
              throws Exception
Description copied from interface: Connection
Secures the plain connection by negotiating TLS with the client. When connecting to a remote server then clientMode will be true and remoteServer is the server name of the remote server. Otherwise clientMode will be false and remoteServer null.

Specified by:
startTLS in interface Connection
Parameters:
clientMode - boolean indicating if this entity is a client or a server.
remoteServer - server name of the remote server we are connecting to or null when not in client mode.
Throws:
Exception - if an error occured while securing the connection.

startCompression

public void startCompression()
Description copied from interface: Connection
Start using compression for this connection. Compression will only be available after TLS has been negotiated. This means that a connection can never be using compression before TLS. However, it is possible to use compression without TLS.

Specified by:
startCompression in interface Connection

isSecure

public boolean isSecure()
Description copied from interface: Connection
Returns true if this connection is secure.

Specified by:
isSecure in interface Connection
Returns:
true if the connection is secure (e.g. SSL/TLS)

validate

public boolean validate()
Description copied from interface: Connection
Verifies that the connection is still live. Typically this is done by sending a whitespace character between packets.

Specified by:
validate in interface Connection
Returns:
true if the socket remains valid, false otherwise.

init

public void init(Session session)
Description copied from interface: Connection
Initializes the connection with it's owning session. Allows the connection class to configure itself with session related information (e.g. stream ID).

Specified by:
init in interface Connection
Parameters:
session - the session that owns this connection

close

public void close()
Closes the session, the virtual connection and notifies listeners that the connection has been closed.

Specified by:
close in interface Connection

registerCloseListener

public void registerCloseListener(ConnectionCloseListener listener,
                                  Object handbackMessage)
Description copied from interface: Connection
Registers a listener for close event notification. Registrations after the Session is closed will be immediately notified before the registration call returns (within the context of the registration call). An optional handback object can be associated with the registration if the same listener is registered to listen for multiple connection closures.

Specified by:
registerCloseListener in interface Connection
Parameters:
listener - the listener to register for events.
handbackMessage - the object to send in the event notification.

removeCloseListener

public void removeCloseListener(ConnectionCloseListener listener)
Description copied from interface: Connection
Removes a registered close event listener. Registered listeners must be able to receive close events up until the time this method returns. (i.e. it is possible to call unregister, receive a close event registration, and then have the unregister call return.)

Specified by:
removeCloseListener in interface Connection
Parameters:
listener - the listener to deregister for close events.

closeVirtualConnection

public abstract void closeVirtualConnection()
Closes the virtual connection. Subsclasses should indicate what closing a virtual connection means. At this point the session has a CLOSED state.


Wildfire 3.2.4 Javadoc

Copyright © 2003-2007 Jive Software.