Remove payload executor
authorChristos KK Loverdos <loverdos@gmail.com>
Mon, 17 Sep 2012 10:17:12 +0000 (13:17 +0300)
committerChristos KK Loverdos <loverdos@gmail.com>
Mon, 17 Sep 2012 10:17:12 +0000 (13:17 +0300)
src/main/scala/gr/grnet/aquarium/connector/handler/PayloadHandlerExecutor.scala [deleted file]
src/main/scala/gr/grnet/aquarium/connector/handler/SynchronousPayloadHandlerExecutor.scala [deleted file]
src/main/scala/gr/grnet/aquarium/connector/rabbitmq/RabbitMQConsumer.scala
src/main/scala/gr/grnet/aquarium/service/RabbitMQService.scala

diff --git a/src/main/scala/gr/grnet/aquarium/connector/handler/PayloadHandlerExecutor.scala b/src/main/scala/gr/grnet/aquarium/connector/handler/PayloadHandlerExecutor.scala
deleted file mode 100644 (file)
index da25a51..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2011-2012 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *   1. Redistributions of source code must retain the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials
- *      provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.aquarium.connector.handler
-
-/**
- * An executor for a [[gr.grnet.aquarium.connector.handler.PayloadHandler]].
- *
- * @author Christos KK Loverdos <loverdos@gmail.com>
- */
-
-trait PayloadHandlerExecutor {
-  def exec(payload: Array[Byte], handler: PayloadHandler)
-          (onSuccess: HandlerResult ⇒ Any)
-          (onError: Throwable ⇒ Any): Unit
-}
diff --git a/src/main/scala/gr/grnet/aquarium/connector/handler/SynchronousPayloadHandlerExecutor.scala b/src/main/scala/gr/grnet/aquarium/connector/handler/SynchronousPayloadHandlerExecutor.scala
deleted file mode 100644 (file)
index f66d631..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright 2011-2012 GRNET S.A. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the following
- * conditions are met:
- *
- *   1. Redistributions of source code must retain the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer.
- *
- *   2. Redistributions in binary form must reproduce the above
- *      copyright notice, this list of conditions and the following
- *      disclaimer in the documentation and/or other materials
- *      provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * The views and conclusions contained in the software and
- * documentation are those of the authors and should not be
- * interpreted as representing official policies, either expressed
- * or implied, of GRNET S.A.
- */
-
-package gr.grnet.aquarium.connector.handler
-
-/**
- * A [[gr.grnet.aquarium.connector.handler.PayloadHandlerExecutor]] that calls the
- * [[gr.grnet.aquarium.connector.handler.PayloadHandler]] synchronously.
- *
- * @author Christos KK Loverdos <loverdos@gmail.com>
- */
-
-final class SynchronousPayloadHandlerExecutor extends PayloadHandlerExecutor {
-
-  def exec(payload: Array[Byte], handler: PayloadHandler)
-          (onSuccess: HandlerResult ⇒ Any)
-          (onError: Throwable ⇒ Any): Unit = {
-
-    try onSuccess(handler.handlePayload(payload))
-    catch { case e: Throwable ⇒ onError(e) }
-  }
-}
index 80c1413..d0a03e5 100644 (file)
@@ -64,11 +64,6 @@ class RabbitMQConsumer(
     handler: PayloadHandler,
 
     /**
     handler: PayloadHandler,
 
     /**
-     * Specifies how we execute the handler
-     */
-    executor: PayloadHandlerExecutor,
-
-    /**
      * After the payload is processed, we call this function with ourselves and the result.
      */
     notifier: (RabbitMQConsumer, Maybe[HandlerResult]) ⇒ Unit
      * After the payload is processed, we call this function with ourselves and the result.
      */
     notifier: (RabbitMQConsumer, Maybe[HandlerResult]) ⇒ Unit
@@ -363,9 +358,14 @@ class RabbitMQConsumer(
 
         val onSuccessF = onSuccessBasicStepF andThen notifierF
 
 
         val onSuccessF = onSuccessBasicStepF andThen notifierF
 
-        executor.exec(body, handler) (onSuccessF) (onErrorF)
+        try {
+          val result0 = handler.handlePayload(body)
+          val result1 = onSuccessF.apply(result0)
+          result1
+        }
+        catch(onErrorF)
       }
       }
-      catch (onErrorF)
+      catch(onErrorF)
     }
   }
 
     }
   }
 
index 226f6b4..cd87565 100644 (file)
@@ -46,8 +46,7 @@ import event.{BalanceEvent, AquariumCreatedEvent, StoreIsAliveBusEvent, StoreIsD
 import gr.grnet.aquarium.connector.rabbitmq.service.PayloadHandlerPostNotifier
 import gr.grnet.aquarium.connector.rabbitmq.conf.RabbitMQKeys.RabbitMQConfKeys
 import gr.grnet.aquarium.connector.rabbitmq.conf.RabbitMQKeys
 import gr.grnet.aquarium.connector.rabbitmq.service.PayloadHandlerPostNotifier
 import gr.grnet.aquarium.connector.rabbitmq.conf.RabbitMQKeys.RabbitMQConfKeys
 import gr.grnet.aquarium.connector.rabbitmq.conf.RabbitMQKeys
-import gr.grnet.aquarium.connector.handler.{SynchronousPayloadHandlerExecutor, ResourceEventPayloadHandler, IMEventPayloadHandler}
-import gr.grnet.aquarium.util.json.JsonSupport
+import gr.grnet.aquarium.connector.handler.{ResourceEventPayloadHandler, IMEventPayloadHandler}
 
 /**
  * The service that is responsible to handle `RabbitMQ` connectivity.
 
 /**
  * The service that is responsible to handle `RabbitMQ` connectivity.
@@ -98,8 +97,6 @@ class RabbitMQService extends Loggable with Lifecycle with Configurable with Aqu
 
     val imHandler = new IMEventPayloadHandler(aquarium, logger)
 
 
     val imHandler = new IMEventPayloadHandler(aquarium, logger)
 
-    val futureExecutor = new SynchronousPayloadHandlerExecutor
-
     // (e)xchange:(r)outing key:(q)
 
     // These two are to trigger an error if the property does not exist
     // (e)xchange:(r)outing key:(q)
 
     // These two are to trigger an error if the property does not exist
@@ -144,7 +141,6 @@ class RabbitMQService extends Loggable with Lifecycle with Configurable with Aqu
         aquarium,
         rccc,
         rcHandler,
         aquarium,
         rccc,
         rcHandler,
-        futureExecutor,
         postNotifier
       )
     }
         postNotifier
       )
     }
@@ -160,7 +156,6 @@ class RabbitMQService extends Loggable with Lifecycle with Configurable with Aqu
         aquarium,
         imcc,
         imHandler,
         aquarium,
         imcc,
         imHandler,
-        futureExecutor,
         postNotifier
       )
     }
         postNotifier
       )
     }