camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [07/28] camel git commit: Moved the child event listener to a separate class and also fixed the comment styles.
Date Fri, 25 Nov 2016 10:00:46 GMT
Moved the child event listener to a separate class and also fixed the comment styles.


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/87574007
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/87574007
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/87574007

Branch: refs/heads/master
Commit: 875740078b343a1aea66080657442ad9e3ae9e79
Parents: 1305ce4
Author: gilfernandes <gil.fernandes@gmail.com>
Authored: Tue Nov 22 13:51:06 2016 +0000
Committer: Andrea Cosentino <ancosen@gmail.com>
Committed: Fri Nov 25 10:05:36 2016 +0100

----------------------------------------------------------------------
 .../component/firebase/FirebaseComponent.java   |  2 +-
 .../component/firebase/FirebaseConsumer.java    | 64 ++++++++++----------
 2 files changed, 34 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/87574007/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
index 0f62e16..f06e06d 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseComponent.java
@@ -1,4 +1,4 @@
-/*
+/**
  * 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.

http://git-wip-us.apache.org/repos/asf/camel/blob/87574007/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
index e85b307..c8859eb 100644
--- a/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
+++ b/components/camel-firebase/src/main/java/org/apache/camel/component/firebase/FirebaseConsumer.java
@@ -47,36 +47,7 @@ public class FirebaseConsumer extends DefaultConsumer {
         FirebaseDatabase
                 .getInstance(endpoint.getFirebaseApp())
                 .getReference(firebaseConfig.getRootReference())
-                .addChildEventListener(new ChildEventListener() {
-                    @Override
-                    public void onChildAdded(DataSnapshot dataSnapshot, String s) {
-                        forwardMessage(new FirebaseMessage.Builder(Operation.CHILD_ADD, dataSnapshot)
-                                .setPreviousChildName(s).build());
-                    }
-
-                    @Override
-                    public void onChildChanged(DataSnapshot dataSnapshot, String s) {
-                        forwardMessage(new FirebaseMessage.Builder(Operation.CHILD_CHANGED,
dataSnapshot)
-                                .setPreviousChildName(s).build());
-                    }
-
-                    @Override
-                    public void onChildRemoved(DataSnapshot dataSnapshot) {
-                        forwardMessage(new FirebaseMessage.Builder(Operation.CHILD_REMOVED,
dataSnapshot).build());
-                    }
-
-                    @Override
-                    public void onChildMoved(DataSnapshot dataSnapshot, String s) {
-                        forwardMessage(new FirebaseMessage.Builder(Operation.CHILD_MOVED,
dataSnapshot)
-                                .setPreviousChildName(s).build());
-                    }
-
-                    @Override
-                    public void onCancelled(DatabaseError databaseError) {
-                        forwardMessage(new FirebaseMessage.Builder(Operation.CANCELLED).setDatabaseError(databaseError)
-                                .build());
-                    }
-                });
+                .addChildEventListener(new FirebaseConsumerEventListener());
     }
 
     private void forwardMessage(FirebaseMessage o) {
@@ -87,7 +58,7 @@ public class FirebaseConsumer extends DefaultConsumer {
             // send message to next processor in the route
             getProcessor().process(exchange);
         } catch (Exception e) {
-            throw new RuntimeCamelException("Message forwarding failed", e);
+            exchange.setException(new RuntimeCamelException("Message forwarding failed",
e));
         } finally {
             // log exception if an exception occurred and was not handled
             if (exchange.getException() != null) {
@@ -95,4 +66,35 @@ public class FirebaseConsumer extends DefaultConsumer {
             }
         }
     }
+
+    private class FirebaseConsumerEventListener implements ChildEventListener {
+        @Override
+        public void onChildAdded(DataSnapshot dataSnapshot, String s) {
+            forwardMessage(new FirebaseMessage.Builder(Operation.CHILD_ADD, dataSnapshot)
+                    .setPreviousChildName(s).build());
+        }
+
+        @Override
+        public void onChildChanged(DataSnapshot dataSnapshot, String s) {
+            forwardMessage(new FirebaseMessage.Builder(Operation.CHILD_CHANGED, dataSnapshot)
+                    .setPreviousChildName(s).build());
+        }
+
+        @Override
+        public void onChildRemoved(DataSnapshot dataSnapshot) {
+            forwardMessage(new FirebaseMessage.Builder(Operation.CHILD_REMOVED, dataSnapshot).build());
+        }
+
+        @Override
+        public void onChildMoved(DataSnapshot dataSnapshot, String s) {
+            forwardMessage(new FirebaseMessage.Builder(Operation.CHILD_MOVED, dataSnapshot)
+                    .setPreviousChildName(s).build());
+        }
+
+        @Override
+        public void onCancelled(DatabaseError databaseError) {
+            forwardMessage(new FirebaseMessage.Builder(Operation.CANCELLED).setDatabaseError(databaseError)
+                    .build());
+        }
+    }
 }


Mime
View raw message