[jboss-svn-commits] JBL Code SVN: r16830 - labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Nov 26 09:21:30 EST 2007
Author: tfennelly
Date: 2007-11-26 09:21:30 -0500 (Mon, 26 Nov 2007)
New Revision: 16830
Modified:
labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
Log:
Formatting
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java 2007-11-26 13:25:44 UTC (rev 16829)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/rosetta/src/org/jboss/internal/soa/esb/couriers/SqlTableCourier.java 2007-11-26 14:21:30 UTC (rev 16830)
@@ -22,18 +22,6 @@
package org.jboss.internal.soa.esb.couriers;
-import java.io.Serializable;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.UUID;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.sql.DataSource;
-
import org.apache.log4j.Logger;
import org.jboss.soa.esb.addressing.Call;
import org.jboss.soa.esb.addressing.MalformedEPRException;
@@ -48,547 +36,474 @@
import org.jboss.soa.esb.util.Util;
import org.xml.sax.SAXParseException;
-public class SqlTableCourier implements PickUpOnlyCourier, DeliverOnlyCourier
-{
- /**
- * disable default constructor
- */
- private SqlTableCourier()
- {
- }
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.io.Serializable;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.UUID;
- /**
- * package protected constructor - Objects of Courier should only be
- * instantiated by the Factory
- *
- * @param epr
- */
- SqlTableCourier(JDBCEpr epr) throws CourierException
- {
- this(epr, false);
- }
+public class SqlTableCourier implements PickUpOnlyCourier, DeliverOnlyCourier {
+ /**
+ * disable default constructor
+ */
+ private SqlTableCourier() {
+ }
- /**
- * package protected constructor - Objects of Courier should only be
- * instantiated by the Factory
- *
- * @param epr
- */
- SqlTableCourier(JDBCEpr epr, boolean isReceiver) throws CourierException
- {
- _isReceiver = isReceiver;
- _epr = epr;
- _sleepForRetries = 3000; // TODO magic number - configurable?
- try
- {
- _postDelete = Boolean.TRUE.equals(Boolean.valueOf(epr
- .getPostDelete()));
- _errorDelete = Boolean.TRUE.equals(Boolean.valueOf(epr
- .getErrorDelete()));
- }
- catch (URISyntaxException e)
- {
- throw new CourierException(e);
- }
+ /**
+ * package protected constructor - Objects of Courier should only be
+ * instantiated by the Factory
+ *
+ * @param epr
+ */
+ SqlTableCourier(JDBCEpr epr) throws CourierException {
+ this(epr, false);
+ }
- } // ________________________________
+ /**
+ * package protected constructor - Objects of Courier should only be
+ * instantiated by the Factory
+ *
+ * @param epr
+ */
+ SqlTableCourier(JDBCEpr epr, boolean isReceiver) throws CourierException {
+ _isReceiver = isReceiver;
+ _epr = epr;
+ _sleepForRetries = 3000; // TODO magic number - configurable?
+ try {
+ _postDelete = Boolean.TRUE.equals(Boolean.valueOf(epr
+ .getPostDelete()));
+ _errorDelete = Boolean.TRUE.equals(Boolean.valueOf(epr
+ .getErrorDelete()));
+ }
+ catch (URISyntaxException e) {
+ throw new CourierException(e);
+ }
- public void cleanup()
- {
- if (null != _conn)
- {
- try
- {
- _conn.release();
- }
- catch (Exception e)
- {
- _logger.info("Unable to release connection");
+ } // ________________________________
+
+ public void cleanup() {
+ if (null != _conn) {
+ try {
+ _conn.release();
+ }
+ catch (Exception e) {
+ _logger.info("Unable to release connection");
_logger.debug("Unable to release connection", e);
- }
- }
+ }
+ }
- } // ________________________________
+ } // ________________________________
- /**
- * package the ESB message in a java.io.Serializable, and write it
- *
- * @param message
- * Message - the message to deliverAsync
- * @return boolean - the result of the delivery
- * @throws CourierException -
- * if problems were encountered
- */
- public boolean deliver(Message message) throws CourierException
- {
- if (_isReceiver)
- throw new CourierException("This is a read-only Courier");
+ /**
+ * package the ESB message in a java.io.Serializable, and write it
+ *
+ * @param message Message - the message to deliverAsync
+ * @return boolean - the result of the delivery
+ * @throws CourierException -
+ * if problems were encountered
+ */
+ public boolean deliver(Message message) throws CourierException {
+ if (_isReceiver)
+ throw new CourierException("This is a read-only Courier");
- if (null == message)
- return false;
+ if (null == message)
+ return false;
- String msgId = null;
- Call call = message.getHeader().getCall();
- if (null==call)
- message.getHeader().setCall(call=new Call());
- try
- {
- if (null==call.getMessageID())
- call.setMessageID(new URI(UUID.randomUUID().toString()));
- msgId = call.getMessageID().toString();
- }
- catch (URISyntaxException e)
- {
- throw new CourierException("Problems with message header ",e);
- }
+ String msgId = null;
+ Call call = message.getHeader().getCall();
+ if (null == call)
+ message.getHeader().setCall(call = new Call());
+ try {
+ if (null == call.getMessageID())
+ call.setMessageID(new URI(UUID.randomUUID().toString()));
+ msgId = call.getMessageID().toString();
+ }
+ catch (URISyntaxException e) {
+ throw new CourierException("Problems with message header ", e);
+ }
- if (null == _conn)
- {
- try
- {
- _conn = getConn();
- }
- catch (Exception e)
- {
- throw new CourierException(e);
- }
- }
+ if (null == _conn) {
+ try {
+ _conn = getConn();
+ }
+ catch (Exception e) {
+ throw new CourierException(e);
+ }
+ }
- while (_conn != null)
- {
- try
- {
- int iCol = 1;
- PreparedStatement PS = insertStatement();
- PS.setString(iCol++, msgId);
- PS.setObject(iCol++, Util.serialize(message));
- PS.setString(iCol++, State.Pending.getColumnValue());
- PS.setLong(iCol++, System.currentTimeMillis());
+ while (_conn != null) {
+ try {
+ int iCol = 1;
+ PreparedStatement PS = insertStatement();
+ PS.setString(iCol++, msgId);
+ PS.setObject(iCol++, Util.serialize(message));
+ PS.setString(iCol++, State.Pending.getColumnValue());
+ PS.setLong(iCol++, System.currentTimeMillis());
- _conn.execUpdWait(PS, 3);
- _conn.commit();
- return true;
- }
- catch (SQLException e)
- {
- if (null != _conn)
- {
- try
- {
- _conn.rollback();
- }
- catch (Exception roll)
- {
- _logger.debug(roll);
- }
- }
-
- _logger.debug("SQL exception during deliver", e);
- throw new CourierException(e);
- }
- catch (Exception e)
- {
- jdbcConnectRetry(e);
- }
- }
- return false;
- } // ________________________________
+ _conn.execUpdWait(PS, 3);
+ _conn.commit();
+ return true;
+ }
+ catch (SQLException e) {
+ if (null != _conn) {
+ try {
+ _conn.rollback();
+ }
+ catch (Exception roll) {
+ _logger.debug(roll);
+ }
+ }
- public Message pickup(long millis) throws CourierException, CourierTimeoutException
- {
- Message result = null;
- long limit = System.currentTimeMillis()
- + ((millis < 100) ? 100 : millis);
- do
- {
- try
- {
+ _logger.debug("SQL exception during deliver", e);
+ throw new CourierException(e);
+ }
+ catch (Exception e) {
+ jdbcConnectRetry(e);
+ }
+ }
+ return false;
+ } // ________________________________
+
+ public Message pickup(long millis) throws CourierException, CourierTimeoutException {
+ Message result = null;
+ long limit = System.currentTimeMillis()
+ + ((millis < 100) ? 100 : millis);
+ do {
+ try {
ResultSet RS = getRowList();
- while (null != RS && RS.next())
- {
- String messageId = RS.getString(1);
- if (null == (result = tryToPickup(messageId)))
- continue;
-
- /*
- * If this is fault message, then throw an exception with the contents. With the
- * exception of user-defined exceptions, faults will have nothing in the body, properties etc.
- */
-
- if (Type.isFaultMessage(result))
- Factory.createExceptionFromFault(result);
-
- return result;
- }
+ while (null != RS && RS.next()) {
+ String messageId = RS.getString(1);
+ if (null == (result = tryToPickup(messageId)))
+ continue;
+
+ /*
+ * If this is fault message, then throw an exception with the contents. With the
+ * exception of user-defined exceptions, faults will have nothing in the body, properties etc.
+ */
+
+ if (Type.isFaultMessage(result))
+ Factory.createExceptionFromFault(result);
+
+ return result;
+ }
}
- catch (SQLException e)
- {
- _logger.debug("SQL Exception during pickup", e);
- return null;
- }
- finally
- {
- // Added to make sure we release transactions from all paths
- if (_conn != null)
- {
- try
- {
- _conn.rollback() ;
- }
- catch (final SQLException sqle) {} //ignore
- }
- }
- try
- {
- long lSleep = limit - System.currentTimeMillis();
- if (_pollLatency < lSleep)
- lSleep = _pollLatency;
- if (lSleep > 0)
- Thread.sleep(lSleep);
- }
- catch (InterruptedException e)
- {
- return null;
- }
- } while (System.currentTimeMillis() <= limit);
- return null;
- } // ________________________________
+ catch (SQLException e) {
+ _logger.debug("SQL Exception during pickup", e);
+ return null;
+ }
+ finally {
+ // Added to make sure we release transactions from all paths
+ if (_conn != null) {
+ try {
+ _conn.rollback();
+ }
+ catch (final SQLException sqle) {
+ } //ignore
+ }
+ }
+ try {
+ long lSleep = limit - System.currentTimeMillis();
+ if (_pollLatency < lSleep)
+ lSleep = _pollLatency;
+ if (lSleep > 0)
+ Thread.sleep(lSleep);
+ }
+ catch (InterruptedException e) {
+ return null;
+ }
+ } while (System.currentTimeMillis() <= limit);
+ return null;
+ } // ________________________________
- private Message tryToPickup(String messageId) throws CourierException,
- SQLException
- {
- int iParm = 1;
+ private Message tryToPickup(String messageId) throws CourierException,
+ SQLException {
+ int iParm = 1;
- select4UpdateStatement().setString(iParm++, messageId);
- select4UpdateStatement().setString(iParm++,
- State.Pending.getColumnValue());
+ select4UpdateStatement().setString(iParm++, messageId);
+ select4UpdateStatement().setString(iParm++,
+ State.Pending.getColumnValue());
- while (_conn != null)
- {
- try
- {
- ResultSet RS = _conn.execQueryWait(select4UpdateStatement(), 3);
- while (RS.next())
- {
- Exception eBad = null;
- try
- {
- Message result = Util.deserialize((Serializable) RS
- .getObject(1));
- if (_postDelete)
- deleteMsg(messageId);
- else
- changeStatus(messageId, State.Done);
- return result;
- }
- catch (ClassCastException e)
- {
- eBad = e;
- }
- catch (SAXParseException e)
- {
- eBad = e;
- }
- catch (Exception e)
- {
- throw new CourierException(e);
- }
- if (null != eBad)
- {
- if (_errorDelete)
- deleteMsg(messageId);
- else
- changeStatus(messageId, State.Error);
- continue;
- }
- }
- return null;
- }
- catch (SQLException e)
- {
- throw new CourierException(e);
- }
- catch (Exception e)
- {
- jdbcConnectRetry(e);
- }
- }
- return null;
- } // ________________________________
+ while (_conn != null) {
+ try {
+ ResultSet RS = _conn.execQueryWait(select4UpdateStatement(), 3);
+ while (RS.next()) {
+ Exception eBad = null;
+ try {
+ Message result = Util.deserialize((Serializable) RS
+ .getObject(1));
+ if (_postDelete)
+ deleteMsg(messageId);
+ else
+ changeStatus(messageId, State.Done);
+ return result;
+ }
+ catch (ClassCastException e) {
+ eBad = e;
+ }
+ catch (SAXParseException e) {
+ eBad = e;
+ }
+ catch (Exception e) {
+ throw new CourierException(e);
+ }
+ if (null != eBad) {
+ if (_errorDelete)
+ deleteMsg(messageId);
+ else
+ changeStatus(messageId, State.Error);
+ continue;
+ }
+ }
+ return null;
+ }
+ catch (SQLException e) {
+ throw new CourierException(e);
+ }
+ catch (Exception e) {
+ jdbcConnectRetry(e);
+ }
+ }
+ return null;
+ } // ________________________________
- private void deleteMsg(String messageId) throws SQLException
- {
- int iParm = 1;
- deleteStatement().setString(iParm++, messageId);
- _conn.execUpdWait(deleteStatement(), 3);
- _conn.commit();
+ private void deleteMsg(String messageId) throws SQLException {
+ int iParm = 1;
+ deleteStatement().setString(iParm++, messageId);
+ _conn.execUpdWait(deleteStatement(), 3);
+ _conn.commit();
- }
+ }
- private void changeStatus(String messageId, State to) throws SQLException
- {
- int iParm = 1;
- updateStatusStatement().setString(iParm++, to.getColumnValue());
- updateStatusStatement().setString(iParm++, messageId);
- _conn.execUpdWait(updateStatusStatement(), 3);
- _conn.commit();
+ private void changeStatus(String messageId, State to) throws SQLException {
+ int iParm = 1;
+ updateStatusStatement().setString(iParm++, to.getColumnValue());
+ updateStatusStatement().setString(iParm++, messageId);
+ _conn.execUpdWait(updateStatusStatement(), 3);
+ _conn.commit();
- }
+ }
- private ResultSet getRowList() throws CourierException
- {
- if (null == _conn)
- {
- try
- {
- _conn = getConn();
- }
- catch (Exception e)
- {
- throw new CourierException(e);
- }
- }
- while (_conn != null)
- {
- try
- {
- return _conn.execQueryWait(listStatement(), 3);
- }
- catch (Exception e)
- {
- jdbcConnectRetry(e);
- }
- }
- return null;
+ private ResultSet getRowList() throws CourierException {
+ if (null == _conn) {
+ try {
+ _conn = getConn();
+ }
+ catch (Exception e) {
+ throw new CourierException(e);
+ }
+ }
+ while (_conn != null) {
+ try {
+ return _conn.execQueryWait(listStatement(), 3);
+ }
+ catch (Exception e) {
+ jdbcConnectRetry(e);
+ }
+ }
+ return null;
- } // _______________________________
+ } // _______________________________
- private void jdbcConnectRetry(Exception exc)
- {
- _logger.debug("DB problem, will try to reconnect", exc);
- if (null != _conn)
- _conn.release();
- _conn = null;
+ private void jdbcConnectRetry(Exception exc) {
+ _logger.debug("DB problem, will try to reconnect", exc);
+ if (null != _conn)
+ _conn.release();
+ _conn = null;
- _prepDelete = _prepGetList = _prepInsert = _prepSel4Upd = _prepUpdateStatus = null;
- for (int i1 = 0; i1 < 3; i1++)
- {
- try
- {
- _conn = getConn();
- }
- catch (Exception e)
- {
- try
- {
- Thread.sleep(_sleepForRetries);
- }
- catch (InterruptedException eInt)
- {
- return;
- }
- }
- }
- } // ________________________________
+ _prepDelete = _prepGetList = _prepInsert = _prepSel4Upd = _prepUpdateStatus = null;
+ for (int i1 = 0; i1 < 3; i1++) {
+ try {
+ _conn = getConn();
+ }
+ catch (Exception e) {
+ try {
+ Thread.sleep(_sleepForRetries);
+ }
+ catch (InterruptedException eInt) {
+ return;
+ }
+ }
+ }
+ } // ________________________________
- private JdbcCleanConn getConn() throws SQLException, MalformedEPRException
- {
- if (null == _conn)
- {
- try
- {
- DataSource DS = null;
- if (_epr.getDatasource() == null) {
- DS = new SimpleDataSource(_epr.getDriver(),
- _epr.getURL(), _epr.getUserName(), _epr.getPassword());
- } else {
- InitialContext initContext;
- try {
- initContext = new InitialContext();
- DS = (DataSource) initContext.lookup(_epr.getDatasource());
- } catch (NamingException e) {
- _logger.error("", e);
- }
- }
- _conn = new JdbcCleanConn(DS);
- }
- catch (URISyntaxException ex)
- {
- throw new MalformedEPRException(ex);
- }
- }
- return _conn;
- } // ________________________________
+ private JdbcCleanConn getConn() throws SQLException, MalformedEPRException {
+ if (null == _conn) {
+ try {
+ DataSource DS = null;
+ if (_epr.getDatasource() == null) {
+ DS = new SimpleDataSource(_epr.getDriver(),
+ _epr.getURL(), _epr.getUserName(), _epr.getPassword());
+ } else {
+ InitialContext initContext;
+ try {
+ initContext = new InitialContext();
+ DS = (DataSource) initContext.lookup(_epr.getDatasource());
+ } catch (NamingException e) {
+ _logger.error("", e);
+ }
+ }
+ _conn = new JdbcCleanConn(DS);
+ }
+ catch (URISyntaxException ex) {
+ throw new MalformedEPRException(ex);
+ }
+ }
+ return _conn;
+ } // ________________________________
- protected PreparedStatement listStatement()
- {
- if (null == _prepGetList)
+ protected PreparedStatement listStatement() {
+ if (null == _prepGetList)
- try
- {
- String[] columns =
- { _epr.getMessageIdColumn(), _epr.getTimestampColumn() };
+ try {
+ String[] columns =
+ {_epr.getMessageIdColumn(), _epr.getTimestampColumn()};
- StringBuilder sb = new StringBuilder("select");
- int i1 = 0;
- for (String col : columns)
- sb.append((i1++ < 1) ? " " : ",").append(col);
- sb.append(" from ").append(_epr.getTableName());
- sb.append(" where ").append(_epr.getStatusColumn())
- .append("='").append(State.Pending.getColumnValue())
- .append("'").append(" order by 2");
- _prepGetList = getConn().prepareStatement(sb.toString());
- }
- catch (Exception e)
- {
- _logger.debug("Unable to prepare SQL statement", e);
- return null;
- }
- return _prepGetList;
- } // ________________________________
+ StringBuilder sb = new StringBuilder("select");
+ int i1 = 0;
+ for (String col : columns)
+ sb.append((i1++ < 1) ? " " : ",").append(col);
+ sb.append(" from ").append(_epr.getTableName());
+ sb.append(" where ").append(_epr.getStatusColumn())
+ .append("='").append(State.Pending.getColumnValue())
+ .append("'").append(" order by 2");
+ _prepGetList = getConn().prepareStatement(sb.toString());
+ }
+ catch (Exception e) {
+ _logger.debug("Unable to prepare SQL statement", e);
+ return null;
+ }
+ return _prepGetList;
+ } // ________________________________
- protected PreparedStatement select4UpdateStatement()
- {
- if (_prepSel4Upd == null)
- {
- try
- {
- /*
- * TODO make this dynamic using a factory pattern.
- */
+ protected PreparedStatement select4UpdateStatement() {
+ if (_prepSel4Upd == null) {
+ try {
+ /*
+ * TODO make this dynamic using a factory pattern.
+ */
- StringBuilder sb = null;
+ StringBuilder sb = null;
- if (!_epr.getURL().contains("hsqldb"))
- {
- sb = new StringBuilder("select ").append(
- _epr.getDataColumn()).append(" from ").append(
- _epr.getTableName()).append(" where ").append(
- _epr.getMessageIdColumn()).append("=?").append(
- " and ").append(_epr.getStatusColumn())
- .append("=?").append(" for update");
- }
- else
- {
- /*
- * HSQL does not support FOR UPDATE! All tables appear to
- * be inherently updatable!
- */
-
- sb = new StringBuilder("select ").append(
- _epr.getDataColumn()).append(" from ").append(
- _epr.getTableName()).append(" where ").append(
- _epr.getMessageIdColumn()).append("=?").append(
- " and ").append(_epr.getStatusColumn())
- .append("=?");
- }
+ if (!_epr.getURL().contains("hsqldb")) {
+ sb = new StringBuilder("select ").append(
+ _epr.getDataColumn()).append(" from ").append(
+ _epr.getTableName()).append(" where ").append(
+ _epr.getMessageIdColumn()).append("=?").append(
+ " and ").append(_epr.getStatusColumn())
+ .append("=?").append(" for update");
+ } else {
+ /*
+ * HSQL does not support FOR UPDATE! All tables appear to
+ * be inherently updatable!
+ */
- _prepSel4Upd = getConn().prepareStatement(sb.toString());
- }
- catch (Exception e)
- {
- _logger.debug(e);
- return null;
- }
- }
+ sb = new StringBuilder("select ").append(
+ _epr.getDataColumn()).append(" from ").append(
+ _epr.getTableName()).append(" where ").append(
+ _epr.getMessageIdColumn()).append("=?").append(
+ " and ").append(_epr.getStatusColumn())
+ .append("=?");
+ }
- return _prepSel4Upd;
- } // ________________________________
+ _prepSel4Upd = getConn().prepareStatement(sb.toString());
+ }
+ catch (Exception e) {
+ _logger.debug(e);
+ return null;
+ }
+ }
- protected PreparedStatement updateStatusStatement()
- {
- if (null == _prepUpdateStatus)
- try
- {
- StringBuilder sb = new StringBuilder("update ").append(
- _epr.getTableName()).append(" set ").append(
- _epr.getStatusColumn()).append("= ?").append(" where ")
- .append(_epr.getMessageIdColumn()).append("=?");
- _prepUpdateStatus = getConn().prepareStatement(sb.toString());
- }
- catch (Exception e)
- {
- _logger.debug(e);
- return null;
- }
- return _prepUpdateStatus;
- } // ________________________________
+ return _prepSel4Upd;
+ } // ________________________________
- protected PreparedStatement insertStatement()
- {
- if (null == _prepInsert)
- try
- {
- String[] columns =
- { _epr.getMessageIdColumn(), _epr.getDataColumn(),
- _epr.getStatusColumn(), _epr.getTimestampColumn() };
+ protected PreparedStatement updateStatusStatement() {
+ if (null == _prepUpdateStatus)
+ try {
+ StringBuilder sb = new StringBuilder("update ").append(
+ _epr.getTableName()).append(" set ").append(
+ _epr.getStatusColumn()).append("= ?").append(" where ")
+ .append(_epr.getMessageIdColumn()).append("=?");
+ _prepUpdateStatus = getConn().prepareStatement(sb.toString());
+ }
+ catch (Exception e) {
+ _logger.debug(e);
+ return null;
+ }
+ return _prepUpdateStatus;
+ } // ________________________________
- StringBuilder sb = new StringBuilder("insert into ").append(
- _epr.getTableName()).append("(");
- int i1 = 0;
- for (String col : columns)
- sb.append((i1++ < 1) ? " " : ",").append(col);
- sb.append(") values (?,?,?,?)");
- _prepInsert = getConn().prepareStatement(sb.toString());
- }
- catch (Exception e)
- {
- _logger.debug(e);
- return null;
- }
- return _prepInsert;
- } // ________________________________
+ protected PreparedStatement insertStatement() {
+ if (null == _prepInsert)
+ try {
+ String[] columns =
+ {_epr.getMessageIdColumn(), _epr.getDataColumn(),
+ _epr.getStatusColumn(), _epr.getTimestampColumn()};
- protected PreparedStatement deleteStatement()
- {
- if (null == _prepDelete)
- try
- {
- StringBuilder sb = new StringBuilder("delete from ").append(
- _epr.getTableName()).append(" where ").append(
- _epr.getMessageIdColumn()).append(" =?");
- _prepDelete = getConn().prepareStatement(sb.toString());
- }
- catch (Exception e)
- {
- _logger.debug(e);
- return null;
- }
- return _prepDelete;
- } // ________________________________
+ StringBuilder sb = new StringBuilder("insert into ").append(
+ _epr.getTableName()).append("(");
+ int i1 = 0;
+ for (String col : columns)
+ sb.append((i1++ < 1) ? " " : ",").append(col);
+ sb.append(") values (?,?,?,?)");
+ _prepInsert = getConn().prepareStatement(sb.toString());
+ }
+ catch (Exception e) {
+ _logger.debug(e);
+ return null;
+ }
+ return _prepInsert;
+ } // ________________________________
- protected enum State
- {
- Pending, WorkInProgress, Done, Error;
- String getColumnValue()
- {
- return toString().substring(0, 1);
- }
- }
+ protected PreparedStatement deleteStatement() {
+ if (null == _prepDelete)
+ try {
+ StringBuilder sb = new StringBuilder("delete from ").append(
+ _epr.getTableName()).append(" where ").append(
+ _epr.getMessageIdColumn()).append(" =?");
+ _prepDelete = getConn().prepareStatement(sb.toString());
+ }
+ catch (Exception e) {
+ _logger.debug(e);
+ return null;
+ }
+ return _prepDelete;
+ } // ________________________________
- public void setPollLatency(Long millis)
- {
- if (millis <= 200)
- _logger.warn("Poll latency must be >= 200 milliseconds - Keeping old value of "+_pollLatency);
- else
- _pollLatency = millis;
- } // ________________________________
-
- protected long _pollLatency = 200;
- protected long _sleepForRetries = 3000; // milliseconds
+ protected enum State {
+ Pending, WorkInProgress, Done, Error;
- protected boolean _postDelete, _errorDelete;
- protected boolean _isReceiver;
+ String getColumnValue() {
+ return toString().substring(0, 1);
+ }
+ }
- protected JDBCEpr _epr;
+ public void setPollLatency(Long millis) {
+ if (millis <= 200)
+ _logger.warn("Poll latency must be >= 200 milliseconds - Keeping old value of " + _pollLatency);
+ else
+ _pollLatency = millis;
+ } // ________________________________
- protected JdbcCleanConn _conn;
+ protected long _pollLatency = 200;
+ protected long _sleepForRetries = 3000; // milliseconds
- protected PreparedStatement _prepGetList;
- protected PreparedStatement _prepSel4Upd;
- protected PreparedStatement _prepUpdateStatus;
- protected PreparedStatement _prepInsert;
- protected PreparedStatement _prepDelete;
+ protected boolean _postDelete, _errorDelete;
+ protected boolean _isReceiver;
- protected static Logger _logger = Logger.getLogger(SqlTableCourier.class);
+ protected JDBCEpr _epr;
+
+ protected JdbcCleanConn _conn;
+
+ protected PreparedStatement _prepGetList;
+ protected PreparedStatement _prepSel4Upd;
+ protected PreparedStatement _prepUpdateStatus;
+ protected PreparedStatement _prepInsert;
+ protected PreparedStatement _prepDelete;
+
+ protected static Logger _logger = Logger.getLogger(SqlTableCourier.class);
}
More information about the jboss-svn-commits
mailing list