camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jans...@apache.org
Subject svn commit: r722562 - in /activemq/camel/trunk/components: camel-atom/ camel-atom/src/main/java/org/apache/camel/component/atom/ camel-atom/src/main/java/org/apache/camel/component/feed/ camel-atom/src/test/java/org/apache/camel/component/atom/ camel-r...
Date Tue, 02 Dec 2008 18:49:05 GMT
Author: janstey
Date: Tue Dec  2 10:49:04 2008
New Revision: 722562

URL: http://svn.apache.org/viewvc?rev=722562&view=rev
Log:
CAMEL-1101 - moving some common feed stuff into a feed component... there is still more to
be done with this.

Added:
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedComponent.java
  (with props)
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedConsumer.java
  (with props)
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
  (with props)
Removed:
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomConsumerSupport.java
Modified:
    activemq/camel/trunk/components/camel-atom/pom.xml
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java
    activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java
    activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
    activemq/camel/trunk/components/camel-rss/pom.xml
    activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java
    activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssConsumerSupport.java
    activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java
    activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java

Modified: activemq/camel/trunk/components/camel-atom/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/pom.xml?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/pom.xml (original)
+++ activemq/camel/trunk/components/camel-atom/pom.xml Tue Dec  2 10:49:04 2008
@@ -34,7 +34,7 @@
   <description>Camel Atom support</description>
 
   <properties>
-    <camel.osgi.export.pkg>org.apache.camel.component.atom.*</camel.osgi.export.pkg>
+    <camel.osgi.export.pkg>org.apache.camel.component.atom.*;org.apache.camel.component.feed.*</camel.osgi.export.pkg>
   </properties>
 
   <repositories>

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomComponent.java
Tue Dec  2 10:49:04 2008
@@ -19,6 +19,8 @@
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
+import org.apache.camel.component.feed.FeedComponent;
+import org.apache.camel.component.feed.FeedEndpoint;
 import org.apache.camel.impl.DefaultComponent;
 
 /**
@@ -28,9 +30,10 @@
  *
  * @version $Revision$
  */
-public class AtomComponent extends DefaultComponent {
+public class AtomComponent extends FeedComponent {
 
-    protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws
Exception {
+    @Override
+    protected FeedEndpoint createEndpoint(String uri, String remaining, Map parameters) throws
Exception {
         return new AtomEndpoint(uri, this, remaining);
     }
 

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEndpoint.java
Tue Dec  2 10:49:04 2008
@@ -24,6 +24,9 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.component.feed.FeedComponent;
+import org.apache.camel.component.feed.FeedConsumer;
+import org.apache.camel.component.feed.FeedEndpoint;
 import org.apache.camel.impl.DefaultPollingEndpoint;
 import org.apache.camel.util.ObjectHelper;
 
@@ -32,132 +35,45 @@
  *
  * @version $Revision$
  */
-public class AtomEndpoint extends DefaultPollingEndpoint {
-
+public class AtomEndpoint extends FeedEndpoint {
     /**
      * Header key for the {@link org.apache.abdera.model.Feed} object is stored on the in
message on the exchange.
      */
     public static final String HEADER_ATOM_FEED = "org.apache.camel.component.atom.feed";
-
-    private String atomUri;
-    private boolean splitEntries = true;
-    private Date lastUpdate;
-    private boolean filter = true;
-
-    public AtomEndpoint(String endpointUri, AtomComponent component, String atomUri) {
-        super(endpointUri, component);
-        this.atomUri = atomUri;
-
-        ObjectHelper.notNull(atomUri, "atomUri property");
+    
+    public AtomEndpoint(String endpointUri, FeedComponent component, String feedUri) {
+        super(endpointUri, component, feedUri);
     }
 
-    public AtomEndpoint(String endpointUri, String atomUri) {
-        this(endpointUri);
-        this.atomUri = atomUri;
-
-        ObjectHelper.notNull(atomUri, "atomUri property");
+    public AtomEndpoint(String endpointUri, String feedUri) {
+        super(endpointUri, feedUri);
     }
 
     public AtomEndpoint(String endpointUri) {
         super(endpointUri);
-    }
+    }   
 
-    public boolean isSingleton() {
-        return true;
-    }
-
-    public Producer createProducer() throws Exception {
-        throw new UnsupportedOperationException("AtomProducer is not implemented");
-    }
-
-    public Consumer createConsumer(Processor processor) throws Exception {
-        AtomConsumerSupport answer;
-        if (isSplitEntries()) {
-            answer = new AtomEntryPollingConsumer(this, processor, filter, lastUpdate);
-        } else {
-            answer = new AtomPollingConsumer(this, processor);
-        }
-        // ScheduledPollConsumer default delay is 500 millis and that is too often for polling
a feed,
-        // so we override with a new default value. End user can override this value by providing
a consumer.delay parameter
-        answer.setDelay(AtomConsumerSupport.DEFAULT_CONSUMER_DELAY);
-        configureConsumer(answer);
-        return answer;
-    }
-
-    /**
-     * Creates an Exchange with the entries as the in body.
-     *
-     * @param feed   the atom feed
-     * @return the created exchange
-     */
-    public Exchange createExchange(Feed feed) {
-        Exchange exchange = createExchange();
-        exchange.getIn().setBody(feed.getEntries());
-        exchange.getIn().setHeader(HEADER_ATOM_FEED, feed);
+    @Override
+    public Exchange createExchange(Object feed) {
+        Exchange exchange = createExchangeWithFeedHeader(feed, HEADER_ATOM_FEED);
+        exchange.getIn().setBody(((Feed)feed).getEntries());
         return exchange;
     }
 
-    /**
-     * Creates an Exchange with the given entry as the in body.
-     *
-     * @param feed   the atom feed
-     * @param entry  the entry as the in body
-     * @return the created exchange
-     */
-    public Exchange createExchange(Feed feed, Entry entry) {
-        Exchange exchange = createExchange();
+    @Override
+    public Exchange createExchange(Object feed, Object entry) {
+        Exchange exchange = createExchangeWithFeedHeader(feed, HEADER_ATOM_FEED);
         exchange.getIn().setBody(entry);
-        exchange.getIn().setHeader(HEADER_ATOM_FEED, feed);
         return exchange;
     }
 
-    // Properties
-    //-------------------------------------------------------------------------
-
-    public String getAtomUri() {
-        return atomUri;
-    }
-
-    public void setAtomUri(String atomUri) {
-        this.atomUri = atomUri;
-    }
-
-    public boolean isSplitEntries() {
-        return splitEntries;
-    }
-
-    /**
-     * Sets whether or not entries should be sent individually or whether the entire
-     * feed should be sent as a single message
-     */
-    public void setSplitEntries(boolean splitEntries) {
-        this.splitEntries = splitEntries;
-    }
-
-    public Date getLastUpdate() {
-        return lastUpdate;
+    @Override
+    protected FeedConsumer createEntryPollingConsumer(FeedEndpoint feedEndpoint, Processor
processor, boolean filter, Date lastUpdate) {
+        return new AtomEntryPollingConsumer(this, processor, filter, lastUpdate);
+    }  
+    
+    @Override
+    protected FeedConsumer createPollingConsumer(FeedEndpoint feedEndpoint, Processor processor)
{
+        return new AtomPollingConsumer(this, processor); 
     }
-
-    /**
-     * Sets the timestamp to be used for filtering entries from the atom feeds.
-     * This options is only in conjunction with the splitEntries.
-     */
-    public void setLastUpdate(Date lastUpdate) {
-        this.lastUpdate = lastUpdate;
-    }
-
-    public boolean isFilter() {
-        return filter;
-    }
-
-    /**
-     * Sets wether to use filtering or not of the entries.
-     */
-    public void setFilter(boolean filter) {
-        this.filter = filter;
-    }
-
-    // Implementation methods
-    //-------------------------------------------------------------------------
-
 }

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomEntryPollingConsumer.java
Tue Dec  2 10:49:04 2008
@@ -55,7 +55,7 @@
 
             boolean valid = true;
             if (entryFilter != null) {
-                valid = entryFilter.isValidEntry(endpoint, document, entry);
+                valid = entryFilter.isValidEntry((AtomEndpoint)endpoint, document, entry);
             }
             if (valid) {
                 Exchange exchange = endpoint.createExchange(feed, entry);
@@ -71,7 +71,7 @@
 
     private Document<Feed> getDocument() throws IOException, ParseException {
         if (document == null) {
-            document = AtomUtils.parseDocument(endpoint.getAtomUri());
+            document = AtomUtils.parseDocument(endpoint.getFeedUri());
             list = document.getRoot().getEntries();
             entryIndex = list.size() - 1;
         }

Modified: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/atom/AtomPollingConsumer.java
Tue Dec  2 10:49:04 2008
@@ -20,20 +20,21 @@
 import org.apache.abdera.model.Feed;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.component.feed.FeedConsumer;
 
 /**
  * Consumer to poll atom feeds and return the full feed.
  *
  * @version $Revision$
  */
-public class AtomPollingConsumer extends AtomConsumerSupport {
+public class AtomPollingConsumer extends FeedConsumer {
 
     public AtomPollingConsumer(AtomEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
     }
 
     protected void poll() throws Exception {
-        Document<Feed> document = AtomUtils.parseDocument(endpoint.getAtomUri());
+        Document<Feed> document = AtomUtils.parseDocument(endpoint.getFeedUri());
         Feed feed = document.getRoot();
         Exchange exchange = endpoint.createExchange(feed);
         getProcessor().process(exchange);

Added: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedComponent.java?rev=722562&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedComponent.java
(added)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedComponent.java
Tue Dec  2 10:49:04 2008
@@ -0,0 +1,31 @@
+/**
+ * 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.component.feed;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * A base class for feed (atom, RSS) components.
+ */
+public abstract class FeedComponent extends DefaultComponent {
+
+    protected abstract FeedEndpoint createEndpoint(String uri, String remaining, Map parameters)
throws Exception;
+
+}

Propchange: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedComponent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedConsumer.java?rev=722562&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedConsumer.java
(added)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedConsumer.java
Tue Dec  2 10:49:04 2008
@@ -0,0 +1,34 @@
+/**
+ * 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.component.feed;
+
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ScheduledPollConsumer;
+
+/**
+ * Base class for consuming feeds.
+ */
+public abstract class FeedConsumer extends ScheduledPollConsumer {
+    public static final long DEFAULT_CONSUMER_DELAY = 60 * 1000L;
+    protected final FeedEndpoint endpoint;
+
+    public FeedConsumer(FeedEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+        this.endpoint = endpoint;
+    }
+
+}

Propchange: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java?rev=722562&view=auto
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
(added)
+++ activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
Tue Dec  2 10:49:04 2008
@@ -0,0 +1,157 @@
+/**
+ * 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.component.feed;
+
+import java.util.Date;
+
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.camel.Consumer;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultPollingEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * A base class for feed (atom, RSS) endpoints.
+ */
+public abstract class FeedEndpoint extends DefaultPollingEndpoint {
+
+    protected String feedUri;
+    protected boolean splitEntries = true;
+    protected Date lastUpdate;
+    protected boolean filter = true;
+
+    public FeedEndpoint(String endpointUri, FeedComponent component, String feedUri) {
+        super(endpointUri, component);
+        this.feedUri = feedUri;
+
+        ObjectHelper.notNull(feedUri, "feedUri property");
+    }
+
+    public FeedEndpoint(String endpointUri, String feedUri) {
+        this(endpointUri);
+        this.feedUri = feedUri;
+
+        ObjectHelper.notNull(feedUri, "feedUri property");
+    }
+
+    public FeedEndpoint(String endpointUri) {
+        super(endpointUri);
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public Producer createProducer() throws Exception {
+        throw new UnsupportedOperationException("FeedProducer is not implemented");
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        FeedConsumer answer;
+        if (isSplitEntries()) {
+            answer = createEntryPollingConsumer(this, processor, filter, lastUpdate);
+        } else {
+            answer = createPollingConsumer(this, processor);
+        }
+        
+        // ScheduledPollConsumer default delay is 500 millis and that is too often for polling
a feed,
+        // so we override with a new default value. End user can override this value by providing
a consumer.delay parameter
+        answer.setDelay(FeedConsumer.DEFAULT_CONSUMER_DELAY);
+        configureConsumer(answer);
+        return answer;
+    }
+
+    protected abstract FeedConsumer createPollingConsumer(FeedEndpoint feedEndpoint, Processor
processor);
+
+    protected abstract FeedConsumer createEntryPollingConsumer(FeedEndpoint feedEndpoint,
Processor processor, boolean filter, Date lastUpdate);
+
+    protected Exchange createExchangeWithFeedHeader(Object feed, String header) {
+        Exchange exchange = createExchange();
+        exchange.getIn().setHeader(header, feed);
+        return exchange;
+    }    
+    
+    /**
+     * Creates an Exchange with the entries as the in body.
+     *
+     * @param feed   the atom feed
+     * @return the created exchange
+     */
+    public abstract Exchange createExchange(Object feed);
+
+    /**
+     * Creates an Exchange with the given entry as the in body.
+     *
+     * @param feed   the feed
+     * @param entry  the entry as the in body
+     * @return the created exchange
+     */
+    public abstract Exchange createExchange(Object feed, Object entry);
+
+    // Properties
+    //-------------------------------------------------------------------------
+
+    public String getFeedUri() {
+        return feedUri;
+    }
+
+    public void setFeedUri(String feedUri) {
+        this.feedUri = feedUri;
+    }
+
+    public boolean isSplitEntries() {
+        return splitEntries;
+    }
+
+    /**
+     * Sets whether or not entries should be sent individually or whether the entire
+     * feed should be sent as a single message
+     */
+    public void setSplitEntries(boolean splitEntries) {
+        this.splitEntries = splitEntries;
+    }
+
+    public Date getLastUpdate() {
+        return lastUpdate;
+    }
+
+    /**
+     * Sets the timestamp to be used for filtering entries from the atom feeds.
+     * This options is only in conjunction with the splitEntries.
+     */
+    public void setLastUpdate(Date lastUpdate) {
+        this.lastUpdate = lastUpdate;
+    }
+
+    public boolean isFilter() {
+        return filter;
+    }
+
+    /**
+     * Sets whether to use filtering or not of the entries.
+     */
+    public void setFilter(boolean filter) {
+        this.filter = filter;
+    }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+
+}

Propchange: activemq/camel/trunk/components/camel-atom/src/main/java/org/apache/camel/component/feed/FeedEndpoint.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
(original)
+++ activemq/camel/trunk/components/camel-atom/src/test/java/org/apache/camel/component/atom/AtomPollingConsumerTest.java
Tue Dec  2 10:49:04 2008
@@ -59,8 +59,8 @@
             public void configure() throws Exception {
                 from("atom:file:src/test/data/feed.atom?splitEntries=false").to("mock:result");
 
-                // this is a bit weird syntax that normally is not used using the atomUri
parameter
-                from("atom:?atomUri=file:src/test/data/feed.atom&splitEntries=false").to("mock:result2");
+                // this is a bit weird syntax that normally is not used using the feedUri
parameter
+                from("atom:?feedUri=file:src/test/data/feed.atom&splitEntries=false").to("mock:result2");
             }
         };
     }

Modified: activemq/camel/trunk/components/camel-rss/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/pom.xml?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rss/pom.xml (original)
+++ activemq/camel/trunk/components/camel-rss/pom.xml Tue Dec  2 10:49:04 2008
@@ -22,6 +22,16 @@
       <artifactId>camel-core</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-atom</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.abdera</groupId>
+          <artifactId>abdera-extensions-main</artifactId>
+        </exclusion>
+      </exclusions>      
+    </dependency>
+    <dependency>
       <groupId>rome</groupId>
       <artifactId>rome</artifactId>
       <version>0.9</version>

Modified: activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java
(original)
+++ activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssComponent.java
Tue Dec  2 10:49:04 2008
@@ -19,6 +19,8 @@
 import java.util.Map;
 
 import org.apache.camel.Endpoint;
+import org.apache.camel.component.feed.FeedComponent;
+import org.apache.camel.component.feed.FeedEndpoint;
 import org.apache.camel.impl.DefaultComponent;
 
 /**
@@ -27,9 +29,9 @@
  * Camel uses <a href="https://rome.dev.java.net/">ROME</a> as the RSS implementation.
 
  *
  */
-public class RssComponent extends DefaultComponent {
+public class RssComponent extends FeedComponent {
 
-    protected Endpoint createEndpoint(String uri, String remaining, Map parameters) throws
Exception {
+    protected FeedEndpoint createEndpoint(String uri, String remaining, Map parameters) throws
Exception {
         return new RssEndpoint(uri, this, remaining);        
     }
 }

Modified: activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssConsumerSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssConsumerSupport.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssConsumerSupport.java
(original)
+++ activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssConsumerSupport.java
Tue Dec  2 10:49:04 2008
@@ -27,22 +27,21 @@
 import com.sun.syndication.io.XmlReader;
 
 import org.apache.camel.Processor;
+import org.apache.camel.component.feed.FeedConsumer;
+import org.apache.camel.component.feed.FeedEndpoint;
 import org.apache.camel.impl.ScheduledPollConsumer;
 
 /**
  * Base class for consuming RSS feeds.
  */
-public abstract class RssConsumerSupport extends ScheduledPollConsumer {
-    public static final long DEFAULT_CONSUMER_DELAY = 60 * 1000L;
-    protected final RssEndpoint endpoint;
+public abstract class RssConsumerSupport extends FeedConsumer {
 
-    public RssConsumerSupport(RssEndpoint endpoint, Processor processor) {
+    public RssConsumerSupport(FeedEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
-        this.endpoint = endpoint;
     }
 
     protected SyndFeed createFeed() throws IOException, MalformedURLException, FeedException
{
-        InputStream in = new URL(endpoint.getRssUri()).openStream();
+        InputStream in = new URL(endpoint.getFeedUri()).openStream();
         SyndFeedInput input = new SyndFeedInput();
         SyndFeed feed = input.build(new XmlReader(in));
         return feed;

Modified: activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java
(original)
+++ activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEndpoint.java
Tue Dec  2 10:49:04 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.rss;
 
+import java.util.Date;
+
 import com.sun.syndication.feed.synd.SyndEntry;
 import com.sun.syndication.feed.synd.SyndFeed;
 
@@ -23,75 +25,56 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.component.atom.AtomEntryPollingConsumer;
+import org.apache.camel.component.atom.AtomPollingConsumer;
+import org.apache.camel.component.feed.FeedComponent;
+import org.apache.camel.component.feed.FeedConsumer;
+import org.apache.camel.component.feed.FeedEndpoint;
 import org.apache.camel.impl.DefaultPollingEndpoint;
 
 /**
  * An <a href="http://activemq.apache.org/camel/rss.html">RSS Endpoint</a>.
  * 
  */
-public class RssEndpoint extends DefaultPollingEndpoint {
+public class RssEndpoint extends FeedEndpoint {
     /**
      * Header key for the {@link com.sun.syndication.feed.synd.SyndFeed} object is stored
on the in message on the exchange.
      */
-    public static final String HEADER_RSS_FEED = "org.apache.camel.component.rss.feed";
-    private String rssUri;   
-    private boolean splitEntries = true;    
-
-    public RssEndpoint(String uri, RssComponent component, String rssUri) {
-        super(uri, component);
-        this.setRssUri(rssUri);
+    public static final String HEADER_RSS_FEED = "org.apache.camel.component.rss.feed"; 
 
+
+    public RssEndpoint(String endpointUri, FeedComponent component, String feedUri) {
+        super(endpointUri, component, feedUri);
     }
 
-    public Producer createProducer() throws Exception {
-        throw new UnsupportedOperationException("RssProducer is not implemented");
-    }  
-    
-    public Consumer createConsumer(Processor processor) throws Exception {
-        RssConsumerSupport answer;
-        if (isSplitEntries()) {
-            answer = new RssEntryPollingConsumer(this, processor);
-        } else {
-            answer = new RssPollingConsumer(this, processor);
-        }
-        // ScheduledPollConsumer default delay is 500 millis and that is too often for polling
a feed,
-        // so we override with a new default value. End user can override this value by providing
a consumer.delay parameter
-        answer.setDelay(RssConsumerSupport.DEFAULT_CONSUMER_DELAY);
-        configureConsumer(answer);
-        return answer;
+    public RssEndpoint(String endpointUri, String feedUri) {
+        super(endpointUri, feedUri);
     }
 
-    public Exchange createExchange(SyndFeed feed) {
-        Exchange exchange = createExchange();
-        exchange.getIn().setBody(feed.getEntries());
-        exchange.getIn().setHeader(HEADER_RSS_FEED, feed);
+    public RssEndpoint(String endpointUri) {
+        super(endpointUri);
+    }      
+    
+    @Override
+    public Exchange createExchange(Object feed) {
+        Exchange exchange = createExchangeWithFeedHeader(feed, HEADER_RSS_FEED);
+        exchange.getIn().setBody(((SyndFeed)feed).getEntries());
         return exchange;
-    }    
+    }
 
-    public Exchange createExchange(SyndFeed feed, SyndEntry entry) {
-        Exchange exchange = createExchange();
+    @Override
+    public Exchange createExchange(Object feed, Object entry) {
+        Exchange exchange = createExchangeWithFeedHeader(feed, HEADER_RSS_FEED);
         exchange.getIn().setBody(entry);
-        exchange.getIn().setHeader(HEADER_RSS_FEED, feed);
         return exchange;
     }
-    
-    public boolean isSingleton() {
-        return true;
-    }
 
-    public void setRssUri(String rssUri) {
-        this.rssUri = rssUri;
-    }
-
-    public String getRssUri() {
-        return rssUri;
-    }
-
-    public void setSplitEntries(boolean splitEntries) {
-        this.splitEntries = splitEntries;
-    }
-
-    public boolean isSplitEntries() {
-        return splitEntries;
-    }   
+    @Override
+    protected FeedConsumer createEntryPollingConsumer(FeedEndpoint feedEndpoint, Processor
processor, boolean filter, Date lastUpdate) {
+        return new RssEntryPollingConsumer(this, processor, filter, lastUpdate);
+    }  
     
+    @Override
+    protected FeedConsumer createPollingConsumer(FeedEndpoint feedEndpoint, Processor processor)
{
+        return new RssPollingConsumer(this, processor); 
+    }
 }

Modified: activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java?rev=722562&r1=722561&r2=722562&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
(original)
+++ activemq/camel/trunk/components/camel-rss/src/main/java/org/apache/camel/component/rss/RssEntryPollingConsumer.java
Tue Dec  2 10:49:04 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.rss;
 
+import java.util.Date;
 import java.util.List;
 
 import com.sun.syndication.feed.synd.SyndEntry;
@@ -36,6 +37,10 @@
         super(endpoint, processor);
     }
 
+    public RssEntryPollingConsumer(RssEndpoint endpoint, Processor processor, boolean filter,
Date lastUpdate) {
+        this(endpoint, processor);
+    }
+
     public void poll() throws Exception {
         SyndFeed feed = createFeed();
         populateList(feed);        



Mime
View raw message