[jboss-cvs] JBoss Messaging SVN: r1818 - trunk/src/main/org/jboss/messaging/core/plugin

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Dec 19 00:47:55 EST 2006


Author: ovidiu.feodorov at jboss.com
Date: 2006-12-19 00:47:54 -0500 (Tue, 19 Dec 2006)
New Revision: 1818

Added:
   trunk/src/main/org/jboss/messaging/core/plugin/IDBlock.java
   trunk/src/main/org/jboss/messaging/core/plugin/IDManager.java
Removed:
   trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java
   trunk/src/main/org/jboss/messaging/core/plugin/IdManager.java
Log:
added refactored classes to SVN

Added: trunk/src/main/org/jboss/messaging/core/plugin/IDBlock.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/IDBlock.java	2006-12-19 05:41:14 UTC (rev 1817)
+++ trunk/src/main/org/jboss/messaging/core/plugin/IDBlock.java	2006-12-19 05:47:54 UTC (rev 1818)
@@ -0,0 +1,80 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.messaging.core.plugin;
+
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+
+import org.jboss.messaging.util.Streamable;
+
+/**
+ * 
+ * A IDBlock.
+ * 
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @version 1.1
+ *
+ * IDBlock.java,v 1.1 2006/03/07 17:11:15 timfox Exp
+ */
+public class IDBlock implements Streamable
+{
+   private long low;
+   private long high;
+   
+   public IDBlock()
+   {      
+   }
+   
+   public IDBlock(long low, long high)
+   {
+      this.low = low;
+      this.high = high;
+   }
+   
+   public long getLow()
+   {
+      return low;
+   }
+   
+   public long getHigh()
+   {
+      return high;
+   }
+
+   public void read(DataInputStream in) throws Exception
+   {
+      low = in.readLong();
+      high = in.readLong();
+   }
+
+   public void write(DataOutputStream out) throws Exception
+   {
+      out.writeLong(low);
+      out.writeLong(high);
+   }
+
+   public String toString()
+   {
+      return "IDBlock[" + low + "-" + high + "]";
+   }
+
+}

Added: trunk/src/main/org/jboss/messaging/core/plugin/IDManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/IDManager.java	2006-12-19 05:41:14 UTC (rev 1817)
+++ trunk/src/main/org/jboss/messaging/core/plugin/IDManager.java	2006-12-19 05:47:54 UTC (rev 1818)
@@ -0,0 +1,138 @@
+/*
+  * JBoss, Home of Professional Open Source
+  * Copyright 2005, JBoss Inc., and individual contributors as indicated
+  * by the @authors tag. See the copyright.txt in the distribution for a
+  * full listing of individual contributors.
+  *
+  * This is free software; you can redistribute it and/or modify it
+  * under the terms of the GNU Lesser General Public License as
+  * published by the Free Software Foundation; either version 2.1 of
+  * the License, or (at your option) any later version.
+  *
+  * This software is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
+  * License along with this software; if not, write to the Free
+  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+  */
+package org.jboss.messaging.core.plugin;
+
+import org.jboss.logging.Logger;
+import org.jboss.messaging.core.plugin.contract.MessagingComponent;
+import org.jboss.messaging.core.plugin.contract.PersistenceManager;
+
+/**
+ * 
+ * A IDManager.
+ * 
+ * @author <a href="tim.fox at jboss.com">Tim Fox</a>
+ * @author <a href="ovidiu at jboss.org">Ovidiu Feodorov</a>
+ * @version 1.1
+ *
+ * IDManager.java,v 1.1 2006/03/07 17:11:15 timfox Exp
+ */
+public class IDManager implements MessagingComponent
+{
+   // Constants -----------------------------------------------------
+
+   private static final Logger log = Logger.getLogger(IDManager.class);
+
+   // Static --------------------------------------------------------
+
+   // Attributes ----------------------------------------------------
+
+   private boolean trace = log.isTraceEnabled();
+
+   private boolean started;
+
+   private String counterName;
+
+   private int bigBlockSize;
+   private long high;
+   private long low;
+
+   private PersistenceManager pm;
+
+   // Constructors --------------------------------------------------
+
+   public IDManager(String counterName, int bigBlockSize, PersistenceManager pm) throws Exception
+   {
+      this.counterName = counterName;
+      this.bigBlockSize = bigBlockSize;
+      this.pm = pm;
+   }
+
+   // MessagingComponent implementation -----------------------------
+
+   public synchronized void start() throws Exception
+   {
+      getNextBigBlock();
+      started = true;
+   }
+
+   public synchronized void stop() throws Exception
+   {
+      started = false;
+   }
+
+   // Public --------------------------------------------------------
+
+   protected void getNextBigBlock() throws Exception
+   {
+      low = pm.reserveIDBlock(counterName, bigBlockSize);
+      high = low + bigBlockSize - 1;
+      if (trace) { log.trace(this + " retrieved next block of size " + bigBlockSize + " from PersistenceManager, starting at " + low); }
+   }
+
+   public synchronized IDBlock getIDBlock(int size) throws Exception
+   {
+      if (!started)
+      {
+         throw new IllegalStateException(this + " is not started");
+      }
+
+      if (size <= 0)
+      {
+         throw new IllegalArgumentException("block size must be > 0");
+      }
+
+      if (size > bigBlockSize)
+      {
+         throw new IllegalArgumentException("block size must be <= bigBlockSize");
+      }
+
+      if (size > high - low + 1)
+      {
+         getNextBigBlock();
+      }
+
+      long low = this.low;
+
+      this.low += size;
+
+      return new IDBlock(low, this.low - 1);
+   }
+
+   public synchronized long getID() throws Exception
+   {
+      return getIDBlock(1).getLow();
+   }
+
+   public String toString()
+   {
+      return "IDManager[" + counterName + ", " + low + "-" + high + "]";
+   }
+
+   // Package protected ---------------------------------------------
+
+   // Protected -----------------------------------------------------
+
+   // Private -------------------------------------------------------
+
+   // Inner classes -------------------------------------------------
+
+}

Deleted: trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java	2006-12-19 05:41:14 UTC (rev 1817)
+++ trunk/src/main/org/jboss/messaging/core/plugin/IdBlock.java	2006-12-19 05:47:54 UTC (rev 1818)
@@ -1,80 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.messaging.core.plugin;
-
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-
-import org.jboss.messaging.util.Streamable;
-
-/**
- * 
- * A IDBlock.
- * 
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @version 1.1
- *
- * IDBlock.java,v 1.1 2006/03/07 17:11:15 timfox Exp
- */
-public class IDBlock implements Streamable
-{
-   private long low;
-   private long high;
-   
-   public IDBlock()
-   {      
-   }
-   
-   public IDBlock(long low, long high)
-   {
-      this.low = low;
-      this.high = high;
-   }
-   
-   public long getLow()
-   {
-      return low;
-   }
-   
-   public long getHigh()
-   {
-      return high;
-   }
-
-   public void read(DataInputStream in) throws Exception
-   {
-      low = in.readLong();
-      high = in.readLong();
-   }
-
-   public void write(DataOutputStream out) throws Exception
-   {
-      out.writeLong(low);
-      out.writeLong(high);
-   }
-
-   public String toString()
-   {
-      return "IDBlock[" + low + "-" + high + "]";
-   }
-
-}

Deleted: trunk/src/main/org/jboss/messaging/core/plugin/IdManager.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/plugin/IdManager.java	2006-12-19 05:41:14 UTC (rev 1817)
+++ trunk/src/main/org/jboss/messaging/core/plugin/IdManager.java	2006-12-19 05:47:54 UTC (rev 1818)
@@ -1,138 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.messaging.core.plugin;
-
-import org.jboss.logging.Logger;
-import org.jboss.messaging.core.plugin.contract.MessagingComponent;
-import org.jboss.messaging.core.plugin.contract.PersistenceManager;
-
-/**
- * 
- * A IDManager.
- * 
- * @author <a href="tim.fox at jboss.com">Tim Fox</a>
- * @author <a href="ovidiu at jboss.org">Ovidiu Feodorov</a>
- * @version 1.1
- *
- * IDManager.java,v 1.1 2006/03/07 17:11:15 timfox Exp
- */
-public class IDManager implements MessagingComponent
-{
-   // Constants -----------------------------------------------------
-
-   private static final Logger log = Logger.getLogger(IDManager.class);
-
-   // Static --------------------------------------------------------
-
-   // Attributes ----------------------------------------------------
-
-   private boolean trace = log.isTraceEnabled();
-
-   private boolean started;
-
-   private String counterName;
-
-   private int bigBlockSize;
-   private long high;
-   private long low;
-
-   private PersistenceManager pm;
-
-   // Constructors --------------------------------------------------
-
-   public IDManager(String counterName, int bigBlockSize, PersistenceManager pm) throws Exception
-   {
-      this.counterName = counterName;
-      this.bigBlockSize = bigBlockSize;
-      this.pm = pm;
-   }
-
-   // MessagingComponent implementation -----------------------------
-
-   public synchronized void start() throws Exception
-   {
-      getNextBigBlock();
-      started = true;
-   }
-
-   public synchronized void stop() throws Exception
-   {
-      started = false;
-   }
-
-   // Public --------------------------------------------------------
-
-   protected void getNextBigBlock() throws Exception
-   {
-      low = pm.reserveIDBlock(counterName, bigBlockSize);
-      high = low + bigBlockSize - 1;
-      if (trace) { log.trace(this + " retrieved next block of size " + bigBlockSize + " from PersistenceManager, starting at " + low); }
-   }
-
-   public synchronized IDBlock getIDBlock(int size) throws Exception
-   {
-      if (!started)
-      {
-         throw new IllegalStateException(this + " is not started");
-      }
-
-      if (size <= 0)
-      {
-         throw new IllegalArgumentException("block size must be > 0");
-      }
-
-      if (size > bigBlockSize)
-      {
-         throw new IllegalArgumentException("block size must be <= bigBlockSize");
-      }
-
-      if (size > high - low + 1)
-      {
-         getNextBigBlock();
-      }
-
-      long low = this.low;
-
-      this.low += size;
-
-      return new IDBlock(low, this.low - 1);
-   }
-
-   public synchronized long getID() throws Exception
-   {
-      return getIDBlock(1).getLow();
-   }
-
-   public String toString()
-   {
-      return "IDManager[" + counterName + ", " + low + "-" + high + "]";
-   }
-
-   // Package protected ---------------------------------------------
-
-   // Protected -----------------------------------------------------
-
-   // Private -------------------------------------------------------
-
-   // Inner classes -------------------------------------------------
-
-}




More information about the jboss-cvs-commits mailing list