servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r406649 - in /incubator/servicemix/trunk/servicemix-services: ./ src/main/java/org/apache/servicemix/timers/ src/main/java/org/apache/servicemix/timers/impl/
Date Mon, 15 May 2006 15:12:13 GMT
Author: gnodet
Date: Mon May 15 08:12:11 2006
New Revision: 406649

URL: http://svn.apache.org/viewcvs?rev=406649&view=rev
Log:
Add a simple timer interface / impl to avoid using commonj which is not released yet

Added:
    incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/Timer.java
    incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerListener.java
    incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerManager.java
    incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/
    incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java
Modified:
    incubator/servicemix/trunk/servicemix-services/pom.xml

Modified: incubator/servicemix/trunk/servicemix-services/pom.xml
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-services/pom.xml?rev=406649&r1=406648&r2=406649&view=diff
==============================================================================
--- incubator/servicemix/trunk/servicemix-services/pom.xml (original)
+++ incubator/servicemix/trunk/servicemix-services/pom.xml Mon May 15 08:12:11 2006
@@ -35,11 +35,6 @@
 
   <dependencies>
     <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-commonj_1.1_spec</artifactId>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
       <groupId>incubator-activemq</groupId>
       <artifactId>activeio-core</artifactId>
       <optional>true</optional>

Added: incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/Timer.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/Timer.java?rev=406649&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/Timer.java
(added)
+++ incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/Timer.java
Mon May 15 08:12:11 2006
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.timers;
+
+public interface Timer {
+
+    boolean cancel();
+    
+    TimerListener getTimerListener();
+    
+}

Added: incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerListener.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerListener.java?rev=406649&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerListener.java
(added)
+++ incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerListener.java
Mon May 15 08:12:11 2006
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.timers;
+
+public interface TimerListener {
+
+    void timerExpired(Timer timer);
+    
+}

Added: incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerManager.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerManager.java?rev=406649&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerManager.java
(added)
+++ incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/TimerManager.java
Mon May 15 08:12:11 2006
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.timers;
+
+import java.util.Date;
+
+public interface TimerManager {
+    
+    Timer schedule(TimerListener listener, long delay);
+    
+    Timer schedule(TimerListener listener, Date date);
+
+}

Added: incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java
URL: http://svn.apache.org/viewcvs/incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java?rev=406649&view=auto
==============================================================================
--- incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java
(added)
+++ incubator/servicemix/trunk/servicemix-services/src/main/java/org/apache/servicemix/timers/impl/TimerManagerImpl.java
Mon May 15 08:12:11 2006
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2005-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.servicemix.timers.impl;
+
+import java.util.Date;
+import java.util.TimerTask;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.servicemix.timers.Timer;
+import org.apache.servicemix.timers.TimerListener;
+import org.apache.servicemix.timers.TimerManager;
+
+public class TimerManagerImpl implements TimerManager {
+
+    private static final Log log = LogFactory.getLog(TimerManagerImpl.class);
+    private static java.util.Timer timer;
+    
+    public Timer schedule(TimerListener listener, long delay) {
+        if (log.isDebugEnabled()) {
+            log.debug("Schedule timer " + listener + " for " + delay);
+        }
+        TimerImpl tt = new TimerImpl(listener);
+        timer.schedule(tt, delay);
+        return tt;
+    }
+
+    public Timer schedule(TimerListener listener, Date date) {
+        if (log.isDebugEnabled()) {
+            log.debug("Schedule timer " + listener + " at " + date);
+        }
+        TimerImpl tt = new TimerImpl(listener);
+        timer.schedule(tt, date);
+        return tt;
+    }
+    
+    protected static class TimerImpl extends TimerTask implements Timer {
+
+        private TimerListener timerListener;
+        
+        public TimerImpl(TimerListener timerListener) {
+            this.timerListener = timerListener;
+        }
+        
+        public boolean cancel() {
+            if (log.isDebugEnabled()) {
+                log.debug("Timer " + timerListener + " cancelled");
+            }
+            return super.cancel();
+        }
+        
+        public TimerListener getTimerListener() {
+            return this.timerListener;
+        }
+
+        public void run() {
+            if (log.isDebugEnabled()) {
+                log.debug("Timer " + timerListener + " expired");
+            }
+            this.timerListener.timerExpired(this);
+        }
+        
+    }
+
+}



Mime
View raw message