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, OracleJDBCAdapter, StreamJDBCAdapter

public class DefaultJDBCAdapter
extends java.lang.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, MessageId messageID, ActiveMQDestination destination, byte[] data, long expiration)
           
 void doAddMessageReference(TransactionContext c, MessageId messageID, ActiveMQDestination destination, long expirationTime, java.lang.String messageRef)
           
 void doCreateTables(TransactionContext c)
           
 void doDeleteOldMessages(TransactionContext c)
           
 void doDeleteSubscription(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriptionName)
           
 void doDropTables(TransactionContext c)
           
 SubscriptionInfo[] doGetAllSubscriptions(TransactionContext c, ActiveMQDestination destination)
           
 java.util.Set doGetDestinations(TransactionContext c)
           
 int doGetDurableSubscriberMessageCount(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriptionName)
           
 long doGetLastMessageBrokerSequenceId(TransactionContext c)
           
 byte[] doGetMessage(TransactionContext c, long seq)
           
 java.lang.String doGetMessageReference(TransactionContext c, long seq)
           
 void doGetNextDurableSubscriberMessageIdStatement(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriberName, long id, JDBCMessageRecoveryListener listener)
           
 byte[] doGetNextDurableSubscriberMessageStatement(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriberName)
           
 void doGetPrevDurableSubscriberMessageIdStatement(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriberName, long id, JDBCMessageRecoveryListener listener)
           
 SubscriptionInfo doGetSubscriberEntry(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriptionName)
           
 void doRecover(TransactionContext c, ActiveMQDestination destination, JDBCMessageRecoveryListener listener)
           
 void doRecoverNextMessages(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriptionName, long seq, int maxReturned, JDBCMessageRecoveryListener listener)
           
 void doRecoverSubscription(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriptionName, JDBCMessageRecoveryListener listener)
           
 void doRemoveAllMessages(TransactionContext c, ActiveMQDestination destinationName)
           
 void doRemoveMessage(TransactionContext c, long seq)
           
 void doSetLastAck(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriptionName, long seq)
           
 void doSetSubscriberEntry(TransactionContext c, ActiveMQDestination destination, java.lang.String clientId, java.lang.String subscriptionName, java.lang.String selector, boolean retroactive)
           
protected  byte[] getBinaryData(java.sql.ResultSet rs, int index)
           
 long getBrokerSequenceId(TransactionContext c, MessageId messageID)
           
 Statements getStatements()
           
 boolean isBatchStatments()
           
 void setBatchStatments(boolean batchStatments)
           
protected  void setBinaryData(java.sql.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(java.sql.PreparedStatement s,
                             int index,
                             byte[] data)
                      throws java.sql.SQLException
Throws:
java.sql.SQLException

getBinaryData

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

doCreateTables

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

doDropTables

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

doGetLastMessageBrokerSequenceId

public long doGetLastMessageBrokerSequenceId(TransactionContext c)
                                      throws java.sql.SQLException,
                                             java.io.IOException
Specified by:
doGetLastMessageBrokerSequenceId in interface JDBCAdapter
Throws:
java.sql.SQLException
java.io.IOException

doAddMessage

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

doAddMessageReference

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

getBrokerSequenceId

public long getBrokerSequenceId(TransactionContext c,
                                MessageId messageID)
                         throws java.sql.SQLException,
                                java.io.IOException
Specified by:
getBrokerSequenceId in interface JDBCAdapter
Throws:
java.sql.SQLException
java.io.IOException

doGetMessage

public byte[] doGetMessage(TransactionContext c,
                           long seq)
                    throws java.sql.SQLException,
                           java.io.IOException
Specified by:
doGetMessage in interface JDBCAdapter
Throws:
java.sql.SQLException
java.io.IOException

doGetMessageReference

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

doRemoveMessage

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

doRecover

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

doSetLastAck

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

doRecoverSubscription

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

doRecoverNextMessages

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

doGetDurableSubscriberMessageCount

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

doSetSubscriberEntry

public void doSetSubscriberEntry(TransactionContext c,
                                 ActiveMQDestination destination,
                                 java.lang.String clientId,
                                 java.lang.String subscriptionName,
                                 java.lang.String selector,
                                 boolean retroactive)
                          throws java.sql.SQLException,
                                 java.io.IOException
Specified by:
doSetSubscriberEntry in interface JDBCAdapter
Throws:
java.sql.SQLException
java.io.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,
                                             java.lang.String clientId,
                                             java.lang.String subscriptionName)
                                      throws java.sql.SQLException,
                                             java.io.IOException
Specified by:
doGetSubscriberEntry in interface JDBCAdapter
Throws:
java.sql.SQLException
java.io.IOException

doGetAllSubscriptions

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

doRemoveAllMessages

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

doDeleteSubscription

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

doDeleteOldMessages

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

doGetDestinations

public java.util.Set doGetDestinations(TransactionContext c)
                                throws java.sql.SQLException,
                                       java.io.IOException
Specified by:
doGetDestinations in interface JDBCAdapter
Throws:
java.sql.SQLException
java.io.IOException

isBatchStatments

public boolean isBatchStatments()

setBatchStatments

public void setBatchStatments(boolean batchStatments)

setUseExternalMessageReferences

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

getStatements

public Statements getStatements()

setStatements

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

doGetNextDurableSubscriberMessageStatement

public byte[] doGetNextDurableSubscriberMessageStatement(TransactionContext c,
                                                         ActiveMQDestination destination,
                                                         java.lang.String clientId,
                                                         java.lang.String subscriberName)
                                                  throws java.sql.SQLException,
                                                         java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

doGetPrevDurableSubscriberMessageIdStatement

public void doGetPrevDurableSubscriberMessageIdStatement(TransactionContext c,
                                                         ActiveMQDestination destination,
                                                         java.lang.String clientId,
                                                         java.lang.String subscriberName,
                                                         long id,
                                                         JDBCMessageRecoveryListener listener)
                                                  throws java.lang.Exception
Specified by:
doGetPrevDurableSubscriberMessageIdStatement in interface JDBCAdapter
Parameters:
c -
destination -
clientId -
subscriberName -
id -
Throws:
java.lang.Exception
See Also:
org.apache.activemq.store.jdbc.JDBCAdapter#doGetPrevDurableSubscriberMessageStatement(org.apache.activemq.store.jdbc.TransactionContext, org.apache.activemq.command.ActiveMQDestination, java.lang.String, java.lang.String, java.lang.String)

doGetNextDurableSubscriberMessageIdStatement

public void doGetNextDurableSubscriberMessageIdStatement(TransactionContext c,
                                                         ActiveMQDestination destination,
                                                         java.lang.String clientId,
                                                         java.lang.String subscriberName,
                                                         long id,
                                                         JDBCMessageRecoveryListener listener)
                                                  throws java.lang.Exception
Specified by:
doGetNextDurableSubscriberMessageIdStatement in interface JDBCAdapter
Parameters:
c -
destination -
clientId -
subscriberName -
id -
Throws:
java.sql.SQLException
java.io.IOException
java.lang.Exception
See Also:
org.apache.activemq.store.jdbc.JDBCAdapter#doGetNextDurableSubscriberMessageIdStatement(org.apache.activemq.store.jdbc.TransactionContext, org.apache.activemq.command.ActiveMQDestination, java.lang.String, java.lang.String, java.lang.String)


Copyright © 2011 Apache Software Foundation. All Rights Reserved.