camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1173840 - in /camel/trunk/components/camel-jclouds/src: main/java/org/apache/camel/component/jclouds/ test/java/org/apache/camel/component/jclouds/
Date Wed, 21 Sep 2011 20:41:53 GMT
Author: hadrian
Date: Wed Sep 21 20:41:52 2011
New Revision: 1173840

URL: http://svn.apache.org/viewvc?rev=1173840&view=rev
Log:
CAMEL-4034. A bit of cleanup and checkstyle fixes

Modified:
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumer.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConstants.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConsumer.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsEndpoint.java
    camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java
    camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsComponentTest.java

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumer.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumer.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreConsumer.java
Wed Sep 21 20:41:52 2011
@@ -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.
@@ -14,9 +14,15 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.jclouds;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.util.LinkedList;
+import java.util.Queue;
+
 import org.apache.camel.BatchConsumer;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -32,17 +38,9 @@ import org.jclouds.blobstore.options.Lis
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectStreamClass;
-import java.util.LinkedList;
-import java.util.Queue;
-
-
 public class JcloudsBlobStoreConsumer extends JcloudsConsumer implements BatchConsumer, ShutdownAware
{
 
-    private static final Logger logger = LoggerFactory.getLogger(JcloudsBlobStoreConsumer.class);
+    private static final Logger LOG = LoggerFactory.getLogger(JcloudsBlobStoreConsumer.class);
 
     private final JcloudsBlobStoreEndpoint endpoint;
 
@@ -83,9 +81,7 @@ public class JcloudsBlobStoreConsumer ex
             exchange.setProperty(JcloudsConstants.BLOB_NAME, blobName);
             queue.add(exchange);
         }
-        if (!queue.isEmpty())
-            return processBatch(CastUtils.cast(queue));
-        else return 0;
+        return queue.isEmpty() ? 0 : processBatch(CastUtils.cast(queue));
     }
 
     @Override
@@ -119,7 +115,7 @@ public class JcloudsBlobStoreConsumer ex
                 }
             });
 
-            logger.trace("Processing exchange [{}]...", exchange);
+            LOG.trace("Processing exchange [{}]...", exchange);
             getProcessor().process(exchange);
         }
 

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreEndpoint.java
Wed Sep 21 20:41:52 2011
@@ -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.
@@ -14,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.jclouds;
 
 import org.apache.camel.Consumer;
@@ -36,19 +35,19 @@ public class JcloudsBlobStoreEndpoint ex
      * @param component
      * @param blobStoreContext
      */
-    public JcloudsBlobStoreEndpoint(String uri, JcloudsComponent component, BlobStoreContext
blobStoreContext,String container) {
+    public JcloudsBlobStoreEndpoint(String uri, JcloudsComponent component, BlobStoreContext
blobStoreContext, String container) {
         super(uri, component);
-        this.blobStoreContext=blobStoreContext;
-        this.container=container;
+        this.blobStoreContext = blobStoreContext;
+        this.container = container;
     }
 
     @Override
     public Producer createProducer() throws Exception {
-        return new JcloudsBlobStoreProducer(this,blobStoreContext,container);
+        return new JcloudsBlobStoreProducer(this, blobStoreContext, container);
     }
 
     @Override
     public Consumer createConsumer(Processor processor) {
-        return new JcloudsBlobStoreConsumer(this,processor,blobStoreContext,container);
+        return new JcloudsBlobStoreConsumer(this, processor, blobStoreContext, container);
     }
 }

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsBlobStoreProducer.java
Wed Sep 21 20:41:52 2011
@@ -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.
@@ -14,24 +14,24 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.jclouds;
 
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+
 import org.apache.camel.Exchange;
+
 import org.jclouds.blobstore.BlobStore;
 import org.jclouds.blobstore.BlobStoreContext;
 import org.jclouds.blobstore.domain.Blob;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-
-
 public class JcloudsBlobStoreProducer extends JcloudsProducer {
 
-    private static final Logger logger = LoggerFactory.getLogger(JcloudsBlobStoreProducer.class);
+    private static final Logger LOG = LoggerFactory.getLogger(JcloudsBlobStoreProducer.class);
 
     private BlobStoreContext blobStoreContext;
     private String container;
@@ -57,7 +57,7 @@ public class JcloudsBlobStoreProducer ex
                 blob.setPayload(baos.toByteArray());
                 blobStore.putBlob(container, blob);
             } catch (IOException e) {
-                logger.error("Error while writing blob", e);
+                LOG.error("Error while writing blob", e);
             } finally {
                 if (oos != null) {
                     try {

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsComponent.java
Wed Sep 21 20:41:52 2011
@@ -27,12 +27,10 @@ import org.jclouds.blobstore.BlobStoreCo
  * Represents the component that manages {@link JcloudsEndpoint}.
  */
 public class JcloudsComponent extends DefaultComponent {
-
     private String provider;
     private String identity;
     private String creadential;
 
-
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object>
parameters) throws Exception {
         Endpoint endpoint = null;
 
@@ -52,7 +50,9 @@ public class JcloudsComponent extends De
                 String container = uriParts[1];
                 BlobStoreContext blobStoreContext = new BlobStoreContextFactory().createContext(provider,
identity, creadential);
                 endpoint = new JcloudsBlobStoreEndpoint(uri, this, blobStoreContext, container);
-            } else throw new Exception("Invalid Endpoint URI. It should contains a valid
container name");
+            } else {
+                throw new Exception("Invalid Endpoint URI. It should contains a valid container
name");
+            }
         }
 
         setProperties(endpoint, parameters);

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConstants.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConstants.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConstants.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConstants.java
Wed Sep 21 20:41:52 2011
@@ -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.
@@ -14,12 +14,14 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.jclouds;
 
-public class JcloudsConstants {
+public final class JcloudsConstants {
     public static final String DELIMETER = ":";
     public static final String BLOBSTORE = "blobstore";
     public static final String BLOB_NAME = "BLOB_NAME";
-
+    
+    private JcloudsConstants() {
+        // utility class
+    }
 }

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConsumer.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConsumer.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsConsumer.java
Wed Sep 21 20:41:52 2011
@@ -22,7 +22,6 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.impl.ScheduledPollConsumer;
 
-
 public class JcloudsConsumer extends ScheduledPollConsumer {
     private final JcloudsEndpoint endpoint;
 

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsEndpoint.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsEndpoint.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsEndpoint.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsEndpoint.java
Wed Sep 21 20:41:52 2011
@@ -21,15 +21,8 @@ import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.impl.DefaultEndpoint;
 
-
-
 public abstract class JcloudsEndpoint extends DefaultEndpoint {
 
-    /**
-     * Constructor
-     * @param uri
-     * @param component
-     */
     public JcloudsEndpoint(String uri, JcloudsComponent component) {
         super(uri, component);
     }
@@ -37,7 +30,4 @@ public abstract class JcloudsEndpoint ex
     public boolean isSingleton() {
         return true;
     }
-
-    public abstract Producer createProducer() throws Exception;
-    public abstract Consumer createConsumer(Processor processor);
 }

Modified: camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java
(original)
+++ camel/trunk/components/camel-jclouds/src/main/java/org/apache/camel/component/jclouds/JcloudsProducer.java
Wed Sep 21 20:41:52 2011
@@ -24,14 +24,11 @@ import org.slf4j.LoggerFactory;
 public class JcloudsProducer extends DefaultProducer {
     private static final transient Logger LOG = LoggerFactory.getLogger(JcloudsProducer.class);
 
-    private JcloudsEndpoint endpoint;
-
     public JcloudsProducer(JcloudsEndpoint endpoint) {
         super(endpoint);
-        this.endpoint = endpoint;
     }
 
     public void process(Exchange exchange) throws Exception {
-        System.out.println(exchange.getIn().getBody());    
+        LOG.debug("JcloudsProducer received: {}", exchange.getIn().getBody());    
     }
 }

Modified: camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsComponentTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsComponentTest.java?rev=1173840&r1=1173839&r2=1173840&view=diff
==============================================================================
--- camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsComponentTest.java
(original)
+++ camel/trunk/components/camel-jclouds/src/test/java/org/apache/camel/component/jclouds/JcloudsComponentTest.java
Wed Sep 21 20:41:52 2011
@@ -34,8 +34,8 @@ public class JcloudsComponentTest extend
 
     @BeforeClass
     public static void setUpClass() throws Exception {
-       BlobStoreContext context = new BlobStoreContextFactory().createContext("transient","id","credential");
-       context.getBlobStore().createContainerInLocation(null, "foo");
+        BlobStoreContext context = new BlobStoreContextFactory().createContext("transient",
"id", "credential");
+        context.getBlobStore().createContainerInLocation(null, "foo");
     }
 
     @Override
@@ -45,7 +45,7 @@ public class JcloudsComponentTest extend
 
     @Test
     public void testProduce() throws InterruptedException {
-         result.expectedMessageCount(1);
-         result.assertIsSatisfied();
+        result.expectedMessageCount(1);
+        result.assertIsSatisfied();
     }
 }



Mime
View raw message