tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r887592 - in /openejb/trunk/openejb3: container/openejb-core/src/main/java/org/apache/openejb/core/managed/ container/openejb-core/src/main/java/org/apache/openejb/core/stateful/ container/openejb-core/src/main/java/org/apache/openejb/util/...
Date Sat, 05 Dec 2009 21:39:38 GMT
Author: dblevins
Date: Sat Dec  5 21:39:37 2009
New Revision: 887592

URL: http://svn.apache.org/viewvc?rev=887592&view=rev
Log:
Slightly improved Duration object.

Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimpleCache.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Duration.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/DurationTest.java
    openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastSearch.java
    openejb/trunk/openejb3/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastSearch.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimpleCache.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimpleCache.java?rev=887592&r1=887591&r2=887592&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimpleCache.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/managed/SimpleCache.java
Sat Dec  5 21:39:37 2009
@@ -80,7 +80,7 @@
         this.passivator = passivator;
         this.capacity = capacity;
         this.bulkPassivate = bulkPassivate;
-        this.timeOut = timeOut.getUnit().convert(timeOut.getTime(), TimeUnit.MILLISECONDS);
+        this.timeOut = timeOut.getTime(TimeUnit.MILLISECONDS);
     }
 
     public synchronized CacheListener<V> getListener() {

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java?rev=887592&r1=887591&r2=887592&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/core/stateful/SimpleCache.java
Sat Dec  5 21:39:37 2009
@@ -80,7 +80,7 @@
         this.passivator = passivator;
         this.capacity = capacity;
         this.bulkPassivate = bulkPassivate;
-        this.timeOut = timeOut.getUnit().convert(timeOut.getTime(), TimeUnit.MILLISECONDS);
+        this.timeOut = timeOut.getTime(TimeUnit.MILLISECONDS);
     }
 
     public synchronized CacheListener<V> getListener() {

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Duration.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Duration.java?rev=887592&r1=887591&r2=887592&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Duration.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Duration.java
Sat Dec  5 21:39:37 2009
@@ -40,6 +40,10 @@
         return time;
     }
 
+    public long getTime(TimeUnit unit) {
+        return this.unit.convert(time, unit);
+    }
+    
     public void setTime(long time) {
         this.time = time;
     }

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/DurationTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/DurationTest.java?rev=887592&r1=887591&r2=887592&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/DurationTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/DurationTest.java
Sat Dec  5 21:39:37 2009
@@ -46,4 +46,23 @@
         assertEquals(new Duration(123, null), new Duration("123"));
         assertEquals(new Duration(-1, null), new Duration("-1"));
     }
+
+    public void testUnitConversion() throws Exception {
+        assertEquals(2 * 1000, MILLISECONDS.convert(2, SECONDS));
+        assertEquals(2 * 1000 * 1000, MICROSECONDS.convert(2, SECONDS));
+        assertEquals(2 * 1000 * 1000 * 1000, NANOSECONDS.convert(2, SECONDS));
+
+        assertEquals(2, SECONDS.convert(2 * 1000 * 1000 * 1000, NANOSECONDS));
+        assertEquals(2, SECONDS.convert(2 * 1000 * 1000, MICROSECONDS));
+        assertEquals(2, SECONDS.convert(2 * 1000, MILLISECONDS));
+
+        // The verbose way of doing the above
+        assertEquals(2 * 1000, new Duration(2, SECONDS).getTime(MILLISECONDS));
+        assertEquals(2 * 1000 * 1000, new Duration(2, SECONDS).getTime(MICROSECONDS));
+        assertEquals(2 * 1000 * 1000 * 1000, new Duration(2, SECONDS).getTime(NANOSECONDS));
+
+        assertEquals(2, new Duration(2 * 1000 * 1000 * 1000, NANOSECONDS).getTime(SECONDS));
+        assertEquals(2, new Duration(2 * 1000 * 1000, MICROSECONDS).getTime(SECONDS));
+        assertEquals(2, new Duration(2 * 1000, MILLISECONDS).getTime(SECONDS));
+    }
 }

Modified: openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastSearch.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastSearch.java?rev=887592&r1=887591&r2=887592&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastSearch.java
(original)
+++ openejb/trunk/openejb3/server/openejb-client/src/main/java/org/apache/openejb/client/MulticastSearch.java
Sat Dec  5 21:39:37 2009
@@ -60,7 +60,7 @@
     }
 
     public URI search(Filter filter, long timeout, TimeUnit unit) throws IOException {
-        timeout = unit.convert(timeout, TimeUnit.MILLISECONDS);
+        timeout = TimeUnit.MILLISECONDS.convert(timeout, unit);
         long waited = 0;
 
         byte[] buf = new byte[BUFF_SIZE];

Modified: openejb/trunk/openejb3/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastSearch.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastSearch.java?rev=887592&r1=887591&r2=887592&view=diff
==============================================================================
--- openejb/trunk/openejb3/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastSearch.java
(original)
+++ openejb/trunk/openejb3/server/openejb-multicast/src/main/java/org/apache/openejb/server/discovery/MulticastSearch.java
Sat Dec  5 21:39:37 2009
@@ -57,7 +57,7 @@
     }
 
     public URI search(Filter filter, long timeout, TimeUnit unit) throws IOException {
-        timeout = unit.convert(timeout, TimeUnit.MILLISECONDS);
+        timeout = TimeUnit.MILLISECONDS.convert(timeout, unit);
         long waited = 0;
 
         byte[] buf = new byte[BUFF_SIZE];



Mime
View raw message