tuwien.auto.calimero.buffer
Class NetworkBuffer

java.lang.Object
  extended by tuwien.auto.calimero.buffer.NetworkBuffer

public final class NetworkBuffer
extends java.lang.Object

A network buffer temporarily stores KNX network messages.

Reasons to do this might be to lower the response time when answering frequently occurring application queries, leading to a better runtime performance. Another use would be to enable user polled applications.

A network buffer contains one or more Configurations, each of it maintains a setting how to handle, i.e. filter and buffer, certain messages. In other words, a network buffer obtains knowledge of buffering messages by adding configurations.
A configuration works with filters set by the user for that configuration. A filter - depending on its filter type - either applies individual filter rules on incoming messages (Configuration.NetworkFilter) or answers requests from users or components working with that configuration (Configuration.RequestFilter).
If a created configuration is activated and no network filter is set, a default filter is used, which simply accepts all cEMI L-Data.
If no request filter is set, no buffer lookup is done on requests, instead the request is forwarded directly to the KNX network.

In general, one network buffer is created for one KNX installation, to easier distinguish between different installations. Nevertheless, this is not enforced in any way; a new configuration also might just always use a new network buffer.


Field Summary
static java.lang.String LOG_SERVICE
          Name of the log service used for network buffer logging.
 
Method Summary
static NetworkBuffer createBuffer(java.lang.String installationID)
          Creates a new network buffer for a KNX installation.
 Configuration createConfiguration(KNXNetworkLink link)
          Creates a new configuration for this network buffer.
static Configuration createConfiguration(KNXNetworkLink link, java.lang.String installationID)
          Creates a new configuration for the network buffer identified by the installation ID.
static NetworkBuffer[] getAllBuffers()
          Returns all network buffers currently in use.
static NetworkBuffer getBuffer(java.lang.String installationID)
          Returns the network buffer for the given installation ID.
 Configuration getConfiguration(KNXNetworkLink bufferedLink)
          Gets the configuration which provides the buffered link.
 java.lang.String getInstallationID()
          Returns the installation identifier of this network buffer.
static void removeBuffer(java.lang.String installationID)
          Removes a network buffer, and all configurations of that buffer.
 void removeConfiguration(Configuration c)
          Removes a configuration from this network buffer.
static void removeConfiguration(Configuration c, java.lang.String installationID)
          Removes a configuration from the network buffer identified by the installation ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_SERVICE

public static final java.lang.String LOG_SERVICE
Name of the log service used for network buffer logging.

See Also:
Constant Field Values
Method Detail

createBuffer

public static NetworkBuffer createBuffer(java.lang.String installationID)
Creates a new network buffer for a KNX installation.

To identify the buffer an unique installation identifier can be given through installationID.
If null or an empty string is supplied for the installation ID, a new default ID is generated of the form "Installation [ID]", where [ID] is an unique incrementing number. Note, the installation ID string is treated case sensitive.

Parameters:
installationID - installation identifier for the network buffer, or null
Returns:
the new network buffer

createConfiguration

public Configuration createConfiguration(KNXNetworkLink link)
Creates a new configuration for this network buffer.

If the supplied link gets closed, the created configuration will get deactivated (see Configuration.activate(boolean)), and the buffered link of the configuration, obtained with Configuration.getBufferedLink(), will get closed as well.

Parameters:
link - KNX network link communicating with the KNX network
Returns:
the new configuration

createConfiguration

public static Configuration createConfiguration(KNXNetworkLink link,
                                                java.lang.String installationID)
Creates a new configuration for the network buffer identified by the installation ID.

The configuration is added to the network buffer specified by the installation ID. If a network buffer with the supplied installation ID does not exist, it will be created. If null or an empty string is supplied for the installation ID, a new default ID is generated (see createBuffer(String).
If the supplied link gets closed, the created configuration will get deactivated (see Configuration.activate(boolean)), and the buffered link of the configuration, obtained with Configuration.getBufferedLink(), will get closed as well.

Parameters:
link - KNX network link communicating with the KNX network
installationID - installation identifier for the network buffer, or null
Returns:
the new configuration

getAllBuffers

public static NetworkBuffer[] getAllBuffers()
Returns all network buffers currently in use.

Returns:
array of network buffers, array length is 0 on no network buffers

getBuffer

public static NetworkBuffer getBuffer(java.lang.String installationID)
Returns the network buffer for the given installation ID.

Parameters:
installationID - installation ID for the network buffer
Returns:
the network buffer, or null if no buffer found

getConfiguration

public Configuration getConfiguration(KNXNetworkLink bufferedLink)
Gets the configuration which provides the buffered link.

If the network link is not a buffered link or not found in the current configurations of this network buffer, null is returned.

Parameters:
bufferedLink - the buffered link to get the configuration for
Returns:
the owning configuration of that link or null

getInstallationID

public java.lang.String getInstallationID()
Returns the installation identifier of this network buffer.

Returns:
installation ID

removeBuffer

public static void removeBuffer(java.lang.String installationID)
Removes a network buffer, and all configurations of that buffer.

For every Configuration contained in the buffer, (tuwien.auto.calimero.buffer.Configuration) is called.

Parameters:
installationID - installation ID of the network buffer to remove

removeConfiguration

public void removeConfiguration(Configuration c)
Removes a configuration from this network buffer.

The configuration is deactivated and will not receive any further events or incoming messages from the base network link supplied at creation of that configuration.

Parameters:
c - the configuration to remove

removeConfiguration

public static void removeConfiguration(Configuration c,
                                       java.lang.String installationID)
Removes a configuration from the network buffer identified by the installation ID.

If installationID is null, all network buffers are searched for the configuration c.
If the network buffer is found containing the specified configuration, (tuwien.auto.calimero.buffer.Configuration) is called on that buffer.

Parameters:
c - the configuration to remove
installationID - installation identifier for the network buffer, or null