View Javadoc

1   /*
2    * $Id: EntryReceiver.java 20320 2010-11-24 15:03:31Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.module.atom.event;
11  
12  import org.mule.api.annotations.expressions.Expr;
13  import org.mule.api.annotations.param.Payload;
14  
15  import java.util.concurrent.atomic.AtomicInteger;
16  
17  import org.apache.abdera.model.Entry;
18  import org.apache.abdera.model.Feed;
19  
20  public class EntryReceiver
21  {
22  
23      private AtomicInteger receivedEntries = new AtomicInteger(0);
24  
25      public void processEntry(@Payload Entry entry, @Expr("#[header:invocation:feed.object]") Feed feed) throws Exception
26      {
27          System.out.println("Received " + receivedEntries.incrementAndGet() + " of " + feed.getEntries().size() + " entries");
28      }
29  
30      public int getCount()
31      {
32          return receivedEntries.get();
33      }
34  
35      public AtomicInteger getReceivedEntries()
36      {
37          return receivedEntries;
38      }
39  }