org.apache.activemq.store.jdbc.adapter
Class DefaultJDBCAdapter

java.lang.Object
  extended by org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter
All Implemented Interfaces:
JDBCAdapter
Direct Known Subclasses:
BlobJDBCAdapter, BytesJDBCAdapter, DB2JDBCAdapter, ImageBasedJDBCAdaptor, MaxDBJDBCAdapter, MySqlJDBCAdapter, StreamJDBCAdapter

public class DefaultJDBCAdapter
extends Object
implements JDBCAdapter

Implements all the default JDBC operations that are used by the JDBCPersistenceAdapter.

sub-classing is encouraged to override the default implementation of methods to account for differences in JDBC Driver implementations.

The JDBCAdapter inserts and extracts BLOB data using the getBytes()/setBytes() operations.

The databases/JDBC drivers that use this adapter are:

Version:
$Revision: 1.10 $

Field Summary
protected  boolean batchStatments
           
protected  Statements statements
           
 
Constructor Summary
DefaultJDBCAdapter()
           
 
Method Summary
 void doAddMessage(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration)
           
 void doAddMessageReference(TransactionContext c, long sequence, MessageId messageID, ActiveMQDestination destination, long expirationTime, String messageRef)
           
 void doCreateTables(TransactionContext c)
           
 void doDeleteOldMessages(TransactionContext c)
           
 void doDeleteSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName)
           
 void doDropTables(TransactionContext c)
           
 SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c, ActiveMQDestination destination)
           
 Set<ActiveMQDestination> doGetDestinations(TransactionContext c)
           
 int doGetDurableSubscriberMessageCount(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName)
           
 long doGetLastAckedDurableSubscriberMessageId(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriberName)
           
 long doGetLastMessageStoreSequenceId(TransactionContext c)
           
 byte[] doGetMessage(TransactionContext c, MessageId id)
           
 byte[] doGetMessageById(TransactionContext c, long storeSequenceId)
           
 int doGetMessageCount(TransactionContext c, ActiveMQDestination destination)
           
 String doGetMessageReference(TransactionContext c, long seq)
           
 byte[] doGetNextDurableSubscriberMessageStatement(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriberName)
           
 SubscriptionInfo doGetSubscriberEntry(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName)
           
 void doMessageIdScan(TransactionContext c, int limit, JDBCMessageIdScanListener listener)
           
 void doRecover(TransactionContext c, ActiveMQDestination destination, JDBCMessageRecoveryListener listener)
           
 void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, long nextSeq, int maxReturned, JDBCMessageRecoveryListener listener)
           
 void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq, int maxReturned, JDBCMessageRecoveryListener listener)
           
 void doRecoverSubscription(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, JDBCMessageRecoveryListener listener)
           
 void doRemoveAllMessages(TransactionContext c, ActiveMQDestination destinationName)
           
 void doRemoveMessage(TransactionContext c, long seq)
           
 void doSetLastAck(TransactionContext c, ActiveMQDestination destination, String clientId, String subscriptionName, long seq)
           
 void doSetSubscriberEntry(TransactionContext c, SubscriptionInfo info, boolean retroactive)
           
protected  byte[] getBinaryData(ResultSet rs, int index)
           
 Statements getStatements()
           
 long getStoreSequenceId(TransactionContext c, MessageId messageID)
           
 boolean isBatchStatments()
           
 void setBatchStatments(boolean batchStatments)
           
protected  void setBinaryData(PreparedStatement s, int index, byte[] data)
           
 void setStatements(Statements statements)
           
 void setUseExternalMessageReferences(boolean useExternalMessageReferences)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

statements

protected Statements statements

batchStatments

protected boolean batchStatments
Constructor Detail

DefaultJDBCAdapter

public DefaultJDBCAdapter()
Method Detail

setBinaryData

protected void setBinaryData(PreparedStatement s,
                             int index,
                             byte[] data)
                      throws SQLException
Throws:
SQLException

getBinaryData

protected byte[] getBinaryData(ResultSet rs,
                               int index)
                        throws SQLException
Throws:
SQLException

doCreateTables

public void doCreateTables(TransactionContext c)
                    throws SQLException,
                           IOException
Specified by:
doCreateTables in interface JDBCAdapter
Throws:
SQLException
IOException

doDropTables

public void doDropTables(TransactionContext c)
                  throws SQLException,
                         IOException
Specified by:
doDropTables in interface JDBCAdapter
Throws:
SQLException
IOException

doGetLastMessageStoreSequenceId

public long doGetLastMessageStoreSequenceId(TransactionContext c)
                                     throws SQLException,
                                            IOException
Specified by:
doGetLastMessageStoreSequenceId in interface JDBCAdapter
Throws:
SQLException
IOException

doGetMessageById

public byte[] doGetMessageById(TransactionContext c,
                               long storeSequenceId)
                        throws SQLException,
                               IOException
Specified by:
doGetMessageById in interface JDBCAdapter
Throws:
SQLException
IOException

doAddMessage

public void doAddMessage(TransactionContext c,
                         long sequence,
                         MessageId messageID,
                         ActiveMQDestination destination,
                         byte[] data,
                         long expiration)
                  throws SQLException,
                         IOException
Specified by:
doAddMessage in interface JDBCAdapter
Throws:
SQLException
IOException

doAddMessageReference

public void doAddMessageReference(TransactionContext c,
                                  long sequence,
                                  MessageId messageID,
                                  ActiveMQDestination destination,
                                  long expirationTime,
                                  String messageRef)
                           throws SQLException,
                                  IOException
Specified by:
doAddMessageReference in interface JDBCAdapter
Throws:
SQLException
IOException

getStoreSequenceId

public long getStoreSequenceId(TransactionContext c,
                               MessageId messageID)
                        throws SQLException,
                               IOException
Specified by:
getStoreSequenceId in interface JDBCAdapter
Throws:
SQLException
IOException

doGetMessage

public byte[] doGetMessage(TransactionContext c,
                           MessageId id)
                    throws SQLException,
                           IOException
Specified by:
doGetMessage in interface JDBCAdapter
Throws:
SQLException
IOException

doGetMessageReference

public String doGetMessageReference(TransactionContext c,
                                    long seq)
                             throws SQLException,
                                    IOException
Specified by:
doGetMessageReference in interface JDBCAdapter
Throws:
SQLException
IOException

doRemoveMessage

public void doRemoveMessage(TransactionContext c,
                            long seq)
                     throws SQLException,
                            IOException
Specified by:
doRemoveMessage in interface JDBCAdapter
Throws:
SQLException
IOException

doRecover

public void doRecover(TransactionContext c,
                      ActiveMQDestination destination,
                      JDBCMessageRecoveryListener listener)
               throws Exception
Specified by:
doRecover in interface JDBCAdapter
Throws:
Exception

doMessageIdScan

public void doMessageIdScan(TransactionContext c,
                            int limit,
                            JDBCMessageIdScanListener listener)
                     throws SQLException,
                            IOException
Specified by:
doMessageIdScan in interface JDBCAdapter
Throws:
SQLException
IOException

doSetLastAck

public void doSetLastAck(TransactionContext c,
                         ActiveMQDestination destination,
                         String clientId,
                         String subscriptionName,
                         long seq)
                  throws SQLException,
                         IOException
Specified by:
doSetLastAck in interface JDBCAdapter
Throws:
SQLException
IOException

doRecoverSubscription

public void doRecoverSubscription(TransactionContext c,
                                  ActiveMQDestination destination,
                                  String clientId,
                                  String subscriptionName,
                                  JDBCMessageRecoveryListener listener)
                           throws Exception
Specified by:
doRecoverSubscription in interface JDBCAdapter
Throws:
Exception

doRecoverNextMessages

public void doRecoverNextMessages(TransactionContext c,
                                  ActiveMQDestination destination,
                                  String clientId,
                                  String subscriptionName,
                                  long seq,
                                  int maxReturned,
                                  JDBCMessageRecoveryListener listener)
                           throws Exception
Specified by:
doRecoverNextMessages in interface JDBCAdapter
Throws:
Exception

doGetDurableSubscriberMessageCount

public int doGetDurableSubscriberMessageCount(TransactionContext c,
                                              ActiveMQDestination destination,
                                              String clientId,
                                              String subscriptionName)
                                       throws SQLException,
                                              IOException
Specified by:
doGetDurableSubscriberMessageCount in interface JDBCAdapter
Throws:
SQLException
IOException

doSetSubscriberEntry

public void doSetSubscriberEntry(TransactionContext c,
                                 SubscriptionInfo info,
                                 boolean retroactive)
                          throws SQLException,
                                 IOException
Specified by:
doSetSubscriberEntry in interface JDBCAdapter
Parameters:
c -
info -
retroactive -
Throws:
SQLException
IOException
See Also:
org.apache.activemq.store.jdbc.JDBCAdapter#doSetSubscriberEntry(java.sql.Connection, java.lang.Object, org.apache.activemq.service.SubscriptionInfo)

doGetSubscriberEntry

public SubscriptionInfo doGetSubscriberEntry(TransactionContext c,
                                             ActiveMQDestination destination,
                                             String clientId,
                                             String subscriptionName)
                                      throws SQLException,
                                             IOException
Specified by:
doGetSubscriberEntry in interface JDBCAdapter
Throws:
SQLException
IOException

doGetAllSubscriptions

public SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c,
                                                ActiveMQDestination destination)
                                         throws SQLException,
                                                IOException
Specified by:
doGetAllSubscriptions in interface JDBCAdapter
Throws:
SQLException
IOException

doRemoveAllMessages

public void doRemoveAllMessages(TransactionContext c,
                                ActiveMQDestination destinationName)
                         throws SQLException,
                                IOException
Specified by:
doRemoveAllMessages in interface JDBCAdapter
Throws:
SQLException
IOException

doDeleteSubscription

public void doDeleteSubscription(TransactionContext c,
                                 ActiveMQDestination destination,
                                 String clientId,
                                 String subscriptionName)
                          throws SQLException,
                                 IOException
Specified by:
doDeleteSubscription in interface JDBCAdapter
Throws:
SQLException
IOException

doDeleteOldMessages

public void doDeleteOldMessages(TransactionContext c)
                         throws SQLException,
                                IOException
Specified by:
doDeleteOldMessages in interface JDBCAdapter
Throws:
SQLException
IOException

doGetLastAckedDurableSubscriberMessageId

public long doGetLastAckedDurableSubscriberMessageId(TransactionContext c,
                                                     ActiveMQDestination destination,
                                                     String clientId,
                                                     String subscriberName)
                                              throws SQLException,
                                                     IOException
Specified by:
doGetLastAckedDurableSubscriberMessageId in interface JDBCAdapter
Throws:
SQLException
IOException

doGetDestinations

public Set<ActiveMQDestination> doGetDestinations(TransactionContext c)
                                           throws SQLException,
                                                  IOException
Specified by:
doGetDestinations in interface JDBCAdapter
Throws:
SQLException
IOException

isBatchStatments

public boolean isBatchStatments()
Returns:
true if batchStements

setBatchStatments

public void setBatchStatments(boolean batchStatments)
Parameters:
batchStatments -

setUseExternalMessageReferences

public void setUseExternalMessageReferences(boolean useExternalMessageReferences)
Specified by:
setUseExternalMessageReferences in interface JDBCAdapter

getStatements

public Statements getStatements()
Returns:
the statements

setStatements

public void setStatements(Statements statements)
Specified by:
setStatements in interface JDBCAdapter

doGetNextDurableSubscriberMessageStatement

public byte[] doGetNextDurableSubscriberMessageStatement(TransactionContext c,
                                                         ActiveMQDestination destination,
                                                         String clientId,
                                                         String subscriberName)
                                                  throws SQLException,
                                                         IOException
Parameters:
c -
destination -
clientId -
subscriberName -
Returns:
Throws:
SQLException
IOException

doGetMessageCount

public int doGetMessageCount(TransactionContext c,
                             ActiveMQDestination destination)
                      throws SQLException,
                             IOException
Specified by:
doGetMessageCount in interface JDBCAdapter
Throws:
SQLException
IOException

doRecoverNextMessages

public void doRecoverNextMessages(TransactionContext c,
                                  ActiveMQDestination destination,
                                  long nextSeq,
                                  int maxReturned,
                                  JDBCMessageRecoveryListener listener)
                           throws Exception
Specified by:
doRecoverNextMessages in interface JDBCAdapter
Throws:
Exception


Copyright © 2005-2011 Apache Software Foundation. All Rights Reserved.