001    /**
002     * 
003     * Copyright 2004 Hiram Chirino
004     * 
005     * Licensed under the Apache License, Version 2.0 (the "License"); 
006     * you may not use this file except in compliance with the License. 
007     * You may obtain a copy of the License at 
008     * 
009     * http://www.apache.org/licenses/LICENSE-2.0
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS, 
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
014     * See the License for the specific language governing permissions and 
015     * limitations under the License. 
016     * 
017     **/
018    package org.activemq.store.jdbc;
019    
020    import java.sql.Connection;
021    import java.sql.SQLException;
022    
023    import javax.jms.JMSException;
024    import javax.transaction.xa.XAException;
025    
026    import org.activemq.message.ActiveMQXid;
027    import org.activemq.service.SubscriberEntry;
028    import org.activemq.store.TransactionStore.RecoveryListener;
029    import org.activemq.util.LongSequenceGenerator;
030    
031    /**
032     * @version $Revision: 1.1 $
033     */
034    public interface JDBCAdapter {
035        
036        public interface MessageListResultHandler {
037            public void onMessage(long seq, String messageID) throws JMSException;
038        }
039        
040        public abstract LongSequenceGenerator getSequenceGenerator();
041        public abstract void doCreateTables(Connection c) throws SQLException;
042        public abstract void doDropTables(Connection c) throws SQLException;
043        public abstract void initSequenceGenerator(Connection c);
044        public abstract void doAddMessage(Connection c, long seq, String messageID,
045                String destinationName, byte[] data, long expiration) throws SQLException,
046                JMSException;
047        public abstract byte[] doGetMessage(Connection c, long seq)
048                throws SQLException;
049        public abstract void doRemoveMessage(Connection c, long seq)
050                throws SQLException;
051        public abstract void doRecover(Connection c, String destinationName, MessageListResultHandler listener)
052                throws SQLException, JMSException;
053        public abstract void doRemoveXid(Connection c, ActiveMQXid xid)
054                throws SQLException, XAException;
055        public abstract void doAddXid(Connection c, ActiveMQXid xid)
056                throws SQLException, XAException;
057        public abstract void doLoadPreparedTransactions(Connection c,
058                RecoveryListener listener) throws SQLException;
059        public abstract void doSetLastAck(Connection c, String destinationName, String sub, long seq) 
060                    throws SQLException, JMSException;
061        public abstract void doRecoverSubscription(Connection c, String destinationName, String sub, MessageListResultHandler listener)
062                    throws SQLException, JMSException;
063        public abstract void doSetSubscriberEntry(Connection c, String destinationName, String sub, SubscriberEntry subscriberEntry) 
064                    throws SQLException, JMSException;
065        public abstract SubscriberEntry doGetSubscriberEntry(Connection c, String destinationName, String sub) 
066                    throws SQLException, JMSException;
067            public abstract Long getMessageSequenceId(Connection c, String messageID)
068                            throws SQLException, JMSException;
069        public abstract void doRemoveAllMessages(Connection c, String destinationName)
070                    throws SQLException, JMSException;
071        public abstract void doDeleteSubscription(Connection c, String destinationName, String subscription)
072            throws SQLException, JMSException;
073        public abstract void doDeleteOldMessages(Connection c)
074            throws SQLException, JMSException;
075    }