org.eclipse.paho.client.mqttv3.persist
Class MemoryPersistence

java.lang.Object
  extended by org.eclipse.paho.client.mqttv3.persist.MemoryPersistence
All Implemented Interfaces:
MqttClientPersistence

public class MemoryPersistence
extends Object
implements MqttClientPersistence

Persistence that uses memory In cases where reliability is not required across client or device restarts memory this memory peristence can be used. In cases where reliability is required like when clean session is set to false then a non-volatile form of persistence should be used.


Constructor Summary
MemoryPersistence()
           
 
Method Summary
 void clear()
          Clears persistence, so that it no longer contains any persisted data.
 void close()
          Close the persistent store that was previously opened.
 boolean containsKey(String key)
          Returns whether or not data is persisted using the specified key.
 MqttPersistable get(String key)
          Gets the specified data out of the persistent store.
 Enumeration keys()
          Returns an Enumeration over the keys in this persistent data store.
 void open(String clientId, String serverURI)
          Initialise the persistent store.
 void put(String key, MqttPersistable persistable)
          Puts the specified data into the persistent store.
 void remove(String key)
          Remove the data for the specified key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryPersistence

public MemoryPersistence()
Method Detail

close

public void close()
           throws MqttPersistenceException
Description copied from interface: MqttClientPersistence
Close the persistent store that was previously opened. This will be called when a client application disconnects from the broker.

Specified by:
close in interface MqttClientPersistence
Throws:
MqttPersistenceException

keys

public Enumeration keys()
                 throws MqttPersistenceException
Description copied from interface: MqttClientPersistence
Returns an Enumeration over the keys in this persistent data store.

Specified by:
keys in interface MqttClientPersistence
Returns:
an enumeration of String objects.
Throws:
MqttPersistenceException

get

public MqttPersistable get(String key)
                    throws MqttPersistenceException
Description copied from interface: MqttClientPersistence
Gets the specified data out of the persistent store.

Specified by:
get in interface MqttClientPersistence
Parameters:
key - the key for the data, which was used when originally saving it.
Returns:
the un-persisted data
Throws:
MqttPersistenceException - if there was a problem getting the data from the persistent store.

open

public void open(String clientId,
                 String serverURI)
          throws MqttPersistenceException
Description copied from interface: MqttClientPersistence
Initialise the persistent store. If a persistent store exists for this client ID then open it, otherwise create a new one. If the persistent store is already open then just return. An application may use the same client ID to connect to many different servers, so the client ID in conjunction with the connection will uniquely identify the persistence store required.

Specified by:
open in interface MqttClientPersistence
Parameters:
clientId - The client for which the persistent store should be opened.
serverURI - The connection string as specified when the MQTT client instance was created.
Throws:
MqttPersistenceException - if there was a problem opening the persistent store.

put

public void put(String key,
                MqttPersistable persistable)
         throws MqttPersistenceException
Description copied from interface: MqttClientPersistence
Puts the specified data into the persistent store.

Specified by:
put in interface MqttClientPersistence
Parameters:
key - the key for the data, which will be used later to retrieve it.
persistable - the data to persist
Throws:
MqttPersistenceException - if there was a problem putting the data into the persistent store.

remove

public void remove(String key)
            throws MqttPersistenceException
Description copied from interface: MqttClientPersistence
Remove the data for the specified key.

Specified by:
remove in interface MqttClientPersistence
Throws:
MqttPersistenceException

clear

public void clear()
           throws MqttPersistenceException
Description copied from interface: MqttClientPersistence
Clears persistence, so that it no longer contains any persisted data.

Specified by:
clear in interface MqttClientPersistence
Throws:
MqttPersistenceException

containsKey

public boolean containsKey(String key)
                    throws MqttPersistenceException
Description copied from interface: MqttClientPersistence
Returns whether or not data is persisted using the specified key.

Specified by:
containsKey in interface MqttClientPersistence
Parameters:
key - the key for data, which was used when originally saving it.
Throws:
MqttPersistenceException


Copyright © 2013. All Rights Reserved.