activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r538662 - in /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel: processor/LifecycleProcessor.java util/Time.java
Date Wed, 16 May 2007 17:42:40 GMT
Author: jstrachan
Date: Wed May 16 10:42:39 2007
New Revision: 538662

URL: http://svn.apache.org/viewvc?view=rev&rev=538662
Log:
added a helper class for when services need to be tied to processors lifecycle

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LifecycleProcessor.java
  (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/Time.java

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LifecycleProcessor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LifecycleProcessor.java?view=auto&rev=538662
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LifecycleProcessor.java
(added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LifecycleProcessor.java
Wed May 16 10:42:39 2007
@@ -0,0 +1,48 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.camel.processor;
+
+import org.apache.camel.Processor;
+import org.apache.camel.Service;
+
+/**
+ * A simple helper class which allows you to attach an artbirary service to a processor which
is
+ * started before the processor and closed after it
+ *
+ * @version $Revision: 1.1 $
+ */
+public class LifecycleProcessor extends DelegateProcessor {
+    private Service service;
+
+    public LifecycleProcessor(Processor next, Service service) {
+        super(next);
+        this.service = service;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        service.start();
+        super.doStart();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        service.stop();
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LifecycleProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/Time.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/Time.java?view=diff&rev=538662&r1=538661&r2=538662
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/Time.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/util/Time.java Wed May
16 10:42:39 2007
@@ -17,6 +17,7 @@
 package org.apache.camel.util;
 
 import java.util.concurrent.TimeUnit;
+import java.util.Date;
 
 /**
  * A helper class for working with times in various units
@@ -62,6 +63,10 @@
 
     public long toMillis() {
         return timeUnit.toMillis(number);
+    }
+
+    public Date toDate() {
+        return new Date(toMillis());
     }
 
     public long getNumber() {



Mime
View raw message