xmlBlaster 2.2.0 API

org.xmlBlaster.util.queue.jdbc
Class XBRefFactory

java.lang.Object
  extended by org.xmlBlaster.util.queue.jdbc.XBFactoryBase
      extended by org.xmlBlaster.util.queue.jdbc.XBFactory
          extended by org.xmlBlaster.util.queue.jdbc.XBRefFactory

public class XBRefFactory
extends XBFactory

Author:
Marcel Ruff, Michele Laghi

Field Summary
private static int BYTE_SIZE
           
private  java.lang.String deleteWithLimitExclSt
           
private  java.lang.String deleteWithLimitInclSt
           
private static int DURABLE
           
private static int FLAG1
           
private  java.lang.String getAndDeleteSt
           
private  java.lang.String getByPrioSt
           
private  java.lang.String getBySamePrioSt
           
private  java.lang.String getFirstRefAndMeatEntriesStartAtSt
           
private  java.lang.String getFirstRefEntriesStartAtSt
           
private  java.lang.String getWithLimitSt
           
private static int LAST_ROW
           
private static java.util.logging.Logger log
           
private static int MEAT_ID
           
private  XBMeatFactory meatFactory
           
private static int META_INFO
           
private static int METHOD_NAME
           
private static int PRIO
           
private static int REF_ID
           
private static int STORE_ID
           
 
Fields inherited from class org.xmlBlaster.util.queue.jdbc.XBFactory
base, countSt, createSt, deleteAllSt, deleteCompleteSt, deleteSt, deleteTransientsSt, dropSt, getAllSt, getCompleteSt, getFirstEntriesSt, getNumOfAllSt, getSt, inList, insertSt, prefix, table
 
Fields inherited from class org.xmlBlaster.util.queue.jdbc.XBFactoryBase
DB2, FIREBIRD, HSQLDB, LDBC, MYSQL, ORACLE, POSTGRES, SQLITE, SQLSERVER_2000, SQLSERVER_2005, UNKNOWN
 
Constructor Summary
XBRefFactory(java.lang.String prefix)
           
 
Method Summary
 int deleteAllStore(XBStore store, java.sql.Connection conn, int timeout)
           
 long deleteList(XBStore store, java.sql.Connection conn, XBEntry[] entries, int maxStLength, int maxNumSt, boolean commitInBetween, int timeout)
          Deletes the specified entries.
 long deleteWithLimit(XBStore store, java.sql.Connection conn, XBRef limitEntry, boolean inclusive)
          deletes the first numOfEntries of the queue until the limitEntry is reached.
protected  void doInit(I_Info info)
           
 XBRef get(XBStore store, long id, java.sql.Connection conn, int timeout)
           
(package private)  ReturnDataHolder getAndDeleteLowest(XBStore store, java.sql.Connection conn, int numOfEntries, long numOfBytes, int maxPriority, long minUniqueId, boolean leaveOne, boolean doDelete, int maxStLength, int maxNumSt, int timeout)
          Under the same transaction it gets and deletes all the entries which fit into the constrains specified in the argument list.
protected  long getByteSize(java.sql.ResultSet rs, int offset)
           
 java.util.List<XBRef> getEntriesByPriority(XBStore store, java.sql.Connection conn, int numOfEntries, long numOfBytes, int minPrio, int maxPrio, boolean onlyId)
          gets the first numOfEntries of the queue which have the priority in the range specified by prioMin and prioMax (inclusive).
 java.util.List<XBRef> getEntriesBySamePriority(XBStore store, java.sql.Connection conn, int numOfEntries, long numOfBytes)
          gets the first numOfEntries of the queue which have the same priority.
 java.util.List<XBRef> getFirstRefEntries(XBStore store, java.sql.Connection conn, long numOfEntries, long numOfBytes, int timeout)
           
 java.util.List<XBRef> getFirstRefEntriesStartAt(XBStore store, java.sql.Connection conn, long numOfEntries, long numOfBytes, int timeout, I_QueueEntry firstEntryExlusive)
           
(package private) static java.lang.String getName()
           xbrefid NUMBER(20) primary key, xbstoreid NUMBER(20) not null, xbmeatid NUMBER(20) , xbdurable char(1) default 'F' not null , xbbytesize NUMBER(10) , xbmetainfo clob default '', xbflag1 varchar(32) default '', xbprio NUMBER(10)
 java.util.List<XBRef> getWithLimit(XBStore store, java.sql.Connection conn, XBRef limitRef)
           
 void insert(XBRef xbRef, java.sql.Connection conn, int timeout)
          Inserts an entry in the database
private  boolean isInsideRange(int numEntries, int maxNumEntries, long numBytes, long maxNumBytes)
          Helper method to find out if still to retrieve entries in getAndDeleteLowest or not.
protected  void prepareDefaultStatements()
          This method must be implemented in all underlying extentions to this class.
private  java.util.List<XBRef> rs2List(XBStore store, java.sql.ResultSet rs, long numOfEntries, long numOfBytes, boolean onlyId)
           
protected  XBRef rsToEntry(XBStore store, java.sql.ResultSet rs)
           
 
Methods inherited from class org.xmlBlaster.util.queue.jdbc.XBFactory
checkSameStore, count, create, delete, deleteTransients, drop, fillDbCol, getDbCol, getList, getNumOfAll, init, isTrue, readStream, whereInStatement
 
Methods inherited from class org.xmlBlaster.util.queue.jdbc.XBFactoryBase
getDbVendor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

REF_ID

private static final int REF_ID
See Also:
Constant Field Values

STORE_ID

private static final int STORE_ID
See Also:
Constant Field Values

MEAT_ID

private static final int MEAT_ID
See Also:
Constant Field Values

DURABLE

private static final int DURABLE
See Also:
Constant Field Values

BYTE_SIZE

private static final int BYTE_SIZE
See Also:
Constant Field Values

META_INFO

private static final int META_INFO
See Also:
Constant Field Values

FLAG1

private static final int FLAG1
See Also:
Constant Field Values

PRIO

private static final int PRIO
See Also:
Constant Field Values

METHOD_NAME

private static final int METHOD_NAME
See Also:
Constant Field Values

LAST_ROW

private static final int LAST_ROW
See Also:
Constant Field Values

getAndDeleteSt

private java.lang.String getAndDeleteSt

getBySamePrioSt

private java.lang.String getBySamePrioSt

getByPrioSt

private java.lang.String getByPrioSt

deleteWithLimitInclSt

private java.lang.String deleteWithLimitInclSt

deleteWithLimitExclSt

private java.lang.String deleteWithLimitExclSt

getWithLimitSt

private java.lang.String getWithLimitSt

getFirstRefEntriesStartAtSt

private java.lang.String getFirstRefEntriesStartAtSt

getFirstRefAndMeatEntriesStartAtSt

private java.lang.String getFirstRefAndMeatEntriesStartAtSt

meatFactory

private XBMeatFactory meatFactory
Constructor Detail

XBRefFactory

public XBRefFactory(java.lang.String prefix)
Method Detail

getName

static java.lang.String getName()
  xbrefid NUMBER(20) primary key,
  xbstoreid NUMBER(20) not null,
  xbmeatid NUMBER(20) ,
  xbdurable char(1) default 'F' not null ,
  xbbytesize NUMBER(10) ,
  xbmetainfo clob default '',
  xbflag1 varchar(32) default '',
  xbprio  NUMBER(10)
 


prepareDefaultStatements

protected void prepareDefaultStatements()
Description copied from class: XBFactory
This method must be implemented in all underlying extentions to this class. It returns (for the different database vendors a default for the creation of the table.

Overrides:
prepareDefaultStatements in class XBFactory

doInit

protected void doInit(I_Info info)
               throws XmlBlasterException
Specified by:
doInit in class XBFactoryBase
Throws:
XmlBlasterException

insert

public void insert(XBRef xbRef,
                   java.sql.Connection conn,
                   int timeout)
            throws java.sql.SQLException,
                   java.io.UnsupportedEncodingException
Inserts an entry in the database

Parameters:
table -
xbMeat - The object to store. Note that
conn - The database connection to use
timeout - the time in seconds it has to wait for a response. If less than 1 it is not set.
Throws:
java.sql.SQLException - If an exception occurs in the backend. For example if the entry already exists in the database.
java.io.UnsupportedEncodingException

rsToEntry

protected XBRef rsToEntry(XBStore store,
                          java.sql.ResultSet rs)
                   throws java.sql.SQLException,
                          java.io.IOException
Specified by:
rsToEntry in class XBFactory
Throws:
java.sql.SQLException
java.io.IOException

getFirstRefEntries

public java.util.List<XBRef> getFirstRefEntries(XBStore store,
                                                java.sql.Connection conn,
                                                long numOfEntries,
                                                long numOfBytes,
                                                int timeout)
                                         throws java.sql.SQLException,
                                                java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

getFirstRefEntriesStartAt

public java.util.List<XBRef> getFirstRefEntriesStartAt(XBStore store,
                                                       java.sql.Connection conn,
                                                       long numOfEntries,
                                                       long numOfBytes,
                                                       int timeout,
                                                       I_QueueEntry firstEntryExlusive)
                                                throws java.sql.SQLException,
                                                       java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

get

public XBRef get(XBStore store,
                 long id,
                 java.sql.Connection conn,
                 int timeout)
          throws java.sql.SQLException,
                 java.io.IOException
Parameters:
sql - The select statement to use to fill the objects.
conn -
Returns:
null if the object has not been found or the object if it has been found on the backend.
Throws:
java.sql.SQLException
java.io.IOException

isInsideRange

private final boolean isInsideRange(int numEntries,
                                    int maxNumEntries,
                                    long numBytes,
                                    long maxNumBytes)
Helper method to find out if still to retrieve entries in getAndDeleteLowest or not.


getAndDeleteLowest

ReturnDataHolder getAndDeleteLowest(XBStore store,
                                    java.sql.Connection conn,
                                    int numOfEntries,
                                    long numOfBytes,
                                    int maxPriority,
                                    long minUniqueId,
                                    boolean leaveOne,
                                    boolean doDelete,
                                    int maxStLength,
                                    int maxNumSt,
                                    int timeout)
                              throws java.sql.SQLException,
                                     java.io.IOException
Under the same transaction it gets and deletes all the entries which fit into the constrains specified in the argument list. The entries are really deleted only if doDelete is true, otherwise they are left untouched on the queue

Returns:
ReturnDataHolder.refList is filled!! (ReturnDataHolder.list is empty)
Throws:
java.sql.SQLException
java.io.IOException
See Also:
I_Queue.takeLowest(int, long, org.xmlBlaster.util.queue.I_QueueEntry, boolean)

rs2List

private java.util.List<XBRef> rs2List(XBStore store,
                                      java.sql.ResultSet rs,
                                      long numOfEntries,
                                      long numOfBytes,
                                      boolean onlyId)
                               throws java.sql.SQLException,
                                      java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

getEntriesByPriority

public java.util.List<XBRef> getEntriesByPriority(XBStore store,
                                                  java.sql.Connection conn,
                                                  int numOfEntries,
                                                  long numOfBytes,
                                                  int minPrio,
                                                  int maxPrio,
                                                  boolean onlyId)
                                           throws java.sql.SQLException,
                                                  java.io.IOException
gets the first numOfEntries of the queue which have the priority in the range specified by prioMin and prioMax (inclusive). If there are not so many entries in the queue, all elements in the queue are returned.

Parameters:
storageId - the storageId of the queue/storage from which to retrieve the information.
numOfEntries - the maximum number of elements to retrieve. If negative there is no constriction.
numOfBytes - the maximum number of bytes to retrieve. If negative, there is no constriction.
minPrio - the minimum priority to retreive (inclusive).
maxPrio - the maximum priority to retrieve (inclusive).
Throws:
java.sql.SQLException
java.io.IOException

getWithLimit

public java.util.List<XBRef> getWithLimit(XBStore store,
                                          java.sql.Connection conn,
                                          XBRef limitRef)
                                   throws java.sql.SQLException,
                                          java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

getEntriesBySamePriority

public java.util.List<XBRef> getEntriesBySamePriority(XBStore store,
                                                      java.sql.Connection conn,
                                                      int numOfEntries,
                                                      long numOfBytes)
                                               throws java.sql.SQLException,
                                                      java.io.IOException
gets the first numOfEntries of the queue which have the same priority. If there are not so many entries in the queue, all elements in the queue are returned.

Parameters:
numOfEntries - the maximum number of elements to retrieve
Throws:
java.sql.SQLException
java.io.IOException

deleteWithLimit

public long deleteWithLimit(XBStore store,
                            java.sql.Connection conn,
                            XBRef limitEntry,
                            boolean inclusive)
                     throws java.sql.SQLException
deletes the first numOfEntries of the queue until the limitEntry is reached.

Parameters:
numOfEntries - the maximum number of elements to retrieve
Throws:
java.sql.SQLException

deleteAllStore

public int deleteAllStore(XBStore store,
                          java.sql.Connection conn,
                          int timeout)
                   throws java.sql.SQLException
Throws:
java.sql.SQLException

getByteSize

protected long getByteSize(java.sql.ResultSet rs,
                           int offset)
                    throws java.sql.SQLException
Specified by:
getByteSize in class XBFactory
Throws:
java.sql.SQLException

deleteList

public long deleteList(XBStore store,
                       java.sql.Connection conn,
                       XBEntry[] entries,
                       int maxStLength,
                       int maxNumSt,
                       boolean commitInBetween,
                       int timeout)
                throws java.sql.SQLException
Deletes the specified entries. Since all entry may not fit in one single operation, they are splitted over different operations. If you specified commitInBetween or the auto-commit flag is set to true, It always returns the number of deleted entries. If a batch could not be completely deleted, it returns the number of operations previously deleted.

Overrides:
deleteList in class XBFactory
Parameters:
store - the store to use.
the - connection to be used.
ids - the array containing all ids to delete.
Returns:
the number of entries successfully processed. These are the first. If an error occurs it stops.
Throws:
java.sql.SQLException

xmlBlaster 2.2.0 API

Copyright © 1999-2014 The xmlBlaster.org contributers.