org.exolab.jms.persistence
Class PersistenceAdapter

java.lang.Object
  |
  +--org.exolab.jms.persistence.PersistenceAdapter
Direct Known Subclasses:
BatchingRdbmsAdapter, ObjectAdapter, RDBMSAdapter

public abstract class PersistenceAdapter
extends java.lang.Object

This adapter is a wrapper class around the persistency mechanism. It isolates the client from the working specifics of the database, by providing a simple straight forward interface. Future changes to the database will only require changes to the adapter.

Version:
$Revision: 1.39.2.1 $ $Date: 2004/05/04 01:26:48 $
Author:
Jim Mourikis
See Also:
ObjectAdapter, RDBMSAdapter

Constructor Summary
PersistenceAdapter()
           
 
Method Summary
abstract  void addDestination(java.sql.Connection connection, java.lang.String name, boolean queue)
          Add a new destination to the database.
abstract  void addDurableConsumer(java.sql.Connection connection, java.lang.String topic, java.lang.String consumer)
          Add the specified durable consumer
abstract  void addMessage(java.sql.Connection connection, MessageImpl message)
          Add a new message to the database.
abstract  void addMessageHandle(java.sql.Connection connection, PersistentMessageHandle handle)
          Add the specified persistent message handle.
abstract  void addUser(java.sql.Connection connection, User user)
           
abstract  boolean checkDestination(java.sql.Connection connection, java.lang.String name)
          Determine if a particular destination name exists
abstract  void close()
          Close the database if open.
abstract  boolean durableConsumerExists(java.sql.Connection connection, java.lang.String name)
          Check if the durable consumer exists
abstract  java.util.Enumeration getAllDestinations(java.sql.Connection connection)
          Get a list of all destinations stored in the database
abstract  java.util.HashMap getAllDurableConsumers(java.sql.Connection connection)
          Return a dictionary of all registered durable consumers.
abstract  java.util.Enumeration getAllUsers(java.sql.Connection connection)
           
abstract  java.sql.Connection getConnection()
          Return a connection to this persistent data store.
abstract  int getDurableConsumerMessageCount(java.sql.Connection connection, java.lang.String destination, java.lang.String name)
          Return the number of unsent message for the specified durable consumer.
abstract  java.util.Enumeration getDurableConsumers(java.sql.Connection connection, java.lang.String topic)
          Get an enumerated list of all durable consumers for the specified JmsTopic destination
abstract  long getLastId(java.sql.Connection connection)
          Check to see if the root is created.
abstract  MessageImpl getMessage(java.sql.Connection connection, java.lang.String id)
          Get a message from the persistence store.
abstract  java.util.Vector getMessageHandles(java.sql.Connection connection, JmsDestination destination, java.lang.String name)
          Get all the persistent message handles for the specified destination and consumer name.
abstract  java.util.Vector getMessages(java.sql.Connection connection, PersistentMessageHandle handle)
          Get at least the next message given the specified persistent handle.
abstract  java.util.Vector getNonExpiredMessages(java.sql.Connection connection, JmsDestination destination)
          Retrieve a list of unexpired PersistentMessageHandle objects, for the specified destination.
abstract  int getQueueMessageCount(java.sql.Connection connection, java.lang.String name)
          Get the number of unsent messages for a the specified queue
abstract  java.util.Vector getUnprocessedMessages(java.sql.Connection connection)
          Return a list of unprocessed messages.
abstract  User getUser(java.sql.Connection connection, User user)
           
abstract  int purgeMessages()
          Deprecated. no replacement
abstract  void removeDestination(java.sql.Connection connection, java.lang.String destination)
          Remove the destination with the specified name and all registered consumers from the database.
abstract  void removeDurableConsumer(java.sql.Connection connection, java.lang.String consumer)
          Remove the durable consumer for the specified topic.
abstract  void removeExpiredMessageHandles(java.sql.Connection connection, java.lang.String consumer)
          Remove all expired messages handles associated with this durable consumer.
abstract  void removeExpiredMessages(java.sql.Connection connection)
          Remove all expired messages and associated references from the database.
abstract  void removeMessage(java.sql.Connection connection, java.lang.String id)
          Remove the message with the specified identity from the database
abstract  void removeMessageHandle(java.sql.Connection connection, PersistentMessageHandle handle)
          Remove the specified persistent message handle.
abstract  void removeUser(java.sql.Connection connection, User user)
           
abstract  void updateIds(java.sql.Connection connection, long id)
          Update the given id.
abstract  void updateMessage(java.sql.Connection connection, MessageImpl message)
          Update this message in the database
abstract  void updateMessageHandle(java.sql.Connection connection, PersistentMessageHandle handle)
          Update the specified persistent message handle.
abstract  void updateUser(java.sql.Connection connection, User user)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PersistenceAdapter

public PersistenceAdapter()
Method Detail

close

public abstract void close()
Close the database if open.

getLastId

public abstract long getLastId(java.sql.Connection connection)
                        throws PersistenceException
Check to see if the root is created. If its not then create it and initialise it to 0. Return the value of this root id.
Returns:
long The id of the last batch.
Throws:
PersistenceException -  

updateIds

public abstract void updateIds(java.sql.Connection connection,
                               long id)
                        throws PersistenceException
Update the given id.
Parameters:
connection - - the connection to use
id - The id to set in the database.
Throws:
PersistenceException -  

addMessage

public abstract void addMessage(java.sql.Connection connection,
                                MessageImpl message)
                         throws PersistenceException
Add a new message to the database.
Parameters:
connection - - the connection to use
MessageImpl - the new message to add
Throws:
PersistenceException -  

updateMessage

public abstract void updateMessage(java.sql.Connection connection,
                                   MessageImpl message)
                            throws PersistenceException
Update this message in the database
Parameters:
connection - - the connection to use
MessageImpl - the new message to update
Throws:
PersistenceException -  

removeMessage

public abstract void removeMessage(java.sql.Connection connection,
                                   java.lang.String id)
                            throws PersistenceException
Remove the message with the specified identity from the database
Parameters:
connection - - the connection to use
name - - the identity of the message to remove.
Throws:
PersistenceException -  

removeExpiredMessages

public abstract void removeExpiredMessages(java.sql.Connection connection)
                                    throws PersistenceException
Remove all expired messages and associated references from the database. It uses the current time to determine messages that have exipred.
Parameters:
connection - - the connection to use
Throws:
PersistenceException -  

removeExpiredMessageHandles

public abstract void removeExpiredMessageHandles(java.sql.Connection connection,
                                                 java.lang.String consumer)
                                          throws PersistenceException
Remove all expired messages handles associated with this durable consumer.
Parameters:
connection - - the connection to use
consumer - - the durable consumer name
Throws:
PersistenceException -  

getNonExpiredMessages

public abstract java.util.Vector getNonExpiredMessages(java.sql.Connection connection,
                                                       JmsDestination destination)
                                                throws PersistenceException
Retrieve a list of unexpired PersistentMessageHandle objects, for the specified destination.
Parameters:
connection - - the connection to use
destination - - the destination in question
Returns:
Vector - collection of unexpired message handles
Throws:
PersistenceException -  

getMessage

public abstract MessageImpl getMessage(java.sql.Connection connection,
                                       java.lang.String id)
                                throws PersistenceException
Get a message from the persistence store.
Parameters:
connection - - the connection to use
String - The id of the message to search for
Returns:
MessageImpl The message if found otherwise null
Throws:
PersistenceException -  

getMessages

public abstract java.util.Vector getMessages(java.sql.Connection connection,
                                             PersistentMessageHandle handle)
                                      throws PersistenceException
Get at least the next message given the specified persistent handle. The handle encodes all the information, including destination and timestamp, required to fetch that and successive messages. This will fault in more than one message for performance
Parameters:
connection - - the connection to use
handle - - the persistent handle to resolve
Returns:
Vector - a vector of MessageImpl
Throws:
PersistenceException -  

getUnprocessedMessages

public abstract java.util.Vector getUnprocessedMessages(java.sql.Connection connection)
                                                 throws PersistenceException
Return a list of unprocessed messages. These are messages that have been stored in the database but not processed.
Parameters:
connection - - the connection to use
Returns:
Vector - a collection of un processed messages
Throws:
PersistenceException -  

addMessageHandle

public abstract void addMessageHandle(java.sql.Connection connection,
                                      PersistentMessageHandle handle)
                               throws PersistenceException
Add the specified persistent message handle.
Parameters:
connection - - the connection to use
handle - - the persistent handle to add
Throws:
PersistenceException -  

updateMessageHandle

public abstract void updateMessageHandle(java.sql.Connection connection,
                                         PersistentMessageHandle handle)
                                  throws PersistenceException
Update the specified persistent message handle.
Parameters:
connection - - the connection to use
handle - - the persistent handle to update
Throws:
PersistenceException -  

removeMessageHandle

public abstract void removeMessageHandle(java.sql.Connection connection,
                                         PersistentMessageHandle handle)
                                  throws PersistenceException
Remove the specified persistent message handle.
Parameters:
connection - - the connection to use
handle - - the persistent handle to remove
Throws:
PersistenceException -  
PersistenceException -  

getMessageHandles

public abstract java.util.Vector getMessageHandles(java.sql.Connection connection,
                                                   JmsDestination destination,
                                                   java.lang.String name)
                                            throws PersistenceException
Get all the persistent message handles for the specified destination and consumer name.

The returned messages reference unacked or unsent messages

NEED A STRATEGY WHEN WE HAVE LOTS OF MESSAGE HANDLES

Parameters:
connection - - the connection to use
destination - - the destination to reference
name - - the consumer name
Throws:
PersistenceException -  

addDurableConsumer

public abstract void addDurableConsumer(java.sql.Connection connection,
                                        java.lang.String topic,
                                        java.lang.String consumer)
                                 throws PersistenceException
Add the specified durable consumer
Parameters:
connection - - the connection to use
topic - - the name of the topic
name - - the name of the consumer
Throws:
PersistenceException -  

removeDurableConsumer

public abstract void removeDurableConsumer(java.sql.Connection connection,
                                           java.lang.String consumer)
                                    throws PersistenceException
Remove the durable consumer for the specified topic.
Parameters:
connection - - the connection to use
consumer - - the consumer name
Throws:
PersistenceException -  

durableConsumerExists

public abstract boolean durableConsumerExists(java.sql.Connection connection,
                                              java.lang.String name)
                                       throws PersistenceException
Check if the durable consumer exists
Parameters:
connection - - the connection to use
name - - durable consumer name
Returns:
boolean - true if it exists and false otherwise
Throws:
PersistenceException -  

getDurableConsumers

public abstract java.util.Enumeration getDurableConsumers(java.sql.Connection connection,
                                                          java.lang.String topic)
                                                   throws PersistenceException
Get an enumerated list of all durable consumers for the specified JmsTopic destination
Parameters:
connection - - the connection to use
topic - - the topic to query
Returns:
Vector - list of durable subscriber names
Throws:
PersistenceException -  

getAllDurableConsumers

public abstract java.util.HashMap getAllDurableConsumers(java.sql.Connection connection)
                                                  throws PersistenceException
Return a dictionary of all registered durable consumers. The dictionary is keyed on consumer name and maps to the underlying destination name. The destination name maybe a wildcard
Parameters:
connection - - the connection to use
Returns:
HashMap key=consumer name and value is destination
Throws:
PersistenceException -  

addDestination

public abstract void addDestination(java.sql.Connection connection,
                                    java.lang.String name,
                                    boolean queue)
                             throws PersistenceException
Add a new destination to the database.
Parameters:
connection - - the connection to use
name - - the destination name
queue - - true if it pertains to a queue
Throws:
PersistenceException -  

removeDestination

public abstract void removeDestination(java.sql.Connection connection,
                                       java.lang.String destination)
                                throws PersistenceException
Remove the destination with the specified name and all registered consumers from the database. Consumer registrations.
Parameters:
connection - - the connection to use
destination - - the name of the destination
Throws:
PersistenceException -  

checkDestination

public abstract boolean checkDestination(java.sql.Connection connection,
                                         java.lang.String name)
                                  throws PersistenceException
Determine if a particular destination name exists
Parameters:
connection - - the connection to use
name - - the name to query
Returns:
boolean - true if it exists; false otherwise
Throws:
PersistenceException -  

getAllDestinations

public abstract java.util.Enumeration getAllDestinations(java.sql.Connection connection)
                                                  throws PersistenceException
Get a list of all destinations stored in the database
Parameters:
connection - - the connection to use
Returns:
Enumeration - the list of destinations
Throws:
PersistenceException -  

getQueueMessageCount

public abstract int getQueueMessageCount(java.sql.Connection connection,
                                         java.lang.String name)
                                  throws PersistenceException
Get the number of unsent messages for a the specified queue
Parameters:
connection - - the connection to use
name - - the name of the queue
Returns:
int - the number of unsent or unacked messages
Throws:
PersistenceException -  

getDurableConsumerMessageCount

public abstract int getDurableConsumerMessageCount(java.sql.Connection connection,
                                                   java.lang.String destination,
                                                   java.lang.String name)
                                            throws PersistenceException
Return the number of unsent message for the specified durable consumer.
Parameters:
connection - - the connection to use
destination - - the destination name
name - - the name of the durable subscriber
Returns:
int - the nmber of unsent or unacked messages
Throws:
PersistenceException -  

purgeMessages

public abstract int purgeMessages()
Deprecated. no replacement

Purge all processed messages from the database.
Returns:
int - the number of messages purged

getConnection

public abstract java.sql.Connection getConnection()
                                           throws PersistenceException
Return a connection to this persistent data store.
Returns:
Connection - a connection to the persistent store or null
Throws:
PersistenceException - - if it cannot retrieve a connection

getAllUsers

public abstract java.util.Enumeration getAllUsers(java.sql.Connection connection)
                                           throws PersistenceException

addUser

public abstract void addUser(java.sql.Connection connection,
                             User user)
                      throws PersistenceException

removeUser

public abstract void removeUser(java.sql.Connection connection,
                                User user)
                         throws PersistenceException

updateUser

public abstract void updateUser(java.sql.Connection connection,
                                User user)
                         throws PersistenceException

getUser

public abstract User getUser(java.sql.Connection connection,
                             User user)
                      throws PersistenceException


Copyright © 1999-2004 The OpenJMS Group. All Rights Reserved.