[jboss-cvs] JBossAS SVN: r62308 - branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 12 14:40:38 EDT 2007


Author: dimitris at jboss.org
Date: 2007-04-12 14:40:38 -0400 (Thu, 12 Apr 2007)
New Revision: 62308

Modified:
   branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
Log:
JBAS-3953, use the correct signature for overriding the baseclass selectTimers(ObjectName) method.

Modified: branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java
===================================================================
--- branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java	2007-04-12 18:23:43 UTC (rev 62307)
+++ branches/Branch_4_0/server/src/main/org/jboss/ejb/txtimer/OracleDatabasePersistencePlugin.java	2007-04-12 18:40:38 UTC (rev 62308)
@@ -23,9 +23,6 @@
 
 // $Id$
 
-import org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil;
-import org.jboss.logging.Logger;
-
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
 import java.io.Serializable;
@@ -39,11 +36,17 @@
 import java.util.Date;
 import java.util.List;
 
+import javax.management.ObjectName;
+
+import org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil;
+import org.jboss.logging.Logger;
+
 /**
  * This DatabasePersistencePlugin uses getBinaryStream/setBinaryStream to persist the
  * serializable objects associated with the timer.
  *
  * @author Thomas.Diesler at jboss.org
+ * @author Dimitris.Andreadis at jboss.org
  * @version $Revision$
  * @since 23-Sep-2004
  */
@@ -52,9 +55,16 @@
    // logging support
    private static Logger log = Logger.getLogger(OracleDatabasePersistencePlugin.class);
 
-   /** Insert a timer object */
-   public void insertTimer(String timerId, TimedObjectId timedObjectId, Date initialExpiration, long intervalDuration, Serializable info)
-           throws SQLException
+   /**
+    * Insert a timer object
+    */
+   public void insertTimer(
+         String timerId,
+         TimedObjectId timedObjectId,
+         Date initialExpiration,
+         long intervalDuration,
+         Serializable info)
+      throws SQLException
    {
       Connection con = null;
       PreparedStatement st = null;
@@ -63,7 +73,9 @@
          con = ds.getConnection();
 
          String sql = "insert into " + getTableName() + " " +
-                 "(" + getColumnTimerID() + "," + getColumnTargetID() + "," + getColumnInitialDate() + "," + getColumnTimerInterval() + "," + getColumnInstancePK() + "," + getColumnInfo() + ") " +
+                 "(" + getColumnTimerID() + "," + getColumnTargetID() +
+                 "," + getColumnInitialDate() + "," + getColumnTimerInterval() +
+                 "," + getColumnInstancePK() + "," + getColumnInfo() + ") " +
                  "values (?,?,?,?,?,?)";
          st = con.prepareStatement(sql);
 
@@ -105,11 +117,12 @@
       }
    }
 
-   /** Select a list of currently persisted timer handles
+   /**
+    * Select a list of currently persisted timer handles
+    * 
     * @return List<TimerHandleImpl>
     */
-   public List selectTimers()
-           throws SQLException
+   public List selectTimers(ObjectName containerId) throws SQLException
    {
       Connection con = null;
       Statement st = null;
@@ -126,19 +139,36 @@
          {
             String timerId = rs.getString(getColumnTimerID());
             TimedObjectId targetId = TimedObjectId.parse(rs.getString(getColumnTargetID()));
-            Date initialDate = rs.getTimestamp(getColumnInitialDate());
-            long interval = rs.getLong(getColumnTimerInterval());
-
-            InputStream isPk = rs.getBinaryStream(getColumnInstancePK());
-            Serializable pKey = (Serializable)deserialize(isPk);
-            InputStream isInfo = rs.getBinaryStream(getColumnInfo());
-            Serializable info = (Serializable)deserialize(isInfo);
-
-            targetId = new TimedObjectId(targetId.getContainerId(), pKey);
-            TimerHandleImpl handle = new TimerHandleImpl(timerId, targetId, initialDate, interval, info);
-            list.add(handle);
+            
+            // add this handle to the returned list, if a null containerId was used
+            // or the containerId filter matches 
+            if (containerId == null || containerId.equals(targetId.getContainerId()))
+            {
+               Date initialDate = rs.getTimestamp(getColumnInitialDate());
+               long interval = rs.getLong(getColumnTimerInterval());
+               
+               InputStream isPk = rs.getBinaryStream(getColumnInstancePK());
+               Serializable pKey = (Serializable)deserialize(isPk);
+               Serializable info = null;
+               try
+               {
+                  InputStream isInfo = rs.getBinaryStream(getColumnInfo());
+                  info = (Serializable)deserialize(isInfo);
+               }
+               catch (Exception e)
+               {
+                  // may happen if listing all handles (containerId is null)
+                  // with a stored custom info object coming from a scoped
+                  // deployment.
+                  log.warn("Cannot deserialize custom info object", e);
+               }
+               // is this really needed? targetId encapsulates pKey as well!
+               targetId = new TimedObjectId(targetId.getContainerId(), pKey);
+               TimerHandleImpl handle = new TimerHandleImpl(timerId, targetId, initialDate, interval, info);
+               
+               list.add(handle);
+            }
          }
-
          return list;
       }
       finally




More information about the jboss-cvs-commits mailing list